explicit use of /etc/rc.d vs service

Giorgos Keramidas keramida at FreeBSD.org
Fri Jan 25 10:39:33 UTC 2013


On 2013-01-24 12:37, "Matthew D. Fuller" <fullermd at over-yonder.net> wrote:
>On Thu, Jan 24, 2013 at 02:52:26PM +0200 I heard the voice of
>Elias Chrysocheris, and lo! it spake thus:
>>
>> It returns an error. But when I /usr/local/etc/rc.d/apache22
>> onerestart evrything works fine...
>
> That could mean it's depending on something in your env variables,
> which service will clear out (and so technically is a bug in your
> setup, if your system script is depending on your user env...)

We debugged this a bit further with Elias in personal email, and it
seems to be related to PATH differences.  The error message was that
'env' cannot find 'python' in the toplevel shebang line of the
hgwebdir.cgi script.  This shows exactly the same error in a test
script:

    $ ls -ld foo.py
    -rwxr-xr-x  1 keramida  users  43 Jan 25 11:33 foo.py

    $ cat -n foo.py
         1	 #!/usr/bin/env python
         2
         3	 print 'Hello world'

    $ env PATH=/bin:/sbin:/usr/bin:/usr/sbin ./foo.py
    env: python: No such file or directory

    $ env PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin ./foo.py
    Hello world

So indeed this is a bug that makes the apache onerestart script depend
on the runtime value of PATH to load everything correctly.



More information about the freebsd-doc mailing list