newsyslog: fix compression arglist construction
Reuse of the index variable in two nested loops resulted in only the first argument in the list being used (fine for gzip, not fine for zstd). Also add tests for xz and zstd, and fix the COMPRESS_SUFFIX_MAXLEN macro. Submitted by: dnelson_1901_yahoo.com Differential Revision: https://reviews.freebsd.org/D16509
This commit is contained in:
parent
bdafaf0aee
commit
19fe43f796
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=336913
@ -105,7 +105,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define COMPRESS_SUFFIX_ZST ".zst"
|
#define COMPRESS_SUFFIX_ZST ".zst"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define COMPRESS_SUFFIX_MAXLEN MAX(MAX(sizeof(COMPRESS_SUFFIX_GZ),sizeof(COMPRESS_SUFFIX_BZ2)),sizeof(COMPRESS_SUFFIX_XZ))
|
#define COMPRESS_SUFFIX_MAXLEN MAX(MAX(MAX(sizeof(COMPRESS_SUFFIX_GZ),sizeof(COMPRESS_SUFFIX_BZ2)),sizeof(COMPRESS_SUFFIX_XZ)),sizeof(COMPRESS_SUFFIX_ZST))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compression types
|
* Compression types
|
||||||
@ -2027,7 +2027,7 @@ do_zipwork(struct zipwork_entry *zwork)
|
|||||||
char zresult[MAXPATHLEN];
|
char zresult[MAXPATHLEN];
|
||||||
char command[BUFSIZ];
|
char command[BUFSIZ];
|
||||||
char **args;
|
char **args;
|
||||||
int c;
|
int c, i;
|
||||||
|
|
||||||
assert(zwork != NULL);
|
assert(zwork != NULL);
|
||||||
pgm_path = NULL;
|
pgm_path = NULL;
|
||||||
@ -2043,10 +2043,10 @@ do_zipwork(struct zipwork_entry *zwork)
|
|||||||
(void) strlcat(zresult,
|
(void) strlcat(zresult,
|
||||||
compress_type[c].suffix, sizeof(zresult));
|
compress_type[c].suffix, sizeof(zresult));
|
||||||
/* the first argument is always NULL, skip it */
|
/* the first argument is always NULL, skip it */
|
||||||
for (c = 1; c < ARGS_NUM; c++) {
|
for (i = 1; i < ARGS_NUM; i++) {
|
||||||
if (compress_type[c].args[c] == NULL)
|
if (compress_type[c].args[i] == NULL)
|
||||||
break;
|
break;
|
||||||
args[c] = compress_type[c].args[c];
|
args[i] = compress_type[c].args[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -498,6 +498,12 @@ tests_normal_rotate ".gz"
|
|||||||
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
||||||
tests_normal_rotate ".bz2"
|
tests_normal_rotate ".bz2"
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCX" > newsyslog.conf
|
||||||
|
tests_normal_rotate ".xz"
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCY" > newsyslog.conf
|
||||||
|
tests_normal_rotate ".zst"
|
||||||
|
|
||||||
# Normal, archive dir
|
# Normal, archive dir
|
||||||
echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
|
||||||
tests_normal_rotate "" "${TMPDIR}/alog/"
|
tests_normal_rotate "" "${TMPDIR}/alog/"
|
||||||
@ -508,6 +514,12 @@ tests_normal_rotate ".gz" "${TMPDIR}/alog/"
|
|||||||
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
||||||
tests_normal_rotate ".bz2" "${TMPDIR}/alog/"
|
tests_normal_rotate ".bz2" "${TMPDIR}/alog/"
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCX" > newsyslog.conf
|
||||||
|
tests_normal_rotate ".xz" "${TMPDIR}/alog/"
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCY" > newsyslog.conf
|
||||||
|
tests_normal_rotate ".zst" "${TMPDIR}/alog/"
|
||||||
|
|
||||||
# Time based, no archive dir
|
# Time based, no archive dir
|
||||||
echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
|
||||||
tests_time_rotate
|
tests_time_rotate
|
||||||
@ -518,6 +530,12 @@ tests_time_rotate "gz" ""
|
|||||||
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
||||||
tests_time_rotate "bz2" ""
|
tests_time_rotate "bz2" ""
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCX" > newsyslog.conf
|
||||||
|
tests_time_rotate "xz" ""
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCY" > newsyslog.conf
|
||||||
|
tests_time_rotate "zst" ""
|
||||||
|
|
||||||
# Time based, archive dir
|
# Time based, archive dir
|
||||||
echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NC" > newsyslog.conf
|
||||||
tests_time_rotate "" "${TMPDIR}/alog/"
|
tests_time_rotate "" "${TMPDIR}/alog/"
|
||||||
@ -528,6 +546,12 @@ tests_time_rotate "gz" "${TMPDIR}/alog/"
|
|||||||
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NCJ" > newsyslog.conf
|
||||||
tests_time_rotate "bz2" "${TMPDIR}/alog/"
|
tests_time_rotate "bz2" "${TMPDIR}/alog/"
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCX" > newsyslog.conf
|
||||||
|
tests_time_rotate "xz" "${TMPDIR}/alog/"
|
||||||
|
|
||||||
|
echo "$LOGFPATH 640 3 * @T00 NCY" > newsyslog.conf
|
||||||
|
tests_time_rotate "zst" "${TMPDIR}/alog/"
|
||||||
|
|
||||||
# RFC-5424; Normal, no archive dir
|
# RFC-5424; Normal, no archive dir
|
||||||
echo "$LOGFPATH5424 640 3 * @T00 NCT" > newsyslog.conf
|
echo "$LOGFPATH5424 640 3 * @T00 NCT" > newsyslog.conf
|
||||||
echo "$LOGFPATH 640 3 * @T00 NC" >> newsyslog.conf
|
echo "$LOGFPATH 640 3 * @T00 NC" >> newsyslog.conf
|
||||||
|
Loading…
Reference in New Issue
Block a user