tunblick/installer.m

Mon, 16 Jan 2012 23:08:14 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 16 Jan 2012 23:08:14 +0100
changeset 23
d783b433388d
parent 1
1a5334dfb21d
permissions
-rw-r--r--

Inconclusively complete possibly missing fields. This change introduces
inconsistencies difficult to correct given incomplete documentation of
IPKG and OPKG packaging standards.

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

mercurial