From owner-freebsd-audit Mon May 27 17:12:34 2002 Delivered-To: freebsd-audit@freebsd.org Received: from turbine.trit.org (turbine.trit.org [63.198.170.141]) by hub.freebsd.org (Postfix) with ESMTP id C914237B409 for ; Mon, 27 May 2002 17:12:29 -0700 (PDT) Received: from turbine.trit.org (localhost [127.0.0.1]) by turbine.trit.org (Postfix) with ESMTP id E5D3E3E5E; Tue, 28 May 2002 00:12:27 +0000 (UTC) To: Dag-Erling Smorgrav Cc: audit@freebsd.org Subject: Re: %j for printf(9) In-Reply-To: ; from des@ofug.org on "23 May 2002 13:16:58 +0200" Date: Tue, 28 May 2002 00:12:27 +0000 From: Dima Dorfman Message-Id: <20020528001227.E5D3E3E5E@turbine.trit.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 Dag-Erling Smorgrav wrote: > Dima Dorfman writes: > > I would also like to solicit comments on what to do with %z; C99 says > > this is the length modifier for size_t, but the kernel treats it as > > signed hex. This patch implements the C99 length modifier as %Z, but > > that probably shouldn't stay. IIRC, I couldn't find any place in the > > kernel that we actually use %z; can it perhaps be removed? > > des@des ~% egrep -r '%[^\" dious]+z' /sec/freebsd/current/src/sys > /sec/freebsd/current/src/sys/ddb/db_examine.c: db_printf("%-*lz", width, (long)value); > /sec/freebsd/current/src/sys/ddb/db_examine.c: db_printf("%8lz", (long)addr); As far as I can tell, these are just implementing %z for the examine command. If we remove %z from printf(9), we can probably remove it from ddb examine, too. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon May 27 17:16:19 2002 Delivered-To: freebsd-audit@freebsd.org Received: from turbine.trit.org (turbine.trit.org [63.198.170.141]) by hub.freebsd.org (Postfix) with ESMTP id 4876D37B404 for ; Mon, 27 May 2002 17:16:16 -0700 (PDT) Received: from turbine.trit.org (localhost [127.0.0.1]) by turbine.trit.org (Postfix) with ESMTP id 4BAC93E5E; Tue, 28 May 2002 00:16:15 +0000 (UTC) To: Dag-Erling Smorgrav Cc: audit@freebsd.org Subject: Re: %j for printf(9) In-Reply-To: ; from des@ofug.org on "25 May 2002 15:29:11 +0200" Date: Tue, 28 May 2002 00:16:14 +0000 From: Dima Dorfman Message-Id: <20020528001615.4BAC93E5E@turbine.trit.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 Dag-Erling Smorgrav wrote: > Dima Dorfman writes: > > Attached is a patch that implements the %j length modifier in > > printf(9). > > Here's an alternative (IMHO less disruptive) patch, which also fixes > the default case. I still like my restructure, but since other people don't seem to share my opinion, I'm fine doing it another (your) way. That said, I think your patch has some bugs that mine doesn't. For example, this: printf("%ld\n", -4); yields "4294967292" with your patch, but not with mine (mine, and printf(3), yield "-4"). I think the attached patch (relative to subr_prf.c *with* your patch applied) fixes it. Thanks. --- subr_prf_des.c Mon May 27 23:55:45 2002 +++ subr_prf.c Tue May 28 00:09:30 2002 @@ -658,19 +658,19 @@ if (jflag) num = va_arg(ap, uintmax_t); else if (qflag) - num = va_arg(ap, u_quad_t); + num = (u_quad_t)va_arg(ap, u_quad_t); else if (lflag) - num = va_arg(ap, u_long); + num = (u_long)va_arg(ap, u_long); else - num = va_arg(ap, u_int); + num = (u_int)va_arg(ap, u_int); goto nosign; fetch_number: if (jflag) - num = va_arg(ap, uintmax_t); + num = va_arg(ap, intmax_t); else if (qflag) - num = va_arg(ap, u_quad_t); + num = (quad_t)va_arg(ap, quad_t); else if (lflag) - num = va_arg(ap, u_long); + num = (long)va_arg(ap, long); else num = sign ? (uintmax_t)va_arg(ap, int) : va_arg(ap, u_int); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon May 27 20:54:57 2002 Delivered-To: freebsd-audit@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 1BE5837B407 for ; Mon, 27 May 2002 20:54:39 -0700 (PDT) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 6E36B5307; Tue, 28 May 2002 05:54:37 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Dima Dorfman Cc: audit@freebsd.org Subject: Re: %j for printf(9) References: <20020528001615.4BAC93E5E@turbine.trit.org> From: Dag-Erling Smorgrav Date: 28 May 2002 05:54:36 +0200 In-Reply-To: <20020528001615.4BAC93E5E@turbine.trit.org> Message-ID: Lines: 16 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 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 Dima Dorfman writes: > I still like my restructure, but since other people don't seem to > share my opinion, I'm fine doing it another (your) way. That said, I > think your patch has some bugs that mine doesn't. For example, this: > > printf("%ld\n", -4); > > yields "4294967292" with your patch, but not with mine (mine, and > printf(3), yield "-4"). I think the attached patch (relative to > subr_prf.c *with* your patch applied) fixes it. Yep. Commit? DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 28 1:37: 2 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 1A42837B400 for ; Tue, 28 May 2002 01:36:59 -0700 (PDT) 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 SAA25374; Tue, 28 May 2002 18:36:46 +1000 Date: Tue, 28 May 2002 18:40:02 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dima Dorfman Cc: Dag-Erling Smorgrav , Subject: Re: %j for printf(9) In-Reply-To: <20020528001227.E5D3E3E5E@turbine.trit.org> Message-ID: <20020528182851.G19885-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 Tue, 28 May 2002, Dima Dorfman wrote: > Dag-Erling Smorgrav wrote: > > Dima Dorfman writes: > > > I would also like to solicit comments on what to do with %z; C99 says > > > this is the length modifier for size_t, but the kernel treats it as > > > signed hex. This patch implements the C99 length modifier as %Z, but > > > that probably shouldn't stay. IIRC, I couldn't find any place in the > > > kernel that we actually use %z; can it perhaps be removed? > > > > des@des ~% egrep -r '%[^\" dious]+z' /sec/freebsd/current/src/sys > > /sec/freebsd/current/src/sys/ddb/db_examine.c: db_printf("%-*lz", width, (long)value); > > /sec/freebsd/current/src/sys/ddb/db_examine.c: db_printf("%8lz", (long)addr); > > As far as I can tell, these are just implementing %z for the examine > command. If we remove %z from printf(9), we can probably remove it > from ddb examine, too. I've already said to rename %z. Its functionality can't be removed since ddb depends on it. ddb's %n has already been renamed to %r, but not completely removed. This together with -fformat-extensions not turning off non-extensions that aren't in the kernel printf() causes bugs if %n is actually used. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 28 1:54:34 2002 Delivered-To: freebsd-audit@freebsd.org Received: from turbine.trit.org (turbine.trit.org [63.198.170.141]) by hub.freebsd.org (Postfix) with ESMTP id 4BF2B37B411 for ; Tue, 28 May 2002 01:54:21 -0700 (PDT) Received: from turbine.trit.org (localhost [127.0.0.1]) by turbine.trit.org (Postfix) with ESMTP id 348AC3E5E for ; Tue, 28 May 2002 08:54:20 +0000 (UTC) To: audit@freebsd.org Subject: VT_LOCKSWITCH Date: Tue, 28 May 2002 08:54:20 +0000 From: Dima Dorfman Message-Id: <20020528085420.348AC3E5E@turbine.trit.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 The attached patch adds an -S option to vidcontrol(1) that allows the user to disallow vty switching. It is implemented using a new VT_LOCKSWITCH ioctl. Although it is possible to implement something like this by VT_SETMODEing to VT_PROCESS and never releasing the vty, that method has a number of downsides, the biggest of which is that some program has to stay resident for the lock to be in effect. Please review. Thanks. P.S.: This patch makes the usage output pretty ugly; I'll fix that in a separate commit (I don't want to put unrelated, cosmetic stuff in this diff). Index: sys/sys/consio.h =================================================================== RCS file: /ref/cvsf/src/sys/sys/consio.h,v retrieving revision 1.14 diff -u -r1.14 consio.h --- sys/sys/consio.h 16 May 2002 10:57:10 -0000 1.14 +++ sys/sys/consio.h 27 May 2002 23:09:46 -0000 @@ -335,6 +335,9 @@ /* get the index of the vty */ #define VT_GETINDEX _IOR('v', 8, int) +/* prevent switching vtys */ +#define VT_LOCKSWITCH _IOW('v', 9, int) + /* * Video mode switching ioctl. See sys/fbio.h for mode numbers. */ Index: sys/dev/syscons/syscons.c =================================================================== RCS file: /ref/cvsf/src/sys/dev/syscons/syscons.c,v retrieving revision 1.384 diff -u -r1.384 syscons.c --- sys/dev/syscons/syscons.c 4 May 2002 15:42:38 -0000 1.384 +++ sys/dev/syscons/syscons.c 27 May 2002 23:15:36 -0000 @@ -981,6 +981,13 @@ *(int *)data = scp->index + 1; return 0; + case VT_LOCKSWITCH: /* prevent vty switching */ + if ((*(int *)data) & 0x01) + sc->flags |= SC_SCRN_VTYLOCK; + else + sc->flags &= ~SC_SCRN_VTYLOCK; + return 0; + case KDENABIO: /* allow io operations */ error = suser(td); if (error != 0) @@ -2074,6 +2081,13 @@ int s; DPRINTF(5, ("sc0: sc_switch_scr() %d ", next_scr + 1)); + + /* prevent switch if previously requested */ + if (sc->flags & SC_SCRN_VTYLOCK) { + sc_bell(sc->cur_scp, sc->cur_scp->bell_pitch, + sc->cur_scp->bell_duration); + return EPERM; + } /* delay switch if the screen is blanked or being updated */ if ((sc->flags & SC_SCRN_BLANKED) || sc->write_in_progress Index: sys/dev/syscons/syscons.h =================================================================== RCS file: /ref/cvsf/src/sys/dev/syscons/syscons.h,v retrieving revision 1.74 diff -u -r1.74 syscons.h --- sys/dev/syscons/syscons.h 13 Apr 2002 22:34:16 -0000 1.74 +++ sys/dev/syscons/syscons.h 27 May 2002 23:14:16 -0000 @@ -194,6 +194,7 @@ #define SC_SCRN_IDLE (1 << 5) #define SC_SCRN_BLANKED (1 << 6) #define SC_SAVER_FAILED (1 << 7) +#define SC_SCRN_VTYLOCK (1 << 8) #define SC_INIT_DONE (1 << 16) #define SC_SPLASH_SCRN (1 << 17) Index: usr.sbin/vidcontrol/vidcontrol.1 =================================================================== RCS file: /ref/cvsf/src/usr.sbin/vidcontrol/vidcontrol.1,v retrieving revision 1.51 diff -u -r1.51 vidcontrol.1 --- usr.sbin/vidcontrol/vidcontrol.1 20 Apr 2002 12:27:15 -0000 1.51 +++ usr.sbin/vidcontrol/vidcontrol.1 27 May 2002 23:35:06 -0000 @@ -13,7 +13,7 @@ .\" @(#)vidcontrol.1 .\" $FreeBSD$ .\" -.Dd May 27, 2001 +.Dd May 27, 2002 .Dt VIDCONTROL 1 .Os .Sh NAME @@ -36,6 +36,7 @@ .Op Fl M Ar char .Op Fl m Cm on | off .Op Fl r Ar foreground Ar background +.Op Fl S Cm on | off .Op Fl s Ar number .Op Fl t Ar N | Cm off .Op Ar mode @@ -213,6 +214,11 @@ .Ar foreground and .Ar background . +.It Fl S Cm on | off +Turn vty switching on or off. +When vty switching is off, +attempts to switch to a different virtual terminal will fail. +(The default is to permit vty switching.) .It Fl s Ar number Set the current vty to .Ar number . Index: usr.sbin/vidcontrol/vidcontrol.c =================================================================== RCS file: /ref/cvsf/src/usr.sbin/vidcontrol/vidcontrol.c,v retrieving revision 1.41 diff -u -r1.41 vidcontrol.c --- usr.sbin/vidcontrol/vidcontrol.c 16 Mar 2002 23:35:51 -0000 1.41 +++ usr.sbin/vidcontrol/vidcontrol.c 27 May 2002 23:38:02 -0000 @@ -76,7 +76,7 @@ "usage: vidcontrol [-CdLPpx] [-b color] [-c appearance] [-f [size] file]", " [-g geometry] [-h size] [-i adapter | mode] [-l screen_map]", " [-m on | off] [-M char] [-r foreground background] [-s num]", -" [-t N | off] [mode] [foreground [background]] [show]"); +" [-S on | off] [-t N | off] [mode] [foreground [background]] [show]"); exit(1); } @@ -518,6 +518,23 @@ ioctl(0, CONS_MOUSECTL, &mouse); } +void +set_lockswitch(char *arg) +{ + int data; + + if (!strcmp(arg, "off")) + data = 0x01; + else if (!strcmp(arg, "on")) + data = 0x02; + else { + warnx("argument to -S must either on or off"); + return; + } + if (ioctl(0, VT_LOCKSWITCH, &data) == -1) + warn("ioctl(VT_LOCKSWITCH)"); +} + static char *adapter_name(int type) { @@ -749,7 +766,7 @@ /* Not reached */ if (ioctl(0, CONS_GETINFO, &info) < 0) err(1, "must be on a virtual console"); - while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:s:t:x")) != -1) + while((opt = getopt(argc, argv, "b:Cc:df:g:h:i:l:LM:m:pPr:S:s:t:x")) != -1) switch(opt) { case 'b': set_border_color(optarg); @@ -805,6 +822,9 @@ break; case 'r': set_reverse_colors(argc, argv, &optind); + break; + case 'S': + set_lockswitch(optarg); break; case 's': set_console(optarg); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 28 2:12:29 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 84C6237B400 for ; Tue, 28 May 2002 02:12:16 -0700 (PDT) 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 TAA29085; Tue, 28 May 2002 19:12:07 +1000 Date: Tue, 28 May 2002 19:15:23 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dima Dorfman Cc: Dag-Erling Smorgrav , Subject: Re: %j for printf(9) In-Reply-To: <20020528001615.4BAC93E5E@turbine.trit.org> Message-ID: <20020528184446.W19885-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 Tue, 28 May 2002, Dima Dorfman wrote: > Dag-Erling Smorgrav wrote: > > Dima Dorfman writes: > > > Attached is a patch that implements the %j length modifier in > > > printf(9). > > > > Here's an alternative (IMHO less disruptive) patch, which also fixes > > the default case. > > I still like my restructure, but since other people don't seem to > share my opinion, I'm fine doing it another (your) way. That said, I > think your patch has some bugs that mine doesn't. For example, this: > > printf("%ld\n", -4); > > yields "4294967292" with your patch, but not with mine (mine, and > printf(3), yield "-4"). I think the attached patch (relative to > subr_prf.c *with* your patch applied) fixes it. Both are not incorrect, since the behaviour is undefined :-). printf("%ld", -4L) would be a better example. My objections to your restructuring are mostly related to getting the conversions for this and other things things right. Forcing everything into a uintmax_t isn't really simple or correct, and the restructuring depends on it. > +++ subr_prf.c Tue May 28 00:09:30 2002 > @@ -658,19 +658,19 @@ > if (jflag) > num = va_arg(ap, uintmax_t); > else if (qflag) > - num = va_arg(ap, u_quad_t); > + num = (u_quad_t)va_arg(ap, u_quad_t); > else if (lflag) > - num = va_arg(ap, u_long); > + num = (u_long)va_arg(ap, u_long); > else > - num = va_arg(ap, u_int); > + num = (u_int)va_arg(ap, u_int); These casts are all no-ops. va_arg() already gives the correct type. This type is unsigned, so there are no surprises promoting it to the type of `num' (uintmax_t). > goto nosign; > fetch_number: > if (jflag) > - num = va_arg(ap, uintmax_t); > + num = va_arg(ap, intmax_t); An (explicit but unnecessary) cast to uintmax_t would make some sense here, since we are changing the value of an intmax_t to store it into a uintmax_t. The conversion happens by default but only clearly works right on 2's complement machines. > else if (qflag) > - num = va_arg(ap, u_quad_t); > + num = (quad_t)va_arg(ap, quad_t); This cast also has no effect. Changing the type in the va_arg() also has no effect on any supported machine, but is necessary on machines with quad_t smaller than intmax_t. Explicit but null casts, first to intmax_t and then to uintmax_t, might be good to show what is happening here. > else if (lflag) > - num = va_arg(ap, u_long); > + num = (long)va_arg(ap, long); u_long was wrong in the same way as u_quad_t was wrong, except the wrongness actually affects supported machines (ones with long smaller than intmax_t). > else > num = sign ? (uintmax_t)va_arg(ap, int) : > va_arg(ap, u_int); I think this `sign' test is needed for the lflag and qflag cases too. It is needed to get the correct sign extension for promotion of types smaller than `num'. In rev.1.1, `int' was the only such type, but in theory even long longs might be smaller that intmax_t. Support for machines with longs smaller than quads seems to be broken in -current. This only affects the %r and %z formats. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 28 2:47:14 2002 Delivered-To: freebsd-audit@freebsd.org Received: from south.nanolink.com (south.nanolink.com [217.75.134.10]) by hub.freebsd.org (Postfix) with SMTP id 0B17337B403 for ; Tue, 28 May 2002 02:47:07 -0700 (PDT) Received: (qmail 81200 invoked by uid 85); 28 May 2002 09:56:05 -0000 Received: from unknown (HELO straylight.ringlet.net) (212.116.140.125) by south.nanolink.com with SMTP; 28 May 2002 09:55:49 -0000 Received: (qmail 11675 invoked by uid 1000); 28 May 2002 09:46:00 -0000 Date: Tue, 28 May 2002 12:45:59 +0300 From: Peter Pentchev To: Dima Dorfman Cc: audit@freebsd.org Subject: Re: VT_LOCKSWITCH Message-ID: <20020528124559.C374@straylight.oblivion.bg> Mail-Followup-To: Dima Dorfman , audit@freebsd.org References: <20020528085420.348AC3E5E@turbine.trit.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="Sr1nOIr3CvdE5hEN" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020528085420.348AC3E5E@turbine.trit.org>; from dima@trit.org on Tue, May 28, 2002 at 08:54:20AM +0000 X-Virus-Scanned: by Nik's Monitoring Daemon (AMaViS perl-11d) 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 --Sr1nOIr3CvdE5hEN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 28, 2002 at 08:54:20AM +0000, Dima Dorfman wrote: > The attached patch adds an -S option to vidcontrol(1) that allows the > user to disallow vty switching. It is implemented using a new > VT_LOCKSWITCH ioctl. Although it is possible to implement something > like this by VT_SETMODEing to VT_PROCESS and never releasing the vty, > that method has a number of downsides, the biggest of which is that > some program has to stay resident for the lock to be in effect. >=20 > Please review. [snip] > Index: usr.sbin/vidcontrol/vidcontrol.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: /ref/cvsf/src/usr.sbin/vidcontrol/vidcontrol.c,v > retrieving revision 1.41 > diff -u -r1.41 vidcontrol.c > --- usr.sbin/vidcontrol/vidcontrol.c 16 Mar 2002 23:35:51 -0000 1.41 > +++ usr.sbin/vidcontrol/vidcontrol.c 27 May 2002 23:38:02 -0000 > @@ -518,6 +518,23 @@ > ioctl(0, CONS_MOUSECTL, &mouse); > } > =20 > +void > +set_lockswitch(char *arg) > +{ > + int data; > + > + if (!strcmp(arg, "off")) > + data =3D 0x01; > + else if (!strcmp(arg, "on")) > + data =3D 0x02; > + else { > + warnx("argument to -S must either on or off"); A very, very minor nit: should this not be 'must *be* either on or off'? :) Other than that, the patch - and the new functionality - looks just fine to me. Great work! :) G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 "yields falsehood, when appended to its quotation." yields falsehood, when = appended to its quotation. --Sr1nOIr3CvdE5hEN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE881HX7Ri2jRYZRVMRAijtAJ9FkcijhtEmkiFC/rZGlBfGNViQ9ACgo+Cl aYfgzSTEiL0sYZklqRwe//4= =3Ceu -----END PGP SIGNATURE----- --Sr1nOIr3CvdE5hEN-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 28 2:50:34 2002 Delivered-To: freebsd-audit@freebsd.org Received: from turbine.trit.org (turbine.trit.org [63.198.170.141]) by hub.freebsd.org (Postfix) with ESMTP id B09DC37B405 for ; Tue, 28 May 2002 02:50:32 -0700 (PDT) Received: from turbine.trit.org (localhost [127.0.0.1]) by turbine.trit.org (Postfix) with ESMTP id 1A2D73E5E for ; Tue, 28 May 2002 09:50:30 +0000 (UTC) To: audit@freebsd.org Subject: Re: VT_LOCKSWITCH In-Reply-To: <20020528124559.C374@straylight.oblivion.bg>; from roam@ringlet.net on "Tue, 28 May 2002 12:45:59 +0300" Date: Tue, 28 May 2002 09:50:30 +0000 From: Dima Dorfman Message-Id: <20020528095031.1A2D73E5E@turbine.trit.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 Peter Pentchev wrote: > On Tue, May 28, 2002 at 08:54:20AM +0000, Dima Dorfman wrote: > > +void > > +set_lockswitch(char *arg) > > +{ > > + int data; > > + > > + if (!strcmp(arg, "off")) > > + data =3D 0x01; > > + else if (!strcmp(arg, "on")) > > + data =3D 0x02; > > + else { > > + warnx("argument to -S must either on or off"); > > A very, very minor nit: should this not be 'must *be* either on or off'? :) Either that or "must either be". The same error exists in two other places in vidcontrol (set_lockswitch() is mostly pasted from set_mouse()); I'll fix all of them in a separate commit. Thanks for catching this! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 28 5:41:24 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 2056537B401 for ; Tue, 28 May 2002 05:41:21 -0700 (PDT) Received: from sheldonh (helo=axl.seasidesoftware.co.za) by axl.seasidesoftware.co.za with local-esmtp (Exim 3.33 #1) id 17CgIE-000BIG-00; Tue, 28 May 2002 14:41:38 +0200 From: Sheldon Hearn To: Dima Dorfman Cc: audit@freebsd.org Subject: Re: VT_LOCKSWITCH In-reply-to: Your message of "Tue, 28 May 2002 08:54:20 GMT." <20020528085420.348AC3E5E@turbine.trit.org> Date: Tue, 28 May 2002 14:41:38 +0200 Message-ID: <43415.1022589698@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 Tue, 28 May 2002 08:54:20 GMT, Dima Dorfman wrote: > The attached patch adds an -S option to vidcontrol(1) that allows the > user to disallow vty switching. It is implemented using a new > VT_LOCKSWITCH ioctl. Ooo! Ooo! This is nice. If you're up to it, I'd love to see the same functionality available as an extension to lock(1). Imagine the convenience of being able to type lock -npS on just one terminal and not have to worry about the rest! Ciao, Sheldon. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 29 10:24:43 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 67D0037BE2B; Wed, 29 May 2002 10:03:55 -0700 (PDT) Received: from hades.hell.gr (patr530-b149.otenet.gr [212.205.244.157]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4TH2P0j014079; Wed, 29 May 2002 20:02:26 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g4TH2OQb020153; Wed, 29 May 2002 20:02:24 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4TFKBQe016859; Wed, 29 May 2002 18:20:11 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Wed, 29 May 2002 18:20:10 +0300 From: Giorgos Keramidas To: freebsd-audit@freebsd.org Cc: Brian Somers , "Crist J. Clark" , Doug Barton , Gregory Neil Shapiro , Robert Watson Subject: Removing perl traces from src/etc/periodic Message-ID: <20020529152010.GA13893@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.99i 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 The following patch removes all traces of perl from etc/periodic. I have tested this by comparing the output of the current periodic stuff and the output of the patched version, but I might have missed something. Mark Murray has also done a bit of testing. If there are no serious problems with this, I would like to get it committed so that we can move one step closer to having a perl free base system :) As usual, your comments, complaints or suggestions are most welcome. What I want you to pay special attention to is the replacement of an inline Perl script in 470.status-named with a subshell invocation. I have tested this with a few lines that were created by my locally running named, but a bit of extra testing won't hurt, I guess. I'd like to apologize to those of you who are Cc:'ed *and* subscribed to -audit, as they will receive duplicate copies of this. You were the ones responsible for the last 50 commits in src/etc/periodic. Since you have all been active in this area, ignore the duplicate. It merely means I didn't want you to miss the post in the rest of the -audit traffic. Cheers, %%% Index: etc/periodic/daily/440.status-mailq =================================================================== RCS file: /home/ncvs/src/etc/periodic/daily/440.status-mailq,v retrieving revision 1.8 diff -u -r1.8 440.status-mailq --- etc/periodic/daily/440.status-mailq 7 May 2002 13:11:05 -0000 1.8 +++ etc/periodic/daily/440.status-mailq 28 May 2002 20:47:54 -0000 @@ -25,7 +25,7 @@ rc=$(case "$daily_status_mailq_shorten" in [Yy][Ee][Ss]) mailq | - perl -ne 'print if /^\s+\S+@/' | + egrep -e '^[[:space:]]+[^[:space:]]+@' | sort | uniq -c | sort -nr | @@ -45,7 +45,7 @@ rc=$(case "$daily_status_mailq_shorten" in [Yy][Ee][Ss]) mailq -Ac | - perl -ne 'print if /^\s+\S+@/' | + egrep -e '^[[:space:]]+[^[:space:]]+@' | sort | uniq -c | sort -nr | Index: etc/periodic/daily/460.status-mail-rejects =================================================================== RCS file: /home/ncvs/src/etc/periodic/daily/460.status-mail-rejects,v retrieving revision 1.14 diff -u -r1.14 460.status-mail-rejects --- etc/periodic/daily/460.status-mail-rejects 30 Apr 2002 17:07:32 -0000 1.14 +++ etc/periodic/daily/460.status-mail-rejects 28 May 2002 20:47:54 -0000 @@ -51,8 +51,9 @@ done cat /var/log/maillog } | - perl -ne "print \"\$2\n\" - if (/reject=/ and /^$start.*ruleset=check_\S+,\s+arg1=(<[^@]+@)?([^>,]+).*reject=/o);" | + fgrep 'reject=' | + egrep -e "^$start.*ruleset=check_[^[:space:]]+,[[:space:]]+arg1=(<[^@]+@)?([^>,]+).*reject=.*" | + sed -e 's/.*arg1=//' -e 's/.*@//' -e 's/[>[:space:]].*$//' | sort -f | uniq -ic | sort -fnr | tee /dev/stderr | wc -l) [ $rc -gt 0 ] && rc=1 fi;; Index: etc/periodic/daily/470.status-named =================================================================== RCS file: /home/ncvs/src/etc/periodic/daily/470.status-named,v retrieving revision 1.2 diff -u -r1.2 470.status-named --- etc/periodic/daily/470.status-named 26 Jul 2001 02:37:12 -0000 1.2 +++ etc/periodic/daily/470.status-named 28 May 2002 20:47:54 -0000 @@ -25,30 +25,30 @@ start=`date -v-1d '+%b %d' | sed 's/0\(.\)$/ \1/'` rc=$(catmsgs | - perl -ne 'print "$2 from $1\n" - if (/^'"$start"'.*named\[\d+\]: denied [AI]XFR from \[(.*)\]\.\d+ for "(.*)"/);' | - sort -f | uniq -ic | - perl -e ' - use Socket; + fgrep '^'"$start"'.*named\[[[:digit:]]\+\]: denied [AI]XFR from \[.*\]\.[[:digit:]]\+ for' | \ + sed -e 's/.*: denied [AI]XFR from \[\(.*\)\]\.[[:digit:]]* for "\(.*\)".*$/\2 from \1/' + sort -f | uniq -ic | ( + usedns=0 + if [ X"${daily_status_named_usedns}" != X"" ]; then + case $daily_status_named_usedns in + [yY][eE][sS]) usedns=1 ;; + esac + fi - while () { - if (/^.*from (.*)$/) { - $ip_addr = $1; - chomp; - if ($ARGV[0] =~ /^yes$/i) { - ($host) = gethostbyaddr(inet_aton($ip_addr), AF_INET); - } else { - $host = ""; - } - - if ($host) { - print "$_ ($host)\n"; - } else { - print "$_\n"; - } - } - } - ' $daily_status_named_usedns | tee /dev/stderr | wc -l) + while read line ;do + ipaddr=`echo "$line" | sed -e 's/^.*from //'` + if [ $usedns -eq 1 ]; then + name=`host "${ipaddr}" 2>/dev/null | \ + grep 'domain name pointer' | \ + sed -e 's/^.* //'` + fi + if [ X"${name}" != X"" ]; then + echo "${line} (${name})" + else + echo "${line}" + fi + done ) | \ + tee /dev/stderr | wc -l) [ $rc -gt 0 ] && rc=1 ;; Index: etc/periodic/security/550.ipfwlimit =================================================================== RCS file: /home/ncvs/src/etc/periodic/security/550.ipfwlimit,v retrieving revision 1.3 diff -u -r1.3 550.ipfwlimit --- etc/periodic/security/550.ipfwlimit 17 May 2002 11:34:12 -0000 1.3 +++ etc/periodic/security/550.ipfwlimit 28 May 2002 20:57:21 -0000 @@ -45,8 +45,10 @@ [Yy][Ee][Ss]) IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null` if [ $? -eq 0 ] && [ "${IPFW_LOG_LIMIT}" -ne 0 ]; then - ipfw -a l | grep " log " | perl -n -e \ - '/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' > ${TMP} + ipfw -a l | grep " log " | \ + grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \ + awk -v limit="$IPFW_LOG_LIMIT" \ + '{if ($2 > limit) {print $0}}' > ${TMP} if [ -s "${TMP}" ]; then rc=1 echo "" Index: etc/periodic/security/650.ip6fwlimit =================================================================== RCS file: /home/ncvs/src/etc/periodic/security/650.ip6fwlimit,v retrieving revision 1.3 diff -u -r1.3 650.ip6fwlimit --- etc/periodic/security/650.ip6fwlimit 17 May 2002 11:34:12 -0000 1.3 +++ etc/periodic/security/650.ip6fwlimit 28 May 2002 20:57:11 -0000 @@ -45,8 +45,10 @@ [Yy][Ee][Ss]) IP6FW_LOG_LIMIT=`sysctl -n net.inet6.ip6.fw.verbose_limit 2> /dev/null` if [ $? -eq 0 ] && [ "${IP6FW_LOG_LIMIT}" -ne 0 ]; then - ip6fw -a l | grep " log " | perl -n -e \ - '/^\d+\s+(\d+)/; print if ($1 >= '$IP6FW_LOG_LIMIT')' > ${TMP} + ip6fw -a l | grep " log " | \ + grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \ + awk -v limit="$IPFW_LOG_LIMIT" \ + '{if ($2 > limit) {print $0}}' > ${TMP} if [ -s "${TMP}" ]; then rc=1 echo "" %%% To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 29 11:29:35 2002 Delivered-To: freebsd-audit@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id E736737B405; Wed, 29 May 2002 11:29:23 -0700 (PDT) Received: from blossom.cjclark.org ([12.234.91.48]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020529182923.QMVQ13253.rwcrmhc54.attbi.com@blossom.cjclark.org>; Wed, 29 May 2002 18:29:23 +0000 Received: (from cjc@localhost) by blossom.cjclark.org (8.11.6/8.11.6) id g4TITM512746; Wed, 29 May 2002 11:29:22 -0700 (PDT) (envelope-from crist.clark@attbi.com) X-Authentication-Warning: blossom.cjclark.org: cjc set sender to crist.clark@attbi.com using -f Date: Wed, 29 May 2002 11:29:22 -0700 From: "Crist J. Clark" To: Giorgos Keramidas Cc: freebsd-audit@freebsd.org, Brian Somers , Doug Barton , Gregory Neil Shapiro , Robert Watson Subject: Re: Removing perl traces from src/etc/periodic Message-ID: <20020529112922.A12700@blossom.cjclark.org> Reply-To: cjclark@alum.mit.edu References: <20020529152010.GA13893@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020529152010.GA13893@hades.hell.gr>; from keramida@freebsd.org on Wed, May 29, 2002 at 06:20:10PM +0300 X-URL: http://people.freebsd.org/~cjc/ 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, May 29, 2002 at 06:20:10PM +0300, Giorgos Keramidas wrote: [snip] > Index: etc/periodic/security/550.ipfwlimit > =================================================================== > RCS file: /home/ncvs/src/etc/periodic/security/550.ipfwlimit,v > retrieving revision 1.3 > diff -u -r1.3 550.ipfwlimit > --- etc/periodic/security/550.ipfwlimit 17 May 2002 11:34:12 -0000 1.3 > +++ etc/periodic/security/550.ipfwlimit 28 May 2002 20:57:21 -0000 > @@ -45,8 +45,10 @@ > [Yy][Ee][Ss]) > IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null` > if [ $? -eq 0 ] && [ "${IPFW_LOG_LIMIT}" -ne 0 ]; then > - ipfw -a l | grep " log " | perl -n -e \ > - '/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' > ${TMP} > + ipfw -a l | grep " log " | \ > + grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \ > + awk -v limit="$IPFW_LOG_LIMIT" \ > + '{if ($2 > limit) {print $0}}' > ${TMP} + ipfw -a l | + awk -v limit="$IPFW_LOG_LIMIT" \ + '/ log / && /^[[:digit:]]+[[:space:]]+[[:digit:]]+/ { \ + if ($2 > limit) {print;} \ + }' > ${TMP} For whatever reason, chaining grep(1)s in front of an awk(1) always bothers me. It's easy enough to do with one awk(1). -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 29 14: 6:51 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 DF23B37B400; Wed, 29 May 2002 14:06:43 -0700 (PDT) Received: from hades.hell.gr (patr530-a118.otenet.gr [212.205.215.118]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4TL6d0j010767; Thu, 30 May 2002 00:06:41 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g4TL6SQf066615; Thu, 30 May 2002 00:06:39 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4TKGcx7058561; Wed, 29 May 2002 23:16:38 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Date: Wed, 29 May 2002 23:16:37 +0300 From: Giorgos Keramidas To: freebsd-audit@FreeBSD.org Cc: "Crist J. Clark" Subject: Re: Removing perl traces from src/etc/periodic Message-ID: <20020529201635.GB57789@hades.hell.gr> References: <20020529152010.GA13893@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020529152010.GA13893@hades.hell.gr> 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 2002-05-29 18:20 +0300, Giorgos Keramidas wrote: > Index: etc/periodic/security/650.ip6fwlimit > - ip6fw -a l | grep " log " | perl -n -e \ > - '/^\d+\s+(\d+)/; print if ($1 >= '$IP6FW_LOG_LIMIT')' > ${TMP} > + ip6fw -a l | grep " log " | \ > + grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \ > + awk -v limit="$IPFW_LOG_LIMIT" \ Of course this should have been awk -v limit="${IP6FW_LOG_LIMIT}". Chris' comments were the reason for a more careful reading of this part, and I discovered this sneaky little bug I managed to introduce while copy/pasting. Already fixed & merged with Chris' (grep+awk -> awk) changes at: http://www.FreeBSD.org/~keramida/diff/2002-05-29.periodic,aa - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri May 31 1:24:18 2002 Delivered-To: freebsd-audit@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id CEBF837B406 for ; Fri, 31 May 2002 01:24:15 -0700 (PDT) Received: by flood.ping.uio.no (Postfix, from userid 2602) id D56FB5307; Fri, 31 May 2002 10:24:13 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Bruce Evans Cc: Dima Dorfman , Subject: Re: %j for printf(9) References: <20020528184446.W19885-100000@gamplex.bde.org> From: Dag-Erling Smorgrav Date: 31 May 2002 10:24:12 +0200 In-Reply-To: <20020528184446.W19885-100000@gamplex.bde.org> Message-ID: Lines: 29 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 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 Bruce, does this look OK? fetch_nosign: if (jflag) num = va_arg(ap, uintmax_t); else if (qflag) num = va_arg(ap, u_quad_t); else if (lflag) num = va_arg(ap, u_long); else num = va_arg(ap, u_int); goto nosign; fetch_number: if (jflag) num = va_arg(ap, intmax_t); else if (qflag) num = sign ? (uintmax_t)va_arg(ap, quad_t) : va_arg(ap, u_quad_t); else if (lflag) num = sign ? (uintmax_t)va_arg(ap, long) : va_arg(ap, u_long); else num = sign ? (uintmax_t)va_arg(ap, int) : va_arg(ap, u_int); goto number; DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri May 31 1:44:47 2002 Delivered-To: freebsd-audit@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 7D17037B406; Fri, 31 May 2002 01:44:26 -0700 (PDT) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [IPv6:fec0::1:12]) by Awfulhak.org (8.12.3/8.12.3) with ESMTP id g4V8iO7e094922; Fri, 31 May 2002 09:44:24 +0100 (BST) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.12.3/8.12.3) with ESMTP id g4V8iIEU024730; Fri, 31 May 2002 09:44:18 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200205310844.g4V8iIEU024730@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: cjclark@alum.mit.edu Cc: Giorgos Keramidas , freebsd-audit@freebsd.org, Brian Somers , Doug Barton , Gregory Neil Shapiro , Robert Watson , brian@Awfulhak.org Subject: Re: Removing perl traces from src/etc/periodic In-Reply-To: Message from "Crist J. Clark" of "Wed, 29 May 2002 11:29:22 PDT." <20020529112922.A12700@blossom.cjclark.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 31 May 2002 09:44:18 +0100 From: Brian Somers 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, May 29, 2002 at 06:20:10PM +0300, Giorgos Keramidas wrote: > > [snip] > > > Index: etc/periodic/security/550.ipfwlimit > > =================================================================== > > RCS file: /home/ncvs/src/etc/periodic/security/550.ipfwlimit,v > > retrieving revision 1.3 > > diff -u -r1.3 550.ipfwlimit > > --- etc/periodic/security/550.ipfwlimit 17 May 2002 11:34:12 -0000 1.3 > > +++ etc/periodic/security/550.ipfwlimit 28 May 2002 20:57:21 -0000 > > @@ -45,8 +45,10 @@ > > [Yy][Ee][Ss]) > > IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null` > > if [ $? -eq 0 ] && [ "${IPFW_LOG_LIMIT}" -ne 0 ]; then > > - ipfw -a l | grep " log " | perl -n -e \ > > - '/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' > ${TMP} > > + ipfw -a l | grep " log " | \ > > + grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \ > > + awk -v limit="$IPFW_LOG_LIMIT" \ > > + '{if ($2 > limit) {print $0}}' > ${TMP} > > + ipfw -a l | > + awk -v limit="$IPFW_LOG_LIMIT" \ > + '/ log / && /^[[:digit:]]+[[:space:]]+[[:digit:]]+/ { \ > + if ($2 > limit) {print;} \ > + }' > ${TMP} > > For whatever reason, chaining grep(1)s in front of an awk(1) always > bothers me. It's easy enough to do with one awk(1). Agreed. Ditto for sed :) > -- > Crist J. Clark | cjclark@alum.mit.edu > | cjclark@jhu.edu > http://people.freebsd.org/~cjc/ | cjc@freebsd.org -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri May 31 4:28:41 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 8F88737B401 for ; Fri, 31 May 2002 04:28:37 -0700 (PDT) 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 VAA28324; Fri, 31 May 2002 21:28:25 +1000 Date: Fri, 31 May 2002 21:31:54 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dag-Erling Smorgrav Cc: Dima Dorfman , Subject: Re: %j for printf(9) In-Reply-To: Message-ID: <20020531205803.L32389-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 31 May 2002, Dag-Erling Smorgrav wrote: > Bruce, does this look OK? > > fetch_nosign: > if (jflag) > num = va_arg(ap, uintmax_t); > else if (qflag) > num = va_arg(ap, u_quad_t); > else if (lflag) > num = va_arg(ap, u_long); > else > num = va_arg(ap, u_int); > goto nosign; > fetch_number: > if (jflag) > num = va_arg(ap, intmax_t); > else if (qflag) > num = sign ? (uintmax_t)va_arg(ap, quad_t) : > va_arg(ap, u_quad_t); > else if (lflag) > num = sign ? (uintmax_t)va_arg(ap, long) : > va_arg(ap, u_long); > else > num = sign ? (uintmax_t)va_arg(ap, int) : > va_arg(ap, u_int); > goto number; OK. I don't remember all the context for this. Is everything restructured so that all the va_arg()'s for fetching integers are in the above patch? If so, consider the following further restructurings: - merge fetch_nosign with nosign (rename it to something like handle_unsigned) and use it handle all the unsigned cases that are now handled by fetch_number. - rename fetch_number to handle_signed and use it for only the signed cases (%d and %+z). - don't bother explicitly casting to uintmax_t for the signed cases. In -current, these casts are used for %+z but not for %d. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri May 31 9:57:59 2002 Delivered-To: freebsd-audit@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 61B8937B405 for ; Fri, 31 May 2002 09:57:48 -0700 (PDT) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 2033B5307; Fri, 31 May 2002 18:57:47 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Bruce Evans Cc: Dima Dorfman , Subject: Re: %j for printf(9) References: <20020531205803.L32389-100000@gamplex.bde.org> From: Dag-Erling Smorgrav Date: 31 May 2002 18:57:46 +0200 In-Reply-To: <20020531205803.L32389-100000@gamplex.bde.org> Message-ID: Lines: 24 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 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 Bruce Evans writes: > I don't remember all the context for this. Is everything restructured so > that all the va_arg()'s for fetching integers are in the above patch? Yes. > If so, consider the following further restructurings: > > - merge fetch_nosign with nosign (rename it to something like > handle_unsigned) and use it handle all the unsigned cases that are now > handled by fetch_number. > - rename fetch_number to handle_signed and use it for only the signed cases > (%d and %+z). These two would actually increase code duplication. > - don't bother explicitly casting to uintmax_t for the signed cases. In > -current, these casts are used for %+z but not for %d. OK. DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri May 31 11: 1: 0 2002 Delivered-To: freebsd-audit@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id A19BA37B403 for ; Fri, 31 May 2002 10:59:56 -0700 (PDT) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 27FDA5307; Fri, 31 May 2002 19:59:55 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Bruce Evans Cc: Dima Dorfman , Subject: Re: %j for printf(9) References: <20020531205803.L32389-100000@gamplex.bde.org> From: Dag-Erling Smorgrav Date: 31 May 2002 19:59:54 +0200 In-Reply-To: Message-ID: Lines: 8 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 --=-=-= Complete updated patch attached. DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=subr_prf.diff Index: sys/kern/subr_prf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/subr_prf.c,v retrieving revision 1.81 diff -u -r1.81 subr_prf.c --- sys/kern/subr_prf.c 29 Apr 2002 09:15:38 -0000 1.81 +++ sys/kern/subr_prf.c 31 May 2002 16:58:16 -0000 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -65,7 +66,7 @@ #define TOLOG 0x04 /* Max number conversion buffer length: a u_quad_t in base 2, plus NUL byte. */ -#define MAXNBUF (sizeof(quad_t) * NBBY + 1) +#define MAXNBUF (sizeof(intmax_t) * NBBY + 1) struct putchar_arg { int flags; @@ -86,8 +87,7 @@ static void msglogchar(int c, int pri); static void msgaddchar(int c, void *dummy); static void putchar(int ch, void *arg); -static char *ksprintn(char *nbuf, u_long num, int base, int *len); -static char *ksprintqn(char *nbuf, u_quad_t num, int base, int *len); +static char *ksprintn(char *nbuf, uintmax_t num, int base, int *len); static void snprintf_func(int ch, void *arg); static int consintr = 1; /* Ok to handle console interrupts? */ @@ -426,9 +426,9 @@ * The buffer pointed to by `nbuf' must have length >= MAXNBUF. */ static char * -ksprintn(nbuf, ul, base, lenp) +ksprintn(nbuf, num, base, lenp) char *nbuf; - u_long ul; + uintmax_t num; int base, *lenp; { char *p; @@ -436,26 +436,8 @@ p = nbuf; *p = '\0'; do { - *++p = hex2ascii(ul % base); - } while (ul /= base); - if (lenp) - *lenp = p - nbuf; - return (p); -} -/* ksprintn, but for a quad_t. */ -static char * -ksprintqn(nbuf, uq, base, lenp) - char *nbuf; - u_quad_t uq; - int base, *lenp; -{ - char *p; - - p = nbuf; - *p = '\0'; - do { - *++p = hex2ascii(uq % base); - } while (uq /= base); + *++p = hex2ascii(num % base); + } while (num /= base); if (lenp) *lenp = p - nbuf; return (p); @@ -491,19 +473,19 @@ kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap) { #define PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; } + const char *percent; char nbuf[MAXNBUF]; char *p, *q, *d; u_char *up; int ch, n; - u_long ul; - u_quad_t uq; - int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot; + uintmax_t num; + int base, lflag, jflag, qflag, tmp, width; + int ladjust, sharpflag, neg, sign, dot; int dwidth; char padc; int retval = 0; - ul = 0; - uq = 0; + num = 0; if (!func) d = (char *) arg; else @@ -519,13 +501,15 @@ padc = ' '; width = 0; while ((ch = (u_char)*fmt++) != '%') { - if (ch == '\0') + if (ch == '\0') return (retval); PCHAR(ch); } - qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; - sign = 0; dot = 0; dwidth = 0; -reswitch: switch (ch = (u_char)*fmt++) { + percent = fmt - 1; + qflag = jflag = lflag = ladjust = sharpflag = + neg = sign = dot = dwidth = 0; +reswitch: + switch (ch = (u_char)*fmt++) { case '.': dot = 1; goto reswitch; @@ -571,17 +555,17 @@ width = n; goto reswitch; case 'b': - ul = va_arg(ap, int); + num = va_arg(ap, int); p = va_arg(ap, char *); - for (q = ksprintn(nbuf, ul, *p++, NULL); *q;) + for (q = ksprintn(nbuf, num, *p++, NULL); *q;) PCHAR(*q--); - if (!ul) + if (num == 0) break; for (tmp = 0; *p;) { n = *p++; - if (ul & (1 << (n - 1))) { + if (num & (1 << (n - 1))) { PCHAR(tmp ? ',' : '<'); for (; (n = *p) > ' '; ++p) PCHAR(n); @@ -611,15 +595,12 @@ } break; case 'd': - if (qflag) - uq = va_arg(ap, quad_t); - else if (lflag) - ul = va_arg(ap, long); - else - ul = va_arg(ap, int); sign = 1; base = 10; - goto number; + goto fetch_number; + case 'j': + jflag = 1; + goto reswitch; case 'l': if (lflag) { lflag = 0; @@ -628,16 +609,10 @@ lflag = 1; goto reswitch; case 'o': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = va_arg(ap, u_int); base = 8; - goto nosign; + goto fetch_nosign; case 'p': - ul = (uintptr_t)va_arg(ap, void *); + num = (uintptr_t)va_arg(ap, void *); base = 16; sharpflag = (width == 0); goto nosign; @@ -646,15 +621,8 @@ goto reswitch; case 'n': case 'r': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = sign ? - (u_long)va_arg(ap, int) : va_arg(ap, u_int); base = radix; - goto number; + goto fetch_number; case 's': p = va_arg(ap, char *); if (p == NULL) @@ -677,50 +645,47 @@ PCHAR(padc); break; case 'u': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = va_arg(ap, u_int); base = 10; - goto nosign; + goto fetch_nosign; case 'x': case 'X': - if (qflag) - uq = va_arg(ap, u_quad_t); + base = 16; + goto fetch_nosign; + case 'z': + base = 16; + goto fetch_number; +fetch_nosign: + if (jflag) + num = va_arg(ap, uintmax_t); + else if (qflag) + num = va_arg(ap, u_quad_t); else if (lflag) - ul = va_arg(ap, u_long); + num = va_arg(ap, u_long); else - ul = va_arg(ap, u_int); - base = 16; + num = va_arg(ap, u_int); goto nosign; - case 'z': - if (qflag) - uq = va_arg(ap, u_quad_t); +fetch_number: + if (jflag) + num = va_arg(ap, intmax_t); + else if (qflag) + num = sign ? va_arg(ap, quad_t) : + va_arg(ap, u_quad_t); else if (lflag) - ul = va_arg(ap, u_long); + num = sign ? va_arg(ap, long) : + va_arg(ap, u_long); else - ul = sign ? - (u_long)va_arg(ap, int) : va_arg(ap, u_int); - base = 16; + num = sign ? va_arg(ap, int) : + va_arg(ap, u_int); goto number; -nosign: sign = 0; -number: - if (qflag) { - if (sign && (quad_t)uq < 0) { - neg = 1; - uq = -(quad_t)uq; - } - p = ksprintqn(nbuf, uq, base, &tmp); - } else { - if (sign && (long)ul < 0) { - neg = 1; - ul = -(long)ul; - } - p = ksprintn(nbuf, ul, base, &tmp); +nosign: + sign = 0; +number: + if (sign && (intmax_t)num < 0) { + neg = 1; + num = -(intmax_t)num; } - if (sharpflag && (qflag ? uq != 0 : ul != 0)) { + p = ksprintn(nbuf, num, base, &tmp); + if (sharpflag && num != 0) { if (base == 8) tmp++; else if (base == 16) @@ -734,7 +699,7 @@ PCHAR(padc); if (neg) PCHAR('-'); - if (sharpflag && (qflag ? uq != 0 : ul != 0)) { + if (sharpflag && num != 0) { if (base == 8) { PCHAR('0'); } else if (base == 16) { @@ -752,10 +717,8 @@ break; default: - PCHAR('%'); - if (lflag) - PCHAR('l'); - PCHAR(ch); + while (percent < fmt) + PCHAR(*percent++); break; } } @@ -783,7 +746,7 @@ dangling = 0; } msgaddchar('<', NULL); - for (p = ksprintn(nbuf, (u_long)pri, 10, NULL); *p;) + for (p = ksprintn(nbuf, (uintmax_t)pri, 10, NULL); *p;) msgaddchar(*p--, NULL); msgaddchar('>', NULL); lastpri = pri; @@ -908,7 +871,7 @@ } SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0, sysctl_kern_msgbuf_clear, "I", "Clear kernel message buffer"); #include "opt_ddb.h" --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri May 31 14: 3:29 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 3D93F37B403 for ; Fri, 31 May 2002 14:03:17 -0700 (PDT) Received: from hades.hell.gr (patr530-b186.otenet.gr [212.205.244.194]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4VL35o3028411; Sat, 1 Jun 2002 00:03:06 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g4VL2SeD000955; Sat, 1 Jun 2002 00:03:03 +0300 (EEST) (envelope-from keramida@FreeBSD.ORG) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4VI1VmS008092; Fri, 31 May 2002 21:01:31 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Date: Fri, 31 May 2002 21:01:30 +0300 From: Giorgos Keramidas To: Brian Somers Cc: cjclark@alum.mit.edu, freebsd-audit@FreeBSD.ORG Subject: Re: Removing perl traces from src/etc/periodic Message-ID: <20020531180129.GC6591@hades.hell.gr> References: <20020529112922.A12700@blossom.cjclark.org> <200205310844.g4V8iIEU024730@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200205310844.g4V8iIEU024730@hak.lan.Awfulhak.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 2002-05-31 09:44 +0100, Brian Somers wrote: > Crist J. Clark wrote: > > > > For whatever reason, chaining grep(1)s in front of an awk(1) always > > bothers me. It's easy enough to do with one awk(1). > > Agreed. Ditto for sed :) I don't quite trust my sed-foo for doing everything in one go, and this was my way of testing the changes in parts. Apart from things like this (which I hope can be changed later) has anyone tested these and found something 'funny' in the output of periodic mailed to root? - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Jun 1 6:25:32 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 09E6837B409 for ; Sat, 1 Jun 2002 06:25:27 -0700 (PDT) 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 XAA15313; Sat, 1 Jun 2002 23:25:14 +1000 Date: Sat, 1 Jun 2002 23:28:48 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dag-Erling Smorgrav Cc: Dima Dorfman , Subject: Re: %j for printf(9) In-Reply-To: Message-ID: <20020601232049.E2458-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 31 May 2002, Dag-Erling Smorgrav wrote: > Bruce Evans writes: > > I don't remember all the context for this. Is everything restructured so > > that all the va_arg()'s for fetching integers are in the above patch? > > Yes. > > > If so, consider the following further restructurings: > > > > - merge fetch_nosign with nosign (rename it to something like > > handle_unsigned) and use it handle all the unsigned cases that are now > > handled by fetch_number. > > - rename fetch_number to handle_signed and use it for only the signed cases > > (%d and %+z). > > These two would actually increase code duplication. It came out 1 line shorter with less duplication for me. Here is a patch relative to the version in your next mail. I didn't rename fetch* to handle*, and I may have broken something moved the initializations of `sign' around too much. I reordered some initializations (especially for %p) so that the order is almost (?) always (base, ..., sign, num). %%% --- subr_prf.c~~ Sat Jun 1 22:59:01 2002 +++ subr_prf.c Sat Jun 1 23:21:44 2002 @@ -596,7 +596,7 @@ break; case 'd': - sign = 1; base = 10; - goto fetch_number; + sign = 1; + goto fetch_sign; case 'j': jflag = 1; @@ -613,8 +613,9 @@ goto fetch_nosign; case 'p': - num = (uintptr_t)va_arg(ap, void *); base = 16; sharpflag = (width == 0); - goto nosign; + sign = 0; + num = (uintptr_t)va_arg(ap, void *); + goto number; case 'q': qflag = 1; @@ -623,5 +624,7 @@ case 'r': base = radix; - goto fetch_number; + if (sign) + goto fetch_sign; + goto fetch_nosign; case 's': p = va_arg(ap, char *); @@ -654,6 +657,8 @@ case 'z': base = 16; - goto fetch_number; + if (sign) + goto fetch_sign; fetch_nosign: + sign = 0; if (jflag) num = va_arg(ap, uintmax_t); @@ -664,20 +669,14 @@ else num = va_arg(ap, u_int); - goto nosign; -fetch_number: + goto number; +fetch_sign: if (jflag) num = va_arg(ap, intmax_t); else if (qflag) - num = sign ? va_arg(ap, quad_t) : - va_arg(ap, u_quad_t); + num = va_arg(ap, quad_t); else if (lflag) - num = sign ? va_arg(ap, long) : - va_arg(ap, u_long); + num = va_arg(ap, long); else - num = sign ? va_arg(ap, int) : - va_arg(ap, u_int); - goto number; -nosign: - sign = 0; + num = va_arg(ap, int); number: if (sign && (intmax_t)num < 0) { %%% To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Jun 1 6:54:41 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 65F3037B400 for ; Sat, 1 Jun 2002 06:54:34 -0700 (PDT) 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 XAA16978; Sat, 1 Jun 2002 23:54:26 +1000 Date: Sat, 1 Jun 2002 23:58:00 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dag-Erling Smorgrav Cc: Dima Dorfman , Subject: Re: %j for printf(9) In-Reply-To: Message-ID: <20020601233017.Q2458-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 31 May 2002, Dag-Erling Smorgrav wrote: > Complete updated patch attached. > Index: sys/kern/subr_prf.c > =================================================================== > RCS file: /home/ncvs/src/sys/kern/subr_prf.c,v > retrieving revision 1.81 > diff -u -r1.81 subr_prf.c > --- sys/kern/subr_prf.c 29 Apr 2002 09:15:38 -0000 1.81 > +++ sys/kern/subr_prf.c 31 May 2002 16:58:16 -0000 > ... > @@ -491,19 +473,19 @@ > kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap) > { > #define PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; } > + const char *percent; Should be with the other char *'s. > char nbuf[MAXNBUF]; > char *p, *q, *d; > u_char *up; > int ch, n; > - u_long ul; > - u_quad_t uq; > - int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot; > + uintmax_t num; > + int base, lflag, jflag, qflag, tmp, width; > + int ladjust, sharpflag, neg, sign, dot; When splitting this, you might consider fixing he disorder in it (but fixing the external disorder and misarrangement of the other declarations of ints should be in a separate patch). > @@ -519,13 +501,15 @@ > padc = ' '; > width = 0; > while ((ch = (u_char)*fmt++) != '%') { > - if (ch == '\0') > + if (ch == '\0') Unrelated style fix :-). > PCHAR(ch); > } > - qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; > - sign = 0; dot = 0; dwidth = 0; > -reswitch: switch (ch = (u_char)*fmt++) { > + percent = fmt - 1; > + qflag = jflag = lflag = ladjust = sharpflag = > + neg = sign = dot = dwidth = 0; > +reswitch: > + switch (ch = (u_char)*fmt++) { Another unrelated style fix. This one makes the patch harder to read. > @@ -646,15 +621,8 @@ > goto reswitch; > case 'n': > case 'r': > - if (qflag) > - uq = va_arg(ap, u_quad_t); Please remove the 'n' case, and check this a bit. I forgot to remove it soon after rev.1.48. > @@ -752,10 +717,8 @@ > > break; > default: > - PCHAR('%'); > - if (lflag) > - PCHAR('l'); > - PCHAR(ch); > + while (percent < fmt) > + PCHAR(*percent++); > break; > } > } This seems to print all the garbage for %. It might be useful to mark up the garbage. But gcc will detect the garbage at compile time for literal strings. > @@ -908,7 +871,7 @@ > } > > SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear, > - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0, > + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0, Unrelated style fix :-). I like the bulk of the patch. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message