Permissions problem after NSTask application launch
Permissions problem after NSTask application launch
- Subject: Permissions problem after NSTask application launch
- From: David Darby <email@hidden>
- Date: Mon, 18 Apr 2005 14:15:56 +1000
I'm trying to do the following using NSTask but get a privileges error.
I have created a small Cocoa application call "RunStudent" that has the
following code in an AppController:
- (void)awakeFromNib
{
[self launchStudentVersion];
}
- (void)launchStudentVersion
{
NSTask* task = [[NSTask alloc] init];
NSMutableArray* args = [NSMutableArray array];
NSBundle* appBundle = [NSBundle mainBundle];
// set arguments
NSString* firstCmd;
NSString* cmd1 = @"/MyApp.app/Contents/MacOS/MyApp";
NSString* cmd2 = @"-student";
NSString* path = [[appBundle bundlePath]
stringByDeletingLastPathComponent];
firstCmd = [path stringByAppendingString:cmd1];
[task setLaunchPath:firstCmd];
NSLog(firstCmd);
[args addObject:firstCmd];
[args addObject:cmd2];
[task setArguments:args];
[task launch];
[NSApp terminate:self];
}
This works as it should, ie when the application is opened from the
Finder, it launches the application called "MyApp" which resides in the
same directory using the command line option of -student which causes
the application to run in "student" mode (with some options disabled).
After launching MyApp, this small application politely quits.
However, when the launched application runs in Student mode, it
strangely cannot access (due to insufficient privileges) any directory
in the same folder. It uses these directories for language and custom
settings. That is, when opened directly, MyApp can access its folders
(note these are not in the MyApp.app directory but the same level
directory). When opened using the run student mode application, it does
not have sufficient privileges to access these folders.
I've ensured all directories are 777 in their privileges but this does
not help.
You might ask why I need to do this? The full version needs to sit in a
shared directory on a school network. The RunStudent application needs
to be visible from client Macs on the network and when opened on a
client mac to hide some of the full program's functionality. I've tried
AppleScripts, Java (which works) and Qt (which works) but these all
have dependencies or large executables which I'd rather avoid.
Can anybody suggest how to fix the remotely launched MyApp's privileges?
David Darby
Em email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden