FreeBSD Bugzilla – Attachment 16789 Details for
Bug 30654
[patch] Added ability for newsyslog(8) to archive logs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
freebsd-5.2.1-pr30654.txt
freebsd-5.2.1-pr30654.txt (text/plain), 5.01 KB, created by
shattered
on 2005-04-01 11:48:39 UTC
(
hide
)
Description:
freebsd-5.2.1-pr30654.txt
Filename:
MIME Type:
Creator:
shattered
Created:
2005-04-01 11:48:39 UTC
Size:
5.01 KB
patch
obsolete
>--- newsyslog.c.orig Tue Sep 23 04:00:26 2003 >+++ newsyslog.c Wed Feb 9 17:23:09 2005 >@@ -1046,7 +1046,7 @@ > errx(1, "malformed line (missing fields):\n%s", > errline); > *parse = '\0'; >- if (!sscanf(q, "%d", &working->numlogs) || working->numlogs < 0) >+ if (!sscanf(q, "%d", &working->numlogs)) > errx(1, "error in config file; bad value for count of logs to save:\n%s", > errline); > >@@ -1286,11 +1286,18 @@ > char zfile1[MAXPATHLEN], zfile2[MAXPATHLEN]; > char jfile1[MAXPATHLEN]; > char tfile[MAXPATHLEN]; >+ char tmp[MAXPATHLEN]; >+ char logdate[BUFSIZ]; > int flags, notified, need_notification, fd, numlogs_c; > struct stat st; >+ time_t logtime; > > flags = ent->flags; > >+ /* build date extension */ >+ logtime = time(NULL); >+ (void) strftime(logdate, BUFSIZ-1, "%Y%m%d%H%M%S", localtime(&logtime)); >+ > if (archtodir) { > char *p; > >@@ -1318,8 +1325,16 @@ > strlcpy(namepart, p + 1, sizeof(namepart)); > > /* name of oldest log */ >- (void) snprintf(file1, sizeof(file1), "%s/%s.%d", dirpart, >- namepart, ent->numlogs); >+ if (ent->numlogs > -1) { >+ /* name of oldest log */ >+ (void) snprintf(file1, sizeof(file1), "%s/%s.%d", >+ dirpart, namepart, ent->numlogs); >+ } else { >+ /* name of dated log */ >+ (void) snprintf(file1, sizeof(file1), "%s/%s.%s", >+ dirpart, namepart, logdate); >+ } >+ /* name of compressed log */ > (void) snprintf(zfile1, sizeof(zfile1), "%s%s", file1, > COMPRESS_POSTFIX); > snprintf(jfile1, sizeof(jfile1), "%s%s", file1, >@@ -1328,6 +1343,15 @@ > /* name of oldest log */ > (void) snprintf(file1, sizeof(file1), "%s.%d", ent->log, > ent->numlogs); >+ if (ent->numlogs > -1) { >+ /* name of oldest log */ >+ (void) snprintf(file1, sizeof(file1), "%s/%s.%d", >+ dirpart, namepart, ent->numlogs); >+ } else { >+ /* name of dated log */ >+ (void) snprintf(file1, sizeof(file1), "%s.%s", >+ ent->log, logdate); >+ } > (void) snprintf(zfile1, sizeof(zfile1), "%s%s", file1, > COMPRESS_POSTFIX); > snprintf(jfile1, sizeof(jfile1), "%s%s", file1, >@@ -1346,7 +1370,7 @@ > > /* Move down log files */ > numlogs_c = ent->numlogs; /* copy for countdown */ >- while (numlogs_c--) { >+ while (--numlogs_c > 0) { > > (void) strlcpy(file2, file1, sizeof(file2)); > >@@ -1473,32 +1497,31 @@ > ent->log); > else if (noaction) > if (flags & CE_COMPACT) >- printf("\tgzip %s.0\n", ent->log); >+ printf("\tgzip %s.%s\n", ent->log, >+ ent->numlogs > -1 ? "0" : logdate); > else >- printf("\tbzip2 %s.0\n", ent->log); >+ printf("\tbzip2 %s.%s\n", ent->log, >+ ent->numlogs > -1 ? "0" : logdate); > else { > if (notified) { > if (verbose) > printf("small pause to allow daemon(s) to close log\n"); > sleep(10); > } >- if (archtodir) { >- (void) snprintf(file1, sizeof(file1), "%s/%s", >- dirpart, namepart); >- if (flags & CE_COMPACT) >- compress_log(file1, >- flags & CE_COMPACTWAIT); >- else if (flags & CE_BZCOMPACT) >- bzcompress_log(file1, >- flags & CE_COMPACTWAIT); >- } else { >- if (flags & CE_COMPACT) >- compress_log(ent->log, >- flags & CE_COMPACTWAIT); >- else if (flags & CE_BZCOMPACT) >- bzcompress_log(ent->log, >- flags & CE_COMPACTWAIT); >+ if (!archtodir) { >+ if (ent->numlogs > 0) >+ (void) snprintf(file1, sizeof(tmp), >+ "%s.0", ent->log); >+ else >+ (void) snprintf(file1, sizeof(tmp), >+ "%s.%s", ent->log, logdate); > } >+ if (flags & CE_COMPACT) >+ compress_log(file1, >+ flags & CE_COMPACTWAIT); >+ else if (flags & CE_BZCOMPACT) >+ bzcompress_log(file1, >+ flags & CE_COMPACTWAIT); > } > } > } >@@ -1534,16 +1557,14 @@ > compress_log(char *logname, int dowait) > { > pid_t pid; >- char tmp[MAXPATHLEN]; > > while (dowait && (wait(NULL) > 0 || errno == EINTR)) > ; >- (void) snprintf(tmp, sizeof(tmp), "%s.0", logname); > pid = fork(); > if (pid < 0) > err(1, "gzip fork"); > else if (!pid) { >- (void) execl(_PATH_GZIP, _PATH_GZIP, "-f", tmp, (char *)0); >+ (void) execl(_PATH_GZIP, _PATH_GZIP, "-f", logname, (char *)0); > err(1, _PATH_GZIP); > } > } >@@ -1553,16 +1574,14 @@ > bzcompress_log(char *logname, int dowait) > { > pid_t pid; >- char tmp[MAXPATHLEN]; > > while (dowait && (wait(NULL) > 0 || errno == EINTR)) > ; >- snprintf(tmp, sizeof(tmp), "%s.0", logname); > pid = fork(); > if (pid < 0) > err(1, "bzip2 fork"); > else if (!pid) { >- execl(_PATH_BZIP2, _PATH_BZIP2, "-f", tmp, (char *)0); >+ execl(_PATH_BZIP2, _PATH_BZIP2, "-f", logname, (char *)0); > err(1, _PATH_BZIP2); > } > } >--- newsyslog.8.orig Mon Apr 28 03:37:31 2003 >+++ newsyslog.8 Wed Feb 9 15:50:39 2005 >@@ -111,7 +111,10 @@ > Specify the mode of the log file and archives. > .It Ar count > Specify the number of archive files to be kept >-besides the log file itself. >+besides the log file itself. If '-1' is specified, then the file will be >+archived with a timestamp appended, instead of the rotation number, and all >+archived files will be retained. For example, 'my.log' would be archived >+as 'my.log.YYYYMMDDHHMMSS'. > .It Ar size > When the size of the log file reaches > .Ar size
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 30654
:
16788
| 16789