Date: Mon, 18 Dec 2017 09:10:05 -0800 From: Cy Schubert <Cy.Schubert@komquats.com> To: Baptiste Daroussin <bapt@FreeBSD.org> Cc: Cy Schubert <Cy.Schubert@komquats.com>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r326617 - head/usr.sbin/newsyslog Message-ID: <201712181710.vBIHA6BZ030527@slippy.cwsent.com> In-Reply-To: Message from Baptiste Daroussin <bapt@FreeBSD.org> of "Mon, 18 Dec 2017 10:36:35 %2B0100." <20171218093635.ilumboo655ualwzs@ivaldir.net>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <20171218093635.ilumboo655ualwzs@ivaldir.net>, Baptiste Daroussin wr ites: > On Fri, Dec 15, 2017 at 05:40:15PM -0800, Cy Schubert wrote: > > In message <201712060944.vB69iZQe027554@repo.freebsd.org>, Baptiste=20 > > Daroussin w > > rites: > > > Author: bapt > > > Date: Wed Dec 6 09:44:35 2017 > > > New Revision: 326617 > > > URL: https://svnweb.freebsd.org/changeset/base/326617 > > > > > > Log: > > > Allow newsyslog to execute compression commands which > > > have a semantic different than the traditional gzip(1) > > > =20 > > > This is done to allow to use zstd(1) as a compression tool without > > > having to patch it to change its default behavior. > > > > > > Modified: > > > head/usr.sbin/newsyslog/newsyslog.c > > > > > > Modified: head/usr.sbin/newsyslog/newsyslog.c > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= > =3D=3D=3D=3D > > > =3D > > > --- head/usr.sbin/newsyslog/newsyslog.c Wed Dec 6 06:49:53 2017 > > > (r326616) > > > +++ head/usr.sbin/newsyslog/newsyslog.c Wed Dec 6 09:44:35 2017 > > > (r326617) > > > @@ -151,14 +151,23 @@ struct compress_types { > > > const char *flag; /* Flag in configuration file */ > > > const char *suffix; /* Compression suffix */ > > > const char *path; /* Path to compression program */ > > > + char **args; /* Comrpession arguments */ > > > }; > > > =20 > > > +static char f_arg[] =3D "-f"; > > > +static char q_arg[] =3D "-q"; > > > +static char rm_arg[] =3D "--rm"; > > > +static char *gz_args[] =3D{ NULL, f_arg, NULL, NULL }; > > > +#define bzip2_args gz_args > > > +#define xz_args gz_args > > > +static char *zstd_args[] =3D { NULL, q_arg, rm_arg, NULL, NULL }; > > > + > > > static const struct compress_types compress_type[COMPRESS_TYPES] =3D { > > > - { "", "", "" }, /* no compression */ > > > - { "Z", COMPRESS_SUFFIX_GZ, _PATH_GZIP }, /* gzip compression */ > > > - { "J", COMPRESS_SUFFIX_BZ2, _PATH_BZIP2 }, /* bzip2 compression */ > > > - { "X", COMPRESS_SUFFIX_XZ, _PATH_XZ }, /* xz compression */ > > > - { "Y", COMPRESS_SUFFIX_ZST, _PATH_ZSTD } /* zst compression */ > > > + { "", "", "", NULL}, /* none */ > > > + { "Z", COMPRESS_SUFFIX_GZ, _PATH_GZIP, gz_args}, /* gzip */ > > > + { "J", COMPRESS_SUFFIX_BZ2, _PATH_BZIP2, bzip2_args}, /* bzip2 */ > > > + { "X", COMPRESS_SUFFIX_XZ, _PATH_XZ, xz_args }, /* xz */ > > > + { "Y", COMPRESS_SUFFIX_ZST, _PATH_ZSTD, zstd_args } /* zst */ > > > }; > > > =20 > > > struct conf_entry { > > > @@ -2001,6 +2010,8 @@ do_zipwork(struct zipwork_entry *zwork) > > > int errsav, fcount, zstatus; > > > pid_t pidzip, wpid; > > > char zresult[MAXPATHLEN]; > > > + char command[BUFSIZ]; > > > + char **args; > > > int c; > > > =20 > > > assert(zwork !=3D NULL); > > > @@ -2013,6 +2024,7 @@ do_zipwork(struct zipwork_entry *zwork) > > > pgm_path =3D compress_type[c].path; > > > (void) strlcat(zresult, > > > compress_type[c].suffix, sizeof(zresult)); > > > + args =3D compress_type[c].args; > > > break; > > > } > > > } > > > @@ -2026,6 +2038,13 @@ do_zipwork(struct zipwork_entry *zwork) > > > else > > > pgm_name++; > > > =20 > > > + args[0] =3D strdup(pgm_name); > > > + if (args[0] =3D=3D NULL) > > > + err(1, "strdup()"); > > > + for (c =3D 0; args[c] !=3D NULL; c++) > > > + ; > > > + args[c] =3D zwork->zw_fname; > > > + > > > if (zwork->zw_swork !=3D NULL && zwork->zw_swork->sw_runcmd =3D=3D 0 = > && > > > zwork->zw_swork->sw_pidok <=3D 0) { > > > warnx( > > > @@ -2035,6 +2054,11 @@ do_zipwork(struct zipwork_entry *zwork) > > > return; > > > } > > > =20 > > > + strlcpy(command, pgm_path, sizeof(command)); > > > + for (c =3D 1; args[c] !=3D NULL; c++) { > > > + strlcat(command, " ", sizeof(command)); > > > + strlcat(command, args[c], sizeof(command)); > > > + } > > > if (noaction) { > > > printf("\t%s %s\n", pgm_name, zwork->zw_fname); > > > change_attrs(zresult, zwork->zw_conf); > > > @@ -2058,8 +2082,8 @@ do_zipwork(struct zipwork_entry *zwork) > > > } > > > if (!pidzip) { > > > /* The child process executes the compression command */ > > > - execl(pgm_path, pgm_path, "-f", zwork->zw_fname, (char *)0); > > > - err(1, "execl(`%s -f %s')", pgm_path, zwork->zw_fname); > > > + execv(pgm_path, (char *const*) args); > > > + err(1, "execv(`%s')", command); > > > } > > > =20 > > > wpid =3D waitpid(pidzip, &zstatus, 0); > > > @@ -2069,13 +2093,12 @@ do_zipwork(struct zipwork_entry *zwork) > > > return; > > > } > > > if (!WIFEXITED(zstatus)) { > > > - warnx("`%s -f %s' did not terminate normally", pgm_name, > > > - zwork->zw_fname); > > > + warnx("`%s' did not terminate normally", command); > > > return; > > > } > > > if (WEXITSTATUS(zstatus)) { > > > - warnx("`%s -f %s' terminated with a non-zero status (%d)", > > > - pgm_name, zwork->zw_fname, WEXITSTATUS(zstatus)); > > > + warnx("`%s' terminated with a non-zero status (%d)", command, > > > + WEXITSTATUS(zstatus)); > > > return; > > > } > > > =20 > > > > >=20 > > Ever since this revision I'm seeing the following errors: > >=20 > > bzip2: Can't open input file ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ: No suc= > h=20 > > file or directory. > > newsyslog: `/usr/bin/bzip2 -f ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ=20 > > /var/log/debug.log.0' terminated with a non-zero status (1) > > bzip2: Bad flag `--rm' > > bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010. > >=20 > > usage: bzip2 [flags and input files in any order] > >=20 > > -h --help print this message > > -d --decompress force decompression > > -z --compress force compression > > -k --keep keep (don't delete) input files > > -f --force overwrite existing output files > > -t --test test compressed file integrity > > -c --stdout output to standard out > > -q --quiet suppress noncritical error messages > > -v --verbose be verbose (a 2nd -v gives more) > > -L --license display software version & license > > -V --version display software version & license > > -s --small use less memory (at most 2500k) > > -1 .. -9 set block size to 100k .. 900k > > --fast alias for -1 > > --best alias for -9 > >=20 > > If invoked as `bzip2', default action is to compress. > > as `bunzip2', default action is to decompress. > > as `bzcat', default action is to decompress to stdout. > >=20 > > If no file names are given, bzip2 compresses or decompresses > > from standard input to standard output. You can combine > > short flags, so `-v -4' means the same as -v4 or -4v, &c. > >=20 > > newsyslog: `/usr/bin/bzip2 -f ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ= > ZZZ > > ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ=20 > > ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ /var/log/messages.0 -q --rm'=20 > > terminated with a non-zero status (1) > > Should be fixed in r326930. > > Sorry about that, > Best regards, > Bapt No problem. Thanks for fixing it. -- Cheers, Cy Schubert <Cy.Schubert@cschubert.com> FreeBSD UNIX: <cy@FreeBSD.org> Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712181710.vBIHA6BZ030527>