コード例 #1
0
ファイル: authz.c プロジェクト: 2asoft/freebsd
svn_error_t *
svn_repos_authz_check_access(svn_authz_t *authz, const char *repos_name,
                             const char *path, const char *user,
                             svn_repos_authz_access_t required_access,
                             svn_boolean_t *access_granted,
                             apr_pool_t *pool)
{
  const char *current_path;

  if (!repos_name)
    repos_name = "";

  /* If PATH is NULL, check if the user has *any* access. */
  if (!path)
    {
      *access_granted = authz_get_any_access(authz->cfg, repos_name,
                                             user, required_access, pool);
      return SVN_NO_ERROR;
    }

  /* Sanity check. */
  SVN_ERR_ASSERT(path[0] == '/');

  /* Determine the granted access for the requested path. */
  path = svn_fspath__canonicalize(path, pool);
  current_path = path;

  while (!authz_get_path_access(authz->cfg, repos_name,
                                current_path, user,
                                required_access,
                                access_granted,
                                pool))
    {
      /* Stop if the loop hits the repository root with no
         results. */
      if (current_path[0] == '/' && current_path[1] == '\0')
        {
          /* Deny access by default. */
          *access_granted = FALSE;
          return SVN_NO_ERROR;
        }

      /* Work back to the parent path. */
      current_path = svn_fspath__dirname(current_path, pool);
    }

  /* If the caller requested recursive access, we need to walk through
     the entire authz config to see whether any child paths are denied
     to the requested user. */
  if (*access_granted && (required_access & svn_authz_recursive))
    *access_granted = authz_get_tree_access(authz->cfg, repos_name, path,
                                            user, required_access, pool);

  return SVN_NO_ERROR;
}
コード例 #2
0
ファイル: editor.c プロジェクト: Ranga123/test1
/* Can we create a node at FSPATH in TXN_ROOT? If something already exists
   at that path, then the client MAY be out of date. We then have to see if
   the path was created/modified in this transaction. IOW, it is new and
   can be replaced without problem.

   Note: the editor protocol disallows double-modifications. This is to
   ensure somebody does not accidentally overwrite another file due to
   being out-of-date.  */
static svn_error_t *
can_create(svn_fs_root_t *txn_root,
           const char *fspath,
           apr_pool_t *scratch_pool)
{
    svn_node_kind_t kind;
    const char *cur_fspath;

    SVN_ERR(svn_fs_check_path(&kind, txn_root, fspath, scratch_pool));
    if (kind == svn_node_none)
        return SVN_NO_ERROR;

    /* ### I'm not sure if this works perfectly. We might have an ancestor
       ### that was modified as a result of a change on a cousin. We might
       ### misinterpret that as a *-here node which brought along this
       ### child. Need to write a test to verify. We may also be able to
       ### test the ancestor to determine if it has been *-here in this
       ### txn, or just a simple modification.  */

    /* Are any of the parents copied/moved/rotated-here?  */
    for (cur_fspath = fspath;
            strlen(cur_fspath) > 1;  /* not the root  */
            cur_fspath = svn_fspath__dirname(cur_fspath, scratch_pool))
    {
        svn_revnum_t created_rev;

        SVN_ERR(svn_fs_node_created_rev(&created_rev, txn_root, cur_fspath,
                                        scratch_pool));
        if (!SVN_IS_VALID_REVNUM(created_rev))
        {
            /* The node has no created revision, meaning it is uncommitted.
               Thus, it was created in this transaction, or it has already
               been modified in some way (implying it has already passed a
               modification check.  */
            /* ### verify the node has been *-here ??  */
            return SVN_NO_ERROR;
        }
    }

    return svn_error_createf(SVN_ERR_FS_OUT_OF_DATE, NULL,
                             _("'%s' already exists, so may be out"
                               " of date; try updating"),
                             fspath);
}