Date: Mon, 15 Jun 2009 16:15:11 +0200 (CEST) From: Pieter Donche <Pieter.Donche@ua.ac.be> To: Valentin Bud <valentin.bud@gmail.com> Cc: Robert Huff <roberthuff@rcn.com>, "mail.list freebsd-questions" <freebsd-questions@freebsd.org> Subject: Re: path for user www Message-ID: <alpine.BSF.2.00.0906151556400.45918@macos.cmi.ua.ac.be> In-Reply-To: <139b44430906150524i70940c6dp2fbc8c22ffd9e55@mail.gmail.com> References: <alpine.BSF.2.00.0906151131390.34405@macos.cmi.ua.ac.be> <18998.13606.129658.46433@jerusalem.litteratus.org> <alpine.BSF.2.00.0906151404040.38025@macos.cmi.ua.ac.be> <139b44430906150524i70940c6dp2fbc8c22ffd9e55@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 15 Jun 2009, Valentin Bud wrote: > On Mon, Jun 15, 2009 at 3:16 PM, Pieter Donche <Pieter.Donche@ua.ac.be> > wrote: > On Mon, 15 Jun 2009, Robert Huff wrote: > Pieter Donche writes: > How can one change the PATH for the > user www ? > to include e.g. /usr/local/bin > In /etc/passwd the entry now is: > www:*:80:80:World Wide Web > Owner:/nonexistent:/usr/sbin/nologin > Start by reading the section 5 man page for > "passwd". > Could you provide a little more detail about > what's breaking > and why you think this user's path is involved? > Robert Huff > Some users on my system run scripts in their webpages. If they specify > commands (e.g.) 'python', it is not found, unless it is specified as > '/usr/local/bin/python', since the Apache runs in an environment which > has as PATH: (as can be seen from phpinfo() output) > /sbin:/bin:/usr/sbin:/usr:bin only. > > How can one make the PATH that Apache httpd deamon will use > be a different path? and where exaclty does it get > /sbin:/bin:/usr/sbin:/usr:bin from > in the first place? > > I could try specifying in /usr/local/sbin/apachectl 's Bourne shell > script: > PATH=/sbin:/bin:/usr/sbin:/usr:bin:/usr/local/sbin:/usr/local/bin > export PATH > > but wouldn't this be set back to the original at an Apache update? > > root has a better path: > PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bi > n:/root/bin > > how could I have httpd have the same path? > > > Hello Pieter, > > I guess you are looking for apache's SetEnv directive: > http://httpd.apache.org/docs/1.3/mod/mod_env.html#setenv (I use apache 2.2.11) 1. I noticed that when I do a # apachectl graceful from within a root shell, then the PATH env. var. for Apache Environment as reported by phpinfo() is equal to the PATH setting of my root user. (/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin) Probably when rebooting the machine, PATH will be set to a very limited /sbin:/bin:/usr/sbin:/usr/bin (where does this come from?) Now I see from reading the apache start-up script /usr/local/sbin/apachectl that one can create a file with instructions to be executed at startup of Apache: any file in /usr/local/etc/apache22/envvars.d is sourced into the start up environment of apache. This directory was empty for the moment. So I could put in there a file, /usr/local/etc/apache22/envvars.d/mysettings PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH # apachectl graceful however this did not change the phpinfo() reported PATH, it remained the same as my root path 2. I also tried, as you suggested # vi /etc/httpd.conf ... SetEnv TEST_ENV_VAR foo-foo SetEnv PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin (the first SetEnv is just to see if it indeed sets Env. vars.) # apachectl graceful The TEST_ENV_VAR foo-foo is reported But again PATH remains the same as my root path. Does this mean when executing # apachectl graceful from within a root shell PATH will ALWAYS be overridden by the value of PATH of the root shell? I don't see what rules of precedence acutally apply ... Anyone can explain me? And will SetEnv in /etc/httpd.conf also work at boot ??? Or will only /usr/local/etc/apache22/envvars.d/mysettings work at boot ?? Or will none of these work at boot ?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.0906151556400.45918>