Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2023 03:01:08 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 6f0636728b53 - main - daemon: move syslog facility and syslog tag into log_params
Message-ID:  <202303020301.322318tN034398@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=6f0636728b53c74d3327a8da8c51efee810fbff0

commit 6f0636728b53c74d3327a8da8c51efee810fbff0
Author:     Ihor Antonov <ihor@antonovs.family>
AuthorDate: 2023-03-02 03:00:42 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-03-02 03:00:42 +0000

    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);
         }
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303020301.322318tN034398>