From owner-freebsd-audit Sun Jan 6 13:20:39 2002 Delivered-To: freebsd-audit@freebsd.org Received: from straylight.ringlet.net (discworld.nanolink.com [217.75.135.248]) by hub.freebsd.org (Postfix) with SMTP id 6276137B41A for ; Sun, 6 Jan 2002 13:20:11 -0800 (PST) Received: (qmail 4636 invoked by uid 1000); 6 Jan 2002 20:20:02 -0000 Date: Sun, 6 Jan 2002 22:20:02 +0200 From: Peter Pentchev To: arch@FreeBSD.org Cc: audit@FreeBSD.org Subject: Re: make(1) enhancement - an 'environment processor' option Message-ID: <20020106222002.E314@straylight.oblivion.bg> Mail-Followup-To: arch@FreeBSD.org, audit@FreeBSD.org References: <20011225202925.F304@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20011225202925.F304@straylight.oblivion.bg>; from roam@ringlet.net on Tue, Dec 25, 2001 at 08:29:25PM +0200 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, No feedback on this proposed change to make(1)? :) If this means that there are no objections, I'm CC'ing this to -audit to let the folks there take a look at it too. FWIW, I've been running three machines with the -stable version of this patch since I posted it, and builds of both the OS and ports all go just fine, using the appropriate environment settings for the matched directories. Or was the introduction a bit too long to read and review? :) If so, one could safely skip the background and go to the explanations and the patch itself :) G'luck, Peter -- You have, of course, just begun reading the sentence that you have just finished reading. On Tue, Dec 25, 2001 at 08:29:25PM +0200, Peter Pentchev wrote: > Hi, > > > As some of you may have noticed, I maintain a little utility that > keeps environment variables on a per-directory basis - the sysutils/penv > port. Basically, what it does is remember what variables you want set > for a specific directory and then hand them in the environment of any > program you want to run. This may be quite useful for ports, especially > those with lots of tweakable knobs, like vpopmail or MySQL, since it won't > let you miss one of those knobs the next time you rebuild the port. > > However, there is one little problem with penv - it only sets > the environment based on the data for the current directory. If a port > has dependencies, and some of them also have knobs, you either have to > set them for the port you want to build, or you have to build > the dependency separately. For example, I want Ghostscript to build > with an A4 output format, but then I want to build Ghostscript as part > of the textproc/docproj build. If I set 'A4=yes' in the print/ghostscript-gnu > directory and then I do a 'make' in the textproc/docproj directory, > penv and make(1) will only pick up the textproc/docproj settings, and > this A4=yes will be lost. If only there was a way to let make(1) read > per-directory information for every single directory it recursed into.. > > > Here is a little patch to make make(1) do just that - invoke an external > 'environment processor', read its output and modify its own environment > before doing anything else. This way, I can keep the A4=yes in the penv > settings for the print/ghostscript-gnu directory and rest assured that > a docproj build will pick it right up. > > This, incidentally, removes the need for the 'penv' invocation to be > visible at all. Whereas before one had to run 'penv make all install', > now all one has to do is run 'make all install', and make(1) will run > penv all by itself. > > For those worried about the overhead of a program invocation, there is > the MAKEENVDIR environment variable, which, if specified, is treated > as an extended regular expression for the directory names to run > the environment processor in. Thus, if MAKEENVDIR is set to something > like, say, "^(/usr|/home/roam/fbsd)/ports/", then the environment > processor will only be run in the Ports collection and not at all during > a buildworld. > > Comments? Flames? Instant shootdowns? :) > > G'luck, > Peter > > -- > .siht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI > > Index: src/usr.bin/make/main.c > =================================================================== > RCS file: /home/ncvs/src/usr.bin/make/main.c,v > retrieving revision 1.49 > diff -u -r1.49 main.c > --- src/usr.bin/make/main.c 25 Apr 2001 14:44:41 -0000 1.49 > +++ src/usr.bin/make/main.c 25 Dec 2001 17:37:25 -0000 > @@ -88,6 +88,7 @@ > #include > #include > #include > +#include > #include > #include > #ifdef __STDC__ > @@ -139,6 +140,8 @@ > static void MainParseArgs __P((int, char **)); > char * chdir_verify_path __P((char *, char *)); > static int ReadMakefile __P((void *, void *)); > +static void ReadEnvProc __P((const char *, const char *, > + const char *)); > static void usage __P((void)); > > static char *curdir; /* startup directory */ > @@ -428,6 +431,81 @@ > return 0; > } > > +/*- > + * ReadEnvProc -- > + * Read the output of an environment processor program and > + * set or unset environment variables accordingly. > + * > + * Results: > + * none > + * > + * Side effects: > + * Executes the program specified by the envproc argument and > + * sets or unsets environment variables according to the program output. > + */ > + > +static void > +ReadEnvProc(const char *envproc, const char *envprocdir, const char *curdir) { > + regex_t regdir; > + int r; > + char regerr[128]; > + FILE *envout; > + char *s, *new; > + size_t len; > + > + /* First check if the env processor needs to run at all here */ > + if ((envprocdir != NULL) && (envprocdir[0] != '\0')) { > + memset(®dir, 0, sizeof(regdir)); > + r = regcomp(®dir, envprocdir, REG_EXTENDED | REG_NOSUB); > + if (r != 0) { > + regerror(r, ®dir, regerr, sizeof(regerr)); > + errx(1, "parsing regexp %s: %s", envprocdir, regerr); > + } > + > + /* If curdir does not match, return w/o executing anything */ > + r = regexec(®dir, curdir, 0, NULL, 0); > + if (r == REG_NOMATCH) > + return; > + if (r != 0) { > + regerror(r, ®dir, regerr, sizeof(regerr)); > + errx(1, "matching regexp %s against %s: %s", > + envprocdir, curdir, regerr); > + } > + } > + > + if ((envout = popen(envproc, "r")) == NULL) > + err(1, "invoking environment processor '%s'", envproc); > + > + while ((s = fgetln(envout, &len)) != NULL) { > + /* Null-terminate as needed */ > + if (s[len - 1] == '\n') { > + s[len - 1] = '\0'; > + new = NULL; > + } else { > + if ((new = realloc(s, len + 1)) == NULL) > + err(1, "reading env processor output"); > + memcpy(new, s, len); > + new[len] = '\0'; > + s = new; > + } > + > + /* > + * A 'var=value' specification sets the variable, while > + * a mere variable name unsets it. > + */ > + if (strchr(s, '=') != NULL) > + putenv(s); > + else > + unsetenv(s); > + > + if (new != NULL) > + free(new); > + } > + if (ferror(envout)) > + err(1, "reading env processor output"); > + > + pclose(envout); > +} > > /*- > * main -- > @@ -465,6 +543,8 @@ > char *cp = NULL, *start; > /* avoid faults on read-only strings */ > static char syspath[] = _PATH_DEFSYSPATH; > + char *envproc = getenv("MAKEENVPROC"); > + char *envprocdir = getenv("MAKEENVDIR"); > > #if DEFSHELL == 2 > /* > @@ -497,6 +577,12 @@ > > if (stat(curdir, &sa) == -1) > err(2, "%s", curdir); > + > + /* > + * Look for an environment processor as early as possible > + */ > + if ((envproc != NULL) && (envproc[0] != '\0')) > + ReadEnvProc(envproc, envprocdir, curdir); > > #if defined(__i386__) && defined(__FreeBSD_version) && \ > __FreeBSD_version > 300003 > Index: src/usr.bin/make/make.1 > =================================================================== > RCS file: /home/ncvs/src/usr.bin/make/make.1,v > retrieving revision 1.48 > diff -u -r1.48 make.1 > --- src/usr.bin/make/make.1 10 Aug 2001 13:45:27 -0000 1.48 > +++ src/usr.bin/make/make.1 25 Dec 2001 17:40:39 -0000 > @@ -32,7 +32,7 @@ > .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 > .\" $FreeBSD$ > .\" > -.Dd March 19, 1994 > +.Dd December 25, 2001 > .Dt MAKE 1 > .Os > .Sh NAME > @@ -373,7 +373,9 @@ > .It Environment variables > Variables defined as part of > .Nm Ns 's > -environment. > +environment or in the output of the > +.Ev MAKEENVPROC > +program, if specified (see the ENVIRONMENT PROCESSORS section below). > .It Global variables > Variables defined in the makefile or in included makefiles. > .It Command line variables > @@ -716,6 +718,47 @@ > .It Cm U > Converts variable to upper-case letters. > .El > +.Sh ENVIRONMENT PROCESSORS > +External programs, called > +.Dq environment processors , > +may provide > +additional environment data before any Makefile parsing is done. > +If the > +.Ev MAKEENVPROC > +environment variable is set before > +.Nm > +is invoked, it is interpreted as a command to obtain additional environment > +variables from. > +.Nm > +executes the command using the > +.Xr popen 3 > +function and examines each line of its output. > +If the line contains a > +.Sq = > +character, it is treated as a > +.Ar variable Ns No = Ns Ar value > +assignment operator and > +.Nm > +sets the respective variable in its environment to the specified value. > +If the line does not contain a > +.Sq = > +character, it is treated as the name of a variable to be removed from the > +.Nm > +environment. > +.Pp > +If the > +.Ev MAKEENVDIR > +environment variable is also set, > +.Nm > +treats it as an extended regular expression (see > +.Xr re_format 7 ) > +and matches the current directory against it. > +If there is no match, the environment processor is not executed at all. > +This allows for running the processor only in certain directory trees, e.g. > +.Pa /usr/ports , > +without the burden of the additional command execution when running > +.Nm > +in other directories. > .Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS > Directives, conditionals, and for loops reminiscent > of the C programming language are provided in > @@ -1174,6 +1217,8 @@ > uses the following environment variables, if they exist: > .Ev MACHINE , > .Ev MAKE , > +.Ev MAKEENVDIR , > +.Ev MAKEENVPROC , > .Ev MAKEFLAGS , > .Ev MAKEOBJDIR , > and To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jan 6 14:22: 2 2002 Delivered-To: freebsd-audit@freebsd.org Received: from thuvia.demon.co.uk (thuvia.demon.co.uk [193.237.34.248]) by hub.freebsd.org (Postfix) with ESMTP id D9F6137B405; Sun, 6 Jan 2002 14:21:55 -0800 (PST) Received: from dotar-sojat.thuvia.org (dotar-sojat.thuvia.org [10.0.0.4]) by phaidor.thuvia.org (8.11.6/8.11.6) with ESMTP id g06MNuk11010; Sun, 6 Jan 2002 22:23:57 GMT (envelope-from mark@thuvia.demon.co.uk) Received: (from mark@localhost) by dotar-sojat.thuvia.org (8.11.6/8.11.6) id g06MQ0781624; Sun, 6 Jan 2002 22:26:00 GMT (envelope-from mark) Date: Sun, 6 Jan 2002 22:26:00 GMT From: Mark Valentine Message-Id: <200201062226.g06MQ0781624@dotar-sojat.thuvia.org> In-Reply-To: Peter Pentchev's message of Jan 6, 9:30pm X-Mailer: Mail User's Shell (7.2.6 beta(5) 10/07/98) To: roam@ringlet.net (Peter Pentchev), arch@freebsd.org Subject: Re: make(1) enhancement - an 'environment processor' option Cc: audit@freebsd.org Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > From: roam@ringlet.net (Peter Pentchev) > Date: Sun 6 Jan, 2002 > Subject: Re: make(1) enhancement - an 'environment processor' option > No feedback on this proposed change to make(1)? :) It looks like it should be easy enough to provide this functionality in the build system (e.g. bsd.port.mk). Can you suggest any other uses for this feature besides supporting penv(1)? make(1) already contains too many hacks for the FreeBSD build system. Cheers, Mark. -- Mark Valentine, Thuvia Labs "Tigers will do ANYTHING for a tuna fish sandwich." Mark Valentine uses "We're kind of stupid that way." *munch* *munch* and endorses FreeBSD -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jan 6 14:30:22 2002 Delivered-To: freebsd-audit@freebsd.org Received: from straylight.ringlet.net (discworld.nanolink.com [217.75.135.248]) by hub.freebsd.org (Postfix) with SMTP id 88FF337B41B for ; Sun, 6 Jan 2002 14:30:15 -0800 (PST) Received: (qmail 5661 invoked by uid 1000); 6 Jan 2002 21:30:05 -0000 Date: Sun, 6 Jan 2002 23:30:05 +0200 From: Peter Pentchev To: Mark Valentine Cc: arch@freebsd.org, audit@freebsd.org Subject: Re: make(1) enhancement - an 'environment processor' option Message-ID: <20020106233005.J314@straylight.oblivion.bg> Mail-Followup-To: Mark Valentine , arch@freebsd.org, audit@freebsd.org References: <200201062226.g06MQ0781624@dotar-sojat.thuvia.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200201062226.g06MQ0781624@dotar-sojat.thuvia.org>; from mark@thuvia.demon.co.uk on Sun, Jan 06, 2002 at 10:26:00PM +0000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Jan 06, 2002 at 10:26:00PM +0000, Mark Valentine wrote: > > From: roam@ringlet.net (Peter Pentchev) > > Date: Sun 6 Jan, 2002 > > Subject: Re: make(1) enhancement - an 'environment processor' option > > > No feedback on this proposed change to make(1)? :) > > It looks like it should be easy enough to provide this functionality in > the build system (e.g. bsd.port.mk). But would it really? I had this idea initially, before I wrote penv(1) as a standalone preprocessor, and believe me, I tried - but it quickly got ugly, when things came to trusting or checking the output of a program to determine which variables should be unset and which ones should be set, including setting variables to values containing whitespace :) > Can you suggest any other uses for this feature besides supporting penv(1)? Not for the moment, no; but supporting penv(1) is nice, and it may be used outside of the ports tree, too. > make(1) already contains too many hacks for the FreeBSD build system. This particular change should be easy to add to GNU make, too; this is on my to-do list for the next couple of days. G'luck, Peter -- This sentence every third, but it still comprehensible. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jan 6 15:30:24 2002 Delivered-To: freebsd-audit@freebsd.org Received: from thuvia.demon.co.uk (thuvia.demon.co.uk [193.237.34.248]) by hub.freebsd.org (Postfix) with ESMTP id ACC4237B400; Sun, 6 Jan 2002 15:30:08 -0800 (PST) Received: from dotar-sojat.thuvia.org (dotar-sojat.thuvia.org [10.0.0.4]) by phaidor.thuvia.org (8.11.6/8.11.6) with ESMTP id g06NWBk11276; Sun, 6 Jan 2002 23:32:12 GMT (envelope-from mark@thuvia.demon.co.uk) Received: (from mark@localhost) by dotar-sojat.thuvia.org (8.11.6/8.11.6) id g06NYFN84452; Sun, 6 Jan 2002 23:34:15 GMT (envelope-from mark) Date: Sun, 6 Jan 2002 23:34:15 GMT From: Mark Valentine Message-Id: <200201062334.g06NYFN84452@dotar-sojat.thuvia.org> In-Reply-To: Peter Pentchev's message of Jan 6, 11:30pm X-Mailer: Mail User's Shell (7.2.6 beta(5) 10/07/98) To: Peter Pentchev Subject: Re: make(1) enhancement - an 'environment processor' option Cc: arch@freebsd.org, audit@freebsd.org Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > From: Peter Pentchev > Date: Sun 6 Jan, 2002 > Subject: Re: make(1) enhancement - an 'environment processor' option > > It looks like it should be easy enough to provide this functionality in > > the build system (e.g. bsd.port.mk). > > But would it really? I had this idea initially, before I wrote penv(1) > as a standalone preprocessor, and believe me, I tried - but it quickly > got ugly, when things came to trusting or checking the output of a program > to determine which variables should be unset and which ones should be set, > including setting variables to values containing whitespace :) Why the complexity? Why the need to run an external program to read the values of these variables? I'm not familiar with penv(1), but from a perusal it seems that it manages some set of simple variable assignments under /var/db, in some horrendous file-per-variable format(?). Why aren't these just stored in a file in make(1) compatible format? Fix that, and just have bsd.port.mk include /var/db/penv/${PORTNAME} if it exists. > > Can you suggest any other uses for this feature besides supporting penv(1)? > > Not for the moment, no; but supporting penv(1) is nice, Touching a fundamental, universal utility to specifically support an application for which it's used 0.001% of the time isn't very nice... > > make(1) already contains too many hacks for the FreeBSD build system. > > This particular change should be easy to add to GNU make, too; this is > on my to-do list for the next couple of days. I'd be quite interested to see how willing the GNU Make maintainers are to adopt this. Cheers, Mark. -- Mark Valentine, Thuvia Labs "Tigers will do ANYTHING for a tuna fish sandwich." Mark Valentine uses "We're kind of stupid that way." *munch* *munch* and endorses FreeBSD -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jan 6 20:34:16 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mta0x15.coxmail.com (cm-fe1.coxmail.com [206.157.225.48]) by hub.freebsd.org (Postfix) with ESMTP id 2FC1337B417 for ; Sun, 6 Jan 2002 20:34:06 -0800 (PST) Received: from enterprise.muriel.penguinpowered.com ([209.249.174.31]) by mta0x15.coxmail.com (InterMail vK.4.03.04.01 201-232-130-101 license 6e1a3d42bf0668978482829d4ed8437d) with ESMTP id <20020107043347.VPF1821.mta0x15@enterprise.muriel.penguinpowered.com> for ; Sun, 6 Jan 2002 23:33:47 -0500 Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="_=XFMail.1.5.2.FreeBSD:20020106233313:192=_" Date: Sun, 06 Jan 2002 23:33:13 -0500 (EST) Reply-To: Mike Heffner From: Mike Heffner To: FreeBSD-audit Subject: Fwd: Re: bin/19422: users can overflow argv to make ps segfault Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.5.2.FreeBSD:20020106233313:192=_ Content-Type: text/plain; charset=us-ascii I'm resending this patch to -audit since I didn't get much response on -bugs, and that the patch is somewhat ugly. Does anyone notice anything wrong with the attached patch? Otherwise, I will commit it shortly. Thanks, -----Fwd: ----- Date: Tue, 11 Dec 2001 23:18:54 -0500 (EST) Sender: owner-freebsd-bugs@FreeBSD.ORG From: Mike Heffner To: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: bin/19422: users can overflow argv to make ps segfault Cc: Marc Olzheim , FreeBSD-bugs Well, I've looked at this a little more. I was able to reproduce it (it took a few times though). Unfortunately, the patch isn't as simple as the one in the PR. Could you please try the attached patch? There is still a problem though, and that is that the strlen()s can seg. fault if the argv[] strings aren't NULL terminated - I don't know how to fix this problem though :( Mike -- Mike Heffner Blacksburg, VA --------------End of forwarded message------------------------- Mike -- Mike Heffner Fredericksburg, VA --_=XFMail.1.5.2.FreeBSD:20020106233313:192=_ Content-type: text/plain; SizeOnDisk=908; name=ps.argoflow.diff; charset=us-ascii Content-description: ps.argoflow.diff Content-disposition: attachment; filename=ps.argoflow.diff Content-transfer-encoding: 7bit Index: fmt.c =================================================================== RCS file: /home/ncvs/src/bin/ps/fmt.c,v retrieving revision 1.14 diff -u -r1.14 fmt.c --- fmt.c 27 Aug 1999 23:14:51 -0000 1.14 +++ fmt.c 12 Dec 2001 04:12:24 -0000 @@ -61,7 +61,8 @@ shquote(argv) char **argv; { - long arg_max; + static long arg_max = -1; + long len; char **p, *dst, *src; static char *buf = NULL; @@ -80,13 +81,16 @@ for (p = argv; (src = *p++) != 0; ) { if (*src == 0) continue; - strvis(dst, src, VIS_NL | VIS_CSTYLE); + len = (4 * arg_max - (dst - buf)) / 4; + strvisx(dst, src, strlen(src) < len ? strlen(src) : len, + VIS_NL | VIS_CSTYLE); while (*dst) dst++; - *dst++ = ' '; + if ((4 * arg_max - (dst - buf)) / 4 > 0) + *dst++ = ' '; } /* Chop off trailing space */ - if (dst != buf) + if (dst != buf && dst[-1] == ' ') dst--; *dst = '\0'; return (buf); --_=XFMail.1.5.2.FreeBSD:20020106233313:192=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Jan 7 14:38:57 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id 6A53D37B405; Mon, 7 Jan 2002 14:38:50 -0800 (PST) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.11.3/8.11.3) with ESMTP id g07Mcgt72460; Mon, 7 Jan 2002 17:38:43 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <20020106222002.E314@straylight.oblivion.bg> References: <20011225202925.F304@straylight.oblivion.bg> <20020106222002.E314@straylight.oblivion.bg> Date: Mon, 7 Jan 2002 17:38:41 -0500 To: Peter Pentchev , arch@FreeBSD.ORG From: Garance A Drosihn Subject: Re: make(1) enhancement - an 'environment processor' option Cc: audit@FreeBSD.ORG Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.1 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 10:20 PM +0200 1/6/02, Peter Pentchev wrote: >Hi, > >No feedback on this proposed change to make(1)? :) I saw your earlier message, and even kept it around because I wanted to reply to it. The thing was, I wasn't quite sure what I wanted to say... Basically, I'm not comfortable with this being incorporated into make, although I don't have a specific reason that it should not be done. I guess it's more of "It just doesn't seem right". > > Basically, what it does is remember what variables you want set > > for a specific directory and then hand them in the environment of > > any program you want to run. This may be quite useful for ports, > > especially those with lots of tweakable knobs, like vpopmail or > > MySQL, since it won't let you miss one of those knobs the next > > time you rebuild the port. In the specific case of ports, the 'portupgrade' utility includes a way to keep track of such environment variables. Check the sample in /usr/local/etc/pkgtools.conf.sample if you have portupgrade installed (and it's definitely worth installing). There's also a 'man 5 pkgtools.conf', but it doesn't seem to say much... Here's an excerpt from that file: # MAKE_ARGS: hash # # This is a hash of ports glob => arguments mapping. portupgrade(1) # and portinstall(1) look it up to pick command line arguments to # pass to make(1). You can use wildcards ("ports glob"). If a # port/package matches multiple entries, all the arguments are # joined using the space as separator. # # cf. -m/--make-args of portupgrade(1), ports_glob(1) # # e.g.: # MAKE_ARGS = { # 'databases/mysql323-*' => 'WITH_CHARSET=ujis', # } This doesn't help for the more general case of "any directory", but the ports collection itself seems to be covered pretty well by this. Note that you could also create "extra categories" of ports, and put your own programs in those categories, and have them covered that way... (okay, that's not a perfect solution, but it would work for some things) portupgrade is a very nice package... :-) -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Jan 9 5:49: 3 2002 Delivered-To: freebsd-audit@freebsd.org Received: from axl.seasidesoftware.co.za (axl.seasidesoftware.co.za [196.31.7.201]) by hub.freebsd.org (Postfix) with ESMTP id 215F237B417 for ; Wed, 9 Jan 2002 05:49:00 -0800 (PST) Received: from sheldonh (helo=axl.seasidesoftware.co.za) by axl.seasidesoftware.co.za with local-esmtp (Exim 3.33 #1) id 16OJ8L-000EuO-00 for audit@FreeBSD.org; Wed, 09 Jan 2002 15:51:13 +0200 From: Sheldon Hearn To: audit@FreeBSD.org Subject: bin/33187: ls -dF and trailing slashes Date: Wed, 09 Jan 2002 15:51:13 +0200 Message-ID: <57311.1010584273@axl.seasidesoftware.co.za> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi folks, What do you think of the following patch, taken from PR bin/33187? It prevents ls -dF /usr/ from producing /usr// which may confuse other programs for which this output is used as input. Ciao Sheldon. Index: ls.c =================================================================== RCS file: /home/ncvs/src/bin/ls/ls.c,v retrieving revision 1.51 diff -u -d -r1.51 ls.c --- ls.c 29 Dec 2001 00:22:29 -0000 1.51 +++ ls.c 9 Jan 2002 13:34:48 -0000 @@ -135,7 +135,7 @@ { static char dot[] = ".", *dotav[] = {dot, NULL}; struct winsize win; - int ch, fts_options, notused; + int ch, fts_options, i, len, notused; char *p; #ifdef COLORLS char termcapbuf[1024]; /* termcap definition buffer */ @@ -392,6 +392,17 @@ printfcn = printlong; else printfcn = printcol; + + /* + * If -d and -F options, strip trailing slashes from arguments + * to avoid duplicated terminating slashes in output. + */ + if (f_listdir && f_type) + for(i=0; i < argc ; i++) { + len = strlen(argv[i]); + if (argv[i][len - 1] == '/') + argv[i][len - 1] = '\0'; + } if (argc) traverse(argc, argv, fts_options); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Jan 9 6:19:46 2002 Delivered-To: freebsd-audit@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 7E84B37B404; Wed, 9 Jan 2002 06:19:38 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id g09EJ6H80172; Wed, 9 Jan 2002 16:19:06 +0200 (EET) (envelope-from ru) Date: Wed, 9 Jan 2002 16:19:06 +0200 From: Ruslan Ermilov To: Sheldon Hearn Cc: audit@FreeBSD.ORG, bug-followup@FreeBSD.ORG Subject: Re: bin/33187: ls -dF and trailing slashes Message-ID: <20020109161906.N41379@sunbay.com> References: <57311.1010584273@axl.seasidesoftware.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57311.1010584273@axl.seasidesoftware.co.za> User-Agent: Mutt/1.3.23i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Jan 09, 2002 at 03:51:13PM +0200, Sheldon Hearn wrote: > > Hi folks, > > What do you think of the following patch, taken from PR bin/33187? > > It prevents > > ls -dF /usr/ > > from producing > > /usr// > > which may confuse other programs for which this output is used as input. > It also doesn't work for ``ls -dF /usr//'' and breaks ``ls -dF /''. > Index: ls.c > =================================================================== > RCS file: /home/ncvs/src/bin/ls/ls.c,v > retrieving revision 1.51 > diff -u -d -r1.51 ls.c > --- ls.c 29 Dec 2001 00:22:29 -0000 1.51 > +++ ls.c 9 Jan 2002 13:34:48 -0000 > @@ -135,7 +135,7 @@ > { > static char dot[] = ".", *dotav[] = {dot, NULL}; > struct winsize win; > - int ch, fts_options, notused; > + int ch, fts_options, i, len, notused; > char *p; > #ifdef COLORLS > char termcapbuf[1024]; /* termcap definition buffer */ > @@ -392,6 +392,17 @@ > printfcn = printlong; > else > printfcn = printcol; > + > + /* > + * If -d and -F options, strip trailing slashes from arguments > + * to avoid duplicated terminating slashes in output. > + */ > + if (f_listdir && f_type) > + for(i=0; i < argc ; i++) { > + len = strlen(argv[i]); > + if (argv[i][len - 1] == '/') > + argv[i][len - 1] = '\0'; > + } > > if (argc) > traverse(argc, argv, fts_options); Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Jan 9 20: 3:52 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 2D61037B416; Wed, 9 Jan 2002 20:03:47 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id PAA07583; Thu, 10 Jan 2002 15:03:44 +1100 Date: Thu, 10 Jan 2002 15:04:31 +1100 (EST) From: Bruce Evans X-X-Sender: To: Ruslan Ermilov Cc: Sheldon Hearn , , Subject: Re: bin/33187: ls -dF and trailing slashes In-Reply-To: <20020109161906.N41379@sunbay.com> Message-ID: <20020110145750.U10820-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 9 Jan 2002, Ruslan Ermilov wrote: > On Wed, Jan 09, 2002 at 03:51:13PM +0200, Sheldon Hearn wrote: > > > > Hi folks, > > > > What do you think of the following patch, taken from PR bin/33187? > > > > It prevents > > > > ls -dF /usr/ > > > > from producing > > > > /usr// > > > > which may confuse other programs for which this output is used as input. > > > It also doesn't work for ``ls -dF /usr//'' and breaks ``ls -dF /''. It also breaks ls of symlinks. E.g.: $ ls -lF /var/crash /var/crash/ lrwxr-xr-x 1 root wheel 8 Mar 5 2001 /var/crash@ -> /c/crash /var/crash/: total 145202 -rw-r--r-- 1 4294967294 wheel 2 Jan 9 14:44 bounds -rw-r--r-- 1 4294967294 wheel 2630180 Jan 9 14:45 kernel.4 -rw-r--r-- 1 root wheel 5 May 19 1994 minfree -rw------- 1 4294967294 wheel 14680064 Nov 24 21:06 vmcore.1 -rw------- 1 4294967294 wheel 1048576 Nov 24 21:09 vmcore.2 -rw------- 1 4294967294 wheel 7053312 Jan 7 14:16 vmcore.3 -rw------- 1 4294967294 wheel 268435456 Jan 9 14:45 vmcore.4 I think the slash should be stripped in the output at most. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 10 1:25: 0 2002 Delivered-To: freebsd-audit@freebsd.org Received: from axl.seasidesoftware.co.za (axl.seasidesoftware.co.za [196.31.7.201]) by hub.freebsd.org (Postfix) with ESMTP id CBF3437B416; Thu, 10 Jan 2002 01:24:56 -0800 (PST) Received: from sheldonh (helo=axl.seasidesoftware.co.za) by axl.seasidesoftware.co.za with local-esmtp (Exim 3.33 #1) id 16ObUD-000OTL-00; Thu, 10 Jan 2002 11:27:01 +0200 From: Sheldon Hearn To: Bruce Evans Cc: Ruslan Ermilov , audit@FreeBSD.ORG Subject: Re: bin/33187: ls -dF and trailing slashes In-reply-to: Your message of "Thu, 10 Jan 2002 15:04:31 +1100." <20020110145750.U10820-100000@gamplex.bde.org> Date: Thu, 10 Jan 2002 11:27:01 +0200 Message-ID: <94074.1010654821@axl.seasidesoftware.co.za> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 10 Jan 2002 15:04:31 +1100, Bruce Evans wrote: > > It also doesn't work for ``ls -dF /usr//'' and breaks ``ls -dF /''. > > It also breaks ls of symlinks. E.g.: Thanks. I've suspended the PR. Ciao, Sheldon. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 10 2:24: 1 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mta6.snfc21.pbi.net (mta6.snfc21.pbi.net [206.13.28.240]) by hub.freebsd.org (Postfix) with ESMTP id C44CC37B419; Thu, 10 Jan 2002 02:23:59 -0800 (PST) Received: from blackbox.pacbell.net ([64.166.86.36]) by mta6.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0GPP009P8WVYEU@mta6.snfc21.pbi.net>; Thu, 10 Jan 2002 02:23:59 -0800 (PST) Received: (from mikem@localhost) by blackbox.pacbell.net (8.11.6/8.11.6) id g0AAOUF03700; Thu, 10 Jan 2002 02:24:30 -0800 (PST envelope-from mikem) Date: Thu, 10 Jan 2002 02:24:30 -0800 From: Mike Makonnen Subject: Re: bin/33187: ls -dF and trailing slashes In-reply-to: <20020109161906.N41379@sunbay.com> To: Ruslan Ermilov Cc: sheldonh@starjuice.net, audit@freebsd.org, bug-followup@freebsd.org Message-id: <200201101024.g0AAOUF03700@blackbox.pacbell.net> MIME-version: 1.0 X-Mailer: Sylpheed version 0.6.5 (GTK+ 1.2.10; i386--freebsd5.0) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT References: <57311.1010584273@axl.seasidesoftware.co.za> <20020109161906.N41379@sunbay.com> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 9 Jan 2002 16:19:06 +0200 Ruslan Ermilov wrote: > > > It also doesn't work for ``ls -dF /usr//'' and breaks ``ls -dF /''. > Ok, the issue is a bit more complicated than I thought at first. Anyways, regardless of the patch, it seems ls(1) accepts the following: ``ls -dF /usr////////////////''. It seems like ls(1) (or rather the fts_* family of functions) doesn't care how many trailing '/' there are. Is this a possible bug in fts_*? Anyone know what POSIX has to say about this? Cheers, mike makonnen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 10 2:32:56 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mta7.pltn13.pbi.net (mta7.pltn13.pbi.net [64.164.98.8]) by hub.freebsd.org (Postfix) with ESMTP id 2C56A37B41B; Thu, 10 Jan 2002 02:32:54 -0800 (PST) Received: from blackbox.pacbell.net ([64.166.86.36]) by mta7.pltn13.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0GPP0084NXAT1K@mta7.pltn13.pbi.net>; Thu, 10 Jan 2002 02:32:53 -0800 (PST) Received: (from mikem@localhost) by blackbox.pacbell.net (8.11.6/8.11.6) id g0AAXPd03715; Thu, 10 Jan 2002 02:33:25 -0800 (PST envelope-from mikem) Date: Thu, 10 Jan 2002 02:33:25 -0800 From: Mike Makonnen Subject: Re: bin/33187: ls -dF and trailing slashes In-reply-to: <20020110145750.U10820-100000@gamplex.bde.org> To: Bruce Evans Cc: ru@freebsd.org, sheldonh@starjuice.net, audit@freebsd.org, bug-followup@freebsd.org Message-id: <200201101033.g0AAXPd03715@blackbox.pacbell.net> MIME-version: 1.0 X-Mailer: Sylpheed version 0.6.5 (GTK+ 1.2.10; i386--freebsd5.0) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT References: <20020109161906.N41379@sunbay.com> <20020110145750.U10820-100000@gamplex.bde.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 10 Jan 2002 15:04:31 +1100 (EST) Bruce Evans wrote: > It also breaks ls of symlinks. E.g.: > > $ ls -lF /var/crash /var/crash/ > lrwxr-xr-x 1 root wheel 8 Mar 5 2001 /var/crash@ -> /c/crash > > /var/crash/: > total 145202 > -rw-r--r-- 1 4294967294 wheel 2 Jan 9 14:44 bounds > -rw-r--r-- 1 4294967294 wheel 2630180 Jan 9 14:45 kernel.4 > -rw-r--r-- 1 root wheel 5 May 19 1994 minfree > -rw------- 1 4294967294 wheel 14680064 Nov 24 21:06 vmcore.1 > -rw------- 1 4294967294 wheel 1048576 Nov 24 21:09 vmcore.2 > -rw------- 1 4294967294 wheel 7053312 Jan 7 14:16 vmcore.3 > -rw------- 1 4294967294 wheel 268435456 Jan 9 14:45 vmcore.4 I realize the pr has been suspended, but just to set the record straight... this is not caused by the patch. The patch only comes into effect when both -d and -F are specified. > I think the slash should be stripped in the output at most. Yeah, you're right. I also just found out ls(1) will accept ``ls /usr////////''. So, should all trailing '/' be stripped on output or is it not worth the effort/POSIX compliance/whatever ? Cheers, mike makonnen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 10 4:38:26 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id CEC0B37B400; Thu, 10 Jan 2002 04:38:18 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA18086; Thu, 10 Jan 2002 23:38:10 +1100 Date: Thu, 10 Jan 2002 23:38:47 +1100 (EST) From: Bruce Evans X-X-Sender: To: Mike Makonnen Cc: , , , Subject: Re: bin/33187: ls -dF and trailing slashes In-Reply-To: <200201101033.g0AAXPd03715@blackbox.pacbell.net> Message-ID: <20020110232640.R12168-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 10 Jan 2002, Mike Makonnen wrote: > On Thu, 10 Jan 2002 15:04:31 +1100 (EST) > Bruce Evans wrote: > > > It also breaks ls of symlinks. E.g.: > > > > $ ls -lF /var/crash /var/crash/ > > lrwxr-xr-x 1 root wheel 8 Mar 5 2001 /var/crash@ -> /c/crash > > > > /var/crash/: > > total 145202 > > -rw-r--r-- 1 4294967294 wheel 2 Jan 9 14:44 bounds > > -rw-r--r-- 1 4294967294 wheel 2630180 Jan 9 14:45 kernel.4 > > -rw-r--r-- 1 root wheel 5 May 19 1994 minfree > > -rw------- 1 4294967294 wheel 14680064 Nov 24 21:06 vmcore.1 > > -rw------- 1 4294967294 wheel 1048576 Nov 24 21:09 vmcore.2 > > -rw------- 1 4294967294 wheel 7053312 Jan 7 14:16 vmcore.3 > > -rw------- 1 4294967294 wheel 268435456 Jan 9 14:45 vmcore.4 > > I realize the pr has been suspended, but just to set the record straight... > this is not caused by the patch. The patch only comes into effect when both -d and -F are specified. I forgot it was -d and my fingers knew it was -l :-). Anyway, "ls -dF /var/crash/" should follow the symlink (if any). Appending a slash is a normal way to get symlinks followed. For ls, you can use -L, but most utilities don't have an equivalent. > > I think the slash should be stripped in the output at most. > > Yeah, you're right. I also just found out ls(1) will accept ``ls /usr////////''. So, should all trailing '/' be stripped on output or is it not > worth the effort/POSIX compliance/whatever ? I doubt that POSIX specifies the output of ls in enough detail to say, but I think stripping should not change the semantics of the pathnames, in case they are used for input. Stripping "//" to "/" changes the semantics, as does stripping "foo/" to "foo" if "foo" is not a directory. Otherwise, trailing slashes may be stripped without changing the semantics. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jan 10 23:35:12 2002 Delivered-To: freebsd-audit@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id B911137B416; Thu, 10 Jan 2002 23:35:04 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id g0B7YE908482; Fri, 11 Jan 2002 09:34:14 +0200 (EET) (envelope-from ru) Date: Fri, 11 Jan 2002 09:34:14 +0200 From: Ruslan Ermilov To: Bruce Evans Cc: Mike Makonnen , sheldonh@starjuice.net, audit@freebsd.org, bug-followup@freebsd.org Subject: Re: bin/33187: ls -dF and trailing slashes Message-ID: <20020111093414.B7527@sunbay.com> References: <200201101033.g0AAXPd03715@blackbox.pacbell.net> <20020110232640.R12168-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020110232640.R12168-100000@gamplex.bde.org> User-Agent: Mutt/1.3.23i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jan 10, 2002 at 11:38:47PM +1100, Bruce Evans wrote: > On Thu, 10 Jan 2002, Mike Makonnen wrote: > > > On Thu, 10 Jan 2002 15:04:31 +1100 (EST) > > Bruce Evans wrote: > > > > > It also breaks ls of symlinks. E.g.: > > > > > > $ ls -lF /var/crash /var/crash/ > > > lrwxr-xr-x 1 root wheel 8 Mar 5 2001 /var/crash@ -> /c/crash > > > > > > /var/crash/: > > > total 145202 > > > -rw-r--r-- 1 4294967294 wheel 2 Jan 9 14:44 bounds > > > -rw-r--r-- 1 4294967294 wheel 2630180 Jan 9 14:45 kernel.4 > > > -rw-r--r-- 1 root wheel 5 May 19 1994 minfree > > > -rw------- 1 4294967294 wheel 14680064 Nov 24 21:06 vmcore.1 > > > -rw------- 1 4294967294 wheel 1048576 Nov 24 21:09 vmcore.2 > > > -rw------- 1 4294967294 wheel 7053312 Jan 7 14:16 vmcore.3 > > > -rw------- 1 4294967294 wheel 268435456 Jan 9 14:45 vmcore.4 > > > > I realize the pr has been suspended, but just to set the record straight... > > this is not caused by the patch. The patch only comes into effect when both -d and -F are specified. > > I forgot it was -d and my fingers knew it was -l :-). Anyway, "ls -dF > /var/crash/" should follow the symlink (if any). Appending a slash > is a normal way to get symlinks followed. For ls, you can use -L, but > most utilities don't have an equivalent. > > > > I think the slash should be stripped in the output at most. > > > > Yeah, you're right. I also just found out ls(1) will accept ``ls /usr////////''. So, should all trailing '/' be stripped on output or is it not > > worth the effort/POSIX compliance/whatever ? > > I doubt that POSIX specifies the output of ls in enough detail to say, but > I think stripping should not change the semantics of the pathnames, in > case they are used for input. Stripping "//" to "/" changes the semantics, > as does stripping "foo/" to "foo" if "foo" is not a directory. Otherwise, > trailing slashes may be stripped without changing the semantics. > Let's not overload our utilities with the stuff like this. There's nothing wrong with trailing slashes if the user so wanted -- for those who doesn't, a simple sed(1) sequence would be in place, or realpath(3) from within C. More to the point, the multiple slashes in the middle of a pathname are not covered by this PR, and I don't see a reason why we should treat trailing slashes differently. I insist on us closing this PR. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Jan 11 3:19:59 2002 Delivered-To: freebsd-audit@freebsd.org Received: from axl.seasidesoftware.co.za (axl.seasidesoftware.co.za [196.31.7.201]) by hub.freebsd.org (Postfix) with ESMTP id 57EF037B404; Fri, 11 Jan 2002 03:19:56 -0800 (PST) Received: from sheldonh (helo=axl.seasidesoftware.co.za) by axl.seasidesoftware.co.za with local-esmtp (Exim 3.33 #1) id 16Ozl8-000CsS-00; Fri, 11 Jan 2002 13:22:06 +0200 From: Sheldon Hearn To: Ruslan Ermilov Cc: Bruce Evans , Mike Makonnen , audit@freebsd.org, bug-followup@freebsd.org Subject: Re: bin/33187: ls -dF and trailing slashes In-reply-to: Your message of "Fri, 11 Jan 2002 09:34:14 +0200." <20020111093414.B7527@sunbay.com> Date: Fri, 11 Jan 2002 13:22:06 +0200 Message-ID: <49503.1010748126@axl.seasidesoftware.co.za> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 11 Jan 2002 09:34:14 +0200, Ruslan Ermilov wrote: > I insist on us closing this PR. No objection from me. Ciao, Sheldon. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Jan 11 3:21:44 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mta7.pltn13.pbi.net (mta7.pltn13.pbi.net [64.164.98.8]) by hub.freebsd.org (Postfix) with ESMTP id AD34D37B416; Fri, 11 Jan 2002 03:21:42 -0800 (PST) Received: from blackbox.pacbell.net ([64.166.86.36]) by mta7.pltn13.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0GPR00H5VU86OW@mta7.pltn13.pbi.net>; Fri, 11 Jan 2002 03:21:42 -0800 (PST) Received: (from mikem@localhost) by blackbox.pacbell.net (8.11.6/8.11.6) id g0BBM8Y88385; Fri, 11 Jan 2002 03:22:08 -0800 (PST envelope-from mikem) Date: Fri, 11 Jan 2002 03:22:01 -0800 From: Mike Makonnen Subject: Re: bin/33187: ls -dF and trailing slashes In-reply-to: <20020111093414.B7527@sunbay.com> To: Ruslan Ermilov Cc: bde@zeta.org.au, sheldonh@starjuice.net, audit@freebsd.org, bug-followup@freebsd.org Message-id: <200201111122.g0BBM8Y88385@blackbox.pacbell.net> MIME-version: 1.0 X-Mailer: Sylpheed version 0.6.5 (GTK+ 1.2.10; i386--freebsd5.0) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT References: <200201101033.g0AAXPd03715@blackbox.pacbell.net> <20020110232640.R12168-100000@gamplex.bde.org> <20020111093414.B7527@sunbay.com> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 11 Jan 2002 09:34:14 +0200 Ruslan Ermilov wrote: > slashes differently. I insist on us closing this PR. Fine with me. Cheers, mike makonnen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Jan 11 17:50: 5 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 3050937B400 for ; Fri, 11 Jan 2002 17:49:54 -0800 (PST) Received: from hades.hell.gr (patr530-a152.otenet.gr [212.205.215.152]) by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id g0C1npO10597 for ; Sat, 12 Jan 2002 03:49:51 +0200 (EET) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id g0BNQWc66732 for audit@freebsd.org; Sat, 12 Jan 2002 01:26:32 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Sat, 12 Jan 2002 01:26:31 +0200 From: Giorgos Keramidas To: audit@FreeBSD.org Subject: last with -y option Message-ID: <20020111232631.GA66629@hades.hell.gr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="8GpibOaaTibBMecb" Content-Disposition: inline User-Agent: Mutt/1.3.25i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --8GpibOaaTibBMecb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The patch that was sent in PR bin/12982 does not apply to the usr.bin/last (probably because our last was modified for WARNS=2 after the patch was submitted), but I liked the idea that it describes. The attached patch adds a -y option to last that will print the year too when listing wtmp records. It also removes a few EOL whitespaces that I found while reading the last.c source. If this does not break any standards, and you don't think that it breaks last(1) in some way, I'll have to find myself an src/ committer to take care of this PR :-) Cheers, -- Giorgos Keramidas . . . . . . . . . keramida@{ceid.upatras.gr,freebsd.org} FreeBSD Documentation Project . . . http://www.freebsd.org/docproj/ FreeBSD: The power to serve . . . . http://www.freebsd.org/ --8GpibOaaTibBMecb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="28.last-y.diff" Content-Transfer-Encoding: quoted-printable Index: last.1 =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 RCS file: /home/ncvs/src/usr.bin/last/last.1,v retrieving revision 1.11 diff -u -2 -r1.11 last.1 --- last.1 10 Jul 2001 14:16:03 -0000 1.11 +++ last.1 9 Dec 2001 01:52:36 -0000 @@ -56,4 +56,5 @@ .Op Fl t Ar tty .Op Fl w +.Op Fl y .Op Ar user ... .Sh DESCRIPTION @@ -162,4 +163,6 @@ Widen the duration field to show seconds, as well as the default days, hours and minutes. +.It Fl w +Report years too in the login session duration. .El .Pp Index: last.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 RCS file: /home/ncvs/src/usr.bin/last/last.c,v retrieving revision 1.21 diff -u -2 -r1.21 last.c --- last.c 29 Oct 2001 00:34:20 -0000 1.21 +++ last.c 11 Jan 2002 23:15:48 -0000 @@ -90,4 +90,5 @@ static int sflag =3D 0; /* show delta in seconds */ static int width =3D 5; /* show seconds in delta */ +static int yflag =3D 0; /* show years in delta */ static int d_first; static time_t snaptime; /* if !=3D 0, we will only @@ -110,5 +111,5 @@ (void)fprintf(stderr, "usage: last [-#] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h hostname]\n" -"\t[-t tty] [-s|w] [user ...]\n"); +"\t[-t tty] [-s|w] [-y] [user ...]\n"); exit(1); } @@ -127,5 +128,5 @@ maxrec =3D -1; snaptime =3D 0; - while ((ch =3D getopt(argc, argv, "0123456789d:f:h:st:w")) !=3D -1) + while ((ch =3D getopt(argc, argv, "0123456789d:f:h:st:wy")) !=3D -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': @@ -164,4 +165,7 @@ width =3D 8; break; + case 'y': + yflag =3D 1; + break; case '?': default: @@ -246,13 +250,22 @@ /* * don't print shutdown/reboot entries - * unless flagged for=20 - */=20 + * unless flagged for + */ if (!snaptime && want(bp)) { t =3D int_to_time(bp->ut_time); tm =3D localtime(&t); - (void) strftime(ct, sizeof(ct), - d_first ? "%a %e %b %R" : - "%a %b %e %R", - tm); + if (yflag) { + (void) strftime(ct, sizeof(ct), + d_first + ? "%a %e %b %Y %R" + : "%a %b %e %Y %R", + tm); + } else { + (void) strftime(ct, sizeof(ct), + d_first + ? "%a %e %b %Y %R" + : "%a %b %e %Y %R", + tm); + } printf("%-*.*s %-*.*s %-*.*s %s\n", UT_NAMESIZE, UT_NAMESIZE, @@ -275,8 +288,17 @@ t =3D int_to_time(bp->ut_time); tm =3D localtime(&t); - (void) strftime(ct, sizeof(ct), - d_first ? "%a %e %b %R" : - "%a %b %e %R", - tm); + if (yflag) { + (void) strftime(ct, sizeof(ct), + d_first + ? "%a %e %b %Y %R" + : "%a %b %e %Y %R", + tm); + } else { + (void) strftime(ct, sizeof(ct), + d_first + ? "%a %e %b %R" + : "%a %b %e %R", + tm); + } printf("%-*.*s %-*.*s %-*.*s %s\n", UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, @@ -293,5 +315,5 @@ if (!strncmp(tt->tty, bp->ut_line, UT_LINESIZE)) break; - =09 + if (tt =3D=3D NULL) { /* add new one */ @@ -303,5 +325,5 @@ LIST_INSERT_HEAD(&ttylist, tt, list); } - =09 + /* * print record if not in snapshot mode and wanted @@ -323,8 +345,15 @@ t =3D int_to_time(bp->ut_time); tm =3D localtime(&t); - (void) strftime(ct, sizeof(ct), - d_first ? "%a %e %b %R" : - "%a %b %e %R", - tm); + if (yflag) { + (void) strftime(ct, sizeof(ct), + d_first ? "%a %e %b %Y %R" : + "%a %b %e %Y %R", + tm); + } else { + (void) strftime(ct, sizeof(ct), + d_first ? "%a %e %b %R" : + "%a %b %e %R", + tm); + } printf("%-*.*s %-*.*s %-*.*s %s ", UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, @@ -346,5 +375,5 @@ delta =3D tt->logout - bp->ut_time; if ( sflag ) { - printf(" (%8ld)\n",=20 + printf(" (%8ld)\n", (long)delta); } else { --8GpibOaaTibBMecb-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message