Alien-SVN

 view release on metacpan or  search on metacpan

src/subversion/subversion/libsvn_repos/repos.c  view on Meta::CPAN

"### grant read ('r') access, read-write ('rw') access, or no access"        NL
"### ('')."                                                                  NL
""                                                                           NL
"[aliases]"                                                                  NL
"# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average"  NL
""                                                                           NL
"[groups]"                                                                   NL
"# harry_and_sally = harry,sally"                                            NL
"# harry_sally_and_joe = harry,sally,&joe"                                   NL
""                                                                           NL
"# [/foo/bar]"                                                               NL
"# harry = rw"                                                               NL
"# &joe = r"                                                                 NL
"# * ="                                                                      NL
""                                                                           NL
"# [repository:/baz/fuz]"                                                    NL
"# @harry_and_sally = rw"                                                    NL
"# * = r"                                                                    NL;

    SVN_ERR_W(svn_io_file_create(svn_dirent_join(repos->conf_path,
                                                 SVN_REPOS__CONF_AUTHZ,
                                                 pool),
                                 authz_contents, 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 \
                                                 SVN_REPOS__HOOK_DESC_EXT,
                                                 pool),
                                 hooks_env_contents, pool),
              _("Creating hooks-env file"));
  }

  return SVN_NO_ERROR;
}

svn_error_t *
svn_repos_hooks_setenv(svn_repos_t *repos,
                       const char *hooks_env_path,
                       apr_pool_t *scratch_pool)
{
  if (hooks_env_path == NULL)
    repos->hooks_env_path = svn_dirent_join(repos->conf_path,
                                            SVN_REPOS__CONF_HOOKS_ENV,
                                            repos->pool);
  else if (!svn_dirent_is_absolute(hooks_env_path))
    repos->hooks_env_path = svn_dirent_join(repos->conf_path,
                                            hooks_env_path,
                                            repos->pool);
  else
    repos->hooks_env_path = apr_pstrdup(repos->pool, hooks_env_path);

  return SVN_NO_ERROR;
}

/* Allocate and return a new svn_repos_t * object, initializing the
   directory pathname members based on PATH, and initializing the
   REPOSITORY_CAPABILITIES member.
   The members FS, FORMAT, and FS_TYPE are *not* initialized (they are null),
   and it is the caller's responsibility to fill them in if needed.  */
static svn_repos_t *
create_svn_repos_t(const char *path, apr_pool_t *pool)
{
  svn_repos_t *repos = apr_pcalloc(pool, sizeof(*repos));

  repos->path = apr_pstrdup(pool, path);
  repos->db_path = svn_dirent_join(path, SVN_REPOS__DB_DIR, pool);
  repos->conf_path = svn_dirent_join(path, SVN_REPOS__CONF_DIR, pool);
  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->hooks_env_path = NULL;
  repos->repository_capabilities = apr_hash_make(pool);
  repos->pool = pool;

  return repos;
}


static svn_error_t *
create_repos_structure(svn_repos_t *repos,
                       const char *path,
                       apr_hash_t *fs_config,
                       apr_pool_t *pool)
{
  /* Create the top-level repository directory. */
  SVN_ERR_W(create_repos_dir(path, pool),
            _("Could not create top-level directory"));

  /* Create the DAV sandbox directory if pre-1.4 or pre-1.5-compatible. */
  if (fs_config
      && (svn_hash_gets(fs_config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE)
          || svn_hash_gets(fs_config, SVN_FS_CONFIG_PRE_1_5_COMPATIBLE)))
    {
      const char *dav_path = svn_dirent_join(repos->path,
                                             SVN_REPOS__DAV_DIR, pool);
      SVN_ERR_W(create_repos_dir(dav_path, pool),
                _("Creating DAV sandbox dir"));
    }



( run in 1.292 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )