⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 repos.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
      "# has been added, modified or deleted.  Subversion runs this hook by"      APR_EOL_STR      "# invoking a program (script, executable, binary, etc.) named"      APR_EOL_STR      "# '" SVN_REPOS__HOOK_POST_REVPROP_CHANGE       "' (for which this file is a template), with the"      APR_EOL_STR      "# following ordered arguments:"      APR_EOL_STR      "#"      APR_EOL_STR      "#   [1] REPOS-PATH   (the path to this repository)"      APR_EOL_STR      "#   [2] REV          (the revision that was tweaked)"      APR_EOL_STR      "#   [3] USER         (the username of the person tweaking the property)"      APR_EOL_STR      "#   [4] PROPNAME     (the property that was changed)"      APR_EOL_STR      "#   [5] ACTION       (the property was 'A'dded, 'M'odified, or "      "'D'eleted)"      APR_EOL_STR      "#"      APR_EOL_STR      "#   [STDIN] PROPVAL  ** the old property value is passed via STDIN."      APR_EOL_STR      "#"      APR_EOL_STR      "# Because the propchange has already completed and cannot be undone,"      APR_EOL_STR      "# the exit code of the hook program is ignored.  The hook program"      APR_EOL_STR      "# can use the 'svnlook' utility to help it examine the"      APR_EOL_STR      "# new property value."      APR_EOL_STR      "#"      APR_EOL_STR      "# On a Unix system, the normal procedure is to have "      "'"      SVN_REPOS__HOOK_POST_REVPROP_CHANGE      "'"       APR_EOL_STR      "# invoke other programs to do the real work, though it may do the"      APR_EOL_STR      "# work itself too."      APR_EOL_STR      "#"      APR_EOL_STR      "# Note that"      " '" SVN_REPOS__HOOK_POST_REVPROP_CHANGE "' "      "must be executable by the user(s) who will"      APR_EOL_STR      "# invoke it (typically the user httpd runs as), and that user must"      APR_EOL_STR      "# have filesystem-level permission to access the repository."      APR_EOL_STR      "#"      APR_EOL_STR      "# On a Windows system, you should name the hook program"      APR_EOL_STR      "# '" SVN_REPOS__HOOK_POST_REVPROP_CHANGE ".bat' or "      "'" SVN_REPOS__HOOK_POST_REVPROP_CHANGE ".exe',"      APR_EOL_STR      "# but the basic idea is the same."      APR_EOL_STR      "# "      APR_EOL_STR      HOOKS_ENVIRONMENT_TEXT      "# "      APR_EOL_STR      "# Here is an example hook script, for a Unix /bin/sh interpreter."      APR_EOL_STR      PREWRITTEN_HOOKS_TEXT      APR_EOL_STR      APR_EOL_STR      "REPOS=\"$1\""      APR_EOL_STR      "REV=\"$2\""      APR_EOL_STR      "USER=\"$3\""      APR_EOL_STR      "PROPNAME=\"$4\""      APR_EOL_STR      "ACTION=\"$5\""      APR_EOL_STR      APR_EOL_STR      "propchange-email.pl \"$REPOS\" \"$REV\" \"$USER\" \"$PROPNAME\" "      "watchers@example.org"      APR_EOL_STR;    SVN_ERR_W(svn_io_file_create(this_path, contents, pool),              _("Creating post-revprop-change hook"));  } /* end post-revprop-change hook */  return SVN_NO_ERROR;}static svn_error_t *create_conf(svn_repos_t *repos, apr_pool_t *pool){  SVN_ERR_W(create_repos_dir(repos->conf_path, pool),            _("Creating conf directory"));  /* Write a default template for svnserve.conf. */  {    static const char * const svnserve_conf_contents =      "### This file controls the configuration of the svnserve daemon, if you"      APR_EOL_STR      "### use it to allow access to this repository.  (If you only allow"      APR_EOL_STR      "### access through http: and/or file: URLs, then this file is"      APR_EOL_STR      "### irrelevant.)"      APR_EOL_STR      APR_EOL_STR      "### Visit http://subversion.tigris.org/ for more information."      APR_EOL_STR      APR_EOL_STR      "[general]"      APR_EOL_STR      "### These options control access to the repository for unauthenticated"      APR_EOL_STR      "### and authenticated users.  Valid values are \"write\", \"read\","      APR_EOL_STR      "### and \"none\".  The sample settings below are the defaults."      APR_EOL_STR      "# anon-access = read"      APR_EOL_STR      "# auth-access = write"      APR_EOL_STR      "### The password-db option controls the location of the password"      APR_EOL_STR      "### database file.  Unless you specify a path starting with a /,"      APR_EOL_STR      "### the file's location is relative to the conf directory."      APR_EOL_STR      "### Uncomment the line below to use the default password file."      APR_EOL_STR      "# password-db = passwd"      APR_EOL_STR      "### The authz-db option controls the location of the authorization"      APR_EOL_STR      "### rules for path-based access control.  Unless you specify a path"      APR_EOL_STR      "### starting with a /, the file's location is relative to the conf"      APR_EOL_STR      "### directory.  If you don't specify an authz-db, no path-based access"      APR_EOL_STR      "### control is done."      APR_EOL_STR      "### Uncomment the line below to use the default authorization file."      APR_EOL_STR      "# authz-db = " SVN_REPOS__CONF_AUTHZ      APR_EOL_STR      "### This option specifies the authentication realm of the repository."      APR_EOL_STR      "### If two repositories have the same authentication realm, they should"      APR_EOL_STR      "### have the same password database, and vice versa.  The default realm"      APR_EOL_STR      "### is repository's uuid."      APR_EOL_STR      "# realm = My First Repository"      APR_EOL_STR;    SVN_ERR_W(svn_io_file_create(svn_repos_svnserve_conf(repos, pool),                                 svnserve_conf_contents, pool),              _("Creating svnserve.conf file"));  }  {    static const char * const passwd_contents =      "### This file is an example password file for svnserve."      APR_EOL_STR      "### Its format is similar to that of svnserve.conf. As shown in the"      APR_EOL_STR      "### example below it contains one section labelled [users]."      APR_EOL_STR      "### The name and password for each user follow, one account per line."      APR_EOL_STR      APR_EOL_STR      "[users]"      APR_EOL_STR      "# harry = harryssecret"      APR_EOL_STR      "# sally = sallyssecret"      APR_EOL_STR;    SVN_ERR_W(svn_io_file_create(svn_path_join(repos->conf_path,                                               SVN_REPOS__CONF_PASSWD,                                               pool),                                 passwd_contents, pool),              _("Creating passwd file"));  }  {    static const char * const authz_contents =      "### This file is an example authorization file for svnserve."      APR_EOL_STR      "### Its format is identical to that of mod_authz_svn authorization"      APR_EOL_STR      "### files."      APR_EOL_STR      "### As shown below each section defines authorizations for the path and"      APR_EOL_STR      "### (optional) repository specified by the section name."      APR_EOL_STR      "### The authorizations follow. An authorization line can refer to a"      APR_EOL_STR      "### single user, to a group of users defined in a special [groups]"      APR_EOL_STR      "### section, or to anyone using the '*' wildcard.  Each definition can"      APR_EOL_STR      "### grant read ('r') access, read-write ('rw') access, or no access"      APR_EOL_STR      "### ('')."      APR_EOL_STR      APR_EOL_STR      "[groups]"      APR_EOL_STR      "# harry_and_sally = harry,sally"      APR_EOL_STR      APR_EOL_STR      "# [/foo/bar]"      APR_EOL_STR      "# harry = rw"      APR_EOL_STR      "# * ="      APR_EOL_STR      APR_EOL_STR      "# [repository:/baz/fuz]"      APR_EOL_STR      "# @harry_and_sally = rw"      APR_EOL_STR      "# * = r"      APR_EOL_STR;    SVN_ERR_W(svn_io_file_create(svn_path_join(repos->conf_path,                                               SVN_REPOS__CONF_AUTHZ,                                               pool),                                 authz_contents, pool),              _("Creating authz file"));  }  return SVN_NO_ERROR;}/* Allocate and return a new svn_repos_t * object, initializing the   directory pathname members based on PATH.   The members FS, FORMAT, and FS_TYPE are *not* initialized (they are null),   and it it 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_path_join(path, SVN_REPOS__DB_DIR, pool);  repos->dav_path = svn_path_join(path, SVN_REPOS__DAV_DIR, pool);  repos->conf_path = svn_path_join(path, SVN_REPOS__CONF_DIR, pool);  repos->hook_path = svn_path_join(path, SVN_REPOS__HOOK_DIR, pool);  repos->lock_path = svn_path_join(path, SVN_REPOS__LOCK_DIR, pool);  return repos;}static svn_error_t *create_repos_structure(svn_repos_t *repos,                       const char *path,                       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.  */  SVN_ERR_W(create_repos_dir(repos->dav_path, pool),            _("Creating DAV sandbox dir"));  /* Create the lock directory.  */  SVN_ERR(create_locks(repos, pool));  /* Create the hooks directory.  */  SVN_ERR(create_hooks(repos, pool));  /* Create the conf directory.  */  SVN_ERR(create_conf(repos, pool));  /* Write the top-level README file. */  {    const char * const readme_header =      "This is a Subversion repository; use the 'svnadmin' tool to examine"      APR_EOL_STR      "it.  Do not add, delete, or modify files here unless you know how"      APR_EOL_STR      "to avoid corrupting the repository."      APR_EOL_STR      APR_EOL_STR;    const char * const readme_bdb_insert =      "The directory \""      SVN_REPOS__DB_DIR      "\" contains a Berkeley DB environment,"      APR_EOL_STR      "you may need to tweak the values in \""      SVN_REPOS__DB_DIR      "/DB_CONFIG\" to match the"      APR_EOL_STR      "requirements of your site."      APR_EOL_STR      APR_EOL_STR;    const char * const readme_footer =      "Visit http://subversion.tigris.org/ for more information."      APR_EOL_STR;    apr_file_t *f;    apr_size_t written;    SVN_ERR(svn_io_file_open(&f,                             svn_path_join(path, SVN_REPOS__README, pool),                             (APR_WRITE | APR_CREATE | APR_EXCL),                             APR_OS_DEFAULT, pool));        SVN_ERR(svn_io_file_write_full(f, readme_header, strlen(readme_header),                                   &written, pool));    if (strcmp(repos->fs_type, SVN_FS_TYPE_BDB) == 0)      SVN_ERR(svn_io_file_write_full(f, readme_bdb_insert,                                     strlen(readme_bdb_insert),                                     &written, pool));    SVN_ERR(svn_io_file_write_full(f, readme_footer, strlen(readme_footer),                                   &written, pool));    SVN_ERR(svn_io_file_close(f, pool));  }  return SVN_NO_ERROR;}/* There is, at present, nothing within the direct responsibility   of libsvn_repos which requires locking.  For historical compatibility   reasons, the BDB libsvn_fs backend does not do its own locking, expecting   libsvn_repos to do the locking for it.  Here we take care of that   backend-specific requirement.    The kind of lock is controlled by EXCLUSIVE and NONBLOCKING.   The lock is scoped to POOL.  */static svn_error_t *lock_repos(svn_repos_t *repos,           svn_boolean_t exclusive,           svn_boolean_t nonblocking,           apr_pool_t *pool){  if (strcmp(repos->fs_type, SVN_FS_TYPE_BDB) == 0)    {      svn_error_t *err;      const char *lockfile_path = svn_repos_db_lockfile(repos, pool);      err = svn_io_file_lock2(lockfile_path, exclusive, nonblocking, pool);      if (err != NULL && APR_STATUS_IS_EAGAIN(err->apr_err))        return err;      SVN_ERR_W(err, _("Error opening db lockfile"));    }  return SVN_NO_ERROR;}svn_error_t *svn_repos_create(svn_repos_t **repos_p,                 const char *path,                 const char *unused_1,                 const char *unused_2,                 apr_hash_t *config,                 apr_hash_t *fs_config,                 apr_pool_t *pool){  svn_repos_t *repos;  svn_error_t *err;  /* Allocate a repository object, filling in the format we will create. */  repos = create_svn_repos_t(path, pool);  repos->format = SVN_REPOS__FORMAT_NUMBER;  /* Discover the type of the filesystem we are about to create. */  if (fs_config)    {      repos->fs_type = apr_hash_get(fs_config, SVN_FS_CONFIG_FS_TYPE,                                    APR_HASH_KEY_STRING);      if (apr_hash_get(fs_config, SVN_FS_CONFIG_PRE_1_4_COMPATIBLE,                       APR_HASH_KEY_STRING))        repos->format = SVN_REPOS__FORMAT_NUMBER_LEGACY;    }  if (! repos->fs_type)    repos->fs_type = DEFAULT_FS_TYPE;  /* Create the various files and subdirectories for the repository. */  SVN_ERR_W(create_repos_structure(repos, path, pool),            _("Repository creation failed"));    /* Lock if needed. */  SVN_ERR(lock_repos(repos, FALSE, FALSE, pool));  /* Create an environment for the filesystem. */  if ((err = svn_fs_create(&repos->fs, repos->db_path, fs_config, pool)))    {      /* If there was an error making the filesytem, e.g. unknown/supported       * filesystem type.  Clean up after ourselves.  Yes this is safe because       * create_repos_structure will fail if the path existed before we started       * so we can't accidentally remove a directory that previously existed. */      svn_error_clear(svn_io_remove_dir(path, pool));      return err;    }  /* This repository is ready.  Stamp it with a format number. */  SVN_ERR(svn_io_write_version_file           (svn_path_join(path, SVN_REPOS__FORMAT, pool),           repos->format, pool));  *repos_p = repos;  return SVN_NO_ERROR;}/* Check if @a path is the root of a repository by checking if the * path contains the expected files and directories.  Return TRUE * on errors (which would be permission errors, probably) so that * we the user will see them after we try to open the repository * for real.  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -