Wed, 29 Jul 2009 11:32:54 +0200
Describe characteristics and workflow of Tunblick build configuration.
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 );
41 runTask(
42 @"/bin/chmod",
43 [NSArray arrayWithObjects:@"-R",@"755",tunPath,tapPath,nil]
44 );
46 runTask(
47 @"/bin/chmod",
48 [NSArray arrayWithObjects:@"744",
49 tunExecutable,
50 tapExecutable,
51 helperPath,
52 openvpnPath,
53 nil]
54 );
55 runTask(
56 @"/bin/chmod",
57 [NSArray arrayWithObjects:@"4111",helperPath,nil]
58 );
59 [pool release];
60 return 0;
61 }
63 void runTask(NSString *launchPath,NSArray *arguments)
64 {
65 NSTask* task = [[[NSTask alloc] init] autorelease];
66 [task setArguments:arguments];
67 [task setLaunchPath:launchPath];
69 NS_DURING {
70 [task launch];
71 } NS_HANDLER {
72 NSLog(@"Exception raised while executing helper %@: %@",launchPath, localException);
73 exit(EXIT_FAILURE);
74 }
75 NS_ENDHANDLER
76 [task waitUntilExit];
77 }