> Factor authz checks down into add_file_or_dir and replace_file_or_dir.
The authz checks and associated call to absent_file_or_dir() appear in both
functions.
This patch factors that out. This is the first real work I've done with the
subversion code, so if it makes sense to do this, could someone check that I
got the semantics right? Oh yea, it probably needs a better (shorter)
function name :-)
Philip Miller
---- PATCH ----
Index: delta.c
===================================================================
--- delta.c (revision 8083)
+++ delta.c (working copy)
@@ -144,6 +144,11 @@
svn_node_kind_t tgt_kind,
apr_pool_t *pool);
+static svn_error_t *check_authz_read_func_or_absent
+ (struct context *c, void *dir_baton,
+ const char *target_path, const char *edit_path,
+ svn_node_kind_t tgt_kind, apr_pool_t *pool);
+
static svn_error_t *delta_dirs (struct context *c,
void *dir_baton,
const char *source_path,
@@ -794,13 +799,8 @@
/* Sanity-check our input. */
assert (target_path && edit_path);
- if (c->authz_read_func)
- {
- SVN_ERR (c->authz_read_func (&allowed, c->target_root, target_path,
- c->authz_read_baton, pool));
- if (!allowed)
- return absent_file_or_dir (c, dir_baton, edit_path, tgt_kind, pool);
- }
+ SVN_ERR (check_authz_read_func_or_absent (c, dir_baton, target_path,
+ edit_path, tgt_kind, pool));
if (tgt_kind == svn_node_dir)
{
@@ -851,13 +851,8 @@
/* Sanity-check our input. */
assert (target_path && source_path && edit_path);
- if (c->authz_read_func)
- {
- SVN_ERR (c->authz_read_func (&allowed, c->target_root, target_path,
- c->authz_read_baton, pool));
- if (!allowed)
- return absent_file_or_dir (c, dir_baton, edit_path, tgt_kind, pool);
- }
+ SVN_ERR (check_authz_read_func_or_absent (c, dir_baton, target_path,
+ edit_path, tgt_kind, pool));
/* Get the base revision for the entry from the hash. */
base_revision = get_path_revision (c->source_root, source_path, pool);
@@ -911,7 +906,27 @@
return SVN_NO_ERROR;
}
+/* Check if we're authorized to edit @a target_path and indicate that it's
+ absent if we're not. */
+static svn_error_t *check_authz_read_func_or_absent
+ (struct context *c, void *dir_baton,
+ const char *target_path, const char *edit_path,
+ svn_node_kind_t tgt_kind, apr_pool_t *pool);
+{
+ svn_boolean_t allowed;
+ if (c->authz_read_func)
+ {
+ SVN_ERR (c->authz_read_func (&allowed, c->target_root, target_path,
+ c->authz_read_baton, pool));
+ if (!allowed)
+ return absent_file_or_dir (c, dir_baton, edit_path, tgt_kind, pool);
+ }
+
+ return SVN_NO_ERROR;
+}
+
+
/* Emit deltas to turn SOURCE_PATH into TARGET_PATH. Assume that
DIR_BATON represents the directory we're constructing to the editor
in the context C. */
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Dec 26 04:01:37 2003