2011/5/17 Mark Phippard <markp...@gmail.com>: > On Mon, May 16, 2011 at 6:11 PM, Konstantin Kolinko > <knst.koli...@gmail.com> wrote: >> 2011/5/16 Mark Phippard <markp...@gmail.com>: >>> Looking at the code in trunk, it seems like this is coded properly and >>> should be working. I am seeing unexpected behavior. Maybe I just do >>> not understand how it works? >>> >>> In Subclipse we expose UI to tell us the config directory location. >>> Most people just leave this as the default, which is same as command >>> line. I wanted to test the password callbacks, so I pointed it at a >>> new folder so that I would get prompted again to cache credentials and >>> accept certs etc. I have verified that the Subclipse code is properly >>> calling the method to set this folder, however I do not get any >>> prompts. >>> Only if I rename the default config directory do I get >>> prompts. And I also see SVN recreate the default. >>> >>> This leads me to believe this code is broken in trunk, but from what I >>> can see it looks right. >>> >>> It looks like it calls a method on ClientContext: >>> >>> ClientContext::setConfigDirectory(const char *configDir) >>> { >>> // A change to the config directory may necessitate creation of >>> // the config templates. >>> SVN::Pool requestPool; >>> SVN_JNI_ERR(svn_config_ensure(configDir, requestPool.pool()), ); >>> >>> m_configDir = (configDir == NULL ? "" : configDir); >>> } >>> >>> Any ideas? >> >> Just guessing: >> >> 1. When you call the method, does it create >> "README.txt", "config", "servers" files in the specified directory? >> >> If so, then svn_config_ensure(..) call works correctly. > > Yes. But that is also why it seems like a problem in SVN. I can see > it create the folder but the actual auth cache is still coming from > the default folder. And if I remove the default folder, it gets > recreated.
The default folder will always be recreated, because org.apache.subversion.javahl.SVNClient Java class constructor always calls setConfigDirectory(null); It does not answer the question why you are observing this issue though. >> 2. The m_configDir field is later used by >> ClientContext::getContext(CommitMessage *message) >> >> Are you calling getContext() after the call to setConfigDirectory() ? > > getContext() is not exposed to JavaHL. It is only used internally by the C++. Oh, I see. SVNClient.cpp calls it internally before every operation. >> 3. Command line client works: >> svn --config-dir conf co https://127.0.0.1/ >> creates the configuration directory, asks whether I trust the >> certificate and remember the choice. >> >> This is with svn 1.7.0-dev from TortoiseSVN nightly. It is built from >> r1103260 of trunk. > > These questions are about JavaHL, not the CLI. Of course it is good > to validate it with the CLI, but as an example, I do not recall the > CLI ever using the auth cache of the default configuration area when > --config-dir was passed. So it seems like this is potentially a > problem in the way JavaHL is driving the API. I was comparing JavaHL code with command line client usage of svn_config_* API methods. Knowing that the command line client works gives some confidence. Looking into \subversion\libsvn_subr\cmdline.c it does: [[[ /* Build an authentication baton to give to libsvn_client. */ svn_auth_open(ab, providers, pool); /* Place any default --username or --password credentials into the auth_baton's run-time parameter hash. */ if (auth_username) svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DEFAULT_USERNAME, auth_username); if (auth_password) svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD, auth_password); /* Same with the --non-interactive option. */ if (non_interactive) svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_NON_INTERACTIVE, ""); if (config_dir) svn_auth_set_parameter(*ab, SVN_AUTH_PARAM_CONFIG_DIR, config_dir); ]]] Compare the above with ClientContext.cpp in ClientContext::getContext(CommitMessage *message). The code in ClientContext.cpp forgets to pass the config_dir setting to the authentication providers: [[[ /* Build an authentication baton to give to libsvn_client. */ svn_auth_open(&ab, providers, pool); /* Place any default --username or --password credentials into the * auth_baton's run-time parameter hash. ### Same with --no-auth-cache? */ if (!m_userName.empty()) svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_USERNAME, m_userName.c_str()); if (!m_passWord.empty()) svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD, m_passWord.c_str()); ]]] Looking into providers implementation, subversion\libsvn_subr\simple_providers.c the methods there (e.g. svn_auth__simple_first_creds_helper(..)) use the config_dir setting. Best regards, Konstantin Kolinko