summaryrefslogtreecommitdiff
path: root/usr.bin/newsyslog
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-10-13 17:24:24 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-10-13 17:24:24 +0000
commit9e48932feec8caf11f28ce75d16987aecfc4b4b3 (patch)
treec0fafe5863e1096b34c71275ad4da655a8350ede /usr.bin/newsyslog
parent8cbbc77e7ed027c96d21d88e8bd7ede2ccbaa994 (diff)
age_old_log() now takes an int * as a parameter so it can return -1
on failure w/o the caller thinking the difference in mtime is -1. Just set modtime to 0 in this case in the caller which effectively ignores it. This fixes a problem where if there was now foo.0 file newsyslog would rotate an empty file.
Diffstat (limited to 'usr.bin/newsyslog')
-rw-r--r--usr.bin/newsyslog/newsyslog.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index f1555f52b9a..1de90eb0021 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.20 1999/08/27 08:49:29 fgsch Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.21 1999/10/13 17:24:23 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.20 1999/08/27 08:49:29 fgsch Exp $";
+static char rcsid[] = "$OpenBSD: newsyslog.c,v 1.21 1999/10/13 17:24:23 millert Exp $";
#endif /* not lint */
#ifndef CONF
@@ -143,7 +143,7 @@ void dotrim __P((char *, int, int, int, int, int, int));
int log_trim __P((char *));
void compress_log __P((char *));
int sizefile __P((char *));
-int age_old_log __P((char *));
+int age_old_log __P((char *, int *));
char *sob __P((char *));
char *son __P((char *));
int isnumberstr __P((char *));
@@ -197,7 +197,8 @@ void do_entry(ent)
printf("%s <%d%s>: ", ent->log, ent->numlogs,
(ent->flags & CE_COMPACT) ? "Z" : "");
size = sizefile(ent->log);
- modtime = age_old_log(ent->log);
+ if (age_old_log(ent->log, &modtime) == -1)
+ modtime = 0;
if (size < 0) {
if (verbose)
printf("does not exist.\n");
@@ -564,8 +565,9 @@ int sizefile(file)
}
/* Return the age of old log file (file.0) */
-int age_old_log(file)
+int age_old_log(file, mtime)
char *file;
+ int *mtime;
{
struct stat sb;
char tmp[MAXPATHLEN];
@@ -574,7 +576,8 @@ int age_old_log(file)
if (stat(strcat(tmp,".0"),&sb) < 0)
if (stat(strcat(tmp,COMPRESS_POSTFIX), &sb) < 0)
return(-1);
- return( (int) (timenow - sb.st_mtime + 1800) / 3600);
+ *mtime = (int) (timenow - sb.st_mtime + 1800) / 3600;
+ return(0);
}
/* Skip Over Blanks */