Re: FindFolder/sudo puzzle
site_archiver@lists.apple.com Delivered-To: installer-dev@lists.apple.com [...] // 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 (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/site_archiver%40lists.a... 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. This email sent to site_archiver@lists.apple.com
participants (1)
-
Stéphane Sudre