• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: FindFolder/sudo puzzle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Re: FindFolder/sudo puzzle (From: Andy O'Meara <email@hidden>)

  • Prev by Date: Cause of TaskLauncher::Launch Failed Error?
  • Next by Date: Re: postflight script and manual install questions
  • Previous by thread: Re: FindFolder/sudo puzzle
  • Next by thread: Re: FindFolder/sudo puzzle
  • Index(es):
    • Date
    • Thread