From owner-freebsd-questions@FreeBSD.ORG Mon Jun 15 14:15:15 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33882106564A for ; Mon, 15 Jun 2009 14:15:15 +0000 (UTC) (envelope-from Pieter.Donche@ua.ac.be) Received: from macos.cmi.ua.ac.be (macos.cmi.ua.ac.be [143.129.75.1]) by mx1.freebsd.org (Postfix) with ESMTP id BDD7D8FC16 for ; Mon, 15 Jun 2009 14:15:14 +0000 (UTC) (envelope-from Pieter.Donche@ua.ac.be) Received: from macos.cmi.ua.ac.be (localhost [127.0.0.1]) by macos.cmi.ua.ac.be (8.14.3/8.14.3) with ESMTP id n5FEFCxK046413; Mon, 15 Jun 2009 16:15:12 +0200 (CEST) (envelope-from Pieter.Donche@ua.ac.be) Received: from localhost (pdon@localhost) by macos.cmi.ua.ac.be (8.14.3/8.14.3/Submit) with ESMTP id n5FEFBbd046410; Mon, 15 Jun 2009 16:15:11 +0200 (CEST) (envelope-from Pieter.Donche@ua.ac.be) X-Authentication-Warning: macos.cmi.ua.ac.be: pdon owned process doing -bs Date: Mon, 15 Jun 2009 16:15:11 +0200 (CEST) From: Pieter Donche X-X-Sender: pdon@macos.cmi.ua.ac.be To: Valentin Bud In-Reply-To: <139b44430906150524i70940c6dp2fbc8c22ffd9e55@mail.gmail.com> Message-ID: References: <18998.13606.129658.46433@jerusalem.litteratus.org> <139b44430906150524i70940c6dp2fbc8c22ffd9e55@mail.gmail.com> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Robert Huff , "mail.list freebsd-questions" Subject: Re: path for user www X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Pieter Donche List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2009 14:15:15 -0000 On Mon, 15 Jun 2009, Valentin Bud wrote: > On Mon, Jun 15, 2009 at 3:16 PM, Pieter Donche > 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 ?