diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-06-26 04:05:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-06-26 04:05:56 +0200 |
commit | 5b0187292d95c991c37efeeaf36fac9628dae5dc (patch) | |
tree | c842457fd8c0490df9a8c18186bda6d5725a4a09 | |
parent | 749a220448f2b1f4a8c865002382397dd9f671b8 (diff) |
dnsconfd: add --syslog switch
-rw-r--r-- | avahi-dnsconfd/main.c | 11 | ||||
-rw-r--r-- | man/avahi-dnsconfd.8.xml.in | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/avahi-dnsconfd/main.c b/avahi-dnsconfd/main.c index 57147cd..719fbeb 100644 --- a/avahi-dnsconfd/main.c +++ b/avahi-dnsconfd/main.c @@ -70,6 +70,7 @@ static enum { static int quit = 0; static int daemonize = 0; +static int use_syslog = 0; #if !HAVE_DECL_ENVIRON extern char **environ; @@ -374,6 +375,7 @@ static void help(FILE *f, const char *argv0) { "%s [options]\n" " -h --help Show this help\n" " -D --daemonize Daemonize after startup\n" + " -s --syslog Write log messages to syslog(3) instead of STDERR\n" " -k --kill Kill a running daemon\n" " -r --refresh Request a running daemon to refresh DNS server data\n" " -c --check Return 0 if a daemon is already running\n" @@ -387,6 +389,7 @@ static int parse_command_line(int argc, char *argv[]) { static const struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "daemonize", no_argument, NULL, 'D' }, + { "syslog", no_argument, NULL, 's' }, { "kill", no_argument, NULL, 'k' }, { "version", no_argument, NULL, 'V' }, { "refresh", no_argument, NULL, 'r' }, @@ -394,7 +397,7 @@ static int parse_command_line(int argc, char *argv[]) { { NULL, 0, NULL, 0 } }; - while ((c = getopt_long(argc, argv, "hDkVrc", long_options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "hDkVrcs", long_options, NULL)) >= 0) { switch(c) { case 'h': @@ -403,6 +406,9 @@ static int parse_command_line(int argc, char *argv[]) { case 'D': daemonize = 1; break; + case 's': + use_syslog = 1; + break; case 'k': command = DAEMON_KILL; break; @@ -606,6 +612,9 @@ int main(int argc, char *argv[]) { /* Child */ } + if (use_syslog || daemonize) + daemon_log_use = DAEMON_LOG_SYSLOG; + chdir("/"); if (daemon_pid_file_create() < 0) { diff --git a/man/avahi-dnsconfd.8.xml.in b/man/avahi-dnsconfd.8.xml.in index b40c676..e01ab44 100644 --- a/man/avahi-dnsconfd.8.xml.in +++ b/man/avahi-dnsconfd.8.xml.in @@ -45,6 +45,11 @@ <optdesc><p>Daemonize after startup and redirect log messages to syslog.</p></optdesc> </option> + <option> + <p><opt>-s | --syslog</opt></p> + <optdesc><p>Log to syslog instead of STDERR. Implied by <opt>--daemonize</opt>.</p></optdesc> + </option> + <option> <p><opt>-k | --kill</opt></p> <optdesc><p>Kill an already running avahi-dnsconfd. (equivalent to sending a SIGTERM)</p></optdesc> |