From owner-svn-src-head@freebsd.org Mon Dec 18 17:18:47 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F06AE9CE84; Mon, 18 Dec 2017 17:18:47 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id AF63E652CD; Mon, 18 Dec 2017 17:18:46 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with ESMTPA id Qz3lenB4lZ8gBQz3meQwRM; Mon, 18 Dec 2017 10:18:39 -0700 X-Authority-Analysis: v=2.2 cv=M/g9E24s c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=kj9zAlcOel0A:10 a=ocR9PWop10UA:10 a=mi56gJdQAAAA:8 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=wbI1F7SKnoTB2mRG3ewA:9 a=CjuIK1q_8ugA:10 a=m6W23KLcDyq3lIHOBnQi:22 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 1989D101; Mon, 18 Dec 2017 09:18:37 -0800 (PST) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id vBIHITrl059357; Mon, 18 Dec 2017 09:18:29 -0800 (PST) (envelope-from cy@slippy.cwsent.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id vBIHISiS058980; Mon, 18 Dec 2017 09:18:28 -0800 (PST) (envelope-from cy@slippy.cwsent.com) Resent-Message-Id: <201712181718.vBIHISiS058980@slippy.cwsent.com> Message-Id: <201712181718.vBIHISiS058980@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Baptiste Daroussin cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r326617 - head/usr.sbin/newsyslog In-Reply-To: Message from Baptiste Daroussin of "Mon, 18 Dec 2017 10:36:35 +0100." <20171218093635.ilumboo655ualwzs@ivaldir.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 18 Dec 2017 09:10:05 -0800 Resent-To: Baptiste Daroussin Resent-Cc: Cy Schubert , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Resent-From: "Cy Schubert (cy)" Resent-Date: Mon, 18 Dec 2017 09:18:28 -0800 X-CMAE-Envelope: MS4wfNMriKcxqrjS3kLsFIufihlHS38E3IzxgB5aI4KVLxMDeZrqqLddXNXByG6lqIjXZoK5NfR1p9xQWp4ZQWLYSE2yqpyRoFxQg370vIL4xrWPacWezIzZ cIkPAwxDyJ/8nR7+swLpSvP6a4EhxdCvv3B4PYewUfyn9+WtZMLmD7RPpxaGvbgOxJ701UD/BC59VKB7dsENjHGfCCzBRe5cvj7CLzuC3c8JQG/w/p2asN95 kIT5/CbPheGHab9aFOePk5z3ap1QTOpOroXyPbUZeZBTD3QT9ovmWyDUuKma7LMy X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Dec 2017 17:18:47 -0000 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 FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.