ubik: Use supplied config directory in ugen
authorSimon Wilkinson <sxw@your-file-system.com>
Mon, 30 May 2011 19:07:01 +0000 (20:07 +0100)
committerDerrick Brashear <shadow@dementia.org>
Tue, 7 Jun 2011 14:56:24 +0000 (07:56 -0700)
ugen_ClientInit permits the configuration directory to use to be
passed on the command line. However, it was then promptly overwritting
the supplied directory with the standard client (or server) directories,
depending on whether localauth was in use or not.

As a start to fixing this anti-social behaviour, modify ugen so that if
we're not doing localauth, and if the caller has passed us a config
directory, use that instead of the system default one. This allows us to
start creating test harnesses for our command line tools.

Change-Id: I6916389ce56df4cee62845a03282c5c10d3095eb
Reviewed-on: http://gerrit.openafs.org/4809
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/ubik/uinit.c

index fee0aad..e43ffc4 100644 (file)
@@ -47,7 +47,6 @@ ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 s
     struct rx_securityClass *sc;
     /* This must change if VLDB_MAXSERVERS becomes larger than MAXSERVERS */
     static struct rx_connection *serverconns[MAXSERVERS];
-    const char *confdir;
 
     code = rx_Init(0);
     if (code) {
@@ -59,20 +58,21 @@ ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 s
     secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
     if (sauth) {
        secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
-       confdir = AFSDIR_SERVER_ETC_DIRPATH;
+       confDir = AFSDIR_SERVER_ETC_DIRPATH;
     } else {
-       confdir = AFSDIR_CLIENT_ETC_DIRPATH;
+       if (confDir == NULL)
+           confDir = AFSDIR_CLIENT_ETC_DIRPATH;
     }
 
     if (noAuthFlag) {
        secFlags |= AFSCONF_SECOPTS_NOAUTH;
     }
 
-    tdir = afsconf_Open(confdir);
+    tdir = afsconf_Open(confDir);
     if (!tdir) {
        fprintf(stderr,
                "%s: Could not process files in configuration directory (%s).\n",
-               funcName, confdir);
+               funcName, confDir);
        return -1;
     }
 
@@ -83,7 +83,7 @@ ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 s
     if (code) {
        afsconf_Close(tdir);
        fprintf(stderr, "%s: can't find cell %s's hosts in %s/%s\n",
-               funcName, cellName, confdir, AFSDIR_CELLSERVDB_FILE);
+               funcName, cellName, confDir, AFSDIR_CELLSERVDB_FILE);
        return -1;
     }
     code = afsconf_PickClientSecObj(tdir, secFlags, &info, cellName, &sc,