summaryrefslogtreecommitdiff
path: root/usr.bin/newsyslog
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-11-06 20:45:27 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-11-06 20:45:27 +0000
commitbf5089acd3e9f0db705a920cd065072473a01d2d (patch)
treee4f14ef5ca4504c086d0b16451a6ea4d6e3081b3 /usr.bin/newsyslog
parent31b614f77ef89bdae0b0ab206c1c1c164e26d4b0 (diff)
Use fchmod instead of chmod and open() instead of creat().
Diffstat (limited to 'usr.bin/newsyslog')
-rw-r--r--usr.bin/newsyslog/newsyslog.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index 1de90eb0021..ea102d1b22c 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.21 1999/10/13 17:24:23 millert Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.22 1999/11/06 20:45:26 millert Exp $ */
/*
* Copyright (c) 1997, Jason Downs. All rights reserved.
@@ -61,7 +61,7 @@ provided "as is" without express or implied warranty.
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.21 1999/10/13 17:24:23 millert Exp $";
+static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.22 1999/11/06 20:45:26 millert Exp $";
#endif /* not lint */
#ifndef CONF
@@ -198,7 +198,7 @@ void do_entry(ent)
(ent->flags & CE_COMPACT) ? "Z" : "");
size = sizefile(ent->log);
if (age_old_log(ent->log, &modtime) == -1)
- modtime = 0;
+ modtime = -1;
if (size < 0) {
if (verbose)
printf("does not exist.\n");
@@ -489,24 +489,22 @@ void dotrim(log, numdays, flags, perm, owner_uid, group_gid, daemon_pid)
(void) rename(log,file1);
}
- if (noaction)
+ if (noaction) {
printf("Start new log...");
- else {
- fd = creat(log,perm);
+ } else {
+ fd = open(log, O_WRONLY|O_TRUNC|O_CREAT, perm);
if (fd < 0)
err(1, "can't start \'%s\' log", log);
if (fchown(fd, owner_uid, group_gid))
err(1, "can't chown \'%s\' log file", log);
+ if (fchmod(fd, perm))
+ err(1, "can't chmod \'%s\' log file", log, perm);
(void) close(fd);
if (!(flags & CE_BINARY))
if (log_trim(log)) /* Add status message */
err(1, "can't add status message to log \'%s\'", log);
}
if (noaction)
- printf("chmod %o %s...",perm,log);
- else
- (void) chmod(log,perm);
- if (noaction)
printf("kill -HUP %d\n",daemon_pid);
else if (daemon_pid < MIN_PID)
warnx("preposterous process number: %d", daemon_pid);