svn_error_t * svn_auth__file_path(const char **path, const char *cred_kind, const char *realmstring, const char *config_dir, apr_pool_t *pool) { const char *authdir_path, *hexname; svn_checksum_t *checksum; /* Construct the path to the directory containing the creds files, e.g. "~/.subversion/auth/svn.simple". The last component is simply the cred_kind. */ SVN_ERR(svn_config_get_user_config_path(&authdir_path, config_dir, SVN_CONFIG__AUTH_SUBDIR, pool)); if (authdir_path) { authdir_path = svn_dirent_join(authdir_path, cred_kind, pool); /* Construct the basename of the creds file. It's just the realmstring converted into an md5 hex string. */ SVN_ERR(svn_checksum(&checksum, svn_checksum_md5, realmstring, strlen(realmstring), pool)); hexname = svn_checksum_to_cstring(checksum, pool); *path = svn_dirent_join(authdir_path, hexname, pool); } else *path = NULL; return SVN_NO_ERROR; }
SVNAuthData::SVNAuthData() : SVNBase() , m_prompt(false) { m_pool = svn_pool_create(NULL); svn_error_clear(svn_client_create_context2(&m_pctx, SVNConfig::Instance().GetConfig(m_pool), m_pool)); // set up authentication m_prompt.Init(m_pool, m_pctx); const char * path = nullptr; svn_config_get_user_config_path(&path, g_pConfigDir, NULL, m_pool); svn_auth_set_parameter(m_pctx->auth_baton, SVN_AUTH_PARAM_CONFIG_DIR, path); m_pctx->client_name = SVNHelper::GetUserAgentString(m_pool); }
/* fonction permettant d'initialiser le contexte avant toute opération svn */ svn_client_ctx_t *initialize_context(){ svn_error_t *err; svn_config_t *cfg; err = svn_config_ensure (NULL, pool); if (err) { svn_handle_error2 (err, stderr, FALSE, "svn_support: "); return NULL; } // -- Creation du contexte -- svn_client_create_context(&ctx,pool); svn_config_get_config (&(ctx->config), NULL, pool); // -- Récupération du fichier de config dans ~/.subversion -- const char *config_path; svn_config_get_user_config_path(&config_path, NULL, SVN_CONFIG_CATEGORY_CONFIG, pool); svn_config_read(&cfg, config_path, TRUE, pool); // -- Initialisation des parametres d'authentification -- svn_cmdline_create_auth_baton(&ctx->auth_baton, TRUE, NULL, NULL, config_path, FALSE, FALSE, cfg, cancel, ctx->cancel_baton, pool); return ctx; }
/* CONFIG_DIR provides an override for the default behavior of reading the default set of overlay files described by read_all()'s doc string. Returns non-NULL *CFG or an error. */ static svn_error_t * get_category_config(svn_config_t **cfg, const char *config_dir, const char *category, apr_pool_t *pool) { const char *usr_reg_path = NULL, *sys_reg_path = NULL; const char *usr_cfg_path, *sys_cfg_path; svn_error_t *err = NULL; *cfg = NULL; if (! config_dir) { #ifdef WIN32 sys_reg_path = apr_pstrcat(pool, SVN_REGISTRY_SYS_CONFIG_PATH, category, SVN_VA_NULL); usr_reg_path = apr_pstrcat(pool, SVN_REGISTRY_USR_CONFIG_PATH, category, SVN_VA_NULL); #endif /* WIN32 */ err = svn_config__sys_config_path(&sys_cfg_path, category, pool); if ((err) && (err->apr_err == SVN_ERR_BAD_FILENAME)) { sys_cfg_path = NULL; svn_error_clear(err); } else if (err) return err; } else sys_cfg_path = NULL; SVN_ERR(svn_config_get_user_config_path(&usr_cfg_path, config_dir, category, pool)); return read_all(cfg, sys_reg_path, usr_reg_path, sys_cfg_path, usr_cfg_path, pool); }