From: Mats Törnros on
On 9 Maj, 09:21, Chris Ridd <chrisr...(a)mac.com> wrote:
> On 2010-05-08 23:33:30 +0100, Tim Streater said:
>
>
>
>
>
> > I'm having a problem with the post-install script I'm using with
> > PackageMaker. I want it to write a file onto the user's desktop when the
> > installer runs. Because in addition the script may modify the Apache
> > config file, it needs admin authorisation, which means the script runs
> > under user 'root'.
>
> > I need to know the logged-in user so I can construct the right file path
> > in order to write on the user's Desktop. At the moment I do a 'id -p'
> > and parse the results, but just now I'm getting this output back from
> > 'id -p':
>
> > login  _spotlight
> > uid root
> > groups wheel _developer _lpoperator _lpadmin admin localaccounts
> > certusers staff everyone procmod procview operator tty sys kmem daemon
> > com.apple.access_screensharing
>
> > Normally it seems to say:
>
> > login tim
>
> > and I pick that up and all works. What is _spotlight doing there? And is
> > there a more reliable way to pick up the short name of the logged in
> > user running the installer?
>
> Try (in a shell) "id -a tim" and "id -a _spotlight" and see if you can
> see any overlap.
>
> Can you pick up the user name earlier on in the installer and pass it
> onto your post-install script via some kind of variable?
>
> You might get a more helpful answer on installer-dev, which I think is
> the name for Apple's installer developer list.
>
> --
> Chris

You can detect the user in the InstallationCheck script that is run as
a normal user. From there you can either save the path in a temporary
text file for postinstall to read, or you can create a symlink
somewhere pointing to the user directory and have the postinstall
script put the files there.

I realize this is kind of a hack but that's kind of what it takes to
still use PackageMaker/Installer.