Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion the behavior of sh xxx.sh
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stephane CHAZELAS  
View profile  
 More options Dec 11 2009, 2:38 am
Newsgroups: comp.unix.shell
From: Stephane CHAZELAS <stephane_chaze...@yahoo.fr>
Date: Fri, 11 Dec 2009 07:38:48 +0000 (UTC)
Local: Fri, Dec 11 2009 2:38 am
Subject: Re: the behavior of sh xxx.sh
2009-12-10, 22:16(-08), haomiao:

> Thanks for all!

> I finally have knowledges that
>   1. In POSIX, first the current directory, then the PATH.
>   2. Not all shell comply with this POSIX rule.
>   3. In my environment (ksh88 in AIX6.1), first PATH, then current
> directory.

Yes, and to clarify the security hole, if you have a setuid ksh
script (for instance /opt/x/bin/foo starting with #! /bin/ksh
-)), one can make another script by the same name and put it in
$PATH (like echo sh > ~/bin/foo; chmod +x ~/bin/foo), then

chdir("/opt/x/bin");
execl("foo", "foo", 0);

Then the system will change that to:

execl("/bin/ksh", "ksh" (or "foo" depending on the system), "-",
"foo", 0); (*)

With the process euid being the owner of /opt/x/bin/foo

But ksh will interpret ~/bin/foo instead of /opt/x/bin/foo
because ~/bin is in $PATH and not /opt/x/bin

(*) Some systems will change it instead to
execl("/bin/ksh", "ksh" (or "foo" depending on the system), "-",
"/dev/fd/3", 0);
where fd 3 is open to /opt/x/bin/foo. That fixes both that hole
and the race condition one.

Note that not all systems support setuid scripts, and on some,
the support can be disabled/enabled at run time.

In any case, a setuid shell script especially a ksh one is most
likely to be a security hole, one should avoid that at all cost.

--
St phane


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.