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

Re: [PATCH] Fix potential crash in libsvn_repos when executing pre-commit hook

From: Branko ─îibej <brane_at_wandisco.com>
Date: Fri, 06 Feb 2015 17:24:36 +0100

On 06.02.2015 17:14, Philip Martin wrote:
> Sergey Raevskiy <sergey.raevskiy_at_visualsvn.com> writes:
>
>> + /* Set an empty pre-commit hook. */
>> +#ifdef WIN32
>> + SVN_ERR(svn_io_file_create(
>> + "test-repo-deprecated-access-context-api/hooks/pre-commit.bat",
>> + "exit 0" APR_EOL_STR, pool));
>> +#else
>> + SVN_ERR(svn_io_file_create(
>> + "test-repo-deprecated-access-context-api/hooks/pre-commit",
>> + "#!/bin/sh" APR_EOL_STR "exit 0" APR_EOL_STR, pool));
>> + SVN_ERR(svn_io_set_file_executable(svn_repos_pre_commit_hook(repos, pool),
>> + TRUE, FALSE, pool));
>> +#endif
> I'd probably use svn_repos_pre_commit_hook in all three places (use
> apr_pstrcat to add the .bat) rather than hard-coding the hook name.
>
> I would expect this to work in practice as I've never seen a Unix
> machine without /bin/sh, but I suppose strictly speaking we cannot rely
> on /bin/sh. Is it portable enough? I suppose we could have a configure
> variable based on CONFIG_SHELL. Or have a configure variable based on
> PYTHON and write the hook in python. Or perhaps compile some C to
> produce an executable and use that by copying it into the repository.

That last would probably the safest thing to do; after all, if we can
produce binaries, we can write portable hook scripts, too.

-- Brane
Received on 2015-02-06 17:25:54 CET

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