[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Updating a live website with a post-commit hook script

From: Ryan Schmidt <subversion-2006q2_at_ryandesign.com>
Date: 2006-06-30 20:15:06 CEST

Bob Proulx wrote:

> Ryan Schmidt wrote:
>
>> Bob Proulx wrote:
>>
>>> Lots of hard coded paths! If /usr/bin is not in path then there
>>> is a
>>> problem. Hard coded paths to programs have always come back to bite
>>> me. I recommend avoiding them.
>>
>> Um, since /usr/bin/svnlook is explicitly specified, /usr/bin does not
>> need to be within the path. This is in fact the whole point, because
>> in Subversion hooks, the path is not set, so you must use absolute
>> paths or it won't work.
>
> Uhm, they work for me. PATH *is* set for me when the hook scripts are
> run. You can test this for yourself by save the $PATH in effect when
> the hook script is run. In my case when run from my web server the
> following PATH is set at the time the hooks are run:
>
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
>
> That looks like the same PATH that is in effect for apache. I am sure
> it is being inherited, just as desired.

Interesting.

According to the documentation, the path should be empty:

http://svnbook.red-bean.com/nightly/en/
svn.reposadmin.create.html#svn.reposadmin.create.hooks

> For security reasons, the Subversion repository executes hook
> scripts with an empty environment—that is, no environment variables
> are set at all, not even $PATH or %PATH%. Because of this, a lot of
> administrators are baffled when their hook script runs fine by
> hand, but doesn't work when run by Subversion. Be sure to
> explicitly set environment variables in your hook and/or use
> absolute paths to programs.

There have been many questions on this list over the past year where
people wonder why their hook scripts don't work, and when they're
told to use absolute paths, they respond saying that worked.

I've tested this before, and again just now, by creating a new
repository, creating a post-commit hook in it to log all the
environment variables to a file, checking it out via the file:///
protocol, and committing a change, and most environment variables,
including PATH, are not set, just like the docs say.

But I've also seen messages recently from Windows users saying the
path is set, though it was set to an unexpected value.

Just now I created a test repository and served it via Apache, and
was surprised to see that all the environment variables I have set in
my shell were inherited by the hook script.

So either the documentation needs to be updated to explain when the
environment will be empty and when it won't be, or the Subversion
code needs to be changed to match the documented behavior.

I tested with Subversion 1.3.2 and Apache 2.2.2 on Mac OS X 10.4.6
PPC G4.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Jun 30 20:16:25 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.