Evan Broder wrote:
> Hi,
>     I think I've got a patch that fixes the postflight script on 10.5.
> 
> There are two things that I fix: first, ps axww seems to for some reason 
> list lots of processes on 10.5. I will freely admit that I don't 
> understand the options to ps on OS X or any other platform - I just kept 
> pulling arguments one at a time until it seemed to do the right thing.

Good catch. To me this looks like a bug in Leopard's /bin/ps: When the 
"-a" flag is present, it ignores the "-p pid" flag. I have immediately 
filed a bug with Apple's bugreporter.

> The other change causes pathsetup.sh to run with the privileges, 
> environment, and shell scripts of the user that is being sudo'd to. 
> Currently, pathsetup.sh will try to write to /var/root/.profile as the 
> normal user, which fails for obvious reasons.

The environment variables (in particular $HOME and $USER) with which the 
installer runs the postflight script keep changing between OS releases, 
sometimes between minor releases. There was a time when the current 
version of postflight did the right thing, but on Leopard your 
suggestion is looks correct, and it looks correct for Tiger, too.

However, I think this needs some more testing: When I try to execute 
this by hand from a root command line prompt, I get weird error messages 
(perhaps due to my using tcsh as login shell):

root# sudo -i -u costabel /sw/bin/pathsetup.sh
Badly placed ()'s.

With another command it gets weirder:

root# sudo -i -u costabel /usr/bin/printenv HOME
\312\376\272\276^B^G^C^PEp^L^R: Command not found.
^QU\211\345WVS\203\354,\213u^H\213]^L\353^E\350\261\377\377\377\307D: 
Event not found.

There is definitely something fishy about this "-i" flag when used with 
a command. On the other hand, "-H" seems to work correctly:

root# sudo -H -u costabel /usr/bin/printenv HOME
/Users/costabel

root# sudo -H -u costabel /sw/bin/pathsetup.sh
--------------------------------
Setting up your Fink environment
--------------------------------

Your environment seems to be correctly
set up for Fink already.

> - Evan Broder
> 
> cvs diff: Diffing installer/resources
> Index: installer/resources/postflight
> ===================================================================
> RCS file: /cvsroot/fink/scripts/installer/resources/postflight,v
> retrieving revision 1.13
> diff -u -r1.13 postflight
> --- installer/resources/postflight    9 Jun 2006 16:59:14 -0000    1.13
> +++ installer/resources/postflight    4 Feb 2008 02:32:33 -0000
> @@ -16,7 +16,7 @@
>  # get ps data for a given PID
>  sub process_info {
>          my($pid) = shift;
> -        my $command = "ps axww -p$pid -o user,ppid,tty,command | tail 
> -n 1";
> +        my $command = "ps xww -p$pid -o user,ppid,tty,command | tail -n 1";
>          my @info = split(/\s+/, `$command`, 4);
>          return (
>                  user => $info[0],
> @@ -40,7 +40,7 @@
>      # Running from Installer.app: have Aqua session, so run pathsetup
>      # as user who ran Installer.app.
>      my $real_user = $info{user};
> -    system "sudo -u $real_user /sw/bin/pathsetup.sh";
> +    system "sudo -i -u $real_user /sw/bin/pathsetup.sh";
>      system "osascript -e 'tell application \"Installer\"' -e 'activate' 
> -e 'end tell'";
>  } else {
>      # Running from commandline: not certain to have Aqua session, so

-- 
Martin


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fink-devel mailing list
Fink-devel@lists.sourceforge.net
http://news.gmane.org/gmane.os.apple.fink.devel

Reply via email to