FreeBSD/contrib/subversion/subversion/svnserve/serve.c
/* Look for the repository given by URL, using ROOT as the virtual
 * repository root.  If we find one, fill in the repos, fs, repos_url,
 * and fs_path fields of REPOSITORY.  VHOST and READ_ONLY flags are the
 * same as in the server baton.
 *
 * CONFIG_POOL and AUTHZ_POOL shall be used to load any object of the
 * respective type.
 *
 * Use SCRATCH_POOL for temporary allocations.
 *
 */
Look for the repository given by URL, using ROOT as the virtual
repository root.  If we find one, fill in the repos, fs, repos_url,
and fs_path fields of REPOSITORY.  VHOST and READ_ONLY flags are the
same as in the server baton.

CONFIG_POOL and AUTHZ_POOL shall be used to load any object of the
respective type.

Use SCRATCH_POOL for temporary allocations.
Look for the repository given by URL using ROOT as the virtual repository root . If we find one fill in the repos fs repos_url and fs_path fields of REPOSITORY . VHOST and READ_ONLY flags are the same as in the server baton . CONFIG_POOL and AUTHZ_POOL shall be used to load any object of the respective type . Use SCRATCH_POOL for temporary allocations .
static svn_error_t *
find_repos(const char *url,
           const char *root,
           svn_boolean_t vhost,
           svn_boolean_t read_only,
           svn_config_t *cfg,
           repository_t *repository,
           svn_repos__config_pool_t *config_pool,
           svn_repos__authz_pool_t *authz_pool,
           apr_hash_t *fs_config,
           apr_pool_t *result_pool,
           apr_pool_t *scratch_pool)
{
  const char *path, *full_path, *fs_path, *hooks_env;
  svn_stringbuf_t *url_buf;
  path = skip_scheme_part(url);
  if (path == NULL)
    return svn_error_createf(SVN_ERR_BAD_URL, NULL,
                             "Non-svn URL passed to svn server: '%s'", url);
  if (! vhost)
    {
      path = strchr(path, '/');
      if (path == NULL)
        path = "";
    }
  path = svn_relpath_canonicalize(path, scratch_pool);
  path = svn_path_uri_decode(path, scratch_pool);
  if (!repos_path_valid(path))
    return svn_error_create(SVN_ERR_BAD_FILENAME, NULL,
                            "Couldn't determine repository path");
  full_path = svn_dirent_join(svn_dirent_canonicalize(root, scratch_pool),
                              path, scratch_pool);
  repository->repos_root = svn_repos_find_root_path(full_path, result_pool);
  if (!repository->repos_root)
    return svn_error_createf(SVN_ERR_RA_SVN_REPOS_NOT_FOUND, NULL,
                             "No repository found in '%s'", url);
  SVN_ERR(svn_repos_open3(&repository->repos, repository->repos_root,
                          fs_config, result_pool, scratch_pool));
  SVN_ERR(svn_repos_remember_client_capabilities(repository->repos,
                                                 repository->capabilities));
  repository->fs = svn_repos_fs(repository->repos);
  fs_path = full_path + strlen(repository->repos_root);
  repository->fs_path = svn_stringbuf_create(*fs_path ? fs_path : "/",
                                             result_pool);
  url_buf = svn_stringbuf_create(url, result_pool);
  svn_path_remove_components(url_buf,
                        svn_path_component_count(repository->fs_path->data));
  repository->repos_url = url_buf->data;
  repository->authz_repos_name = svn_dirent_is_child(root,
                                                     repository->repos_root,
                                                     result_pool);
  if (repository->authz_repos_name == NULL)
    repository->repos_name = svn_dirent_basename(repository->repos_root,
                                                 result_pool);
  else
    repository->repos_name = repository->authz_repos_name;
  repository->repos_name = svn_path_uri_encode(repository->repos_name,
                                               result_pool);
  if (NULL == cfg)
    {
      repository->base = svn_repos_conf_dir(repository->repos, result_pool);
      SVN_ERR(svn_repos__config_pool_get(&cfg, NULL, config_pool,
                                         svn_repos_svnserve_conf
                                            (repository->repos, result_pool),
                                         FALSE, FALSE, repository->repos,
                                         result_pool));
    }
  SVN_ERR(load_pwdb_config(repository, cfg, config_pool, result_pool));
  SVN_ERR(load_authz_config(repository, repository->repos_root, cfg,
                            authz_pool, result_pool));
#ifdef SVN_HAVE_SASL
    {
      const char *val;
      SVN_ERR(svn_config_get_bool(cfg, &repository->use_sasl,
                                  SVN_CONFIG_SECTION_SASL,
                                  SVN_CONFIG_OPTION_USE_SASL, FALSE));
      svn_config_get(cfg, &val, SVN_CONFIG_SECTION_SASL,
                    SVN_CONFIG_OPTION_MIN_SSF, "0");
      SVN_ERR(svn_cstring_atoui(&repository->min_ssf, val));
      svn_config_get(cfg, &val, SVN_CONFIG_SECTION_SASL,
                    SVN_CONFIG_OPTION_MAX_SSF, "256");
      SVN_ERR(svn_cstring_atoui(&repository->max_ssf, val));
    }
#endif
  SVN_ERR(svn_fs_get_uuid(repository->fs, &repository->realm, scratch_pool));
  svn_config_get(cfg, &repository->realm, SVN_CONFIG_SECTION_GENERAL,
                 SVN_CONFIG_OPTION_REALM, repository->realm);
  repository->realm = apr_pstrdup(result_pool, repository->realm);
  set_access(repository, cfg, read_only);
  svn_config_get(cfg, &hooks_env, SVN_CONFIG_SECTION_GENERAL,
                 SVN_CONFIG_OPTION_HOOKS_ENV, NULL);
  if (hooks_env)
    hooks_env = svn_dirent_internal_style(hooks_env, scratch_pool);
  repository->hooks_env = apr_pstrdup(result_pool, hooks_env);
  return SVN_NO_ERROR;
}
static svn_error_t * find_repos ( const char * url , const char * root , svn_boolean_t vhost , svn_boolean_t read_only , svn_config_t * cfg , repository_t * repository , svn_repos__config_pool_t * config_pool , svn_repos__authz_pool_t * authz_pool , apr_hash_t * fs_config , apr_pool_t * result_pool , apr_pool_t * scratch_pool ) { const char * path , * full_path , * fs_path , * hooks_env ; svn_stringbuf_t * url_buf ; path = skip_scheme_part ( url ) ; if ( path == NULL ) return svn_error_createf ( SVN_ERR_BAD_URL , NULL , " " , url ) ; if ( ! vhost ) { path = strchr ( path , ' ' ) ; if ( path == NULL ) path = " " ; } path = svn_relpath_canonicalize ( path , scratch_pool ) ; path = svn_path_uri_decode ( path , scratch_pool ) ; if ( ! repos_path_valid ( path ) ) return svn_error_create ( SVN_ERR_BAD_FILENAME , NULL , " " ) ; full_path = svn_dirent_join ( svn_dirent_canonicalize ( root , scratch_pool ) , path , scratch_pool ) ; repository -> repos_root = svn_repos_find_root_path ( full_path , result_pool ) ; if ( ! repository -> repos_root ) return svn_error_createf ( SVN_ERR_RA_SVN_REPOS_NOT_FOUND , NULL , " " , url ) ; SVN_ERR ( svn_repos_open3 ( & repository -> repos , repository -> repos_root , fs_config , result_pool , scratch_pool ) ) ; SVN_ERR ( svn_repos_remember_client_capabilities ( repository -> repos , repository -> capabilities ) ) ; repository -> fs = svn_repos_fs ( repository -> repos ) ; fs_path = full_path + strlen ( repository -> repos_root ) ; repository -> fs_path = svn_stringbuf_create ( * fs_path ? fs_path : " " , result_pool ) ; url_buf = svn_stringbuf_create ( url , result_pool ) ; svn_path_remove_components ( url_buf , svn_path_component_count ( repository -> fs_path -> data ) ) ; repository -> repos_url = url_buf -> data ; repository -> authz_repos_name = svn_dirent_is_child ( root , repository -> repos_root , result_pool ) ; if ( repository -> authz_repos_name == NULL ) repository -> repos_name = svn_dirent_basename ( repository -> repos_root , result_pool ) ; else repository -> repos_name = repository -> authz_repos_name ; repository -> repos_name = svn_path_uri_encode ( repository -> repos_name , result_pool ) ; if ( NULL == cfg ) { repository -> base = svn_repos_conf_dir ( repository -> repos , result_pool ) ; SVN_ERR ( svn_repos__config_pool_get ( & cfg , NULL , config_pool , svn_repos_svnserve_conf ( repository -> repos , result_pool ) , FALSE , FALSE , repository -> repos , result_pool ) ) ; } SVN_ERR ( load_pwdb_config ( repository , cfg , config_pool , result_pool ) ) ; SVN_ERR ( load_authz_config ( repository , repository -> repos_root , cfg , authz_pool , result_pool ) ) ; #ifdef SVN_HAVE_SASL { const char * val ; SVN_ERR ( svn_config_get_bool ( cfg , & repository -> use_sasl , SVN_CONFIG_SECTION_SASL , SVN_CONFIG_OPTION_USE_SASL , FALSE ) ) ; svn_config_get ( cfg , & val , SVN_CONFIG_SECTION_SASL , SVN_CONFIG_OPTION_MIN_SSF , " " ) ; SVN_ERR ( svn_cstring_atoui ( & repository -> min_ssf , val ) ) ; svn_config_get ( cfg , & val , SVN_CONFIG_SECTION_SASL , SVN_CONFIG_OPTION_MAX_SSF , " " ) ; SVN_ERR ( svn_cstring_atoui ( & repository -> max_ssf , val ) ) ; } #endif SVN_ERR ( svn_fs_get_uuid ( repository -> fs , & repository -> realm , scratch_pool ) ) ; svn_config_get ( cfg , & repository -> realm , SVN_CONFIG_SECTION_GENERAL , SVN_CONFIG_OPTION_REALM , repository -> realm ) ; repository -> realm = apr_pstrdup ( result_pool , repository -> realm ) ; set_access ( repository , cfg , read_only ) ; svn_config_get ( cfg , & hooks_env , SVN_CONFIG_SECTION_GENERAL , SVN_CONFIG_OPTION_HOOKS_ENV , NULL ) ; if ( hooks_env ) hooks_env = svn_dirent_internal_style ( hooks_env , scratch_pool ) ; repository -> hooks_env = apr_pstrdup ( result_pool , hooks_env ) ; return SVN_NO_ERROR ; }
Look for the repository given by URL, using ROOT as the virtual
 repository root.
Look for the repository given by URL using ROOT as the virtual repository root .
/* Skip past the scheme and authority part. */ /* Ensure that it isn't possible to escape the root by disallowing
     '..' segments. */ /* Join the server-configured root with the client path. */ /* Search for a repository in the full path. */ /* Open the repository and fill in b with the resulting information. */ /* If the svnserve configuration has not been loaded then load it from the
   * repository. */ /* Should we use Cyrus SASL? */ /* Use the repository UUID as the default 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. */ /* Configure hook script environment variables. */