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

Re: Environment variables in hook scripts?

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Thu, 21 Mar 2013 17:21:10 +0000

Pavel Lyalyakin <pavel.lyalyakin_at_visualsvn.com> writes:

> [[
> Before Subversion calls a hook script, it removes all variables --
> including $PATH on Unix, and %PATH% on Windows -- from the
> environment. Therefore, your script can only run another program if
> you spell out that program's absolute name.
> ]]
>
> Is this statement true?
>
> I've just tested this with Windows 7 64bit and Apache Subversion
> 1.7.8: NO environment variables get removed.

It's certainly true for Unix platforms. Subversion first calls
apr_procattr_cmdtype_set setting cmd=APR_PROGRAM and then calls
apr_proc_create passing env=NULL. APR says that APR_PROGRAM doesn't
copy the environment.

On Unix the combination of APR_PROGRAM and env=NULL causes an empty
array to be passed to execve. That gives an empty environment.

On Windows, as far as I can tell by looking at the code, it causes a
null pointer to be passed to CreateProcessW. The Microsoft documentation
says that will cause the environment to be inherited.

So it seems that there is a bug in apr_proc_create on Windows.
Subversion might be able to work around this bug by explicitly passing
an non-null, empty environment to apr_proc_create.

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download
Received on 2013-03-21 18:21:56 CET

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

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