From: Andrew Deason Date: Tue, 30 Oct 2018 20:41:22 +0000 (-0500) Subject: aklog: Avoid misleading AFSCELL message X-Git-Tag: debian/1.8.4_pre1-1~9^2^2~3 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=033b66b0d688dd12f929475a0686149df63f8a70;p=packages%2Fo%2Fopenafs.git aklog: Avoid misleading AFSCELL message Currently, if the AFSCELL environment variable is set, aklog (and other libauth-using utilities) print out a message when afsconf_GetLocalCell is called: Note: Operation is performed on cell env.example.com However, this message is also printed (with the AFSCELL cell) when aklog is given the -cell command-line argument, even though aklog actually uses the cell given on the command line. For example: $ AFSCELL=env.example.com aklog -cell cli.example.com -d Note: Operation is performed on cell env.example.com Authenticating to cell cli.example.com (server srv1.example.com). [...] libauth will normally not print the "Operation" message if we're not using the default cell, but it determines this by checking if someone called afsconf_GetCellInfo before calling afsconf_GetLocalCell. And currently, aklog calls afsconf_GetLocalCell before afsconf_GetCellInfo, so the message gets printed because libauth has no way of knowing that we're actually using a different cell. klog gets around this by making an additional ignored call to afsconf_GetCellInfo before afsconf_GetLocalCell, but we can fix this in aklog by just changing the order of the calls. So, just call afsconf_GetCellInfo first; if we're using the local cell, we can just give a NULL cell parameter, instead of looking up the local cellname first. Reviewed-on: https://gerrit.openafs.org/13371 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot (cherry picked from commit 877d9d79a32b9e81911cb567f844b11c693229f0) Change-Id: I67350be8c25fb93975442175a64098123503b40c Reviewed-on: https://gerrit.openafs.org/13676 Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk Reviewed-by: Cheyenne Wills Reviewed-by: Stephan Wiesand --- diff --git a/src/aklog/aklog.c b/src/aklog/aklog.c index 63b5a7f75..49cb782dc 100644 --- a/src/aklog/aklog.c +++ b/src/aklog/aklog.c @@ -382,19 +382,24 @@ get_cellconfig(const char *config, char *cell, exit(AKLOG_AFS); } - if (afsconf_GetLocalCell(configdir, *local_cell, MAXCELLCHARS)) { - fprintf(stderr, "%s: can't determine local cell.\n", progname); - exit(AKLOG_AFS); + if (cell != NULL && cell[0] == '\0') { + /* Use the local cell */ + cell = NULL; } - if ((cell == NULL) || (cell[0] == 0)) - cell = *local_cell; - /* XXX - This function modifies 'cell' by passing it through lcstring */ if (afsconf_GetCellInfo(configdir, cell, NULL, cellconfig)) { - fprintf(stderr, "%s: Can't get information about cell %s.\n", - progname, cell); + if (cell != NULL) { + fprintf(stderr, "%s: Can't get information about cell %s.\n", + progname, cell); + } else { + fprintf(stderr, "%s: Can't get information about the local cell.\n", + progname); + } status = AKLOG_AFS; + } else if (afsconf_GetLocalCell(configdir, *local_cell, MAXCELLCHARS)) { + fprintf(stderr, "%s: can't determine local cell.\n", progname); + exit(AKLOG_AFS); } afsconf_Close(configdir);