diff --git a/doc/man-pages/pod1/pts.pod b/doc/man-pages/pod1/pts.pod index d3a890b053..978ee356be 100644 --- a/doc/man-pages/pod1/pts.pod +++ b/doc/man-pages/pod1/pts.pod @@ -111,18 +111,36 @@ The value of the AFSCELL environment variable. The local F file. +=item * + +The local F file. + +=back + Do not combine the B<-cell> and B<-localauth> options. A command on which the B<-localauth> flag is included always runs in the local cell (as defined in the server machine's local F file), whereas a command on which the B<-cell> argument is included runs in the specified foreign cell. -=back - =item B<-config> > The location of the directory to use to obtain configuration information, including the CellServDB. This is primarily provided for testing purposes. +If the B<-config> and B<-localauth> arguments are omitted, the command +interpreter searches for the configuration information in the following order: + +=over 4 + +=item * + +The F directory. + +=item * + +The F directory. + +=back =item B<-force> diff --git a/doc/man-pages/pod1/vos.pod.in b/doc/man-pages/pod1/vos.pod.in index f0ec34acd9..fb321326a0 100644 --- a/doc/man-pages/pod1/vos.pod.in +++ b/doc/man-pages/pod1/vos.pod.in @@ -157,6 +157,10 @@ The value of the AFSCELL environment variable. The local F file. +=item * + +The local F file. + =back Do not combine the B<-cell> and B<-localauth> options. A command on which @@ -169,6 +173,20 @@ specified foreign cell. The location of the directory to use to obtain configuration information, including the CellServDB. This is primarily provided for testing purposes. +If the B<-config> and B<-localauth> arguments are omitted, the command +interpreter searches for the configuration information in the following order: + +=over 4 + +=item * + +The F directory. + +=item * + +The F directory. + +=back =item B<-help> diff --git a/doc/man-pages/pod8/bos.pod b/doc/man-pages/pod8/bos.pod index 70f912667f..59889ed60e 100644 --- a/doc/man-pages/pod8/bos.pod +++ b/doc/man-pages/pod8/bos.pod @@ -147,6 +147,10 @@ The value of the AFSCELL environment variable. The local F file. +=item * + +The local F file. + =back Do not combine the B<-cell> and B<-localauth> options. A command on which diff --git a/src/bozo/bos.c b/src/bozo/bos.c index 7d56ce07a6..62f2a60303 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -88,6 +88,7 @@ GetConn(struct cmd_syndesc *as, int aencrypt) char *hostname; char *cellname = NULL; const char *confdir; + const char *retry_confdir; afs_int32 code; struct rx_connection *tconn; afs_int32 addr; @@ -113,16 +114,23 @@ GetConn(struct cmd_syndesc *as, int aencrypt) if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */ secFlags |= AFSCONF_SECOPTS_LOCALAUTH; confdir = AFSDIR_SERVER_ETC_DIRPATH; + retry_confdir = NULL; } else { confdir = AFSDIR_CLIENT_ETC_DIRPATH; + retry_confdir = AFSDIR_SERVER_ETC_DIRPATH; } if (as->parms[ADDPARMOFFSET + 1].items) { /* -noauth */ + /* If we're running with -noauth, we don't need a configuration + * directory. */ secFlags |= AFSCONF_SECOPTS_NOAUTH; } else { - /* If we're running with -noauth, we don't need a configuration - * directory */ tdir = afsconf_Open(confdir); + if (tdir == NULL && retry_confdir != NULL) { + fprintf(stderr, "bos: Retrying initialization with directory %s\n", + retry_confdir); + tdir = afsconf_Open(retry_confdir); + } if (tdir == NULL) { fprintf(stderr, "bos: can't open cell database (%s)\n", confdir); exit(1); diff --git a/src/ptserver/pts.c b/src/ptserver/pts.c index 8329db3328..c97307bdf1 100644 --- a/src/ptserver/pts.c +++ b/src/ptserver/pts.c @@ -45,7 +45,7 @@ struct sourcestack { struct authstate { int sec; - const char *confdir; + int initialized; char cell[MAXCELLCHARS]; }; @@ -185,6 +185,7 @@ GetGlobals(struct cmd_syndesc *as, void *arock) afs_int32 sec; int changed = 0; const char* confdir; + const char* retry_confdir; whoami = as->a0name; @@ -196,7 +197,7 @@ GetGlobals(struct cmd_syndesc *as, void *arock) } sec = state->sec; - if (state->confdir == NULL) { + if (state->initialized == 0) { changed = 1; } @@ -227,21 +228,31 @@ GetGlobals(struct cmd_syndesc *as, void *arock) if (as->parms[OPT_test].items || as->parms[OPT_localauth].items) { changed = 1; confdir = AFSDIR_SERVER_ETC_DIRPATH; + retry_confdir = NULL; } else { - if (sec == 2) + if (sec == 2) { confdir = AFSDIR_SERVER_ETC_DIRPATH; - else + retry_confdir = NULL; + } else { confdir = AFSDIR_CLIENT_ETC_DIRPATH; + retry_confdir = AFSDIR_SERVER_ETC_DIRPATH; + } } if (as->parms[OPT_config].items) { /* -config */ changed = 1; confdir = as->parms[OPT_config].items->data; + retry_confdir = NULL; } if (changed) { CleanUp(as, arock); code = pr_Initialize(sec, confdir, cell); + if (code != 0 && retry_confdir != NULL) { + fprintf(stderr, "pts: Retrying initialization with directory %s\n", + retry_confdir); + code = pr_Initialize(sec, retry_confdir, cell); + } } else { code = 0; } @@ -250,7 +261,7 @@ GetGlobals(struct cmd_syndesc *as, void *arock) return code; } state->sec = sec; - state->confdir = confdir; + state->initialized = 1; if (cell && cell != state->cell) strncpy(state->cell, cell, MAXCELLCHARS-1); diff --git a/src/volser/vos.c b/src/volser/vos.c index e43e9fb3f8..007bfe5064 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -106,7 +106,6 @@ cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_CONFIG, \ int rxInitDone = 0; extern struct ubik_client *cstruct; -const char *confdir; static struct tqHead busyHead, notokHead; @@ -5829,6 +5828,8 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock) char *tcell; afs_int32 code; int secFlags; + const char *confdir = AFSDIR_CLIENT_ETC_DIRPATH; + const char *retry_confdir = AFSDIR_SERVER_ETC_DIRPATH; /* Initialize the ubik_client connection */ rx_SetRxDeadTime(90); @@ -5845,6 +5846,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock) if (as->parms[COMMONPARM_OFFSET_LOCALAUTH].items) { /* -localauth specified */ secFlags |= AFSCONF_SECOPTS_LOCALAUTH; confdir = AFSDIR_SERVER_ETC_DIRPATH; + retry_confdir = NULL; } if (as->parms[COMMONPARM_OFFSET_ENCRYPT].items /* -encrypt specified */ @@ -5854,11 +5856,19 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock) ) secFlags |= AFSCONF_SECOPTS_ALWAYSENCRYPT; - if (as->parms[COMMONPARM_OFFSET_CONFIG].items) /* -config flag set */ + if (as->parms[COMMONPARM_OFFSET_CONFIG].items) { /* -config flag set */ confdir = as->parms[COMMONPARM_OFFSET_CONFIG].items->data; + retry_confdir = NULL; + } - if ((code = vsu_ClientInit(confdir, tcell, secFlags, UV_SetSecurity, - &cstruct))) { + code = vsu_ClientInit(confdir, tcell, secFlags, UV_SetSecurity, &cstruct); + if (code != 0 && retry_confdir != NULL) { + fprintf(STDERR, "vos: Retrying initialization with directory %s\n", + retry_confdir); + code = vsu_ClientInit(retry_confdir, tcell, secFlags, UV_SetSecurity, + &cstruct); + } + if (code != 0) { fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n", (unsigned long)code); exit(1); @@ -5900,8 +5910,6 @@ main(int argc, char **argv) sigaction(SIGSEGV, &nsa, NULL); #endif - confdir = AFSDIR_CLIENT_ETC_DIRPATH; - cmd_SetBeforeProc(MyBeforeProc, NULL); ts = cmd_CreateSyntax("create", CreateVolume, NULL, 0, "create a new volume");