Created
January 16, 2015 01:38
-
-
Save calum-github/712cdb7f74100b19e6ae to your computer and use it in GitHub Desktop.
Java 2014-001 scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Scripts from JavaSecurity.pkg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| $0 =~ m/.*\/(.*)$/; | |
| my $stage = $1; | |
| my $action = $ARGV[3]; | |
| my $wd = `pwd`; | |
| chomp($wd); | |
| my $actionsDir = $wd . "/" . 'postinstall' . "_actions/"; | |
| my $upgradeDir = $wd . "/" . 'postupgrade' . "_actions/"; | |
| my $upgrade = 0; | |
| my $debug = 1; | |
| my $count; | |
| if ( $0 =~ /postupgrade/ || $0 =~ /preupgrade/ || $action =~ /upgrade/) { | |
| system("logger -p install.info 'Upgrade scripts will be run.'") if ( $debug ); | |
| $upgrade = 1; | |
| } | |
| if ( $stage =~ /pre/ ) | |
| { | |
| $actionsDir = $wd . "/" . 'preinstall' . "_actions/"; | |
| $upgradeDir = $wd . "/" . 'preupgrade' . "_actions/"; | |
| } | |
| if ( $upgrade == 1 && -e $upgradeDir ) { | |
| system("logger -p install.info 'Running Upgrade Scripts . . .'") if ( $debug ); | |
| $count = 0; | |
| foreach my $action (`/bin/ls \Q$upgradeDir\E`) { | |
| chomp($action); | |
| system("logger -p install.info 'Begin script: $action'") if ( $debug ); | |
| system($upgradeDir . $action, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]); | |
| system("logger -p install.info 'End script: $action'") if ( $debug ); | |
| $count++; | |
| } | |
| system("logger -p install.info '$count Upgrade Scripts run.'") if ( $debug ); | |
| } | |
| if ( -e $actionsDir ) { | |
| system("logger -p install.info 'Running Install Scripts . . .'") if ( $debug ); | |
| $count = 0; | |
| foreach my $action (`/bin/ls \Q$actionsDir\E`) { | |
| chomp($action); | |
| system("logger -p install.info 'Begin script: $action'") if ( $debug ); | |
| system($actionsDir . $action, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3],$upgrade); | |
| system("logger -p install.info 'End script: $action'") if ( $debug ); | |
| $count++; | |
| } | |
| system("logger -p install.info '$count Install Scripts run.'") if ( $debug ); | |
| } | |
| exit(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python2.6 | |
| import os, sys, subprocess | |
| ruid, euid = os.getuid(), os.geteuid() | |
| if min(ruid, euid) != 0: | |
| print >>sys.stderr, "Needs to be run with privileges! (%i, %i)" % (ruid, euid) | |
| sys.exit(1) | |
| if ruid != 0: os.setuid(0) | |
| elif euid != 0: os.seteuid(0) | |
| sh = subprocess.Popen(['/bin/sh'], stdin=subprocess.PIPE) | |
| sh.stdin.write(""" | |
| MAJOR_VERS=`sw_vers -productVersion|cut -d'.' -f2` | |
| if [ "$MAJOR_VERS" -ge 7 ]; then | |
| # only works on Lion or above | |
| /bin/launchctl asuser `id -u "$USER"` /bin/launchctl unload -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist 2>/dev/null | |
| /bin/launchctl asuser `id -u "$USER"` /bin/launchctl load -w -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist | |
| else | |
| # only works on SL/Leopard | |
| /bin/launchctl unload -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist 2>/dev/null | |
| /bin/launchctl load -w -S Aqua /System/Library/LaunchAgents/com.apple.mrt.uiagent.plist | |
| fi | |
| # fix for bug in AC 2.4.2 | |
| sudo -u "$USER" /bin/launchctl unload /System/Library/LaunchDaemons/com.apple.mrt.plist 2>/dev/null | |
| /bin/launchctl unload /System/Library/LaunchDaemons/com.apple.mrt.plist 2>/dev/null | |
| /bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.mrt.plist | |
| """) | |
| sh.stdin.close() | |
| ret = sh.wait() | |
| sys.stderr.write('%i' % ret) | |
| sys.exit(ret) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment