[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Help request: svn_config_ensure and charset handling

From: Greg Hudson <ghudson_at_MIT.EDU>
Date: 2004-08-13 05:40:37 CEST

I'm trying to work around the httpd 2.0.50 APR bug, and the first step
is to replace calls to apr_dir_make() with calls to svn_io_dir_make()
so that we have a single place for the workaround. Most of these
calls are in config_file.c.

Since this is for a 1.1 backport, I don't want to break charset
handling in the process. Unfortunately, the current code seems to be
wrong in several places, which means the scope of my fix is going to
have to expand, which is never fun when you're preparing a change for
backporting. So I'd like some help verifying that my understanding is
correct.

In clients/cmdline/main.c, I see:

      case svn_cl__config_dir_opt:
        opt_state.config_dir = apr_pstrdup (pool,
                                            svn_path_canonicalize (opt_arg,
                                                                   pool));

Is this correct? opt_arg is in the locale charset, as far as I know,
which means it's not a valid argument to svn_path_canonicalize.

So we now have in opt_state.config_dir either NULL or a path which
theoretically ought to be in UTF-8 but in practice is in the locale
charset. We pass this to svn_config_ensure(), which (over in
libsvn_subr/config_file.c) calls svn_config__user_config_path(), which
handles NULL values by doing (error-checking elided):

    apr_err = apr_uid_current (&uid, &gid, pool);
    apr_err = apr_uid_name_get (&username, uid, pool);
    apr_err = apr_uid_homepath_get (&homedir, username, pool);
    *path_p = svn_path_join_many (pool,
                                  svn_path_canonicalize (homedir, pool),
                                  SVN_CONFIG__USR_DIRECTORY, fname, NULL);

(This is disappointing because well-behaved programs allow $HOME to
override the passwd file, but that's a side point.) Again, I think
we've taken a path in the locale charset and passed it to
svn_path_canonicalize. So we've replaced the NULL value with, again,
a path which theoretically ought to be in UTF-8 but which in practice
is in the locale charset.

svn_config_ensure() then uses the path with both svn_io_check_path()
and with apr_dir_make(), without converting from UTF-8 to the locale
charset for the APR call. I assume this means any non-ASCII
characters in the homedir will break when svn_io_check_path() tries to
convert the supposedly-UTF-8 path to the locale charset.

I *think* the correct solution is:

  * Fix clients/cmdline/main.c to convert the config_dir argument to
    UTF-8.
  * Fix config_dir.c to convert the homedir to UTF-8.
  * When the apr_dir_make and apr_file_open calls are converted to
    svn_io calls, the right thing will happen.

But I'd like some confirmation.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Aug 13 05:41:29 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.