tunblick/installer.m

Wed, 29 Jul 2009 11:28:31 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 29 Jul 2009 11:28:31 +0200
changeset 2
da073b397539
child 6
fe330a707a9f
permissions
-rw-r--r--

Adjust for OSX10.5 and Xcode3.1.3 building 32/64 bit universal releases.

michael@1 1 /*
michael@1 2 * Copyright (c) 2004 Angelo Laub
michael@1 3 *
michael@1 4 * This program is free software; you can redistribute it and/or modify
michael@1 5 * it under the terms of the GNU General Public License version 2
michael@1 6 * as published by the Free Software Foundation.
michael@1 7 *
michael@1 8 * This program is distributed in the hope that it will be useful,
michael@1 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
michael@1 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
michael@1 11 * GNU General Public License for more details.
michael@1 12 *
michael@1 13 * You should have received a copy of the GNU General Public License
michael@1 14 * along with this program (see the file COPYING included with this
michael@1 15 * distribution); if not, write to the Free Software Foundation, Inc.,
michael@1 16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
michael@1 17 */
michael@1 18
michael@1 19 #include "installer.h"
michael@1 20
michael@1 21 int main(int argc, char *argv[])
michael@1 22 {
michael@1 23 NSAutoreleasePool *pool = [NSAutoreleasePool new];
michael@1 24 NSString *thisBundle = [[NSString stringWithUTF8String:argv[0]] stringByDeletingLastPathComponent];
michael@1 25
michael@1 26 NSString *tunPath = [thisBundle stringByAppendingPathComponent:@"/tun.kext"];
michael@1 27 NSString *tapPath = [thisBundle stringByAppendingPathComponent:@"/tap.kext"];
michael@1 28
michael@1 29 NSString *tunExecutable = [tunPath stringByAppendingPathComponent:@"/Contents/MacOS/tun"];
michael@1 30 NSString *tapExecutable = [tapPath stringByAppendingPathComponent:@"/Contents/MacOS/tap"];
michael@1 31
michael@1 32 NSString *helperPath = [thisBundle stringByAppendingPathComponent:@"/openvpnstart"];
michael@1 33 NSString *openvpnPath = [thisBundle stringByAppendingPathComponent:@"/openvpn"];
michael@1 34
michael@1 35 runTask(
michael@1 36 @"/usr/sbin/chown",
michael@1 37 [NSArray arrayWithObjects:@"-R",@"root:wheel",thisBundle,nil]
michael@1 38 );
michael@1 39
michael@1 40
michael@1 41 runTask(
michael@1 42 @"/bin/chmod",
michael@1 43 [NSArray arrayWithObjects:@"-R",@"755",tunPath,tapPath,nil]
michael@1 44 );
michael@1 45
michael@1 46 runTask(
michael@1 47 @"/bin/chmod",
michael@1 48 [NSArray arrayWithObjects:@"744",
michael@1 49 tunExecutable,
michael@1 50 tapExecutable,
michael@1 51 helperPath,
michael@1 52 openvpnPath,
michael@1 53 nil]
michael@1 54 );
michael@1 55 runTask(
michael@1 56 @"/bin/chmod",
michael@1 57 [NSArray arrayWithObjects:@"4111",helperPath,nil]
michael@1 58 );
michael@1 59 [pool release];
michael@1 60 return 0;
michael@1 61 }
michael@1 62
michael@1 63 void runTask(NSString *launchPath,NSArray *arguments)
michael@1 64 {
michael@1 65 NSTask* task = [[[NSTask alloc] init] autorelease];
michael@1 66 [task setArguments:arguments];
michael@1 67 [task setLaunchPath:launchPath];
michael@1 68
michael@1 69 NS_DURING {
michael@1 70 [task launch];
michael@1 71 } NS_HANDLER {
michael@1 72 NSLog(@"Exception raised while executing helper %@: %@",launchPath, localException);
michael@1 73 exit(EXIT_FAILURE);
michael@1 74 }
michael@1 75 NS_ENDHANDLER
michael@1 76 [task waitUntilExit];
michael@1 77 }

mercurial