Fix issue #1700 - hook script ignored when symlink is broken.
* hooks.c
(check_hook_cmd): New parameter indicates if the found hook script
is a broken symbolic link.
(svn_repos__hooks_start_commit, svn_repos__hooks_pre_commit,
svn_repos__hooks_post_commit, svn_repos__hooks_pre_revprop_change,
svn_repos__hooks_post_revprop_change): Fail commit if the hook
script is a broken symbolic link.
Index: hooks.c
===================================================================
--- hooks.c (revision 10462)
+++ hooks.c (working copy)
@@ -145,11 +145,12 @@
}
-/* Check if the HOOK program exists and is a file, using POOL for
- temporary allocations. Returns the hook program if found,
- otherwise NULL. */
+/* Check if the HOOK program exists and is a file or a symbolic link, using
+ POOL for temporary allocations. Returns the hook program if found,
+ otherwise NULL. BROKEN_LINK tells if the hook program is a broken
symbolic
+ link. */
static const char*
-check_hook_cmd (const char *hook, apr_pool_t *pool)
+check_hook_cmd (const char *hook, svn_boolean_t *broken_link, apr_pool_t
*pool)
{
static const char* const check_extns[] = {
#ifdef WIN32
@@ -171,11 +172,19 @@
svn_node_kind_t kind;
if (!(err = svn_io_check_resolved_path (hook_path, &kind, pool))
&& kind == svn_node_file)
- return hook_path;
-
+ {
+ *broken_link = FALSE;
+ return hook_path;
+ }
+ svn_error_clear(err);
+ if (!(err = svn_io_check_special_path (hook_path, &kind, pool))
+ && kind == svn_node_special)
+ {
+ *broken_link = TRUE;
+ return hook_path;
+ }
+ svn_error_clear(err);
}
-
- svn_error_clear(err);
return NULL;
}
@@ -186,9 +195,16 @@
apr_pool_t *pool)
{
const char *hook = svn_repos_start_commit_hook (repos, pool);
+ svn_boolean_t broken_link;
- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
{
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
const char *args[4];
args[0] = hook;
@@ -209,9 +225,16 @@
apr_pool_t *pool)
{
const char *hook = svn_repos_pre_commit_hook (repos, pool);
+ svn_boolean_t broken_link;
- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
{
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
const char *args[4];
args[0] = hook;
@@ -232,9 +255,16 @@
apr_pool_t *pool)
{
const char *hook = svn_repos_post_commit_hook (repos, pool);
+ svn_boolean_t broken_link;
- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
{
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
const char *args[4];
args[0] = hook;
@@ -258,9 +288,16 @@
apr_pool_t *pool)
{
const char *hook = svn_repos_pre_revprop_change_hook (repos, pool);
+ svn_boolean_t broken_link;
- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
{
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
const char *args[6];
apr_file_t *stdin_handle = NULL;
@@ -307,9 +344,16 @@
apr_pool_t *pool)
{
const char *hook = svn_repos_post_revprop_change_hook (repos, pool);
+ svn_boolean_t broken_link;
- if ((hook = check_hook_cmd (hook, pool)))
+ if ((hook = check_hook_cmd (hook, &broken_link, pool)) && broken_link)
{
+ return svn_error_createf
+ (SVN_ERR_REPOS_HOOK_FAILURE, NULL,
+ "Failed to run '%s' hook; broken symlink", hook);
+ }
+ else if (hook)
+ {
const char *args[6];
apr_file_t *stdin_handle = NULL;
_________________________________________________________________
MSN Hotmail, o maior webmail do Brasil. http://www.hotmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Aug 2 19:50:13 2004