Re: FindFolder/sudo puzzle
Re: FindFolder/sudo puzzle
- Subject: Re: FindFolder/sudo puzzle
- From: Stéphane Sudre <email@hidden>
- Date: Mon, 26 May 2008 19:34:17 +0200
On May 25, 2008, at 12:42 AM, Andy O'Meara wrote:
Thanks for the suggestions, Kevin. Unfortunately, I now realize
that our little app runs under sudo root, it doesn't even matter if
it know the right dir since any files or dir it creates will get
tainted with root permission/ownership. Basically, this seems to
rule out being able to write any files once the installer is in
preflight (since its sudoed at that point).
The only idea I have remaining is launching my app using sudo -u,
which would solve the FindFolder() issue as well as the file owner/
permissions issue. The only thing left, however, is to choose the
most reliable method to to get the username (or uid). The most
obvious method would be the following in preflight:
MY_RESULT=`sudo -u "${USER}" "$1/Contents/Resources/MyApp.app/
Contents/MacOS/MyApp"`
Does anyone see any issues with this for use in 10.3 and later? Is
it safe for me to be using USER?
Another solution without using sudo would be to rely on the
SystemConfiguration framework to get the uid of the currently logged
in user.
[...]
// We need to locate the current user home folder
NSString * tUserName;
uid_t tUID;
gid_t tGID;
tUserName=(NSString *)SCDynamicStoreCopyConsoleUser(NULL,&tUID,&tGID);
if (tUserName!=nil && [tUserName isEqualToString:@"loginwindow"]==NO)
{
// Is it the console user?
NSString * tHomeFolder;
tHomeFolder=NSHomeDirectoryForUser(tUserName);
if (tHomeFolder!=nil)
{
// ...
}
[tUserName release];
}
else
{
(void)fprintf(stderr, "No user is currently logged in\n");
}
My $0.02
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden