bart
Posts: 251 Joined: Wed Apr 26, 2000 12:42 am
Post
by bart » Thu May 20, 2010 6:45 am
Not sure if this is a bug or not but
my vortex userid is "vhttpd" but <exec> on Centos 5.5 by default seems to have root's PATH and not the vhttpd's.
IE: /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
So I did a
<strfmt "%s:%s" $PATH "/vhttpd/bin">
<$PATH=$ret>
<exec ENVSET PATH=$PATH $command>
now exec's PATH is very different:
/usr/kerberos/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:/vhttpd/bin:/root/bin
John
Site Admin
Posts: 2597 Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:
Post
by John » Thu May 20, 2010 8:03 am
The PATH and other environment variables will be inherited from the process that starts the web server. The PATH set when you log in is set by the shell and is not seen if a process changes user.
John Turnbull
Thunderstone Software
bart
Posts: 251 Joined: Wed Apr 26, 2000 12:42 am
Post
by bart » Thu May 20, 2010 8:53 am
Agreed. However I'm seeing a behavior diff between v5 and v6.
Since vhttpd is setuid to the web user and I'm exec-ing in the following manner, I dont quite understand:
<exec CHDIR=$cwd fromfile="" bin nobr /bin/bash --login -c "echo $PATH"></exec>
bart
Posts: 251 Joined: Wed Apr 26, 2000 12:42 am
Post
by bart » Thu May 20, 2010 9:48 am
OK new issue. I changed the code to hardwire the PATH to that of the web-user and found the following:
This works:
<exec CHDIR=$cwd ENVSET PATH=$execpath fromfile="" bin nobr /bin/bash --login -c $cmd></exec>
This does not:
<exec ENVSET PATH=$execpath CHDIR=$cwd fromfile="" bin nobr /bin/bash --login -c $cmd></exec>
The change-dir does not execute in the latter case.
mark
Site Admin
Posts: 5513 Joined: Tue Apr 25, 2000 6:56 pm
Post
by mark » Thu May 20, 2010 10:52 am
ENVSET takes all assignments up to the next non-assignment. So in example 1 PATH and fromfile are put into the environment. In example 2 PATH, CHDIR, and fromfile are put in the environemtn.