From owner-svn-src-all@freebsd.org Mon Dec 18 09:36:36 2017 Return-Path: Delivered-To: svn-src-all@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 D7D0AE81CA2; Mon, 18 Dec 2017 09:36:36 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B0EE772791; Mon, 18 Dec 2017 09:36:36 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: by freefall.freebsd.org (Postfix, from userid 1235) id 0DC786585; Mon, 18 Dec 2017 09:36:36 +0000 (UTC) Date: Mon, 18 Dec 2017 10:36:35 +0100 From: Baptiste Daroussin To: Cy Schubert Cc: 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: <20171218093635.ilumboo655ualwzs@ivaldir.net> References: <201712060944.vB69iZQe027554@repo.freebsd.org> <201712160140.vBG1eF98037302@slippy.cwsent.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jbk4wldury4uphkl" Content-Disposition: inline In-Reply-To: <201712160140.vBG1eF98037302@slippy.cwsent.com> User-Agent: NeoMutt/20171208 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Dec 2017 09:36:36 -0000 --jbk4wldury4uphkl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 --jbk4wldury4uphkl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgOTj3suS2urGXVU3Y4mL3PG3PloFAlo3jCMACgkQY4mL3PG3 Plq93xAA5Pg2GDQS0hdwtexvUZdFuw8ppgh9Xtx3dybNgTsZ2hEYrxbOjsOvCmk2 DsdqS+Vwex9N+6FSzuLZ9E0mf+MD4vv11P10yEC9WX5t9WJRFFZT17pUC5Fi8c/M R0TGi+tnpIcKgxy7lZzdFQgoH0Tl2JZ695KblwuxygWffmXyvlaC7H8iG2E+KK9n U6LmM6pLisIjLostYgZFjDQlIQ0fV0AfG2YZhtKox476GabnwJJaVMj9C+xFneJm v09v6RHQb/A6Xe2/u0kCQ+3A68nlQCuLNEhydWOd6x+Vu6+EyTqFzrxtlaCdDpiT 1fomK33nDGzp7xVrDhbqU9dB8+vDV4RgRFPsPGfZnljFut3WSmlO8PbVdxEJPNwM d52H4XdsL3cLeWvDymxp03tZ9fw7e3vQE3syhlRfdCrGJF7fRw49bcY1dHr2kR14 5cIPzKWjLNwe1iUqVnMBpJNbuYeT8VoqtRmoDee8QLrh9bkjefgzgw/dA6wykQAg PBJvvff4kUrUiDJEYz06wGLugaPXJxurBG0jBJoB+oqFBvbuXldj3BcBIr5j15/I MY1j97wASK5ZSBVi9R+sDYo9f6z2G9uNFZRLOL/ZeufIYxSx991FuVDqBUodf2XT fc0t0iEFceW78g5PPZ/YZVLRBH4ibdC7CbNj3J4w1165Zae2emo= =+HWq -----END PGP SIGNATURE----- --jbk4wldury4uphkl--