Hi All,
This patch fixes Issue #3781 ->
http://subversion.tigris.org/issues/show_bug.cgi?id=3781
and the corresponding XFail case in authz_tests.py (case_sensitive_authz).
This makes the section names of the authz files case sensitive.
Attached is the patch and log message.
Index: subversion/libsvn_subr/config.c
===================================================================
--- subversion/libsvn_subr/config.c (revision 1068828)
+++ subversion/libsvn_subr/config.c (working copy)
@@ -78,7 +78,9 @@
svn_error_t *
-svn_config_create(svn_config_t **cfgp, apr_pool_t *result_pool)
+svn_config_create(svn_config_t **cfgp,
+ svn_boolean_t section_names_case_sensitive,
+ apr_pool_t *result_pool)
{
svn_config_t *cfg = apr_palloc(result_pool, sizeof(*cfg));
@@ -88,19 +90,22 @@
cfg->x_values = FALSE;
cfg->tmp_key = svn_stringbuf_create("", result_pool);
cfg->tmp_value = svn_stringbuf_create("", result_pool);
-
+ cfg->section_names_case_sensitive = section_names_case_sensitive;
+
*cfgp = cfg;
return SVN_NO_ERROR;
}
svn_error_t *
-svn_config_read(svn_config_t **cfgp, const char *file,
- svn_boolean_t must_exist, apr_pool_t *pool)
+svn_config_read2(svn_config_t **cfgp, const char *file,
+ svn_boolean_t must_exist,
+ svn_boolean_t section_names_case_sensitive,
+ apr_pool_t *pool)
{
svn_config_t *cfg;
svn_error_t *err;
- SVN_ERR(svn_config_create(&cfg, pool));
+ SVN_ERR(svn_config_create(&cfg, section_names_case_sensitive, pool));
/* Yes, this is platform-specific code in Subversion, but there's no
practical way to migrate it into APR, as it's simultaneously
@@ -154,7 +159,7 @@
#ifdef WIN32
if (sys_registry_path)
{
- SVN_ERR(svn_config_read(cfgp, sys_registry_path, FALSE, pool));
+ SVN_ERR(svn_config_read2(cfgp, sys_registry_path, FALSE, FALSE, pool));
red_config = TRUE;
}
#endif /* WIN32 */
@@ -165,7 +170,7 @@
SVN_ERR(svn_config_merge(*cfgp, sys_file_path, FALSE));
else
{
- SVN_ERR(svn_config_read(cfgp, sys_file_path, FALSE, pool));
+ SVN_ERR(svn_config_read2(cfgp, sys_file_path, FALSE, FALSE, pool));
red_config = TRUE;
}
}
@@ -179,7 +184,7 @@
SVN_ERR(svn_config_merge(*cfgp, usr_registry_path, FALSE));
else
{
- SVN_ERR(svn_config_read(cfgp, usr_registry_path, FALSE, pool));
+ SVN_ERR(svn_config_read2(cfgp, usr_registry_path, FALSE, FALSE,
pool));
red_config = TRUE;
}
}
@@ -191,7 +196,7 @@
SVN_ERR(svn_config_merge(*cfgp, usr_file_path, FALSE));
else
{
- SVN_ERR(svn_config_read(cfgp, usr_file_path, FALSE, pool));
+ SVN_ERR(svn_config_read2(cfgp, usr_file_path, FALSE, FALSE, pool));
red_config = TRUE;
}
}
@@ -327,7 +332,7 @@
### We could use a tmp subpool for this, since merge_cfg is going
to be tossed afterwards. Premature optimization, though? */
svn_config_t *merge_cfg;
- SVN_ERR(svn_config_read(&merge_cfg, file, must_exist, cfg->pool));
+ SVN_ERR(svn_config_read2(&merge_cfg, file, must_exist, FALSE, cfg->pool));
/* Now copy the new options into the original table. */
for_each_option(merge_cfg, cfg, merge_cfg->pool, merge_callback);
@@ -387,7 +392,8 @@
/* Canonicalize the hash key */
svn_stringbuf_set(cfg->tmp_key, section);
- make_hash_key(cfg->tmp_key->data);
+ if (! cfg->section_names_case_sensitive)
+ make_hash_key(cfg->tmp_key->data);
sec_ptr = apr_hash_get(cfg->sections, cfg->tmp_key->data,
cfg->tmp_key->len);
@@ -618,7 +624,10 @@
/* Even the section doesn't exist. Create it. */
sec = apr_palloc(cfg->pool, sizeof(*sec));
sec->name = apr_pstrdup(cfg->pool, section);
- sec->hash_key = make_hash_key(apr_pstrdup(cfg->pool, section));
+ if(cfg->section_names_case_sensitive)
+ sec->hash_key = sec->name;
+ else
+ sec->hash_key = make_hash_key(apr_pstrdup(cfg->pool, section));
sec->options = apr_hash_make(cfg->pool);
apr_hash_set(cfg->sections, sec->hash_key, APR_HASH_KEY_STRING, sec);
}
Index: subversion/libsvn_subr/config_impl.h
===================================================================
--- subversion/libsvn_subr/config_impl.h (revision 1068828)
+++ subversion/libsvn_subr/config_impl.h (working copy)
@@ -63,6 +63,9 @@
/* Temporary value used for expanded default values in svn_config_get.
(Using a stringbuf so that frequent resetting is efficient.) */
svn_stringbuf_t *tmp_value;
+
+ /* Specifies whether section names are populated case sensitively. */
+ svn_boolean_t section_names_case_sensitive;
};
Index: subversion/libsvn_subr/deprecated.c
===================================================================
--- subversion/libsvn_subr/deprecated.c (revision 1068828)
+++ subversion/libsvn_subr/deprecated.c (working copy)
@@ -1064,3 +1064,16 @@
start, end, TRUE,
pool, pool));
}
+
+/*** From config.c ***/
+
+svn_error_t *
+svn_config_read(svn_config_t **cfgp, const char *file,
+ svn_boolean_t must_exist,
+ apr_pool_t *pool)
+{
+ return svn_error_return(svn_config_read2(cfgp, file,
+ must_exist,
+ FALSE,
+ pool));
+}
Index: subversion/tests/libsvn_subr/cache-test.c
===================================================================
--- subversion/tests/libsvn_subr/cache-test.c (revision 1068828)
+++ subversion/tests/libsvn_subr/cache-test.c (working copy)
@@ -169,7 +169,7 @@
if (opts->config_file)
{
- SVN_ERR(svn_config_read(&config, opts->config_file, TRUE, pool));
+ SVN_ERR(svn_config_read2(&config, opts->config_file, TRUE, FALSE, pool));
SVN_ERR(svn_cache__make_memcache_from_config(&memcache, config, pool));
}
@@ -215,7 +215,7 @@
if (opts->config_file)
{
- SVN_ERR(svn_config_read(&config, opts->config_file, TRUE, pool));
+ SVN_ERR(svn_config_read2(&config, opts->config_file, TRUE, FALSE, pool));
SVN_ERR(svn_cache__make_memcache_from_config(&memcache, config, pool));
}
Index: subversion/tests/libsvn_subr/config-test.c
===================================================================
--- subversion/tests/libsvn_subr/config-test.c (revision 1068828)
+++ subversion/tests/libsvn_subr/config-test.c (working copy)
@@ -109,7 +109,7 @@
SVN_ERR(init_params(pool));
cfg_file = apr_pstrcat(pool, srcdir, "/", "config-test.cfg", (char *)NULL);
- SVN_ERR(svn_config_read(&cfg, cfg_file, TRUE, pool));
+ SVN_ERR(svn_config_read2(&cfg, cfg_file, TRUE, FALSE, pool));
/* Test values retrieved from our ConfigParser instance against
values retrieved using svn_config. */
@@ -160,7 +160,7 @@
SVN_ERR(init_params(pool));
cfg_file = apr_pstrcat(pool, srcdir, "/", "config-test.cfg", (char *)NULL);
- SVN_ERR(svn_config_read(&cfg, cfg_file, TRUE, pool));
+ SVN_ERR(svn_config_read2(&cfg, cfg_file, TRUE, FALSE, pool));
for (i = 0; true_keys[i] != NULL; i++)
{
@@ -220,7 +220,7 @@
SVN_ERR(init_params(pool));
cfg_file = apr_pstrcat(pool, srcdir, "/", "config-test.cfg", (char *)NULL);
- SVN_ERR(svn_config_read(&cfg, cfg_file, TRUE, pool));
+ SVN_ERR(svn_config_read2(&cfg, cfg_file, TRUE, FALSE, pool));
if (! svn_config_has_section(cfg, "section1"))
return fail(pool, "Failed to find section1");
Index: subversion/tests/cmdline/atomic-ra-revprop-change.c
===================================================================
--- subversion/tests/cmdline/atomic-ra-revprop-change.c (revision 1068828)
+++ subversion/tests/cmdline/atomic-ra-revprop-change.c (working copy)
@@ -119,7 +119,9 @@
svn_config_t *servers;
/* Populate SERVERS. */
- SVN_ERR(svn_config_create(&servers, pool));
+ SVN_ERR(svn_config_create(&servers,
+ FALSE /*section_names_case_sensitive*/,
+ pool));
svn_config_set(servers, SVN_CONFIG_SECTION_GLOBAL,
SVN_CONFIG_OPTION_HTTP_LIBRARY, http_library);
Index: subversion/tests/cmdline/authz_tests.py
===================================================================
--- subversion/tests/cmdline/authz_tests.py (revision 1068828)
+++ subversion/tests/cmdline/authz_tests.py (working copy)
@@ -1084,7 +1084,6 @@
[], 'ls', '-R',
sbox.repo_url)
-@XFail()
@Issue(3781)
@Skip(svntest.main.is_ra_type_file)
def case_sensitive_authz(sbox):
Index: subversion/include/svn_config.h
===================================================================
--- subversion/include/svn_config.h (revision 1068828)
+++ subversion/include/svn_config.h (working copy)
@@ -189,10 +189,14 @@
/** Set @a *cfgp to an empty @c svn_config_t structure,
* allocated in @a result_pool.
*
+ * Pass TRUE to @a section_names_case_sensitive if
+ * section names are to be populated case sensitively.
+ *
* @since New in 1.7.
*/
svn_error_t *
svn_config_create(svn_config_t **cfgp,
+ svn_boolean_t section_names_case_sensitive,
apr_pool_t *result_pool);
/** Read configuration data from @a file (a file or registry path) into
@@ -200,8 +204,27 @@
*
* If @a file does not exist, then if @a must_exist, return an error,
* otherwise return an empty @c svn_config_t.
+ *
+ * If @a section_names_case_sensitive is TRUE, populate section name hashes
+ * case sensitively.
+ *
+ * @since New in 1.7.
*/
+
svn_error_t *
+svn_config_read2(svn_config_t **cfgp,
+ const char *file,
+ svn_boolean_t must_exist,
+ svn_boolean_t section_names_case_sensitive,
+ apr_pool_t *pool);
+
+/** Similar to svn_config_read2, but always passes FALSE to
+ * section_names_case_sensitive.
+ *
+ * @deprecated Provided for backward compatibility with 1.6 API.
+ */
+SVN_DEPRECATED
+svn_error_t *
svn_config_read(svn_config_t **cfgp,
const char *file,
svn_boolean_t must_exist,
Index: subversion/libsvn_repos/authz.c
===================================================================
--- subversion/libsvn_repos/authz.c (revision 1068828)
+++ subversion/libsvn_repos/authz.c (working copy)
@@ -746,7 +746,7 @@
baton.err = SVN_NO_ERROR;
/* Load the rule file. */
- SVN_ERR(svn_config_read(&authz->cfg, file, must_exist, pool));
+ SVN_ERR(svn_config_read2(&authz->cfg, file, must_exist, TRUE, pool));
baton.config = authz->cfg;
/* Step through the entire rule file, stopping on error. */
Index: subversion/svnserve/serve.c
===================================================================
--- subversion/svnserve/serve.c (revision 1068828)
+++ subversion/svnserve/serve.c (working copy)
@@ -235,7 +235,7 @@
const char *pwdb_path, *authzdb_path;
svn_error_t *err;
- SVN_ERR(svn_config_read(cfg, filename, must_exist, pool));
+ SVN_ERR(svn_config_read2(cfg, filename, must_exist, FALSE, pool));
svn_config_get(*cfg, &pwdb_path, SVN_CONFIG_SECTION_GENERAL,
SVN_CONFIG_OPTION_PASSWORD_DB, NULL);
@@ -245,7 +245,7 @@
{
pwdb_path = svn_dirent_join(base, pwdb_path, pool);
- err = svn_config_read(pwdb, pwdb_path, TRUE, pool);
+ err = svn_config_read2(pwdb, pwdb_path, TRUE, FALSE, pool);
if (err)
{
if (server)
Index: subversion/libsvn_fs_fs/fs_fs.c
===================================================================
--- subversion/libsvn_fs_fs/fs_fs.c (revision 1068828)
+++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
@@ -1074,9 +1074,9 @@
{
fs_fs_data_t *ffd = fs->fsap_data;
- SVN_ERR(svn_config_read(&ffd->config,
- svn_dirent_join(fs->path, PATH_CONFIG, pool),
- FALSE, fs->pool));
+ SVN_ERR(svn_config_read2(&ffd->config,
+ svn_dirent_join(fs->path, PATH_CONFIG, pool),
+ FALSE, FALSE, fs->pool));
/* Initialize ffd->rep_sharing_allowed. */
if (ffd->format >= SVN_FS_FS__MIN_REP_SHARING_FORMAT)
Fix Issue #3781 (Case sensitive authz).
* subversion/tests/cmdline/authz_tests.py
(case_sensitive_authz): Removed XFail decorator.
* subversion/include/svn_config.h
(svn_config_create) : Documented new parameter.
(svn_config_read) : Deprecated.
(svn_config_read2) : New function prototype, updated documentation.
* subversion/libsvn_subr/config_impl.h
(svn_config_t): Added a new boolean called section_names_case_sensitive.
* subversion/libsvn_subr/deprecated.c
(svn_config_read): New function that calls svn_config_read2
with section_names_case_sensitive as FALSE.
* subversion/libsvn_subr/config.c
(svn_config_create): Added a parameter section_names_case_sensitive
which is used to initialize the config.
(find_option,
svn_config_set) : Added logic to make section names case sensitive.
(svn_config_read) : Deprecated.
(svn_config_read2) : New function that deprecates svn_config_read.
Accepts a boolean section_names_case_sensitive,
and populates the section names case sensitively
if TRUE.
(read_all, svn_config_merge) : Fixed callers.
* subversion/libsvn_repos/authz.c,
subversion/tests/libsvn_subr/cache-test.c,
subversion/tests/libsvn_subr/config-test.c,
subversion/tests/cmdline/atomic-ra-revprop-change.c,
subversion/svnserve/serve.c,
subversion/libsvn_fs_fs/fs_fs.c
(svn_repos_authz_read, test_memcache_basic, test_memcache_longkey,
test_text_retrieval,test_boolean_retrieval, test_has_section,
construct_config, load_configs, read_config) : Fixed callers.
Patch by: Arwin Arni <arwin{_AT_}collab.net>