Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/svnserve/serve.c view on Meta::CPAN
url_buf = svn_stringbuf_create(url, pool);
svn_path_remove_components(url_buf,
svn_path_component_count(b->fs_path->data));
b->repos_url = url_buf->data;
b->authz_repos_name = svn_dirent_is_child(root, repos_root, pool);
if (b->authz_repos_name == NULL)
b->repos_name = svn_dirent_basename(repos_root, pool);
else
b->repos_name = b->authz_repos_name;
b->repos_name = svn_path_uri_encode(b->repos_name, pool);
/* If the svnserve configuration has not been loaded then load it from the
* repository. */
if (NULL == b->cfg)
{
b->base = svn_repos_conf_dir(b->repos, pool);
SVN_ERR(svn_config_read3(&b->cfg, svn_repos_svnserve_conf(b->repos, pool),
FALSE, /* must_exist */
FALSE, /* section_names_case_sensitive */
FALSE, /* option_names_case_sensitive */
pool));
SVN_ERR(load_pwdb_config(b, conn, pool));
SVN_ERR(load_authz_config(b, conn, repos_root, pool));
}
/* svnserve.conf has been loaded via the --config-file option so need
* to load pwdb and authz. */
else
{
SVN_ERR(load_pwdb_config(b, conn, pool));
SVN_ERR(load_authz_config(b, conn, repos_root, pool));
}
#ifdef SVN_HAVE_SASL
/* Should we use Cyrus SASL? */
SVN_ERR(svn_config_get_bool(b->cfg, &b->use_sasl, SVN_CONFIG_SECTION_SASL,
SVN_CONFIG_OPTION_USE_SASL, FALSE));
#endif
/* Use the repository UUID as the default realm. */
SVN_ERR(svn_fs_get_uuid(b->fs, &b->realm, pool));
svn_config_get(b->cfg, &b->realm, SVN_CONFIG_SECTION_GENERAL,
SVN_CONFIG_OPTION_REALM, b->realm);
/* Make sure it's possible for the client to authenticate. Note
that this doesn't take into account any authz configuration read
above, because we can't know about access it grants until paths
are given by the client. */
if (get_access(b, UNAUTHENTICATED) == NO_ACCESS
&& (get_access(b, AUTHENTICATED) == NO_ACCESS
|| (!b->tunnel_user && !b->pwdb && !b->use_sasl)))
return error_create_and_log(SVN_ERR_RA_NOT_AUTHORIZED, NULL,
"No access allowed to this repository",
b, conn, pool);
/* 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_ERR(svn_repos_hooks_setenv(b->repos, hooks_env, pool));
return SVN_NO_ERROR;
}
/* Compute the authentication name EXTERNAL should be able to get, if any. */
static const char *get_tunnel_user(serve_params_t *params, apr_pool_t *pool)
{
/* Only offer EXTERNAL for connections tunneled over a login agent. */
if (!params->tunnel)
return NULL;
/* If a tunnel user was provided on the command line, use that. */
if (params->tunnel_user)
return params->tunnel_user;
return svn_user_get_name(pool);
}
static void
fs_warning_func(void *baton, svn_error_t *err)
{
fs_warning_baton_t *b = baton;
log_server_error(err, b->server, b->conn, b->pool);
/* TODO: Keep log_pool in the server baton, cleared after every log? */
svn_pool_clear(b->pool);
}
/* Return the normalized repository-relative path for the given PATH
* (may be a URL, full path or relative path) and fs contained in the
* server baton BATON. Allocate the result in POOL.
*/
static const char *
get_normalized_repo_rel_path(void *baton,
const char *path,
apr_pool_t *pool)
{
server_baton_t *sb = baton;
if (svn_path_is_url(path))
{
/* This is a copyfrom URL. */
path = svn_uri_skip_ancestor(sb->repos_url, path, pool);
path = svn_fspath__canonicalize(path, pool);
}
else
{
/* This is a base-relative path. */
if ((path)[0] != '/')
/* Get an absolute path for use in the FS. */
path = svn_fspath__join(sb->fs_path->data, path, pool);
}
return path;
}
/* Get the revision root for REVISION in fs given by server baton BATON
* and return it in *FS_ROOT. Use HEAD if REVISION is SVN_INVALID_REVNUM.
* Use POOL for allocations.
*/
static svn_error_t *
( run in 1.901 second using v1.01-cache-2.11-cpan-2ed5026b665 )