Re: [Fink-devel] Patch for 10.5 Binary Installer
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/postflight9 Jun 2006 16:59:14 -1.13 +++ installer/resources/postflight4 Feb 2008 02:32:33 - @@ -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/vse012070mrt/direct/01/ ___ Fink-devel mailing list Fink-devel@lists.sourceforge.net http://news.gmane.org/gmane.os.apple.fink.devel
Re: [Fink-devel] Patch for 10.5 Binary Installer
Martin Costabel wrote: 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 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. Yeah, -H is probably what you want more than -i. In terms of behavior changing across versions, this isn't something we should run into again - by using -H you explicitly specify the behavior you want; this is a flag that is standardized across every sudo I've run into. - Evan - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Fink-devel mailing list Fink-devel@lists.sourceforge.net http://news.gmane.org/gmane.os.apple.fink.devel
Re: [Fink-devel] Patch for 10.5 Binary Installer
Martin Costabel wrote: 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. I imagine that it will be closed as invalid. With -a, you are essentially asking for all processes with a controlling terminal, with -p you ask for all processes which match the given process id. ps will return both all the processes with a controlling terminal and all processes matching the pid. $ ps -a | wc -l 4 $ ps -a -p 1 | wc -l 5 http://www.opengroup.org/onlinepubs/95399/utilities/ps.html Peter -- Peter O'Gorman http://pogma.com - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Fink-devel mailing list Fink-devel@lists.sourceforge.net http://news.gmane.org/gmane.os.apple.fink.devel
Re: [Fink-devel] Patch for 10.5 Binary Installer
Peter O'Gorman wrote: [] I imagine that it will be closed as invalid. With -a, you are essentially asking for all processes with a controlling terminal, with -p you ask for all processes which match the given process id. ps will return both all the processes with a controlling terminal and all processes matching the pid. Argh; I really should know better by now than to read man pages on a Leopard machine on which I haven't mucked out personally the 4500 or so man pages that remain from Tiger when doing an upgrade install. :-( I guess the line proposed by Evan - using ps xww -p pid is correct for Tiger and Leopard anyway. -- Martin - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Fink-devel mailing list Fink-devel@lists.sourceforge.net http://news.gmane.org/gmane.os.apple.fink.devel
Re: [Fink-devel] Patch for 10.5 Binary Installer
(Sorry - this is in the scripts module if that's not clear) - Evan 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. 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. - 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/postflight9 Jun 2006 16:59:14 -1.13 +++ installer/resources/postflight4 Feb 2008 02:32:33 - @@ -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 - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Fink-devel mailing list Fink-devel@lists.sourceforge.net http://news.gmane.org/gmane.os.apple.fink.devel - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Fink-devel mailing list Fink-devel@lists.sourceforge.net http://news.gmane.org/gmane.os.apple.fink.devel