Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150536992
D7953.1792573207.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D7953.1792573207.diff
View Options
Index: usr.sbin/daemon/daemon.c
===================================================================
--- usr.sbin/daemon/daemon.c
+++ usr.sbin/daemon/daemon.c
@@ -45,6 +45,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
+
static void dummy_sighandler(int);
static void restrict_process(const char *);
static int wait_child(pid_t pid, sigset_t *mask);
@@ -55,14 +57,15 @@
{
struct pidfh *ppfh, *pfh;
sigset_t mask, oldmask;
- int ch, nochdir, noclose, restart, serrno;
- const char *pidfile, *ppidfile, *title, *user;
+ int ch, nochdir, noclose, restart, serrno, syslog;
+ const char *pidfile, *ppidfile, *title, *user, *tag, *priority;
pid_t otherpid, pid;
nochdir = noclose = 1;
restart = 0;
- ppidfile = pidfile = title = user = NULL;
- while ((ch = getopt(argc, argv, "cfp:P:rt:u:")) != -1) {
+ syslog = 0;
+ ppidfile = pidfile = user = tag = priority = NULL;
+ while ((ch = getopt(argc, argv, "cfp:P:ru:t:sh:")) != -1) {
switch (ch) {
case 'c':
nochdir = 0;
@@ -70,6 +73,9 @@
case 'f':
noclose = 0;
break;
+ case 'h':
+ priority = optarg;
+ break;
case 'p':
pidfile = optarg;
break;
@@ -79,9 +85,15 @@
case 'r':
restart = 1;
break;
+ case 's':
+ syslog = 1;
+ break;
case 't':
title = optarg;
break;
+ case 'T':
+ tag = optarg;
+ break;
case 'u':
user = optarg;
break;
@@ -94,6 +106,7 @@
if (argc == 0)
usage();
+
ppfh = pfh = NULL;
/*
@@ -198,8 +211,42 @@
if (user != NULL)
restrict_process(user);
+ /* Grell's code */
+ if(syslog)
+ {
+ FILE *fl;
+ char logger_cmd[200] = "logger";
+ char tagstring[200];
+ char prioritystring[200];
+
+ if(tag != NULL){
+ snprintf(tagstring, sizeof tagstring, " -t %s", tag);
+ strncat(logger_cmd, tagstring, 199);
+ }
+
+ if(priority != NULL){ /* user specifies the facility and priority */
+ snprintf(prioritystring, sizeof prioritystring, " -p %s", priority);
+ strncat(logger_cmd, prioritystring, 199);
+ }
+
+ fl = popen(logger_cmd,"w");
+ if(fl == NULL){
+ goto exit;
+ }
+
+ int nf;
+ nf = fileno(fl);
+ dup2(nf,STDOUT_FILENO);
+ dup2(nf,STDERR_FILENO);
+
+ execvp(argv[0], argv);
+ }
+
+ /* end Grell's code */
+
execvp(argv[0], argv);
+
/*
* execvp() failed -- report the error. The child is
* now running, so the exit status doesn't matter.
@@ -276,7 +323,7 @@
usage(void)
{
(void)fprintf(stderr, "%s\n\t%s\n",
- "usage: daemon [-cfr] [-p child_pidfile] [-P supervisor_pidfile]",
+ "usage: daemon [-cfrs] [-h facility.priority] [-p child_pidfile] [-P supervisor_pidfile] [-T custom_tag] ",
"[-t title] [-u user] command arguments ...");
exit(1);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 21, 9:00 AM (11 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30584729
Default Alt Text
D7953.1792573207.diff (2 KB)
Attached To
Mode
D7953: daemon(8): Add support for logging via syslog
Attached
Detach File
Event Timeline
Log In to Comment