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 <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit
877d9d79a32b9e81911cb567f844b11c693229f0)
Change-Id: I67350be8c25fb93975442175a64098123503b40c
Reviewed-on: https://gerrit.openafs.org/13676
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
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);