From 87041d676c93dfe35a085b9b5aaa73e74c08bc90 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Sat, 17 Oct 2020 20:51:51 -0500 Subject: [PATCH] bozo: Properly detect presence of -auditlog cmd_OptionAsString returns non-zero if the given option _isn't_ given (CMD_MISSING), so we need to call osi_audit_file only when cmd_OptionAsString returns 0. Since commit f6cdf71 (bozo: Use libcmd for command line options), this causes bosserver to complain on startup if no -auditlog was given: $ bosserver Warning: auditlog (null) not writable, ignored. To fix this, skip calling osi_audit_file if -auditlog was not given. While we're changing this anyway, change our processing of our audit-related options to more closely match what other daemons do, like ptserver or viced, so it's easier to see if we're doing the right thing. That is, just call cmd_OptionAsString() without a conditional, and just test if auditFileName is non-NULL later on, after options processing. Change-Id: I563c7efd02cb5210c32c0cc7f5a03683db792e98 Reviewed-on: https://gerrit.openafs.org/14402 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/bozo/bosserver.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index 5807a9b..2c46d80 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -1043,6 +1043,8 @@ main(int argc, char **argv, char **envp) #endif /* general server options */ + cmd_OptionAsString(opts, OPT_auditlog, &auditFileName); + if (cmd_OptionAsString(opts, OPT_auditinterface, &auditIface) == 0) { if (osi_audit_interface(auditIface)) { printf("Invalid audit interface '%s'\n", auditIface); @@ -1052,10 +1054,6 @@ main(int argc, char **argv, char **envp) free(auditIface); } - if (cmd_OptionAsString(opts, OPT_auditlog, &auditFileName)) { - osi_audit_file(auditFileName); - free(auditFileName); - } cmd_OptionAsFlag(opts, OPT_transarc_logs, &DoTransarcLogs); #ifndef AFS_NT40_ENV @@ -1074,6 +1072,9 @@ main(int argc, char **argv, char **envp) /* rxkad options */ cmd_OptionAsFlag(opts, OPT_dotted, &rxkadDisableDotCheck); + if (auditFileName != NULL) + osi_audit_file(auditFileName); + #ifndef AFS_NT40_ENV if (geteuid() != 0) { printf("bosserver: must be run as root.\n"); -- 1.9.4