diff options
author | pjd <pjd@FreeBSD.org> | 2006-03-06 10:36:33 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2006-03-06 10:36:33 +0000 |
commit | 96923c291c08e18b976f0a170240c3883133501d (patch) | |
tree | 485d4836cd2004fa2b2689fb876d66dfcef6f5dc /usr.sbin/syslogd/syslogd.c | |
parent | e26ef35902bca6a5b8f5bac7fec6eb538707969b (diff) | |
download | FreeBSD-src-96923c291c08e18b976f0a170240c3883133501d.zip FreeBSD-src-96923c291c08e18b976f0a170240c3883133501d.tar.gz |
By default (for security reasons) syslogd(8) doesn't create log files
when they don't exist, but sometimes its quite useful (eg. we use
non-standard log files and memory backed /var/, which is populated on
boot).
Add -C option which tells syslogd(8) to create log files if they don't
exist.
Glanced at by: phk
MFC after: 3 days
Diffstat (limited to 'usr.sbin/syslogd/syslogd.c')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 31c61c9..a41b22c 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -286,6 +286,7 @@ static int family = PF_INET; /* protocol family (IPv4 only) */ static int send_to_all; /* send message to all IPv4/IPv6 addresses */ static int use_bootfile; /* log entire bootfile for every kern msg */ static int no_compress; /* don't compress messages (1=pipes, 2=all) */ +static int logflags = O_WRONLY|O_APPEND; /* flags used to open log files */ static char bootfile[MAXLINE+1]; /* booted kernel file */ @@ -350,7 +351,7 @@ main(int argc, char *argv[]) socklen_t len; bindhostname = NULL; - while ((ch = getopt(argc, argv, "46Aa:b:cdf:kl:m:nop:P:sS:uv")) != -1) + while ((ch = getopt(argc, argv, "46Aa:b:cCdf:kl:m:nop:P:sS:uv")) != -1) switch (ch) { case '4': family = PF_INET; @@ -373,6 +374,9 @@ main(int argc, char *argv[]) case 'c': no_compress++; break; + case 'C': + logflags |= O_CREAT; + break; case 'd': /* debug */ Debug++; break; @@ -689,7 +693,7 @@ usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", - "usage: syslogd [-46Acdknosuv] [-a allowed_peer]", + "usage: syslogd [-46ACcdknosuv] [-a allowed_peer]", " [-b bind address] [-f config_file]", " [-l log_socket] [-m mark_interval]", " [-P pid_file] [-p log_socket]"); @@ -1886,7 +1890,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) break; case '/': - if ((f->f_file = open(p, O_WRONLY|O_APPEND, 0)) < 0) { + if ((f->f_file = open(p, logflags, 0600)) < 0) { f->f_type = F_UNUSED; logerror(p); break; |