From 6f0636728b53c74d3327a8da8c51efee810fbff0 Mon Sep 17 00:00:00 2001 From: Ihor Antonov Date: Wed, 1 Mar 2023 21:00:42 -0600 Subject: [PATCH] daemon: move syslog facility and syslog tag into log_params Since struct log_params already contains logging-related varaiables, including syslog-related, move remaining syslog-related variables into struct log_params as well Reviewed by: kevans Pull Request: https://github.com/freebsd/freebsd-src/pull/669 --- usr.sbin/daemon/daemon.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index 379c31a0a221..6904dfa1896f 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -61,7 +61,9 @@ __FBSDID("$FreeBSD$"); struct log_params { const char *output_filename; + const char *syslog_tag; int syslog_priority; + int syslog_facility; int noclose; int output_fd; bool syslog_enabled; @@ -146,13 +148,11 @@ main(int argc, char *argv[]) bool log_reopen = false; char *p = NULL; const char *pidfile = NULL; - const char *syslog_tag = "daemon"; const char *ppidfile = NULL; const char *title = NULL; const char *user = NULL; int ch = 0; int child_eof = 0; - int syslog_facility = LOG_DAEMON; int nochdir = 1; int pfd[2] = { -1, -1 }; int restart = 0; @@ -160,6 +160,8 @@ main(int argc, char *argv[]) struct log_params logpar = { .syslog_enabled = false, .syslog_priority = LOG_NOTICE, + .syslog_tag = "daemon", + .syslog_facility = LOG_DAEMON, .noclose = 1, .output_fd = -1, .output_filename = NULL @@ -188,8 +190,8 @@ main(int argc, char *argv[]) log_reopen = true; break; case 'l': - syslog_facility = get_log_mapping(optarg, facilitynames); - if (syslog_facility == -1) { + logpar.syslog_facility = get_log_mapping(optarg, facilitynames); + if (logpar.syslog_facility == -1) { errx(5, "unrecognized syslog facility"); } logpar.syslog_enabled = true; @@ -232,7 +234,7 @@ main(int argc, char *argv[]) title = optarg; break; case 'T': - syslog_tag = optarg; + logpar.syslog_tag = optarg; logpar.syslog_enabled = true; break; case 'u': @@ -264,7 +266,7 @@ main(int argc, char *argv[]) } if (logpar.syslog_enabled) { - openlog(syslog_tag, LOG_PID | LOG_NDELAY, syslog_facility); + openlog(logpar.syslog_tag, LOG_PID | LOG_NDELAY, logpar.syslog_facility); } /*