subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1380608 - in /subversion/trunk/subversion: include/ libsvn_ra_local/ libsvn_repos/ mod_dav_svn/ svnserve/
Date Tue, 04 Sep 2012 12:43:41 GMT
Author: stsp
Date: Tue Sep  4 12:43:40 2012
New Revision: 1380608

URL: http://svn.apache.org/viewvc?rev=1380608&view=rev
Log:
Fix issue #4113, "convert SVNHooksEnv and svnserve.conf[hooks-env] to
use a common configuration files".

The hook environment is now specified in a separate configuration file.
By default, the file is searched for at 'conf/hooks-env' in the repository,
and read if it exists. The mod_dav_svn SVNHooksEnv and svnserve hooks-env
options may now be used to change file's the default location, e.g. to share
a single hooks environment configuration between multiple repositories.

* subversion/include/svn_config.h
  (SVN_CONFIG_SECTION_HOOKS_ENV): Remove, replaced by...
  (SVN_CONFIG_OPTION_HOOKS_ENV): ... this.

* subversion/include/svn_repos.h
  (svn_repos_hooks_setenv): Update declaration (see below for semantic
   changes).

* subversion/libsvn_ra_local/split_url.c
  (svn_ra_local__split_URL): Configure hook script environment. This finally
   allows RA-local clients to support the hook script environment feature.
   RA-local client always use the default configuration file location.

* subversion/libsvn_repos/hooks.c
  (run_hook_cmd): Choose the hook environment to use from the caller-provided
   hooks environment hash. Use either a hook-specific environment, or the
   default environment, if defined.

* subversion/libsvn_repos/repos.c
  (create_conf): Create a hooks-env configuration file template. Change the
   hooks-env example in svnserve.conf -- 'hooks-env' is now an option, not
   a section of options.
  (parse_hooks_env_option_baton parse_hooks_env_option,
   parse_hooks_env_section_baton, parse_hooks_env_section,
   parse_hooks_env): New set of functions/batons to parse the hooks-env file.
  (svn_repos_hooks_setenv): Expect a path to a hooks environment configuration
   file, instead of a single environment hash.
  (create_svn_repos_t): Initialise hooks_env to NULL (i.e. empty environment).

* subversion/libsvn_repos/repos.h
  (SVN_REPOS__CONF_HOOKS_ENV,
   SVN_REPOS__HOOKS_ENV_DEFAULT_SECTION): New named contants.
  (svn_repos_t): Update doc string for hooks_env member.

* subversion/mod_dav_svn/dav_svn.h
  (dav_svn__get_hooks_env): Update declaration.

* subversion/mod_dav_svn/mod_dav_svn.c
  (dir_conf_t): The hooks_env member is now a path to a configuration file,
   rather than a hash table.
  (SVNHooksEnv_cmd): Expect a path to a configuration file instead of a
   list of environment variables and their values.
  (dav_svn__get_hooks_env): Return a path (const char *) instead of a hash.
  (cmds): Update documentation of SVNHooksEnv option.

* subversion/mod_dav_svn/repos.c
  (get_resource): Update call to svn_repos_hooks_setenv().

* subversion/svnserve/serve.c
  (hooks_env_conf_cb): Remove, now unused.
  (find_repos): Get the hooks-env option from the configuration, which
   now specifies the path to the hooks-env file, rather than parsing
   'hooks-env' as a section of options.

Modified:
    subversion/trunk/subversion/include/svn_config.h
    subversion/trunk/subversion/include/svn_repos.h
    subversion/trunk/subversion/libsvn_ra_local/split_url.c
    subversion/trunk/subversion/libsvn_repos/hooks.c
    subversion/trunk/subversion/libsvn_repos/repos.c
    subversion/trunk/subversion/libsvn_repos/repos.h
    subversion/trunk/subversion/mod_dav_svn/dav_svn.h
    subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
    subversion/trunk/subversion/mod_dav_svn/repos.c
    subversion/trunk/subversion/svnserve/serve.c

Modified: subversion/trunk/subversion/include/svn_config.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_config.h?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_config.h (original)
+++ subversion/trunk/subversion/include/svn_config.h Tue Sep  4 12:43:40 2012
@@ -131,12 +131,12 @@ typedef struct svn_config_t svn_config_t
 #define SVN_CONFIG_OPTION_AUTHZ_DB                  "authz-db"
 /** @since New in 1.7. */
 #define SVN_CONFIG_OPTION_FORCE_USERNAME_CASE       "force-username-case"
+/** @since New in 1.8. */
+#define SVN_CONFIG_OPTION_HOOKS_ENV                 "hooks-env"
 #define SVN_CONFIG_SECTION_SASL                 "sasl"
 #define SVN_CONFIG_OPTION_USE_SASL                  "use-sasl"
 #define SVN_CONFIG_OPTION_MIN_SSF                   "min-encryption"
 #define SVN_CONFIG_OPTION_MAX_SSF                   "max-encryption"
-/** @since New in 1.8. */
-#define SVN_CONFIG_SECTION_HOOKS_ENV            "hooks-env"
 
 /* For repository password database */
 #define SVN_CONFIG_SECTION_USERS                "users"

Modified: subversion/trunk/subversion/include/svn_repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_repos.h?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_repos.h (original)
+++ subversion/trunk/subversion/include/svn_repos.h Tue Sep  4 12:43:40 2012
@@ -778,16 +778,25 @@ const char *
 svn_repos_post_unlock_hook(svn_repos_t *repos,
                            apr_pool_t *pool);
 
-/** Set the environment that @a repos's hooks will inherit to @a hooks_env,
- * a hash table where keys and values represent names and values of environment
- * variables. @a hooks_env must live at least as long as @a repos.
+/** Set the environment that @a repos's hooks will inherit.
+ * The environment is specified in a file at @a hooks_env_path.
+ * If @a hooks_env_path is @c NULL, the file is searched at its
+ * default location in the repository. If @a hooks_env_path is
+ * not absolute, it specifies a path relative to the parent of
+ * the file's default location in the repository.
  *
- * If this function is not called, hooks will run in an empty environment.
+ * The @a result_pool should be the same pool that @a repos was allocated in.
+ * The @a scratch_pool is used for temporary allocations.
+ *
+ * If this function is not called, or if the file does not list any
+ * environment variables, hooks will run in an empty environment.
  *
  * @since New in 1.8. */
-void
+svn_error_t *
 svn_repos_hooks_setenv(svn_repos_t *repos,
-                       apr_hash_t *hooks_env);
+                       const char *hooks_env_path,
+                       apr_pool_t *result_pool,
+                       apr_pool_t *scratch_pool);
 
 /** @} */
 

Modified: subversion/trunk/subversion/libsvn_ra_local/split_url.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_local/split_url.c?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_local/split_url.c (original)
+++ subversion/trunk/subversion/libsvn_ra_local/split_url.c Tue Sep  4 12:43:40 2012
@@ -74,5 +74,8 @@ svn_ra_local__split_URL(svn_repos_t **re
                              - svn_path_component_count(repos_root_dirent));
   *repos_url = urlbuf->data;
 
+  /* Configure hook script environment variables. */
+  SVN_ERR(svn_repos_hooks_setenv(*repos, NULL, pool, pool));
+
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_repos/hooks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/hooks.c?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/hooks.c (original)
+++ subversion/trunk/subversion/libsvn_repos/hooks.c Tue Sep  4 12:43:40 2012
@@ -215,6 +215,7 @@ run_hook_cmd(svn_string_t **result,
   svn_error_t *err;
   apr_proc_t cmd_proc = {0};
   apr_pool_t *cmd_pool;
+  apr_hash_t *hook_env = NULL;
 
   if (result)
     {
@@ -234,8 +235,19 @@ run_hook_cmd(svn_string_t **result,
    * destroy in order to clean up the stderr pipe opened for the process. */
   cmd_pool = svn_pool_create(pool);
 
+  /* Check if a custom environment is defined for this hook, or else
+   * whether a default environment is defined. */
+  if (hooks_env)
+    {
+      hook_env = apr_hash_get(hooks_env, name, APR_HASH_KEY_STRING);
+      if (hook_env == NULL)
+        hook_env = apr_hash_get(hooks_env,
+                                SVN_REPOS__HOOKS_ENV_DEFAULT_SECTION,
+                                APR_HASH_KEY_STRING);
+    }
+    
   err = svn_io_start_cmd3(&cmd_proc, ".", cmd, args,
-                          env_from_env_hash(hooks_env, pool, pool),
+                          env_from_env_hash(hook_env, pool, pool),
                           FALSE, FALSE, stdin_handle, result != NULL,
                           null_handle, TRUE, NULL, cmd_pool);
   if (!err)

Modified: subversion/trunk/subversion/libsvn_repos/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.c?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.c (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.c Tue Sep  4 12:43:40 2012
@@ -34,6 +34,7 @@
 #include "svn_repos.h"
 #include "svn_hash.h"
 #include "svn_version.h"
+#include "svn_config.h"
 
 #include "private/svn_repos_private.h"
 #include "private/svn_subr_private.h"
@@ -166,13 +167,6 @@ svn_repos_post_revprop_change_hook(svn_r
                        pool);
 }
 
-void
-svn_repos_hooks_setenv(svn_repos_t *repos,
-                       apr_hash_t *hooks_env)
-{
-  repos->hooks_env = hooks_env;
-}
-
 static svn_error_t *
 create_repos_dir(const char *path, apr_pool_t *pool)
 {
@@ -1041,6 +1035,13 @@ create_conf(svn_repos_t *repos, apr_pool
 "### \"none\" (to compare usernames as-is without case conversion, which"    NL
 "### is the default behavior)."                                              NL
 "# force-username-case = none"                                               NL
+"### The hooks-env options specifies a path to the hook script environment " NL
+"### configuration file. This option overrides the per-repository default"   NL
+"### and can be used to configure the hook script environment for multiple " NL
+"### repositories in a single file, if an absolute path is specified."       NL
+"### Unless you specify an absolute path, the file's location is relative"   NL
+"### to the directory containing this file."                                 NL
+"# hooks-env = " SVN_REPOS__CONF_HOOKS_ENV                                   NL
 ""                                                                           NL
 "[sasl]"                                                                     NL
 "### This option specifies whether you want to use the Cyrus SASL"           NL
@@ -1055,17 +1056,7 @@ create_conf(svn_repos_t *repos, apr_pool
 "### to the effective key length for encryption (e.g. 128 means 128-bit"     NL
 "### encryption). The values below are the defaults."                        NL
 "# min-encryption = 0"                                                       NL
-"# max-encryption = 256"                                                     NL
-""                                                                           NL
-"[hooks-env]"                                                                NL
-"### Options in this section define environment variables for use by"        NL
-"### hook scripts run by svnserve."                                          NL
-#ifdef WIN32
-"# PATH = C:\\Program Files\\Subversion\\bin"                                NL
-#else
-"# PATH = /bin:/sbin:/usr/bin:/usr/sbin"                                     NL
-#endif
-"# LC_CTYPE = en_US.UTF-8"                                                   NL;
+"# max-encryption = 256"                                                     NL;
 
     SVN_ERR_W(svn_io_file_create(svn_repos_svnserve_conf(repos, pool),
                                  svnserve_conf_contents, pool),
@@ -1132,6 +1123,129 @@ create_conf(svn_repos_t *repos, apr_pool
               _("Creating authz file"));
   }
 
+  {
+    static const char * const hooks_env_contents =
+"### This file is an example hook script environment configuration file."    NL
+"### Hook scripts run in an empty environment by default."                   NL
+"### As shown below each section defines environment variables for a"        NL
+"### particular hook script. The [default] section defines environment"      NL
+"### variables for all hook scripts, unless overridden by a hook-specific"   NL
+"### section."                                                               NL
+""                                                                           NL
+"### This example configures a UTF-8 locale for all hook scripts, so that "  NL
+"### special characters, such as umlauts, may be printed to stderr."         NL
+"### If UTF-8 is used with a mod_dav_svn server, the SVNUseUTF8 option must" NL
+"### also be set to 'yes' in httpd.conf."                                    NL
+"### With svnserve, the LANG environment variable of the svnserve process"   NL
+"### must be set to the same value as given here."                           NL
+"[default]"                                                                  NL
+"# LANG = en_US.UTF-8"                                                       NL
+""                                                                           NL
+"### This sets the PATH environment variable for the pre-commit hook."       NL
+"# [pre-commit]"                                                             NL
+"# PATH = /usr/local/bin:/usr/bin:/usr/sbin"                                 NL;
+
+    SVN_ERR_W(svn_io_file_create(svn_dirent_join(repos->conf_path,
+                                                 SVN_REPOS__CONF_HOOKS_ENV,
+                                                 pool),
+                                 hooks_env_contents, pool),
+              _("Creating hooks-env file"));
+  }
+
+  return SVN_NO_ERROR;
+}
+
+/* Baton for parse_hooks_env_option. */
+struct parse_hooks_env_option_baton {
+  /* The name of the section being parsed. If not the default section,
+   * the section name should match the name of a hook to which the
+   * options apply. */
+  const char *section;
+  apr_hash_t *hooks_env;
+} parse_hooks_env_option_baton;
+
+/* An implementation of svn_config_enumerator2_t.
+ * Set environment variable NAME to value VALUE in the environment for
+ * all hooks (in case the current section is the default section),
+ * or the hook with the name corresponding to the current section's name. */
+static svn_boolean_t
+parse_hooks_env_option(const char *name, const char *value,
+                       void *baton, apr_pool_t *pool)
+{
+  struct parse_hooks_env_option_baton *bo = baton;
+  apr_pool_t *result_pool = apr_hash_pool_get(bo->hooks_env);
+  apr_hash_t *hook_env;
+  
+  hook_env = apr_hash_get(bo->hooks_env, bo->section, APR_HASH_KEY_STRING);
+  if (hook_env == NULL)
+    {
+      hook_env = apr_hash_make(result_pool);
+      apr_hash_set(bo->hooks_env, apr_pstrdup(result_pool, bo->section),
+                   APR_HASH_KEY_STRING, hook_env);
+    }
+  apr_hash_set(hook_env, apr_pstrdup(result_pool, name),
+               APR_HASH_KEY_STRING, apr_pstrdup(result_pool, value));
+
+  return TRUE;
+}
+
+struct parse_hooks_env_section_baton {
+  svn_config_t *cfg;
+  apr_hash_t *hooks_env;
+} parse_hooks_env_section_baton;
+
+/* An implementation of svn_config_section_enumerator2_t. */
+static svn_boolean_t
+parse_hooks_env_section(const char *name, void *baton, apr_pool_t *pool)
+{
+  struct parse_hooks_env_section_baton *b = baton;
+  struct parse_hooks_env_option_baton bo;
+
+  bo.section = name;
+  bo.hooks_env = b->hooks_env;
+
+  (void)svn_config_enumerate2(b->cfg, name, parse_hooks_env_option, &bo, pool);
+
+  return TRUE;
+}
+
+/* Parse the hooks env file for this repository. */
+static svn_error_t *
+parse_hooks_env(svn_repos_t *repos,
+                const char *local_abspath,
+                apr_pool_t *result_pool,
+                apr_pool_t *scratch_pool)
+{
+  svn_config_t *cfg;
+  int n;
+  struct parse_hooks_env_section_baton b;
+
+  SVN_ERR(svn_config_read2(&cfg, local_abspath, FALSE, TRUE, scratch_pool));
+  b.cfg = cfg;
+  b.hooks_env = apr_hash_make(result_pool);
+  n = svn_config_enumerate_sections2(cfg, parse_hooks_env_section, &b,
+                                     scratch_pool);
+  if (n > 0)
+    repos->hooks_env = b.hooks_env;
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_repos_hooks_setenv(svn_repos_t *repos,
+                       const char *hooks_env_path,
+                       apr_pool_t *result_pool,
+                       apr_pool_t *scratch_pool)
+{
+  if (hooks_env_path == NULL)
+    hooks_env_path = svn_dirent_join(repos->conf_path,
+                                     SVN_REPOS__CONF_HOOKS_ENV, scratch_pool);
+  else if (!svn_dirent_is_absolute(hooks_env_path))
+    hooks_env_path = svn_dirent_join(repos->conf_path, hooks_env_path,
+                                     scratch_pool);
+
+  SVN_ERR(parse_hooks_env(repos, hooks_env_path, result_pool, scratch_pool));
+
   return SVN_NO_ERROR;
 }
 
@@ -1151,6 +1265,7 @@ create_svn_repos_t(const char *path, apr
   repos->hook_path = svn_dirent_join(path, SVN_REPOS__HOOK_DIR, pool);
   repos->lock_path = svn_dirent_join(path, SVN_REPOS__LOCK_DIR, pool);
   repos->repository_capabilities = apr_hash_make(pool);
+  repos->hooks_env = NULL;
 
   return repos;
 }

Modified: subversion/trunk/subversion/libsvn_repos/repos.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/repos.h?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/repos.h (original)
+++ subversion/trunk/subversion/libsvn_repos/repos.h Tue Sep  4 12:43:40 2012
@@ -85,6 +85,11 @@ extern "C" {
 /* The extension added to the names of example hook scripts. */
 #define SVN_REPOS__HOOK_DESC_EXT        ".tmpl"
 
+/* The file which contains a custom set of environment variables
+ * passed inherited to hook scripts, in the repository conf directory. */
+#define SVN_REPOS__CONF_HOOKS_ENV "hooks-env"
+/* The name of the default section in the hooks-env config file. */
+#define SVN_REPOS__HOOKS_ENV_DEFAULT_SECTION "default"
 
 /* The configuration file for svnserve, in the repository conf directory. */
 #define SVN_REPOS__CONF_SVNSERVE_CONF "svnserve.conf"
@@ -142,7 +147,15 @@ struct svn_repos_t
   apr_hash_t *repository_capabilities;
 
   /* The environment inherited to hook scripts. If NULL, hooks run
-   * in an empty environment. */
+   * in an empty environment.
+   *
+   * This is a nested hash table.
+   * The entry with name SVN_REPOS__HOOKS_ENV_DEFAULT_SECTION contains the
+   * default environment for all hooks in form of an apr_hash_t with keys
+   * and values describing the names and values of environment variables.
+   * Defaults can be overridden by an entry matching the name of a hook.
+   * E.g. an entry with the name SVN_REPOS__HOOK_PRE_COMMIT provides the
+   * environment specific to the pre-commit hook. */
   apr_hash_t *hooks_env;
 };
 

Modified: subversion/trunk/subversion/mod_dav_svn/dav_svn.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/dav_svn.h?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/dav_svn.h (original)
+++ subversion/trunk/subversion/mod_dav_svn/dav_svn.h Tue Sep  4 12:43:40 2012
@@ -389,7 +389,7 @@ const char *dav_svn__get_root_dir(reques
 int dav_svn__get_compression_level(void);
 
 /* Return the hook script environment parsed from the configuration. */
-apr_hash_t *dav_svn__get_hooks_env(request_rec *r);
+const char *dav_svn__get_hooks_env(request_rec *r);
 
 /** For HTTP protocol v2, these are the new URIs and URI stubs
     returned to the client in our OPTIONS response.  They all depend

Modified: subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/mod_dav_svn.c Tue Sep  4 12:43:40 2012
@@ -96,7 +96,7 @@ typedef struct dir_conf_t {
   enum conf_flag txdelta_cache;      /* whether to enable txdelta caching */
   enum conf_flag fulltext_cache;     /* whether to enable fulltext caching */
   enum conf_flag revprop_cache;      /* whether to enable revprop caching */
-  apr_hash_t *hooks_env;             /* environment for hook scripts */
+  const char *hooks_env;             /* path to hook script env config file */
 } dir_conf_t;
 
 
@@ -550,43 +550,9 @@ SVNUseUTF8_cmd(cmd_parms *cmd, void *con
 static const char *
 SVNHooksEnv_cmd(cmd_parms *cmd, void *config, const char *arg1)
 {
-  apr_array_header_t *var;
-
-  var = svn_cstring_split(arg1, "=", TRUE, cmd->pool);
-  if (var && var->nelts >= 2)
-    {
-      dir_conf_t *conf = config;
-      const char *name;
-      const char *val;
-
-      if (! conf->hooks_env)
-        conf->hooks_env = apr_hash_make(cmd->pool);
-
-      name = apr_pstrdup(apr_hash_pool_get(conf->hooks_env),
-                         APR_ARRAY_IDX(var, 0, const char *));
-
-      /* Special case for values which contain '='. */
-      if (var->nelts > 2)
-        {
-          svn_stringbuf_t *buf;
-          int i;
-
-          buf = svn_stringbuf_create(APR_ARRAY_IDX(var, 1, const char *),
-                                     cmd->pool);
-          for (i = 2; i < var->nelts; i++)
-            {
-              svn_stringbuf_appendbyte(buf, '=');
-              svn_stringbuf_appendcstr(buf, APR_ARRAY_IDX(var, i, const char *));
-            }
-
-          val = apr_pstrdup(apr_hash_pool_get(conf->hooks_env), buf->data);
-        }
-      else
-        val = apr_pstrdup(apr_hash_pool_get(conf->hooks_env),
-                          APR_ARRAY_IDX(var, 1, const char *));
+  dir_conf_t *conf = config;
 
-      apr_hash_set(conf->hooks_env, name, APR_HASH_KEY_STRING, val);
-    }
+  conf->hooks_env = svn_dirent_internal_style(arg1, cmd->pool);
 
   return NULL;
 }
@@ -878,7 +844,7 @@ dav_svn__get_compression_level(void)
   return svn__compression_level;
 }
 
-apr_hash_t *
+const char *
 dav_svn__get_hooks_env(request_rec *r)
 {
   dir_conf_t *conf;
@@ -1136,10 +1102,12 @@ static const command_rec cmds[] =
                "use UTF-8 as native character encoding (default is ASCII)."),
 
   /* per directory/location */
-  AP_INIT_ITERATE("SVNHooksEnv", SVNHooksEnv_cmd, NULL,
-                  ACCESS_CONF|RSRC_CONF,
-                  "Set the environment of hook scripts via any number of "
-                  "VAR=VAL arguments (the default hook environment is empty)."),
+  AP_INIT_TAKE1("SVNHooksEnv", SVNHooksEnv_cmd, NULL,
+                ACCESS_CONF|RSRC_CONF,
+                "Sets the path to the configuration file for the environment "
+                "of hook scripts. If not absolute, the path is relative to "
+                "the repostiory's conf directory (by default the hooks-env "
+                "file in the repository is used)."),
   { NULL }
 };
 

Modified: subversion/trunk/subversion/mod_dav_svn/repos.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/repos.c?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/repos.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/repos.c Tue Sep  4 12:43:40 2012
@@ -2217,8 +2217,9 @@ get_resource(request_rec *r,
                                          HTTP_INTERNAL_SERVER_ERROR, r);
         }
 
-      /* Configure the hooks environment, if not empty. */
-      svn_repos_hooks_setenv(repos->repos, dav_svn__get_hooks_env(r));
+      /* Configure hook script environment variables. */
+      svn_repos_hooks_setenv(repos->repos, dav_svn__get_hooks_env(r),
+                             r->connection->pool, r->pool);
     }
 
   /* cache the filesystem object */

Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1380608&r1=1380607&r2=1380608&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Tue Sep  4 12:43:40 2012
@@ -2944,24 +2944,6 @@ repos_path_valid(const char *path)
   return TRUE;
 }
 
-/* Callback which receives hook environment variables from the hook
- * environment configuration section,
- * An implementation of svn_config_enumerator2_t. */
-static svn_boolean_t
-hooks_env_conf_cb(const char *name,
-                  const char *value,
-                  void *baton,
-                  apr_pool_t *pool)
-{
-  apr_hash_t *hooks_env = baton;
-  apr_pool_t *hash_pool = apr_hash_pool_get(hooks_env);
-
-  apr_hash_set(hooks_env, apr_pstrdup(hash_pool, name),
-               APR_HASH_KEY_STRING, apr_pstrdup(hash_pool, value));
-
-  return TRUE;
-}
-
 /* Look for the repository given by URL, using ROOT as the virtual
  * repository root.  If we find one, fill in the repos, fs, cfg,
  * repos_url, and fs_path fields of B.  Set B->repos's client
@@ -2974,7 +2956,7 @@ static svn_error_t *find_repos(const cha
                                const apr_array_header_t *capabilities,
                                apr_pool_t *pool)
 {
-  const char *path, *full_path, *repos_root, *fs_path;
+  const char *path, *full_path, *repos_root, *fs_path, *hooks_env;
   svn_stringbuf_t *url_buf;
 
   /* Skip past the scheme and authority part. */
@@ -3052,16 +3034,12 @@ static svn_error_t *find_repos(const cha
                                  "No access allowed to this repository",
                                  b, conn, pool);
 
-  /* If a hook environment has been configured, set it up. */
-  if (svn_config_has_section(b->cfg, SVN_CONFIG_SECTION_HOOKS_ENV))
-    {
-      apr_hash_t *hooks_env = apr_hash_make(pool);
-
-      svn_config_enumerate2(b->cfg, SVN_CONFIG_SECTION_HOOKS_ENV,
-                            hooks_env_conf_cb, hooks_env, pool);
-
-      svn_repos_hooks_setenv(b->repos, hooks_env);
-    }
+  /* Configure hook script environment variables. */
+  svn_config_get(b->cfg, &hooks_env, SVN_CONFIG_SECTION_GENERAL,
+                 SVN_CONFIG_OPTION_HOOKS_ENV, NULL);
+  if (hooks_env)
+    hooks_env = svn_dirent_internal_style(hooks_env, pool);
+  svn_repos_hooks_setenv(b->repos, hooks_env, pool, pool);
 
   return SVN_NO_ERROR;
 }



Mime
View raw message