From owner-freebsd-audit Tue May 14 15:25:43 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.musha.org (daemon.musha.org [218.44.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 00FBD37B401 for ; Tue, 14 May 2002 15:25:36 -0700 (PDT) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id BCE8D4D801 for ; Wed, 15 May 2002 07:25:34 +0900 (JST) Date: Wed, 15 May 2002 07:25:35 +0900 Message-ID: <86adr2z7s0.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: audit@FreeBSD.org Subject: a tiny bug in ldd(1)'s shlib support User-Agent: Wanderlust/2.9.11 (Unchained Melody) SEMI/1.14.3 (Ushinoya) LIMIT/1.14.7 (Fujiidera) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") 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 I found a tiny bug in ldd(1)'s shlib support. If you do ldd against libc.so, you'll get the following: knu@archon[2]% ldd /usr/lib/libc.so /usr/lib/libc.so: ldd: /usr/lib/libc.so: (null) /usr/lib/libc.so: exit status 1 This is because dlopen("/usr/lib/libc.so", RTLD_TRACE) returns without an error as ldd(1) has already libc.so loaded. The attached patch fixes the proglem by checking the return value of dlopen() and exiting gracefully when no error has occurred: knu@archon[2]% ./ldd /usr/lib/libc.so /usr/lib/libc.so: Can I commit this? (Or someone else please) -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." Index: ldd.c =================================================================== RCS file: /home/ncvs/src/usr.bin/ldd/ldd.c,v retrieving revision 1.31 diff -u -r1.31 ldd.c --- ldd.c 28 Apr 2002 12:55:35 -0000 1.31 +++ ldd.c 14 May 2002 22:09:58 -0000 @@ -220,12 +220,13 @@ } break; case 0: - if (is_shlib == 0) { + if (is_shlib) { + if (dlopen(*argv, RTLD_TRACE)) + _exit(0); /* libc.so */ + warnx("%s: %s", *argv, dlerror()); + } else { execl(*argv, *argv, (char *)NULL); warn("%s", *argv); - } else { - dlopen(*argv, RTLD_TRACE); - warnx("%s: %s", *argv, dlerror()); } _exit(1); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 14 23:18:48 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 5AA8137B405 for ; Tue, 14 May 2002 23:18:38 -0700 (PDT) Received: from hades.hell.gr (patr530-a051.otenet.gr [212.205.215.51]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4F6IY1b017425 for ; Wed, 15 May 2002 09:18:35 +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 g4F6IWtQ048018 for ; Wed, 15 May 2002 09:18:32 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4F6IU3A048017 for freebsd-audit@FreeBSD.org; Wed, 15 May 2002 09:18:30 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Wed, 15 May 2002 09:18:28 +0300 From: Giorgos Keramidas To: freebsd-audit@FreeBSD.org Subject: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020515061827.GA47688@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 Here's a patch that adds to our cat(1) the same functionality as NetBSD cat(1) when passed -f on the command line. The original commit log from NetBSD's CVS tree is: ---------------------------- revision 1.18 date: 2000/01/15 01:13:15; author: christos; state: Exp; lines: +4 -2 branches: 1.18.4; Add a -f fflag that makes sure that we only try to read from plain files so that there is no chance to block. What do you all think of this? %%% Index: cat.1 =================================================================== RCS file: /home/ncvs/src/bin/cat/cat.1,v retrieving revision 1.19 diff -u -r1.19 cat.1 --- cat.1 25 Sep 2001 18:10:18 -0000 1.19 +++ cat.1 15 May 2002 05:57:28 -0000 @@ -82,6 +82,8 @@ option), and display a dollar sign .Pq Ql \&$ at the end of each line. +.It Fl f +Only attempt to display regular files. .It Fl n Number the output lines, starting at 1. .It Fl s Index: cat.c =================================================================== RCS file: /home/ncvs/src/bin/cat/cat.c,v retrieving revision 1.21 diff -u -r1.21 cat.c --- cat.c 22 Feb 2002 20:42:57 -0000 1.21 +++ cat.c 15 May 2002 05:56:26 -0000 @@ -66,7 +66,7 @@ #include #include -int bflag, eflag, nflag, sflag, tflag, vflag; +int bflag, eflag, fflag, nflag, sflag, tflag, vflag; int rval; const char *filename; @@ -85,7 +85,7 @@ setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc, argv, "benstuv")) != -1) + while ((ch = getopt(argc, argv, "befnstuv")) != -1) switch (ch) { case 'b': bflag = nflag = 1; /* -b implies -n */ @@ -93,6 +93,9 @@ case 'e': eflag = vflag = 1; /* -e implies -v */ break; + case 'f': + fflag = 1; + break; case 'n': nflag = 1; break; @@ -110,12 +113,12 @@ break; default: fprintf(stderr, - "usage: cat [-benstuv] [-] [file ...]\n"); + "usage: cat [-befnstuv] [-] [file ...]\n"); exit(1); } argv += optind; - if (bflag || eflag || nflag || sflag || tflag || vflag) + if (bflag || eflag || fflag || nflag || sflag || tflag || vflag) scanfiles(argv, 1); else scanfiles(argv, 0); @@ -138,7 +141,15 @@ filename = "stdin"; fd = STDIN_FILENO; } else { + struct stat st; + filename = path; + if (stat(path, &st) < 0 || + S_ISREG(st.st_mode) == 0) { + i++; /* Skip to next file. */ + continue; + } + fd = open(path, O_RDONLY); #ifndef NO_UDOM_SUPPORT if (fd < 0 && errno == EOPNOTSUPP) %%% -- Giorgos Keramidas - http://www.FreeBSD.org keramida@FreeBSD.org - The Power to Serve To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 4:23:13 2002 Delivered-To: freebsd-audit@freebsd.org Received: from svr-ganmtc-appserv-mgmt.ncf.coxexpress.com (svr-ganmtc-appserv-mgmt.ncf.coxexpress.com [24.136.46.5]) by hub.freebsd.org (Postfix) with ESMTP id 0E1E237B408; Wed, 15 May 2002 04:23:10 -0700 (PDT) Received: from darkstar.doublethink.cx (cpe-oca-24-136-59-202-cmcpe.ncf.coxexpress.com [24.136.59.202]) by svr-ganmtc-appserv-mgmt.ncf.coxexpress.com (8.11.4/8.11.4) with ESMTP id g4FBN9701888; Wed, 15 May 2002 07:23:09 -0400 Received: by darkstar.doublethink.cx (Postfix, from userid 1000) id D8C741BD; Wed, 15 May 2002 07:23:09 -0400 (EDT) Date: Wed, 15 May 2002 07:23:09 -0400 From: Chris Faulhaber To: Giorgos Keramidas Cc: freebsd-audit@FreeBSD.org Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020515112309.GA53228@darkstar.doublethink.cx> Mail-Followup-To: Chris Faulhaber , Giorgos Keramidas , freebsd-audit@FreeBSD.org References: <20020515061827.GA47688@hades.hell.gr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline In-Reply-To: <20020515061827.GA47688@hades.hell.gr> User-Agent: Mutt/1.3.28i 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 --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 15, 2002 at 09:18:28AM +0300, Giorgos Keramidas wrote: > Here's a patch that adds to our cat(1) the same functionality as > NetBSD cat(1) when passed -f on the command line. The original > commit log from NetBSD's CVS tree is: >=20 > } else { > + struct stat st; > + > filename =3D path; > + if (stat(path, &st) < 0 || > + S_ISREG(st.st_mode) =3D=3D 0) { > + i++; /* Skip to next file. */ > + continue; > + } > + You might not want to declare 'st' with such a local scope; otherwise looks ok here. --=20 Chris D. Faulhaber - jedgar@fxp.org - jedgar@FreeBSD.org -------------------------------------------------------- FreeBSD: The Power To Serve - http://www.FreeBSD.org --FCuugMFkClbJLl1L Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: FreeBSD: The Power To Serve iEYEARECAAYFAjziRR0ACgkQObaG4P6BelCi8ACdGJ2J6Mas0OeBtfns/Kd46FI8 oH4AmwcIA+ka1+Bb0rWkeQGIxfOixruk =WD3t -----END PGP SIGNATURE----- --FCuugMFkClbJLl1L-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 11: 4: 3 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.musha.org (daemon.musha.org [218.44.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 0FE7D37BBA1; Wed, 15 May 2002 11:02:57 -0700 (PDT) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id E18D24D800; Thu, 16 May 2002 02:42:32 +0900 (JST) Date: Thu, 16 May 2002 02:42:34 +0900 Message-ID: <86sn4t8fzp.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: audit@FreeBSD.org Cc: current@FreeBSD.org Subject: moused(8): char signed-ness problem with gcc 3.1 User-Agent: Wanderlust/2.9.11 (Unchained Melody) SEMI/1.14.3 (Ushinoya) LIMIT/1.14.7 (Fujiidera) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") 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 I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the following code differently (CFLAGS=-O): int main(void) { unsigned char i = 127; printf("%d\n", ((char)(i << 1)) / 2); return 0; } gcc 2.95.4 says it's -1, whereas gcc 3.1 says it's 127. On FreeBSD char should be signed, so I suspect it's a (optimization) bug of gcc 3.1 which should be fixed. Or we'll have to do a mass audit of the whole src tree to check and fix the similar expressions. In any case, this behavior makes moused(8) return a stupid value of 127 when you roll the mouse wheel up under ps/2-sysmouse-intellimouse protocol. Attached is a patch that makes the whole expression look more logical and works around the above behavior at the same time. -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." Index: moused.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/moused/moused.c,v retrieving revision 1.55 diff -u -r1.55 moused.c --- moused.c 28 Apr 2002 11:59:30 -0000 1.55 +++ moused.c 15 May 2002 17:16:40 -0000 @@ -1972,7 +1972,7 @@ act->dx = (char)(pBuf[1]) + (char)(pBuf[3]); act->dy = - ((char)(pBuf[2]) + (char)(pBuf[4])); if (rodent.level == 1) { - act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1))/2; + act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1)) >> 1; act->button |= ((~pBuf[7] & MOUSE_SYS_EXTBUTTONS) << 3); } break; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 12: 1:46 2002 Delivered-To: freebsd-audit@freebsd.org Received: from snipe.prod.itd.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by hub.freebsd.org (Postfix) with ESMTP id 5A6F237B412; Wed, 15 May 2002 12:01:34 -0700 (PDT) Received: from pool0412.cvx21-bradley.dialup.earthlink.net ([209.179.193.157] helo=mindspring.com) by snipe.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 17841i-00007s-00; Wed, 15 May 2002 12:01:30 -0700 Message-ID: <3CE2B06B.BF034A4E@mindspring.com> Date: Wed, 15 May 2002 12:00:59 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Akinori MUSHA Cc: audit@FreeBSD.org, current@FreeBSD.org Subject: Re: moused(8): char signed-ness problem with gcc 3.1 References: <86sn4t8fzp.wl@archon.local.idaemons.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Akinori MUSHA wrote: > I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the > following code differently (CFLAGS=-O): > > int main(void) > { > unsigned char i = 127; > printf("%d\n", ((char)(i << 1)) / 2); > return 0; > } > Cool... > gcc 2.95.4 says it's -1, Promotion of operand to int; conversion to lvalue type after the operation. > whereas gcc 3.1 says it's 127. Promotion of operand to lvalue type. > On FreeBSD > char should be signed, so I suspect it's a (optimization) bug of gcc > 3.1 which should be fixed. Or we'll have to do a mass audit of the > whole src tree to check and fix the similar expressions. Technically, I think, because of the parenthesis, that GCC 2.95 is right, and GCC 3.1 is wrong. Given that the conversion to "char" is done prior to the division, it should happen first. From the assembly, it looks like 3.1 is treating "/2" as ">>1", and illegally canceling out the "<<1" with the ">>1" *before* the conversion. Or maybe it's the conversion to int that happens on the stack value for a %d argument to printf... Maybe one of out C standards people can define when the conversion is defined to occur, so we can get a real ruling. Note that: int main(void) { unsigned char i = 127; printf("%d\n", (char)((i << 1) / 2)); return 0; } ...yields 127 on gcc 2.95, so it's definitely order of conversion being totally screwed by gcc 3.1. Basically, it's assuming commutability where it's not present. > In any case, this behavior makes moused(8) return a stupid value of > 127 when you roll the mouse wheel up under ps/2-sysmouse-intellimouse > protocol. Attached is a patch that makes the whole expression look > more logical and works around the above behavior at the same time. [ ... ] > - act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1))/2; > + act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1)) >> 1; This is *soooooooooo* counter intuitive that it's evil! -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 12:26:35 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 B38BB37B401; Wed, 15 May 2002 12:26:16 -0700 (PDT) Received: from kokeb.ambesa.net ([64.166.86.104]) by mta6.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0GW600K0E3BS5M@mta6.snfc21.pbi.net>; Wed, 15 May 2002 12:26:16 -0700 (PDT) Received: from kokeb.ambesa.net (localhost [127.0.0.1]) by kokeb.ambesa.net (8.12.3/8.12.3) with ESMTP id g4FJVe0Q059151; Wed, 15 May 2002 12:31:40 -0700 (PDT envelope-from makonnen@pacbell.net) Received: (from mikem@localhost) by kokeb.ambesa.net (8.12.3/8.12.3/Submit) id g4FJVd8T059150; Wed, 15 May 2002 12:31:39 -0700 (PDT) Date: Wed, 15 May 2002 13:31:03 -0600 From: Mike Makonnen Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. In-reply-to: <20020515061827.GA47688@hades.hell.gr> To: Giorgos Keramidas Cc: freebsd-audit@FreeBSD.ORG Message-id: <1021491063.45509.645.camel@kokeb.ambesa.net> MIME-version: 1.0 X-Mailer: Evolution/1.0.2 Content-type: text/plain Content-transfer-encoding: 7BIT References: <20020515061827.GA47688@hades.hell.gr> X-Authentication-warning: kokeb.ambesa.net: mikem set sender to makonnen@pacbell.net using -f 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, 2002-05-15 at 00:18, Giorgos Keramidas wrote: > Here's a patch that adds to our cat(1) the same functionality as > NetBSD cat(1) when passed -f on the command line. The original > commit log from NetBSD's CVS tree is: [snip] > @@ -138,7 +141,15 @@ > filename = "stdin"; > fd = STDIN_FILENO; > } else { > + struct stat st; > + > filename = path; > + if (stat(path, &st) < 0 || > + S_ISREG(st.st_mode) == 0) { > + i++; /* Skip to next file. */ > + continue; > + } > + just a minor nit, You might want to show a warning, since stat(2) can fail for any number of reasons not related to the type of file. 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 Wed May 15 12:35:27 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail-green.research.att.com (H-135-207-30-103.research.att.com [135.207.30.103]) by hub.freebsd.org (Postfix) with ESMTP id 58B8037B41C; Wed, 15 May 2002 12:35:01 -0700 (PDT) Received: from alliance.research.att.com (alliance.research.att.com [135.207.26.26]) by mail-green.research.att.com (Postfix) with ESMTP id DB8721E152; Wed, 15 May 2002 15:34:56 -0400 (EDT) Received: from windsor.research.att.com (windsor.research.att.com [135.207.26.46]) by alliance.research.att.com (8.8.7/8.8.7) with ESMTP id PAA07067; Wed, 15 May 2002 15:34:54 -0400 (EDT) From: Bill Fenner Received: (from fenner@localhost) by windsor.research.att.com (8.8.8+Sun/8.8.5) id MAA20988; Wed, 15 May 2002 12:34:54 -0700 (PDT) Message-Id: <200205151934.MAA20988@windsor.research.att.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII To: tlambert2@mindspring.com Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Cc: knu@iDaemons.org, audit@FreeBSD.ORG, current@FreeBSD.ORG References: <86sn4t8fzp.wl@archon.local.idaemons.org> <3CE2B06B.BF034A4E@mindspring.com> Date: Wed, 15 May 2002 12:34:53 -0700 Versions: dmail (solaris) 2.4/makemail 2.9b 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 gcc 3.1 simply defaults to unsigned chars. 127 << 1 = 254; 254 / 2 = 127. My machine is too slow to test this expeditiously, but I'm trying adding "#define DEFAULT_SIGNED_CHAR 1" into freebsd-native.h . Bill To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 12:42: 4 2002 Delivered-To: freebsd-audit@freebsd.org Received: from alpha.develop.ferrari.net (host1.ferrari-electronic.de [62.159.79.193]) by hub.freebsd.org (Postfix) with ESMTP id 253CD37B40D; Wed, 15 May 2002 12:41:56 -0700 (PDT) Received: (from robert@localhost) by alpha.develop.ferrari.net (8.11.6/8.11.6/SuSE Linux 0.5) id g4FJY6o31405; Wed, 15 May 2002 21:34:06 +0200 Date: Wed, 15 May 2002 21:34:06 +0200 From: Robert Drehmel To: Akinori MUSHA Cc: audit@FreeBSD.org, current@FreeBSD.org Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Message-ID: <20020515213406.A30720@alpha.develop.ferrari.net> References: <86sn4t8fzp.wl@archon.local.idaemons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86sn4t8fzp.wl@archon.local.idaemons.org> User-Agent: Mutt/1.3.22.1i 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, May 16, 2002 at 02:42:34AM +0900, Akinori MUSHA wrote: > I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the > following code differently (CFLAGS=-O): > > int main(void) > { > unsigned char i = 127; > printf("%d\n", ((char)(i << 1)) / 2); > return 0; > } I think GCC 3.1 does a logical right shift by one to optimize the division by two instead of an arithmetic right shift. ciao, -robert To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 12:49:31 2002 Delivered-To: freebsd-audit@freebsd.org Received: from albatross.prod.itd.earthlink.net (albatross.mail.pas.earthlink.net [207.217.120.120]) by hub.freebsd.org (Postfix) with ESMTP id 6728737B406; Wed, 15 May 2002 12:49:26 -0700 (PDT) Received: from pool0412.cvx21-bradley.dialup.earthlink.net ([209.179.193.157] helo=mindspring.com) by albatross.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 1784m1-0003nb-00; Wed, 15 May 2002 12:49:22 -0700 Message-ID: <3CE2BBA2.9416C455@mindspring.com> Date: Wed, 15 May 2002 12:48:50 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bill Fenner Cc: knu@iDaemons.org, audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 References: <86sn4t8fzp.wl@archon.local.idaemons.org> <3CE2B06B.BF034A4E@mindspring.com> <200205151934.MAA20988@windsor.research.att.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Bill Fenner wrote: > gcc 3.1 simply defaults to unsigned chars. 127 << 1 = 254; 254 / 2 = 127. > > My machine is too slow to test this expeditiously, but I'm trying > adding "#define DEFAULT_SIGNED_CHAR 1" into freebsd-native.h . I will bet today's lunch money that you have found it for sure. I guess we will have to go around adding "signed" everywhere, if it's no longer the default. Unsigned is a stupid, counter-intuitive default, and has been, ever since I first used AIX. My bet is a conspiracy by AIX folks so that Open Source software will work on AIX without them having to fix their stupid defaults. 8-) 8-). If this isn't the default, then "signed" is too much like "const" and "volatile" and other "you can't ignore them or I will generate bad code" keywords. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 12:50:34 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail-green.research.att.com (mail-green.research.att.com [135.207.30.103]) by hub.freebsd.org (Postfix) with ESMTP id 8E01137B40D; Wed, 15 May 2002 12:50:10 -0700 (PDT) Received: from alliance.research.att.com (alliance.research.att.com [135.207.26.26]) by mail-green.research.att.com (Postfix) with ESMTP id DFACC1E069; Wed, 15 May 2002 15:50:09 -0400 (EDT) Received: from windsor.research.att.com (windsor.research.att.com [135.207.26.46]) by alliance.research.att.com (8.8.7/8.8.7) with ESMTP id PAA07322; Wed, 15 May 2002 15:50:09 -0400 (EDT) From: Bill Fenner Received: (from fenner@localhost) by windsor.research.att.com (8.8.8+Sun/8.8.5) id MAA21380; Wed, 15 May 2002 12:50:08 -0700 (PDT) Message-Id: <200205151950.MAA21380@windsor.research.att.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII To: tlambert2@mindspring.com, knu@iDaemons.org, audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 References: <86sn4t8fzp.wl@archon.local.idaemons.org> <3CE2B06B.BF034A4E@mindspring.com> <200205151934.MAA20988@windsor.research.att.com> Date: Wed, 15 May 2002 12:50:08 -0700 Versions: dmail (solaris) 2.4/makemail 2.9b 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 Duh. Sometimes I wish I had the patience to wait for my tests to complete before sharing my guesses. I jumped to a wildly incorrect conclusion; gcc 3.1 still defaults to signed chars. Sorry for the bizarre misdirection. Bill To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 12:51:47 2002 Delivered-To: freebsd-audit@freebsd.org Received: from albatross.prod.itd.earthlink.net (albatross.mail.pas.earthlink.net [207.217.120.120]) by hub.freebsd.org (Postfix) with ESMTP id 52F8D37B412; Wed, 15 May 2002 12:51:10 -0700 (PDT) Received: from pool0412.cvx21-bradley.dialup.earthlink.net ([209.179.193.157] helo=mindspring.com) by albatross.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 1784nj-0006Jo-00; Wed, 15 May 2002 12:51:08 -0700 Message-ID: <3CE2BC0D.A38EFAEF@mindspring.com> Date: Wed, 15 May 2002 12:50:37 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bill Fenner Cc: knu@iDaemons.org, audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 References: <86sn4t8fzp.wl@archon.local.idaemons.org> <3CE2B06B.BF034A4E@mindspring.com> <200205151934.MAA20988@windsor.research.att.com> <200205151950.MAA21380@windsor.research.att.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Bill Fenner wrote: > Duh. Sometimes I wish I had the patience to wait for my tests to complete > before sharing my guesses. I jumped to a wildly incorrect conclusion; gcc > 3.1 still defaults to signed chars. Sorry for the bizarre misdirection. There goes my lunch money. 8-(. Man, your explanation was preferrable to a real bug. 8-(. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 13:22:42 2002 Delivered-To: freebsd-audit@freebsd.org Received: from dignus.com (sdsl-64-32-254-102.dsl.iad.megapath.net [64.32.254.102]) by hub.freebsd.org (Postfix) with ESMTP id 98B5037B407; Wed, 15 May 2002 13:22:25 -0700 (PDT) Received: from lakes.dignus.com (lakes.dignus.com [10.0.0.3]) by dignus.com (8.11.6/8.11.3) with ESMTP id g4FKHVa15972; Wed, 15 May 2002 16:17:31 -0400 (EDT) (envelope-from rivers@dignus.com) Received: (from rivers@localhost) by lakes.dignus.com (8.11.6/8.11.3) id g4FKIc946014; Wed, 15 May 2002 16:18:38 -0400 (EDT) (envelope-from rivers) Date: Wed, 15 May 2002 16:18:38 -0400 (EDT) From: Thomas David Rivers Message-Id: <200205152018.g4FKIc946014@lakes.dignus.com> To: audit@FreeBSD.ORG, knu@iDaemons.org Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Cc: current@FreeBSD.ORG In-Reply-To: <86sn4t8fzp.wl@archon.local.idaemons.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 > > I observed gcc 2.95.4 and gcc 3.1 interpret (or maybe optimize) the > following code differently (CFLAGS=-O): > > int main(void) > { > unsigned char i = 127; > printf("%d\n", ((char)(i << 1)) / 2); > return 0; > } > > gcc 2.95.4 says it's -1, whereas gcc 3.1 says it's 127. On FreeBSD > char should be signed, so I suspect it's a (optimization) bug of gcc > 3.1 which should be fixed. Or we'll have to do a mass audit of the > whole src tree to check and fix the similar expressions. Let's examine the what the "right" answer should be: First - in the expression (i << 1) - the unsigned char `i' will be promoted to a signed int through the correct integral promotion rules, then left-shifted 1 bit. The result of that is an int. So - this becomes: ((char)(254)) / 2 ; The expression: (char)(254) is then also promoted to int when it participates in the division operation. So, the value 254 is converted into a (signed) char, and then converted to an int. Converting 254 to a signed character should result in an integer value of -2. Then, -2 / 2 becomes -1. If characters were unsigned by default, you do get the value 127... So - yes - it seems gcc 3.1 does have a problem... - Dave Rivers - -- rivers@dignus.com Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 13:29:58 2002 Delivered-To: freebsd-audit@freebsd.org Received: from dignus.com (sdsl-64-32-254-102.dsl.iad.megapath.net [64.32.254.102]) by hub.freebsd.org (Postfix) with ESMTP id C013537B404; Wed, 15 May 2002 13:29:49 -0700 (PDT) Received: from lakes.dignus.com (lakes.dignus.com [10.0.0.3]) by dignus.com (8.11.6/8.11.3) with ESMTP id g4FKOua16003; Wed, 15 May 2002 16:24:56 -0400 (EDT) (envelope-from rivers@dignus.com) Received: (from rivers@localhost) by lakes.dignus.com (8.11.6/8.11.3) id g4FKQ3746098; Wed, 15 May 2002 16:26:03 -0400 (EDT) (envelope-from rivers) Date: Wed, 15 May 2002 16:26:03 -0400 (EDT) From: Thomas David Rivers Message-Id: <200205152026.g4FKQ3746098@lakes.dignus.com> To: fenner@research.att.com, tlambert2@mindspring.com Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Cc: audit@FreeBSD.ORG, current@FreeBSD.ORG, knu@iDaemons.org In-Reply-To: <3CE2BBA2.9416C455@mindspring.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 Terry Lambert wrote: > > Bill Fenner wrote: > > gcc 3.1 simply defaults to unsigned chars. 127 << 1 = 254; 254 / 2 = 127. > > > > My machine is too slow to test this expeditiously, but I'm trying > > adding "#define DEFAULT_SIGNED_CHAR 1" into freebsd-native.h . > > I will bet today's lunch money that you have found it for sure. > > I guess we will have to go around adding "signed" everywhere, if > it's no longer the default. > > Unsigned is a stupid, counter-intuitive default, and has been, > ever since I first used AIX. > > My bet is a conspiracy by AIX folks so that Open Source software > will work on AIX without them having to fix their stupid defaults. > > 8-) 8-). Well - it's not counter-intuitive on many machines... For example, on the IBM mainframe - there is an instruction to load a character into a register - but not one that loads *and* sign-extends. So, you can get much better code if characters are unsigned by default. So in our C/C++ compilers for the mainframe, the default is unsigned as well. I wonder if the AIX people were looking for mainframe compatibility in this decision, or was it motivated by the PowerPC instruction set? Does anyone know what the Mac default is (since they are PowerPC based as well?) - Dave Rivers - -- rivers@dignus.com Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 14:18:31 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 4085237B40D for ; Wed, 15 May 2002 14:18:05 -0700 (PDT) Received: from hades.hell.gr (patr530-b174.otenet.gr [212.205.244.182]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4FLI2HL027105; Thu, 16 May 2002 00:18:03 +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 g4FLI16m068466; Thu, 16 May 2002 00:18:01 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4FLI0qp068465; Thu, 16 May 2002 00:18:00 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 16 May 2002 00:17:59 +0300 From: Giorgos Keramidas To: Mike Makonnen Cc: freebsd-audit@FreeBSD.org Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020515211758.GB68380@hades.hell.gr> References: <20020515061827.GA47688@hades.hell.gr> <1021491063.45509.645.camel@kokeb.ambesa.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1021491063.45509.645.camel@kokeb.ambesa.net> 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 In message: <1021491063.45509.645.camel@kokeb.ambesa.net> Mike Makonnen writes: > > @@ -138,7 +141,15 @@ > > filename = "stdin"; > > fd = STDIN_FILENO; > > } else { > > + struct stat st; > > + > > filename = path; > > + if (stat(path, &st) < 0 || > > + S_ISREG(st.st_mode) == 0) { > > + i++; /* Skip to next file. */ > > + continue; > > + } > > + > > just a minor nit, > > You might want to show a warning, since stat(2) can fail for any number > of reasons not related to the type of file. Sure, I've changed it to the following. Since this is a minor change, I'll see that is gets done later tonight, if nobody objects 'til then. %%% + if (stat(path, &st) < 0) { + warn("%s", path); + i++; /* Skip to next file. */ + continue; + } + if (S_ISREG(st.st_mode) == 0) { + i++; /* Skip to next file. */ + continue; + } %%% -- Giorgos Keramidas - http://www.FreeBSD.org keramida@FreeBSD.org - The Power to Serve To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 20:46:13 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail-blue.research.att.com (mail-blue.research.att.com [135.207.30.102]) by hub.freebsd.org (Postfix) with ESMTP id A756837B403; Wed, 15 May 2002 20:46:09 -0700 (PDT) Received: from alliance.research.att.com (alliance.research.att.com [135.207.26.26]) by mail-blue.research.att.com (Postfix) with ESMTP id 0EC3F4CECC; Wed, 15 May 2002 23:46:09 -0400 (EDT) Received: from windsor.research.att.com (windsor.research.att.com [135.207.26.46]) by alliance.research.att.com (8.8.7/8.8.7) with ESMTP id XAA12409; Wed, 15 May 2002 23:46:07 -0400 (EDT) From: Bill Fenner Received: (from fenner@localhost) by windsor.research.att.com (8.8.8+Sun/8.8.5) id UAA27116; Wed, 15 May 2002 20:46:07 -0700 (PDT) Message-Id: <200205160346.UAA27116@windsor.research.att.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII To: rivers@dignus.com Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Cc: audit@FreeBSD.ORG, knu@iDaemons.org, current@FreeBSD.ORG Date: Wed, 15 May 2002 20:46:06 -0700 Versions: dmail (solaris) 2.4/makemail 2.9b 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 > So - yes - it seems gcc 3.1 does have a problem... Indeed - easily determined by breaking down the expression. So, who's gonna report it to gcc-bugs? knu?... int main() { unsigned char i = 127; char j; printf("%d\n", ((char)(i << 1))); j = ((char)(i << 1)) / 2; printf("%d\n", j); j = ((char)(i << 1)); printf("%d\n", j / 2); return 0; } Bill To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 15 21:19:23 2002 Delivered-To: freebsd-audit@freebsd.org Received: from swan.prod.itd.earthlink.net (swan.mail.pas.earthlink.net [207.217.120.123]) by hub.freebsd.org (Postfix) with ESMTP id 4F43637B406; Wed, 15 May 2002 21:19:16 -0700 (PDT) Received: from pool0568.cvx40-bradley.dialup.earthlink.net ([216.244.44.58] helo=mindspring.com) by swan.prod.itd.earthlink.net with esmtp (Exim 3.33 #2) id 178CjQ-00038e-00; Wed, 15 May 2002 21:19:12 -0700 Message-ID: <3CE33321.B2FBD340@mindspring.com> Date: Wed, 15 May 2002 21:18:41 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Thomas David Rivers Cc: fenner@research.att.com, audit@FreeBSD.ORG, current@FreeBSD.ORG, knu@iDaemons.org Subject: Re: moused(8): char signed-ness problem with gcc 3.1 References: <200205152026.g4FKQ3746098@lakes.dignus.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Thomas David Rivers wrote: > Well - it's not counter-intuitive on many machines... For example, > on the IBM mainframe - there is an instruction to load a character > into a register - but not one that loads *and* sign-extends. So, > you can get much better code if characters are unsigned by default. Sounds like time to get out the wire wrap tools... and fix the hardware, not the software. > So in our C/C++ compilers for the mainframe, the default is > unsigned as well. > > I wonder if the AIX people were looking for mainframe > compatibility in this decision, or was it motivated > by the PowerPC instruction set? Does anyone know what > the Mac default is (since they are PowerPC based as well?) RS/6000's didn't used to use PPC processors at all; so it's probably intentional software compatability. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 0:37:48 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 047A437B408; Thu, 16 May 2002 00:37:41 -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 RAA20279; Thu, 16 May 2002 17:37:38 +1000 Date: Thu, 16 May 2002 17:40:01 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Giorgos Keramidas Cc: Mike Makonnen , Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. In-Reply-To: <20020515211758.GB68380@hades.hell.gr> Message-ID: <20020516164332.B1704-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, 16 May 2002, Giorgos Keramidas wrote: > In message: <1021491063.45509.645.camel@kokeb.ambesa.net> > Mike Makonnen writes: > > > @@ -138,7 +141,15 @@ > > > filename = "stdin"; > > > fd = STDIN_FILENO; > > > } else { > > > + struct stat st; > > > + > > > filename = path; > > > + if (stat(path, &st) < 0 || > > > + S_ISREG(st.st_mode) == 0) { > > > + i++; /* Skip to next file. */ > > > + continue; > > > + } > > > + > > > > just a minor nit, > > > > You might want to show a warning, since stat(2) can fail for any number > > of reasons not related to the type of file. > > Sure, I've changed it to the following. Since this is a minor change, > I'll see that is gets done later tonight, if nobody objects 'til then. > > %%% > + if (stat(path, &st) < 0) { > + warn("%s", path); > + i++; /* Skip to next file. */ > + continue; > + } > + if (S_ISREG(st.st_mode) == 0) { > + i++; /* Skip to next file. */ > + continue; > + } > %%% I object. If stat() fails, then we have no idea about the file type, so we shouldn't classify it as regular and must set rval so that the error is reflected in cat's exit status. Letting the old code handle the error seems best. Using stat() instead of fstat() gives some races. NetBSD reduces the races by checking the mode both before and after open(). I didn't notice if your full patch does this (and deleted it :). Checking the mode again after open (after we have found fd > 0) would also fix the missing (?) check that stdin is a regular file. NetBSD doesn't check the mode of stdin but its man page says that -f causes non-plain files to be skipped. Checking the mode of stdin is also slightly wrong if stdin is refered to as /dev/stdin instead of "-". /dev/stdin is a (symlink to a) cdev, so it is never considered to be "plain". A more fundamental bug: The new variable fflag is never used. Style bugs: - nested declaration of st. - more verbose and bogus handling of the variable 'i'. 'i' is just the loop counter for a `for' loop that is obfuscated as a `while' loop. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 3:41:36 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 92BDA37B401 for ; Thu, 16 May 2002 03:41:31 -0700 (PDT) Received: (qmail 37484 invoked from network); 16 May 2002 10:49:22 -0000 Received: from unknown (HELO straylight.ringlet.net) (212.116.140.125) by south.nanolink.com with SMTP; 16 May 2002 10:49:22 -0000 Received: (qmail 4496 invoked by uid 1000); 16 May 2002 10:40:45 -0000 Date: Thu, 16 May 2002 13:40:45 +0300 From: Peter Pentchev To: Bruce Evans Cc: Giorgos Keramidas , Mike Makonnen , freebsd-audit@FreeBSD.ORG Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020516134044.A349@straylight.oblivion.bg> Mail-Followup-To: Bruce Evans , Giorgos Keramidas , Mike Makonnen , freebsd-audit@FreeBSD.ORG References: <20020515211758.GB68380@hades.hell.gr> <20020516164332.B1704-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020516164332.B1704-100000@gamplex.bde.org>; from bde@zeta.org.au on Thu, May 16, 2002 at 05:40:01PM +1000 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 --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 16, 2002 at 05:40:01PM +1000, Bruce Evans wrote: > On Thu, 16 May 2002, Giorgos Keramidas wrote: [snip] > > Sure, I've changed it to the following. Since this is a minor change, > > I'll see that is gets done later tonight, if nobody objects 'til then. > > > > %%% > > + if (stat(path, &st) < 0) { > > + warn("%s", path); > > + i++; /* Skip to next file. */ > > + continue; > > + } > > + if (S_ISREG(st.st_mode) =3D=3D 0) { > > + i++; /* Skip to next file. */ > > + continue; > > + } > > %%% [snip] > Style bugs: > - nested declaration of st. > - more verbose and bogus handling of the variable 'i'. 'i' is just the > loop counter for a `for' loop that is obfuscated as a `while' loop. Also, aren't we supposed to test the return values of syscalls explicitly against -1, and not just < 0? At least that was the impression that Ruslan gave me some time ago.. 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 Nostalgia ain't what it used to be. --a8Wt8u1KmwUX3Y2C Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE844ys7Ri2jRYZRVMRArWxAKCpDS3wb5U1zAB1iiGVdA7vlYoN4QCfVpK7 jOoqby5+92LWuDNEaHalKw4= =q3r1 -----END PGP SIGNATURE----- --a8Wt8u1KmwUX3Y2C-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 3:51:31 2002 Delivered-To: freebsd-audit@freebsd.org Received: from dignus.com (sdsl-64-32-254-102.dsl.iad.megapath.net [64.32.254.102]) by hub.freebsd.org (Postfix) with ESMTP id 9174C37B400; Thu, 16 May 2002 03:51:26 -0700 (PDT) Received: from lakes.dignus.com (lakes.dignus.com [10.0.0.3]) by dignus.com (8.11.6/8.11.3) with ESMTP id g4GAkXa17669; Thu, 16 May 2002 06:46:33 -0400 (EDT) (envelope-from rivers@dignus.com) Received: (from rivers@localhost) by lakes.dignus.com (8.11.6/8.11.3) id g4GAldU47929; Thu, 16 May 2002 06:47:39 -0400 (EDT) (envelope-from rivers) Date: Thu, 16 May 2002 06:47:39 -0400 (EDT) From: Thomas David Rivers Message-Id: <200205161047.g4GAldU47929@lakes.dignus.com> To: rivers@dignus.com, tlambert2@mindspring.com Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Cc: audit@FreeBSD.ORG, current@FreeBSD.ORG, fenner@research.att.com, knu@iDaemons.org In-Reply-To: <3CE33321.B2FBD340@mindspring.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 Terry Lambert wrote: > Thomas David Rivers wrote: > > Well - it's not counter-intuitive on many machines... For example, > > on the IBM mainframe - there is an instruction to load a character > > into a register - but not one that loads *and* sign-extends. So, > > you can get much better code if characters are unsigned by default. > > Sounds like time to get out the wire wrap tools... and fix the > hardware, not the software. Ha! That may not be a bad idea :-) > > > So in our C/C++ compilers for the mainframe, the default is > > unsigned as well. > > > > I wonder if the AIX people were looking for mainframe > > compatibility in this decision, or was it motivated > > by the PowerPC instruction set? Does anyone know what > > the Mac default is (since they are PowerPC based as well?) > > RS/6000's didn't used to use PPC processors at all; so it's > probably intentional software compatability. I'm confused then - the one we have here seems to. There was a version of something very RS/6000-like that didn't, but I thought RS/6000s did... - Dave Rivers - -- rivers@dignus.com Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 4:31:28 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.musha.org (daemon.musha.org [218.44.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 0662837B401; Thu, 16 May 2002 04:31:20 -0700 (PDT) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id 8B7664D801; Thu, 16 May 2002 20:31:18 +0900 (JST) Date: Thu, 16 May 2002 20:31:19 +0900 Message-ID: <86k7q48h2w.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: Bill Fenner Cc: obrien@FreeBSD.org, rivers@dignus.com, audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 In-Reply-To: <200205160346.UAA27116@windsor.research.att.com> References: <200205160346.UAA27116@windsor.research.att.com> User-Agent: Wanderlust/2.9.11 (Unchained Melody) SEMI/1.14.3 (Ushinoya) LIMIT/1.14.7 (Fujiidera) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") 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 [CC: obrien, who has been working on bringing in gcc 3.1] At Wed, 15 May 2002 20:46:06 -0700, Bill Fenner wrote: > > So - yes - it seems gcc 3.1 does have a problem... > > Indeed - easily determined by breaking down the expression. > > So, who's gonna report it to gcc-bugs? knu?... > > int > main() > { > unsigned char i = 127; > char j; > > printf("%d\n", ((char)(i << 1))); > j = ((char)(i << 1)) / 2; > printf("%d\n", j); > j = ((char)(i << 1)); > printf("%d\n", j / 2); > return 0; > } Somehow, specifying -fsigned-char, which I thought was the default, fixed the problem. So, the cause may be in our configuration of gcc? I'll send-pr if it isn't. -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 4:57: 1 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 8E81E37B406; Thu, 16 May 2002 04:56:55 -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 VAA11006; Thu, 16 May 2002 21:56:33 +1000 Date: Thu, 16 May 2002 21:58:56 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Akinori MUSHA Cc: Bill Fenner , , , , Subject: Re: moused(8): char signed-ness problem with gcc 3.1 In-Reply-To: <86k7q48h2w.wl@archon.local.idaemons.org> Message-ID: <20020516215731.K499-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, 16 May 2002, Akinori MUSHA wrote: > [CC: obrien, who has been working on bringing in gcc 3.1] > > At Wed, 15 May 2002 20:46:06 -0700, > Bill Fenner wrote: > > So, who's gonna report it to gcc-bugs? knu?... > > > > int > > main() > > { > > unsigned char i = 127; > > char j; > > > > printf("%d\n", ((char)(i << 1))); > > j = ((char)(i << 1)) / 2; > > printf("%d\n", j); > > j = ((char)(i << 1)); > > printf("%d\n", j / 2); > > return 0; > > } > > Somehow, specifying -fsigned-char, which I thought was the default, > fixed the problem. So, the cause may be in our configuration of gcc? -fsigned-char doesn't fix it for me. Neither does repacling "char" by "signed char". moused is broken too. It assumes that plain chars are signed. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 5:14:11 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 C91B637B406; Thu, 16 May 2002 05:14:08 -0700 (PDT) Received: by flood.ping.uio.no (Postfix, from userid 2602) id DEF5A5307; Thu, 16 May 2002 14:14:05 +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: Peter Pentchev Cc: Bruce Evans , Giorgos Keramidas , Mike Makonnen , freebsd-audit@FreeBSD.ORG Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. References: <20020515211758.GB68380@hades.hell.gr> <20020516164332.B1704-100000@gamplex.bde.org> <20020516134044.A349@straylight.oblivion.bg> From: Dag-Erling Smorgrav Date: 16 May 2002 14:14:05 +0200 In-Reply-To: <20020516134044.A349@straylight.oblivion.bg> Message-ID: Lines: 10 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 Peter Pentchev writes: > Also, aren't we supposed to test the return values of syscalls explicitly > against -1, and not just < 0? Is a negative return value different from -1 more correct than -1? Should it be silently ignored? 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 Thu May 16 5:24:46 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 139E237B41F for ; Thu, 16 May 2002 05:24:28 -0700 (PDT) Received: (qmail 57327 invoked from network); 16 May 2002 12:32:11 -0000 Received: from unknown (HELO straylight.ringlet.net) (212.116.140.125) by south.nanolink.com with SMTP; 16 May 2002 12:32:11 -0000 Received: (qmail 84438 invoked by uid 1000); 16 May 2002 12:23:45 -0000 Date: Thu, 16 May 2002 15:23:45 +0300 From: Peter Pentchev To: Dag-Erling Smorgrav Cc: Bruce Evans , Giorgos Keramidas , Mike Makonnen , freebsd-audit@FreeBSD.ORG Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020516152345.E349@straylight.oblivion.bg> Mail-Followup-To: Dag-Erling Smorgrav , Bruce Evans , Giorgos Keramidas , Mike Makonnen , freebsd-audit@FreeBSD.ORG References: <20020515211758.GB68380@hades.hell.gr> <20020516164332.B1704-100000@gamplex.bde.org> <20020516134044.A349@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="2qXFWqzzG3v1+95a" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from des@ofug.org on Thu, May 16, 2002 at 02:14:05PM +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 --2qXFWqzzG3v1+95a Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 16, 2002 at 02:14:05PM +0200, Dag-Erling Smorgrav wrote: > Peter Pentchev writes: > > Also, aren't we supposed to test the return values of syscalls explicit= ly > > against -1, and not just < 0? >=20 > Is a negative return value different from -1 more correct than -1? > Should it be silently ignored? Hmm. The standards (and our manual pages) say that most syscalls return *exactly* -1 on error. A negative value different than -1 should be treated as some kind of meta-error; maybe something that might warrant an err(EX_OSERR, ...). No, I do not really think that it is possible - or even thinkable - to make that check every time a syscall is invoked :) Actually, now I don't know what to think - for the past few months, I have been writing my own programs with explicit checks for -1. Is there an OS out there that returns negative values other than -1? I presume that no *new* OS and no new syscalls will be written to return such, so no further incompatibility would be introduced; but is there an existing platform that would break programs which check explicitly for -1? 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 What would this sentence be like if it weren't self-referential? --2qXFWqzzG3v1+95a Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE846TR7Ri2jRYZRVMRAsAoAJ9J/SvWvVtjiKTPGKkU2uxAoBQUnwCgnLlv c9kiXUlEwmKEqfMm0+4ie7o= =Ig8u -----END PGP SIGNATURE----- --2qXFWqzzG3v1+95a-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 5:39:59 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 0990237B406 for ; Thu, 16 May 2002 05:39:53 -0700 (PDT) Received: from hades.hell.gr (patr530-b220.otenet.gr [212.205.244.228]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4GCdnHL019424; Thu, 16 May 2002 15:39:50 +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 g4GCdm6m093572; Thu, 16 May 2002 15:39:48 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4GCcaNh093522; Thu, 16 May 2002 15:38:36 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 16 May 2002 15:38:35 +0300 From: Giorgos Keramidas To: Bruce Evans Cc: Mike Makonnen , freebsd-audit@FreeBSD.org Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020516123835.GA93447@hades.hell.gr> References: <20020515211758.GB68380@hades.hell.gr> <20020516164332.B1704-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020516164332.B1704-100000@gamplex.bde.org> 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 On 2002-05-16 17:40, Bruce Evans wrote: > > > + if (stat(path, &st) < 0) { > > ... > > + if (S_ISREG(st.st_mode) == 0) { > > I object. If stat() fails, then we have no idea about the file type, > so we shouldn't classify it as regular and must set rval so that the > error is reflected in cat's exit status. Letting the old code handle > the error seems best. > > Using stat() instead of fstat() gives some races. NetBSD reduces the > races by checking the mode both before and after open(). I have the following version of basesrc/bin/cat locally: $NetBSD: cat.c,v 1.30 2002/05/09 02:13:10 thorpej Exp $ This checks only after the open with fstat(). I agree that using fstat() is better. Thanks for pointing this out ;) > A more fundamental bug: > The new variable fflag is never used. Whoops. That's what one gets for writing C programs very late. Fixed. I had probably meant to add this after the code works with *stat() and forgot all about it, when testing. Thank you again. > Style bugs: > - nested declaration of st. Removed after a comment by Mike Makonnen. > - more verbose and bogus handling of the variable 'i'. 'i' is just the > loop counter for a `for' loop that is obfuscated as a `while' loop. I can't think of some way to use `i' differently, without rewriting the `while' loop as a `for' loop too. Mixing this change with the addition of -f seemed like wrong to me though. The conversion to a `for' loop can be done in a separate change, if it's deemed necessary. What is it that makes you think the handling of `i' in the added code is bogus? :-/ To save the readers of the list a few KB, I won't post the patch again. Its updated version can be found at: http://www.FreeBSD.org/~keramida/diff/2002-05-16.cat,aa - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 5:43:55 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 DFBA937B405 for ; Thu, 16 May 2002 05:43:49 -0700 (PDT) Received: from hades.hell.gr (patr530-b220.otenet.gr [212.205.244.228]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4GChkHL027513; Thu, 16 May 2002 15:43:47 +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 g4GChi6m093773; Thu, 16 May 2002 15:43:44 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4GChh9I093768; Thu, 16 May 2002 15:43:44 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 16 May 2002 15:43:43 +0300 From: Giorgos Keramidas To: Peter Pentchev Cc: Dag-Erling Smorgrav , Bruce Evans , Mike Makonnen , freebsd-audit@FreeBSD.ORG Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020516124343.GA93634@hades.hell.gr> References: <20020515211758.GB68380@hades.hell.gr> <20020516164332.B1704-100000@gamplex.bde.org> <20020516134044.A349@straylight.oblivion.bg> <20020516152345.E349@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020516152345.E349@straylight.oblivion.bg> 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 On 2002-05-16 15:23, Peter Pentchev wrote: > Actually, now I don't know what to think - for the past few months, > I have been writing my own programs with explicit checks for -1. > Is there an OS out there that returns negative values other than -1? > I presume that no *new* OS and no new syscalls will be written to > return such, so no further incompatibility would be introduced; > but is there an existing platform that would break programs which > check explicitly for -1? I'm not sure. The < 0 check is almost hardwired in my fingers, because of a few years of writing it this way. Just trying to be on the safe side of the world, I guess. - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 6: 2:20 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 C572137B409 for ; Thu, 16 May 2002 06:02:16 -0700 (PDT) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 0362D5307; Thu, 16 May 2002 15:02: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: Giorgos Keramidas Cc: Peter Pentchev , Bruce Evans , Mike Makonnen , freebsd-audit@FreeBSD.ORG Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. References: <20020515211758.GB68380@hades.hell.gr> <20020516164332.B1704-100000@gamplex.bde.org> <20020516134044.A349@straylight.oblivion.bg> <20020516152345.E349@straylight.oblivion.bg> <20020516124343.GA93634@hades.hell.gr> From: Dag-Erling Smorgrav Date: 16 May 2002 15:02:13 +0200 In-Reply-To: <20020516124343.GA93634@hades.hell.gr> Message-ID: Lines: 15 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 Giorgos Keramidas writes: > I'm not sure. The < 0 check is almost hardwired in my fingers, > because of a few years of writing it this way. Just trying to be on > the safe side of the world, I guess. It's also a single instruction (+ a flag check) on most architectures, while an explicit comparison is at least two, and possibly trashes a register. That being said, I use == -1 myself - but I don't think < 0 is wrong, just different. As long as we're consistent, I don't care. 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 Thu May 16 6:11:11 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 10FBF37B405 for ; Thu, 16 May 2002 06:11:06 -0700 (PDT) Received: (qmail 57521 invoked from network); 16 May 2002 13:18:51 -0000 Received: from unknown (HELO straylight.ringlet.net) (212.116.140.125) by south.nanolink.com with SMTP; 16 May 2002 13:18:51 -0000 Received: (qmail 6346 invoked by uid 1000); 16 May 2002 13:10:24 -0000 Date: Thu, 16 May 2002 16:10:24 +0300 From: Peter Pentchev To: Dag-Erling Smorgrav Cc: Giorgos Keramidas , Bruce Evans , Mike Makonnen , freebsd-audit@FreeBSD.ORG Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020516161024.G349@straylight.oblivion.bg> Mail-Followup-To: Dag-Erling Smorgrav , Giorgos Keramidas , Bruce Evans , Mike Makonnen , freebsd-audit@FreeBSD.ORG References: <20020515211758.GB68380@hades.hell.gr> <20020516164332.B1704-100000@gamplex.bde.org> <20020516134044.A349@straylight.oblivion.bg> <20020516152345.E349@straylight.oblivion.bg> <20020516124343.GA93634@hades.hell.gr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="5L6AZ1aJH5mDrqCQ" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from des@ofug.org on Thu, May 16, 2002 at 03:02:13PM +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 --5L6AZ1aJH5mDrqCQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 16, 2002 at 03:02:13PM +0200, Dag-Erling Smorgrav wrote: > Giorgos Keramidas writes: > > I'm not sure. The < 0 check is almost hardwired in my fingers, > > because of a few years of writing it this way. Just trying to be on > > the safe side of the world, I guess. >=20 > It's also a single instruction (+ a flag check) on most architectures, > while an explicit comparison is at least two, and possibly trashes a > register. >=20 > That being said, I use =3D=3D -1 myself - but I don't think < 0 is wrong, > just different. As long as we're consistent, I don't care. It was exactly about being consistent that I first brought this up; IMO, at least within FreeBSD, being consistent would be =3D=3D -1. 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 What would this sentence be like if it weren't self-referential? --5L6AZ1aJH5mDrqCQ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE846+/7Ri2jRYZRVMRAnP1AJ9ceMF/6Vf6EF7Odn9KEYMnuDyuqgCeOFZD cDM/GMWWQYaTP7GjeR938Ck= =LwcT -----END PGP SIGNATURE----- --5L6AZ1aJH5mDrqCQ-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 7:24: 7 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.musha.org (daemon.musha.org [218.44.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 8398F37B4F3; Thu, 16 May 2002 07:22:01 -0700 (PDT) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id 3136B4D801; Thu, 16 May 2002 23:21:59 +0900 (JST) Date: Thu, 16 May 2002 23:21:59 +0900 Message-ID: <86it5o896g.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: Bruce Evans Cc: Bill Fenner , , , , Subject: Re: moused(8): char signed-ness problem with gcc 3.1 In-Reply-To: <20020516215731.K499-100000@gamplex.bde.org> References: <86k7q48h2w.wl@archon.local.idaemons.org> <20020516215731.K499-100000@gamplex.bde.org> User-Agent: Wanderlust/2.9.11 (Unchained Melody) SEMI/1.14.3 (Ushinoya) LIMIT/1.14.7 (Fujiidera) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") 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 At Thu, 16 May 2002 21:58:56 +1000 (EST), Bruce Evans wrote: > > Somehow, specifying -fsigned-char, which I thought was the default, > > fixed the problem. So, the cause may be in our configuration of gcc? > > -fsigned-char doesn't fix it for me. Neither does repacling "char" by > "signed char". Oops, I was testing on a different box. Sorry. > moused is broken too. It assumes that plain chars are signed. How about this? Index: moused.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/moused/moused.c,v retrieving revision 1.55 diff -u -r1.55 moused.c --- moused.c 28 Apr 2002 11:59:30 -0000 1.55 +++ moused.c 16 May 2002 14:15:42 -0000 @@ -1718,8 +1718,8 @@ return 0; } - act->dx = (char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); - act->dy = (char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); + act->dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); + act->dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); break; case MOUSE_PROTO_GLIDEPOINT: /* GlidePoint */ @@ -1728,8 +1728,8 @@ MouseMan+ */ act->button = (act->obutton & (MOUSE_BUTTON2DOWN | MOUSE_BUTTON4DOWN)) | butmapmss[(pBuf[0] & MOUSE_MSS_BUTTONS) >> 4]; - act->dx = (char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); - act->dy = (char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); + act->dx = (signed char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F)); + act->dy = (signed char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F)); break; case MOUSE_PROTO_MSC: /* MouseSystems Corp */ @@ -1737,15 +1737,15 @@ case MOUSE_PROTO_MARIQUA: /* Mariqua */ #endif act->button = butmapmsc[(~pBuf[0]) & MOUSE_MSC_BUTTONS]; - act->dx = (char)(pBuf[1]) + (char)(pBuf[3]); - act->dy = - ((char)(pBuf[2]) + (char)(pBuf[4])); + act->dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]); + act->dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4])); break; case MOUSE_PROTO_JOGDIAL: /* JogDial */ if (rBuf == 0x6c) - act->dz=-1; + act->dz = -1; if (rBuf == 0x72) - act->dz=1; + act->dz = 1; if (rBuf == 0x64) act->button = MOUSE_BUTTON1DOWN; if (rBuf == 0x75) @@ -1792,8 +1792,8 @@ case MOUSE_PROTO_BUS: /* Bus */ case MOUSE_PROTO_INPORT: /* InPort */ act->button = butmapmsc[(~pBuf[0]) & MOUSE_MSC_BUTTONS]; - act->dx = (char)pBuf[1]; - act->dy = - (char)pBuf[2]; + act->dx = (signed char)pBuf[1]; + act->dy = - (signed char)pBuf[2]; break; case MOUSE_PROTO_PS2: /* PS/2 */ @@ -1822,7 +1822,7 @@ case MOUSE_MODEL_INTELLI: case MOUSE_MODEL_NET: /* wheel data is in the fourth byte */ - act->dz = (char)pBuf[3]; + act->dz = (signed char)pBuf[3]; if ((act->dz >= 7) || (act->dz <= -7)) act->dz = 0; /* some compatible mice may have additional buttons */ @@ -1969,10 +1969,10 @@ case MOUSE_PROTO_SYSMOUSE: /* sysmouse */ act->button = butmapmsc[(~pBuf[0]) & MOUSE_SYS_STDBUTTONS]; - act->dx = (char)(pBuf[1]) + (char)(pBuf[3]); - act->dy = - ((char)(pBuf[2]) + (char)(pBuf[4])); + act->dx = (signed char)(pBuf[1]) + (signed char)(pBuf[3]); + act->dy = - ((signed char)(pBuf[2]) + (signed char)(pBuf[4])); if (rodent.level == 1) { - act->dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1))/2; + act->dz = ((signed char)(pBuf[5] << 1) + (signed char)(pBuf[6] << 1)) >> 1; act->button |= ((~pBuf[7] & MOUSE_SYS_EXTBUTTONS) << 3); } break; -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 7:41:27 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 2049137B419 for ; Thu, 16 May 2002 07:39:06 -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 AAA22705; Fri, 17 May 2002 00:32:43 +1000 Date: Fri, 17 May 2002 00:35:07 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Giorgos Keramidas Cc: Mike Makonnen , Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. In-Reply-To: <20020516123835.GA93447@hades.hell.gr> Message-ID: <20020516235833.S933-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, 16 May 2002, Giorgos Keramidas wrote: > On 2002-05-16 17:40, Bruce Evans wrote: > > Using stat() instead of fstat() gives some races. NetBSD reduces the > > races by checking the mode both before and after open(). > > I have the following version of basesrc/bin/cat locally: > $NetBSD: cat.c,v 1.30 2002/05/09 02:13:10 thorpej Exp $ > > This checks only after the open with fstat(). I agree that using > fstat() is better. Thanks for pointing this out ;) Oops, I misread 1.27. It checks only after open() too (deep in fopen() in the cooked case). Problems with open() are limited by using the O_NONBLOCK flag in the -f case, but there can still be problems (open() and/or close() can have side effects), so I think a stat() should be tried first and checked later. > Removed after a comment by Mike Makonnen. > > > - more verbose and bogus handling of the variable 'i'. 'i' is just the > > loop counter for a `for' loop that is obfuscated as a `while' loop. > > I can't think of some way to use `i' differently, without rewriting > the `while' loop as a `for' loop too. Mixing this change with the > addition of -f seemed like wrong to me though. The conversion to a > `for' loop can be done in a separate change, if it's deemed necessary. > > What is it that makes you think the handling of `i' in the added code > is bogus? :-/ The obfuscated `for' loop wasn't too bad when `i' was incremented in one place, but `i' is now incremented in 3 places and commented on in two places. I first noticed the style bug of duplicating the comment. One comment about a simple increment may be justified because the loop is obfuscated, but not two. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 8:48:15 2002 Delivered-To: freebsd-audit@freebsd.org Received: from shale.csir.co.za (shale.csir.co.za [146.64.46.5]) by hub.freebsd.org (Postfix) with ESMTP id F38D337B42B; Thu, 16 May 2002 08:47:13 -0700 (PDT) Received: (from reg@localhost) by shale.csir.co.za (8.11.6/8.11.6) id g4GFkiq39615; Thu, 16 May 2002 17:46:44 +0200 (SAT) (envelope-from reg) Date: Thu, 16 May 2002 17:46:44 +0200 From: Jeremy Lea To: "Bruce A. Mah" Cc: audit@FreeBSD.ORG, ports@FreeBSD.ORG, sobomax@FreeBSD.ORG Subject: Re: pkg_version in C [was: Re: Perl scripts that need rewriting - Progress!] Message-ID: <20020516174644.A38650@shale.csir.co.za> References: <200205091933.g49JXMjV041629@grimreaper.grondar.org> <20020514145039.B13083@shale.csir.co.za> <200205141714.g4EHELC5007391@intruder.bmah.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200205141714.g4EHELC5007391@intruder.bmah.org>; from bmah@FreeBSD.ORG on Tue, May 14, 2002 at 10:14:21AM -0700 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, On Tue, May 14, 2002 at 10:14:21AM -0700, Bruce A. Mah wrote: > 1. The version comparisons passed all of the regression tests that knu > and I made for the original pkg_version (test-pkg_version.sh). This > gives me a nice warm fuzzy feeling about that part of the code. Of course it does... I wouldn't have posted it otherwise! ;-) > 4. You commented that you didn't like the way we did "-s" before. If > you think it'd be better as (say) a regex or a globbing expression, I > don't believe there'd be much problem with going that route. knu > used globbing when he wrote portversion, if you want some precedent. Well, the pkg_* utilities each work in the same way - they take a list of packages on the command line or a -a flag for all. They then work over that list one package at a time... I think it would be a bad idea to change any of command line flags now. I've never quite figured out why we have both globbing and regex matching in pkg_* though... Anyway, a revised patch is at: http://people.freebsd.org/~reg/pkg_version.patch Besides people's comments, there are a few changes to the comparison (multiple matches didn't work in the first version), and I've made the name matching more strict. I was asked to CC -audit, so I've dropped -current from the list. Regards, -Jeremy -- FreeBSD - Because the best things in life are free... http://www.freebsd.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 9:29:41 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 59CB637B400 for ; Thu, 16 May 2002 09:29:24 -0700 (PDT) Received: from hades.hell.gr (patr530-a094.otenet.gr [212.205.215.94]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4GGTIHL007565; Thu, 16 May 2002 19:29:20 +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 g4GGTH6m096362; Thu, 16 May 2002 19:29:17 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4GGTCJs096357; Thu, 16 May 2002 19:29:12 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 16 May 2002 19:29:10 +0300 From: Giorgos Keramidas To: Bruce Evans Cc: freebsd-audit@FreeBSD.org Subject: Re: RFC: Port of NetBSD cat(1)'s -f option. Message-ID: <20020516162909.GA96280@hades.hell.gr> References: <20020516123835.GA93447@hades.hell.gr> <20020516235833.S933-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020516235833.S933-100000@gamplex.bde.org> 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 On 2002-05-17 00:35, Bruce Evans wrote: > On Thu, 16 May 2002, Giorgos Keramidas wrote: > > $NetBSD: cat.c,v 1.30 2002/05/09 02:13:10 thorpej Exp $ > > This checks only after the open with fstat(). I agree that using > > fstat() is better. Thanks for pointing this out ;) > > Problems with open() are limited by using the O_NONBLOCK flag in the > -f case, but there can still be problems (open() and/or close() can > have side effects), so I think a stat() should be tried first and > checked later. Side-effects meaning things like the creation of new device nodes in the case of cloning devices, or similar? Hmmm. Relying on stat() to check if a file is a regular file, and then using fstat() to verify this would require something like the following though: struct stat st; int fd; if (stat(pathname, &st) == -1) ... if (S_ISREG(st.st_mode) == 0) ... /* Open the file. */ if (fstat(fd, &st) == -1) ... if (S_ISREG(st.st_mode) == 0) ... This doesn't eliminate the possibility of a race condition, but I have to agree it makes things a bit safer. This can be seen at: http://www.FreeBSD.org/~keramida/diff/2002-05-16.cat,ab > > What is it that makes you think the handling of `i' in the added code > > is bogus? :-/ > > The obfuscated `for' loop wasn't too bad when `i' was incremented in one > place, but `i' is now incremented in 3 places and commented on in two > places. I first noticed the style bug of duplicating the comment. One > comment about a simple increment may be justified because the loop is > obfuscated, but not two. I think I'll turn the while in a for loop too, if this change is made. There is a diff that only changes the while to for at: http://www.FreeBSD.org/~keramida/diff/2002-05-16.cat,ac and a diff both the -f flag part and the while->for change at: http://www.FreeBSD.org/~keramida/diff/2002-05-16.cat,ad I'm more in favour of the ,ad diff, since it looks much better than the rest. Not necessarily as a diff, but as resulting code. -- Giorgos Keramidas - http://www.FreeBSD.org keramida@FreeBSD.org - The Power to Serve To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 10:45:11 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.musha.org (daemon.musha.org [218.44.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 8B1C037B40B; Thu, 16 May 2002 10:45:03 -0700 (PDT) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id 9CEF84D800; Fri, 17 May 2002 02:44:58 +0900 (JST) Date: Fri, 17 May 2002 02:45:00 +0900 Message-ID: <86elgc7zs3.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: audit@FreeBSD.org Cc: current@FreeBSD.org Subject: Re: moused(8): char signed-ness problem with gcc 3.1 In-Reply-To: <86sn4t8fzp.wl@archon.local.idaemons.org> References: <86sn4t8fzp.wl@archon.local.idaemons.org> User-Agent: Wanderlust/2.9.11 (Unchained Melody) SEMI/1.14.3 (Ushinoya) LIMIT/1.14.7 (Fujiidera) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") 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 I've submitted a bug report to GCC GNATS: http://gcc.gnu.org/cgi-bin/gnatsweb.pl?database=gcc&pr=6677&cmd=view+audit-trail Let's see how they handle this. -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 11:43:12 2002 Delivered-To: freebsd-audit@freebsd.org Received: from dragon.nuxi.com (trang.nuxi.com [66.92.13.169]) by hub.freebsd.org (Postfix) with ESMTP id 44A9337B403; Thu, 16 May 2002 11:43:05 -0700 (PDT) Received: from dragon.nuxi.com (obrien@localhost [127.0.0.1]) by dragon.nuxi.com (8.12.3/8.12.2) with ESMTP id g4GIgmfg067811; Thu, 16 May 2002 11:42:48 -0700 (PDT) (envelope-from obrien@dragon.nuxi.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.12.3/8.12.3/Submit) id g4GIglhS067810; Thu, 16 May 2002 11:42:47 -0700 (PDT) Date: Thu, 16 May 2002 11:42:47 -0700 From: "David O'Brien" To: Akinori MUSHA Cc: Bill Fenner , rivers@dignus.com, audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Message-ID: <20020516114247.A67791@dragon.nuxi.com> Reply-To: obrien@FreeBSD.ORG Mail-Followup-To: David O'Brien , Akinori MUSHA , Bill Fenner , rivers@dignus.com, audit@FreeBSD.ORG, current@FreeBSD.ORG References: <200205160346.UAA27116@windsor.research.att.com> <86k7q48h2w.wl@archon.local.idaemons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <86k7q48h2w.wl@archon.local.idaemons.org>; from knu@iDaemons.org on Thu, May 16, 2002 at 08:31:19PM +0900 X-Operating-System: FreeBSD 5.0-CURRENT Organization: The NUXI BSD group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 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, May 16, 2002 at 08:31:19PM +0900, Akinori MUSHA wrote: > > > So - yes - it seems gcc 3.1 does have a problem... > > Indeed - easily determined by breaking down the expression. > > So, who's gonna report it to gcc-bugs? knu?... Specifically what is the problem? Given the program below, take the ISO-C spec and explain the problem. Or even w/o the spec -- I haven't been reading this thread. > > int > > main() > > { > > unsigned char i = 127; > > char j; > > > > printf("%d\n", ((char)(i << 1))); > > j = ((char)(i << 1)) / 2; > > printf("%d\n", j); > > j = ((char)(i << 1)); > > printf("%d\n", j / 2); > > return 0; > > } > > Somehow, specifying -fsigned-char, which I thought was the default, > fixed the problem. So, the cause may be in our configuration of gcc? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 12: 7: 0 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail-blue.research.att.com (mail-blue.research.att.com [135.207.30.102]) by hub.freebsd.org (Postfix) with ESMTP id 3E32437B400; Thu, 16 May 2002 12:06:54 -0700 (PDT) Received: from alliance.research.att.com (alliance.research.att.com [135.207.26.26]) by mail-blue.research.att.com (Postfix) with ESMTP id 8531D4CE67; Thu, 16 May 2002 15:06:50 -0400 (EDT) Received: from windsor.research.att.com (windsor.research.att.com [135.207.26.46]) by alliance.research.att.com (8.8.7/8.8.7) with ESMTP id PAA21556; Thu, 16 May 2002 15:06:49 -0400 (EDT) From: Bill Fenner Received: (from fenner@localhost) by windsor.research.att.com (8.8.8+Sun/8.8.5) id MAA06850; Thu, 16 May 2002 12:06:49 -0700 (PDT) Message-Id: <200205161906.MAA06850@windsor.research.att.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII To: obrien@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Cc: knu@iDaemons.org, audit@FreeBSD.ORG, current@FreeBSD.ORG References: <200205160346.UAA27116@windsor.research.att.com> <86k7q48h2w.wl@archon.local.idaemons.org> <20020516114247.A67791@dragon.nuxi.com> Date: Thu, 16 May 2002 12:06:49 -0700 Versions: dmail (solaris) 2.4/makemail 2.9b 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 >Specifically what is the problem? Given the program below, take the >ISO-C spec and explain the problem. Or even w/o the spec -- I haven't >been reading this thread. > > int > > main() > > { > > unsigned char i = 127; > > char j; > > > > printf("%d\n", ((char)(i << 1))); This prints -2, which is correct -- (signed char)254 is -2. > > j = ((char)(i << 1)) / 2; > > printf("%d\n", j); This prints 127, which is incorrect. -2 / 2 is -1. > > j = ((char)(i << 1)); > > printf("%d\n", j / 2); This breaks down the previous expression into two halves, and results in the correct answer of -1. However, there should be no difference between ((char)(i << 1)) / 2 and char j = ((char)(i << 1); j / 2 Bill To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 12:12: 3 2002 Delivered-To: freebsd-audit@freebsd.org Received: from dragon.nuxi.com (trang.nuxi.com [66.92.13.169]) by hub.freebsd.org (Postfix) with ESMTP id A3CAD37B408; Thu, 16 May 2002 12:11:57 -0700 (PDT) Received: from dragon.nuxi.com (obrien@localhost [127.0.0.1]) by dragon.nuxi.com (8.12.3/8.12.2) with ESMTP id g4GJBvfg068445; Thu, 16 May 2002 12:11:57 -0700 (PDT) (envelope-from obrien@dragon.nuxi.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.12.3/8.12.3/Submit) id g4GJBvdX068444; Thu, 16 May 2002 12:11:57 -0700 (PDT) Date: Thu, 16 May 2002 12:11:57 -0700 From: "David O'Brien" To: Bill Fenner Cc: audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Message-ID: <20020516121157.F67791@dragon.nuxi.com> Reply-To: obrien@FreeBSD.ORG Mail-Followup-To: David O'Brien , Bill Fenner , audit@FreeBSD.ORG, current@FreeBSD.ORG References: <200205160346.UAA27116@windsor.research.att.com> <86k7q48h2w.wl@archon.local.idaemons.org> <20020516114247.A67791@dragon.nuxi.com> <200205161906.MAA06850@windsor.research.att.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200205161906.MAA06850@windsor.research.att.com>; from fenner@research.att.com on Thu, May 16, 2002 at 12:06:49PM -0700 X-Operating-System: FreeBSD 5.0-CURRENT Organization: The NUXI BSD group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 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, May 16, 2002 at 12:06:49PM -0700, Bill Fenner wrote: > >Specifically what is the problem? Given the program below, take the > >ISO-C spec and explain the problem. Or even w/o the spec -- I haven't > >been reading this thread. > > > > int > > > main() > > > { > > > unsigned char i = 127; > > > char j; > > > > > > printf("%d\n", ((char)(i << 1))); > > This prints -2, which is correct -- (signed char)254 is -2. > > > > j = ((char)(i << 1)) / 2; > > > printf("%d\n", j); > > This prints 127, which is incorrect. -2 / 2 is -1. > > > > j = ((char)(i << 1)); > > > printf("%d\n", j / 2); > > This breaks down the previous expression into two halves, and > results in the correct answer of -1. However, there should > be no difference between > ((char)(i << 1)) / 2 > and > char j = ((char)(i << 1); j / 2 Sounds like you should forward this to gcc-bugs@gcc.gnu.org. :-) CC audit@ (and current@) so we can all see what the GNU people say. Don't forget to show the output of `cc -v'. Or run `gccbug' from a recient gcc31 port install. If you do this instead, please send me the PR #. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 12:19:41 2002 Delivered-To: freebsd-audit@freebsd.org Received: from leviathan.inethouston.net (leviathan.inethouston.net [66.64.12.249]) by hub.freebsd.org (Postfix) with ESMTP id 67C6D37B410; Thu, 16 May 2002 12:19:38 -0700 (PDT) Received: by leviathan.inethouston.net (Postfix, from userid 1001) id E89D73198CE; Thu, 16 May 2002 14:19:40 -0500 (CDT) Date: Thu, 16 May 2002 14:19:40 -0500 From: "David W. Chapman Jr." To: David O'Brien Cc: Bill Fenner , audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Message-ID: <20020516191940.GB24893@leviathan.inethouston.net> Reply-To: "David W. Chapman Jr." Mail-Followup-To: David O'Brien , Bill Fenner , audit@FreeBSD.ORG, current@FreeBSD.ORG References: <200205160346.UAA27116@windsor.research.att.com> <86k7q48h2w.wl@archon.local.idaemons.org> <20020516114247.A67791@dragon.nuxi.com> <200205161906.MAA06850@windsor.research.att.com> <20020516121157.F67791@dragon.nuxi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020516121157.F67791@dragon.nuxi.com> User-Agent: Mutt/1.3.99i X-Operating-System: FreeBSD 4.5-STABLE i386 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 > Sounds like you should forward this to gcc-bugs@gcc.gnu.org. :-) > CC audit@ (and current@) so we can all see what the GNU people say. > Don't forget to show the output of `cc -v'. knu has already created a gnats pr with gcc and posted the url. -- David W. Chapman Jr. dwcjr@inethouston.net Raintree Network Services, Inc. dwcjr@freebsd.org FreeBSD Committer To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 13:45:53 2002 Delivered-To: freebsd-audit@freebsd.org Received: from gw.nectar.cc (gw.nectar.cc [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id C8C9937B407 for ; Thu, 16 May 2002 13:45:26 -0700 (PDT) Received: from madman.nectar.cc (madman.nectar.cc [10.0.1.111]) by gw.nectar.cc (Postfix) with ESMTP id 4018955 for ; Thu, 16 May 2002 15:45:26 -0500 (CDT) Received: from madman.nectar.cc (localhost [IPv6:::1]) by madman.nectar.cc (8.12.3/8.11.6) with ESMTP id g4GKjPpd026655 for ; Thu, 16 May 2002 15:45:26 -0500 (CDT) (envelope-from nectar@madman.nectar.cc) Received: (from nectar@localhost) by madman.nectar.cc (8.12.3/8.12.3/Submit) id g4GKjPTf026654 for freebsd-audit@FreeBSD.org; Thu, 16 May 2002 15:45:25 -0500 (CDT) Date: Thu, 16 May 2002 15:45:25 -0500 From: "Jacques A. Vidrine" To: freebsd-audit@FreeBSD.org Subject: Kerberos 5 and SU Message-ID: <20020516204525.GA26640@madman.nectar.cc> Mail-Followup-To: "Jacques A. Vidrine" , freebsd-audit@FreeBSD.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline User-Agent: Mutt/1.3.99i X-Url: http://www.nectar.cc/ 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 --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, Attached are two similar implementations of Kerberos 5 support for su(1). Why two? 1. pam_ksu --- This is the long-term solution, but is only appropriate for -CURRENT. -STABLE does not have OpenPAM, and more importantly does not have a PAMified SU [1]. 2. su --- This is for -STABLE only. Support was added in parallel to the existing Kerberos 4 support. This has made the code even more #ifdef grotty, but it will not be maintained after 4.x anyway. The code path is still straightforward. FYI, the `get_target_principal' functions in each correspond, and the `auth_krb5' function in pam_ksu corresponds with the `kerberos5' function in su(1). Please tear it up :-) I'm gone for the weekend. Cheers, -- Jacques A. Vidrine http://www.nectar.cc/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine@verio.net . nectar@FreeBSD.org . nectar@kth.se [1] DES reports that he currently has no plans to backport the SU PAMificiation. --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="su.patch" Index: Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/su/Makefile,v retrieving revision 1.29 diff -u -r1.29 Makefile --- Makefile 2000/02/24 21:06:21 1.29 +++ Makefile 2002/05/16 20:42:46 @@ -14,10 +14,19 @@ CFLAGS+= -Wall .if exists(${DESTDIR}${LIBDIR}/libkrb.a) && defined(MAKE_KERBEROS4) -CFLAGS+=-DKERBEROS +CFLAGS+=-DKERBEROS4 DPADD+= ${LIBKRB} ${LIBCRYPTO} ${LIBCOM_ERR} LDADD+= -lkrb -lcrypto -lcom_err DISTRIBUTION= krb4 +.endif + +.if exists(${DESTDIR}${LIBDIR}/libkrb5.a) && defined(MAKE_KERBEROS5) +CFLAGS+=-DKERBEROS5 +DPADD+= ${LIBKRB5} ${LIBASN1} ${LIBCRYPTO} ${LIBCRYPT} ${LIBCOM_ERR} \ + ${LIBROKEN} +LDADD+= -lkrb5 -lasn1 -lcrypto -lcrypt -lcom_err \ + -L${.OBJDIR}/../../../../kerberos5/lib/libroken -lroken +DISTRIBUTION= krb5 .endif BINMODE=4555 Index: su.c =================================================================== RCS file: /home/ncvs/src/usr.bin/su/su.c,v retrieving revision 1.34.2.3 diff -u -r1.34.2.3 su.c --- su.c 2001/08/17 15:44:42 1.34.2.3 +++ su.c 2002/05/16 20:42:46 @@ -69,28 +69,42 @@ #include #endif -#ifdef KERBEROS +#ifdef KERBEROS5 +#include +#include + +static long get_target_principal(krb5_context context, const char *user, + const char *ruser, char **su, krb5_principal *suprinc); +static long kerberos5(krb5_context context, krb5_principal suprinc, + const char *pass); + +int use_kerberos5 = 1; +#endif + +#ifdef KERBEROS4 #include #include #include -#ifdef LOGIN_CAP -#define ARGSTR "-Kflmc:" -#else -#define ARGSTR "-Kflm" -#endif -static int kerberos(char *username, char *user, int uid, char *pword); +static int kerberos4(char *username, char *user, int uid, char *pword); static int koktologin(char *name, char *toname); + +int use_kerberos4 = 1; +#endif /* KERBEROS4 */ -int use_kerberos = 1; -#else /* !KERBEROS */ #ifdef LOGIN_CAP -#define ARGSTR "-flmc:" +#define LOGIN_CAP_ARG(x) x #else -#define ARGSTR "-flm" +#define LOGIN_CAP_ARG(x) #endif -#endif /* KERBEROS */ +#if defined(KERBEROS4) || defined(KERBEROS5) +#define KERBEROS_ARG(x) x +#else +#define KERBEROS_ARG(x) +#endif +#define COMMON_ARG(x) x +#define ARGSTR "-" COMMON_ARG("flm") LOGIN_CAP_ARG("c:") KERBEROS_ARG("K") char *ontty __P((void)); int chshell __P((char *)); @@ -118,9 +132,14 @@ char *class=NULL; int setwhat; #endif -#ifdef KERBEROS +#if defined(KERBEROS4) || defined(KERBEROS5) char *k; #endif +#ifdef KERBEROS5 + char *suname, *ccname; + krb5_context context; + krb5_principal suprinc; +#endif char shellbuf[MAXPATHLEN]; #ifdef WHEELSU @@ -130,9 +149,14 @@ user = "root"; while((ch = getopt(argc, argv, ARGSTR)) != -1) switch((char)ch) { -#ifdef KERBEROS +#if defined(KERBEROS4) || defined(KERBEROS5) case 'K': - use_kerberos = 0; +#ifdef KERBEROS4 + use_kerberos4 = 0; +#endif +#ifdef KERBEROS5 + use_kerberos5 = 0; +#endif break; #endif case 'f': @@ -179,10 +203,22 @@ argv += optind; -#ifdef KERBEROS +#if defined(KERBEROS4) || defined(KERBEROS5) k = auth_getval("auth_list"); - if (k && !strstr(k, "kerberos")) - use_kerberos = 0; + if (k && !strstr(k, "kerberos")) { +#ifdef KERBEROS4 + use_kerberos4 = 0; +#endif +#ifdef KERBEROS5 + use_kerberos5 = 0; +#endif + } +#endif +#ifdef KERBEROS5 + suname = NULL; + suprinc = NULL; + if (krb5_init_context(&context) != 0) + use_kerberos5 = 0; #endif errno = 0; prio = getpriority(PRIO_PROCESS, 0); @@ -235,13 +271,23 @@ #endif /* WHEELSU */ if (ruid) { -#ifdef KERBEROS - if (use_kerberos && koktologin(username, user) +#ifdef KERBEROS4 + if (use_kerberos4 && koktologin(username, user) && !pwd->pw_uid) { - warnx("kerberos: not in %s's ACL.", user); - use_kerberos = 0; + warnx("kerberos4: not in %s's ACL.", user); + use_kerberos4 = 0; } #endif +#ifdef KERBEROS5 + if (use_kerberos5) { + if (!(get_target_principal(context, user, username, + &suname, &suprinc) == 0 && + krb5_kuserok(context, suprinc, user))) { + warnx("kerberos5: not in %s's ACL.", user); + use_kerberos5 = 0; + } + } +#endif { /* * Only allow those with pw_gid==0 or those listed in @@ -288,15 +334,23 @@ p = getpass("Password:"); if (strcmp(pwd->pw_passwd, crypt(p, pwd->pw_passwd))) { #endif -#ifdef KERBEROS - if (!use_kerberos || (use_kerberos && kerberos(username, user, pwd->pw_uid, p))) -#endif - { - fprintf(stderr, "Sorry\n"); - syslog(LOG_AUTH|LOG_WARNING, "BAD SU %s to %s%s", username, user, ontty()); - exit(1); - } +#ifdef KERBEROS4 + if (use_kerberos4 && kerberos4(username, user, + pwd->pw_uid, p) == 0) + goto authok; +#endif +#ifdef KERBEROS5 + if (use_kerberos5 && kerberos5(context, + suprinc, p) == 0) + goto authok; +#endif + fprintf(stderr, "Sorry\n"); + syslog(LOG_AUTH|LOG_WARNING, + "BAD SU %s to %s%s", username, user, + ontty()); + exit(1); } + authok: #ifdef WHEELSU if (iswheelsu) { pwd = getpwnam(user); @@ -361,9 +415,12 @@ if (!asme) { if (asthem) { p = getenv("TERM"); -#ifdef KERBEROS +#ifdef KERBEROS4 k = getenv("KRBTKFILE"); #endif +#ifdef KERBEROS5 + ccname = getenv("KRB5CCNAME"); +#endif if ((cleanenv = calloc(20, sizeof(char*))) == NULL) errx(1, "calloc"); cleanenv[0] = NULL; @@ -376,10 +433,14 @@ #endif if (p) (void)setenv("TERM", p, 1); -#ifdef KERBEROS +#ifdef KERBEROS4 if (k) (void)setenv("KRBTKFILE", k, 1); #endif +#ifdef KERBEROS5 + if (ccname) + (void)setenv("KRB5CCNAME", ccname, 1); +#endif if (chdir(pwd->pw_dir) < 0) errx(1, "no directory"); } @@ -413,12 +474,8 @@ static void usage() { - (void)fprintf(stderr, "usage: su [-] %s%s[login [args]]\n", -#ifdef KERBEROS - "[-Kflm] ", -#else - "[-flm] ", -#endif + (void)fprintf(stderr, "usage: su [-] [-%s] %s[login [args]]\n", + KERBEROS_ARG("K") COMMON_ARG("flm"), #ifdef LOGIN_CAP "[-c class] " #else @@ -454,10 +511,146 @@ snprintf(buf, sizeof(buf), " on %s", p); return (buf); } + +#ifdef KERBEROS5 +const char superuser[] = "root"; + +/* Authenticate using Kerberos 5. + * context -- An initialized krb5_context. + * suprinc -- The target krb5_principal. + * pass -- The user's password. + * Note that a valid keytab in the default location with a host entry + * must be available. + * Returns 0 if authentication was successful, or a com_err error code if + * it was not. + */ +static long +kerberos5(krb5_context context, krb5_principal suprinc, const char *pass) +{ + krb5_creds creds; + krb5_get_init_creds_opt gic_opt; + krb5_verify_init_creds_opt vic_opt; + long rv; + + krb5_get_init_creds_opt_init(&gic_opt); + krb5_verify_init_creds_opt_init(&vic_opt); + rv = krb5_get_init_creds_password(context, &creds, suprinc, + pass, NULL, NULL, 0, NULL, &gic_opt); + if (rv != 0) { + syslog(LOG_NOTICE|LOG_AUTH, "BAD Kerberos5 SU: %s", + error_message(rv)); /* XXX */ + return (rv); + } + krb5_verify_init_creds_opt_set_ap_req_nofail(&vic_opt, 1); + rv = krb5_verify_init_creds(context, &creds, NULL, NULL, NULL, + &vic_opt); + krb5_free_cred_contents(context, &creds); + if (rv != 0) { + syslog(LOG_NOTICE|LOG_AUTH, "BAD Kerberos5 SU: %s", + error_message(rv)); /* XXX */ + return (rv); + } + return (0); +} + +/* Determine the target principal given the current user and the target user. + * context -- An initialized krb5_context. + * user -- The target username. + * ruser -- The current username. + * su -- (out) The target principal name. + * suprinc -- (out) The target krb5_principal. + * When the target user is `root', the target principal will be a `root + * instance', e.g. `luser/root@REA.LM'. Otherwise, the target principal + * will simply be the current user's default principal name. Note that + * in any case, if KRB5CCNAME is set and a credentials cache exists, the + * principal name found there will be the `starting point', rather than + * the ruser parameter. + * + * Returns 0 for success, or a com_err error code on failure. + */ +static long +get_target_principal(krb5_context context, const char *user, const char *ruser, + char **su, krb5_principal *suprinc) +{ + krb5_principal princ; + krb5_ccache ccache; + char *unparsed, *p; + long rv; + uid_t euid; + + *suprinc = NULL; + princ = NULL; + /* Unless KRB5CCNAME was explicitly set, we won't really be able + * to look at the credentials cache since krb5_cc_default will + * look at getuid(). + */ + if (getenv("KRB5CCNAME") != NULL) { + /* Lower privs while messing about with the credentials + * cache. + */ + euid = geteuid(); + rv = seteuid(getuid()); + if (rv != 0) + return (errno); + rv = krb5_cc_default(context, &ccache); + if (rv == 0) { + rv = krb5_cc_get_principal(context, ccache, &princ); + krb5_cc_close(context, ccache); + if (rv != 0) + princ = NULL; /* just to be safe */ + } + rv = seteuid(euid); + if (rv != 0) + return (errno); + } + if (princ == NULL) { + rv = krb5_make_principal(context, &princ, NULL, ruser, NULL); + if (rv != 0) { + warnx("Could not determine default principal name."); + return (rv); + } + } + /* Now that we have some principal, if the target account is + * `root', then transform it into a `root' instance, e.g. + * `user@REA.LM' -> `user/root@REA.LM'. + */ + rv = krb5_unparse_name(context, princ, &unparsed); + krb5_free_principal(context, princ); + if (rv != 0) { + warnx("krb5_unparse_name: %s", error_message(rv)); + return (rv); + } + if (strcmp(user, superuser) == 0) { + p = strrchr(unparsed, '@'); + if (p == NULL) { + warnx("malformed principal name `%s'", unparsed); + free(unparsed); + return (rv); + } + *p++ = '\0'; + *su = NULL; + (void)asprintf(su, "%s/%s@%s", unparsed, superuser, p); + free(unparsed); + } else + *su = unparsed; + + if (*su == NULL) + return errno; + rv = krb5_parse_name(context, *su, &princ); + if (rv != 0) { + warnx("krb5_parse_name `%s': %s", *su, error_message(rv)); + free(*su); + return (rv); + } + *suprinc = princ; + return 0; +} + +#endif -#ifdef KERBEROS +#ifdef KERBEROS4 int -kerberos(username, user, uid, pword) +kerberos4(username, user, uid, pword) char *username, *user; int uid; char *pword; @@ -503,14 +696,14 @@ if (kerno != KSUCCESS) { if (kerno == KDC_PR_UNKNOWN) { - warnx("kerberos: principal unknown: %s.%s@%s", + warnx("kerberos4: principal unknown: %s.%s@%s", (uid == 0 ? username : user), (uid == 0 ? "root" : ""), lrealm); return (1); } - warnx("kerberos: unable to su: %s", krb_err_txt[kerno]); + warnx("kerberos4: unable to su: %s", krb_err_txt[kerno]); syslog(LOG_NOTICE|LOG_AUTH, - "BAD Kerberos SU: %s to %s%s: %s", + "BAD Kerberos4 SU: %s to %s%s: %s", username, user, ontty(), krb_err_txt[kerno]); return (1); } @@ -556,7 +749,7 @@ if ((kerno = krb_rd_req(&ticket, "rcmd", savehost, faddr, &authdata, "")) != KSUCCESS) { - warnx("kerberos: unable to verify rcmd ticket: %s\n", + warnx("kerberos4: unable to verify rcmd ticket: %s\n", krb_err_txt[kerno]); syslog(LOG_NOTICE|LOG_AUTH, "failed su: %s to %s%s: %s", username, --dDRMvlgZJXvWKvBx Content-Type: application/x-shar Content-Disposition: attachment; filename="pam_ksu.shar" Content-Transfer-Encoding: quoted-printable # This is a shell archive. Save it in a file, remove anything before=0A# t= his line, and then unpack it by entering "sh file". Note, it may=0A# creat= e directories; files and directories will be owned by you and=0A# have defa= ult permissions.=0A#=0A# This archive contains:=0A#=0A# pam_ksu=0A# pam_ksu= /Makefile=0A# pam_ksu/pam_ksu.8=0A# pam_ksu/pam_ksu.c=0A#=0Aecho c - pam_ks= u=0Amkdir -p pam_ksu > /dev/null 2>&1=0Aecho x - pam_ksu/Makefile=0Ased 's/= ^X//' >pam_ksu/Makefile << 'END-of-pam_ksu/Makefile'=0AX# Copyright 2002 Fr= eeBSD, Inc.=0AX# All rights reserved.=0AX#=0AX# Redistribution and use in s= ource and binary forms, with or without=0AX# modification, are permitted pr= ovided that the following conditions=0AX# are met:=0AX# 1. Redistributions = of source code must retain the above copyright=0AX# notice, this list of= conditions and the following disclaimer.=0AX# 2. Redistributions in binary= form must reproduce the above copyright=0AX# notice, this list of condi= tions and the following disclaimer in the=0AX# documentation and/or othe= r materials provided with the distribution.=0AX#=0AX# THIS SOFTWARE IS PROV= IDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND=0AX# ANY EXPRESS OR IMPLI= ED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE=0AX# IMPLIED WARRANTIES O= F MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE=0AX# ARE DISCLAIMED.= IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE=0AX# FOR ANY DIREC= T, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL=0AX# DAMAGES = (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS=0AX# OR SER= VICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)=0AX# HOWEVE= R CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT=0AX# L= IABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY=0A= X# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF= =0AX# SUCH DAMAGE.=0AX#=0AX# $FreeBSD: src/lib/libpam/modules/pam_krb5/Make= file,v 1.2.2.3 2001/07/30 10:03:58 markm Exp $=0AX=0AXPAMDIR=3D ${.CURDIR}= /../../../../contrib/libpam=0AX=0AXLIB=3D pam_ksu=0AXSRCS=3D pam_ksu.c=0A= XCFLAGS+=3D -Wall=0AXCFLAGS+=3D -I${PAMDIR}/libpam/include=0AXCFLAGS+=3D -I= ${.CURDIR}/../../libpam=0AXDPADD=3D ${LIBKRB5} ${LIBASN1} ${LIBCRYPTO} ${L= IBCRYPT} \=0AX ${LIBCOM_ERR} ${LIBROKEN}=0AXLDADD=3D -lkrb5 -lasn1 -lcryp= to -lcrypt -lcom_err \=0AX -L${.OBJDIR}/../../../../kerberos5/lib/libroken= -lroken =0AXMAN=3D pam_ksu.8=0AX#INTERNALLIB=3D yes=0AX#INTERNALSTATICLIB= =3Dyes=0AX=0AX.include =0AEND-of-pam_ksu/Makefile=0Aecho x - pa= m_ksu/pam_ksu.8=0Ased 's/^X//' >pam_ksu/pam_ksu.8 << 'END-of-pam_ksu/pam_ks= u.8'=0AX.\" Copyright (c) 2001 Mark R V Murray=0AX.\" All rights reserved.= =0AX.\" Copyright (c) 2001 Networks Associates Technology, Inc.=0AX.\" All = rights reserved.=0AX.\"=0AX.\" This software was developed for the FreeBSD = Project by ThinkSec AS and=0AX.\" NAI Labs, the Security Research Division = of Network Associates, Inc.=0AX.\" under DARPA/SPAWAR contract N66001-01-C-= 8035 ("CBOSS"), as part of the=0AX.\" DARPA CHATS research program.=0AX.\"= =0AX.\" Redistribution and use in source and binary forms, with or without= =0AX.\" modification, are permitted provided that the following conditions= =0AX.\" are met:=0AX.\" 1. Redistributions of source code must retain the a= bove copyright=0AX.\" notice, this list of conditions and the following = disclaimer.=0AX.\" 2. Redistributions in binary form must reproduce the abo= ve copyright=0AX.\" notice, this list of conditions and the following di= sclaimer in the=0AX.\" documentation and/or other materials provided wit= h the distribution.=0AX.\" 3. The name of the author may not be used to end= orse or promote=0AX.\" products derived from this software without speci= fic prior written=0AX.\" permission.=0AX.\"=0AX.\" THIS SOFTWARE IS PROV= IDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND=0AX.\" ANY EXPRESS OR IMP= LIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE=0AX.\" IMPLIED WARRANTI= ES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE=0AX.\" ARE DISCL= AIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE=0AX.\" FOR A= NY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL=0AX.\= " DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS= =0AX.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTIO= N)=0AX.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRAC= T, STRICT=0AX.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARI= SING IN ANY WAY=0AX.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF = THE POSSIBILITY OF=0AX.\" SUCH DAMAGE.=0AX.\"=0AX.\" $FreeBSD$=0AX.\"=0AX.D= d May 15, 2002=0AX.Dt pam_ksu 8=0AX.Os=0AX.Sh NAME=0AX.Nm pam_ksu=0AX.Nd Ke= rberos 5 SU PAM module=0AX.Sh SYNOPSIS=0AX.Op Ar service-name=0AX.Ar module= -type=0AX.Ar control-flag=0AX.Pa pam_ksu=0AX.Op Ar options=0AX.Sh DESCRIPTI= ON=0AXThe Kerberos 5 SU authentication service module for PAM,=0AX.Nm=0AXfo= r only one PAM category: authentication.=0AXIn terms of the=0AX.Ar module-t= ype=0AXparameter, this is the=0AX.Dq Li auth=0AXfeature.=0AXThe module is s= pecifically designed to be used with the=0AX.Xr su 1=0AXutility.=0AX.\" It = also provides a null function for session management.=0AX.Ss Kerberos 5 SU = Authentication Module=0AXThe Kerberos 5 SU authentication component provide= s functions to verify=0AXthe identity of a user=0AX.Pq Fn pam_sm_authentica= te ,=0AXand determine whether or not the user is authorized to obtain the= =0AXprivileges of the target account.=0AXIf the target account is `root', t= hen the Kerberos 5 principal used=0AXfor authentication and authorization w= ill be the `root' instance of=0AXthe current user, e.g. `user/root@REAL.M'.= =0AXOtherwise, the principal will simply be the current user's default=0AXp= rincipal, e.g. `user@REAL.M'.=0AX.Pp=0AXThe user is prompted for a password= if necessary. Authorization is performed=0AXby comparing the Kerberos 5 p= rincipal with those listed in the=0AX.Pa .k5login=0AXfile in the target acc= ount's home directory=0AX.Pq e.g. /root/.k5login for root .=0AX.Pp=0AXThe f= ollowing options may be passed to the authentication module:=0AX.Bl -tag -w= idth ".Cm use_first_pass"=0AX.It Cm debug=0AX.Xr syslog 3=0AXdebugging info= rmation at=0AX.Dv LOG_DEBUG=0AXlevel.=0AX.It Cm use_first_pass=0AXIf the au= thentication module=0AXis not the first in the stack,=0AXand a previous mod= ule=0AXobtained the user's password,=0AXthat password is used=0AXto authent= icate the user.=0AXIf this fails,=0AXthe authentication module returns fail= ure=0AXwithout prompting the user for a password.=0AXThis option has no eff= ect=0AXif the authentication module=0AXis the first in the stack,=0AXor if = no previous modules=0AXobtained the user's password.=0AX.It Cm try_first_pa= ss=0AXThis option is similar to the=0AX.Cm use_first_pass=0AXoption,=0AXexc= ept that if the previously obtained password fails,=0AXthe user is prompted= for another password.=0AX.El=0AX.Sh SEE ALSO=0AX.Xr su 1 ,=0AX.Xr syslog 3= ,=0AX.Xr pam.conf 5 ,=0AX.Xr pam 8=0AEND-of-pam_ksu/pam_ksu.8=0Aecho x - p= am_ksu/pam_ksu.c=0Ased 's/^X//' >pam_ksu/pam_ksu.c << 'END-of-pam_ksu/pam_k= su.c'=0AX/*-=0AX * Copyright (c) 2002 Jacques A. Vidrine =0AX * All rights reserved.=0AX *=0AX * Redistribution and use in source = and binary forms, with or without=0AX * modification, are permitted provide= d that the following conditions=0AX * are met:=0AX * 1. Redistributions of = source code must retain the above copyright=0AX * notice, this list of c= onditions and the following disclaimer.=0AX * 2. Redistributions in binary = form must reproduce the above copyright=0AX * notice, this list of condi= tions and the following disclaimer in the=0AX * documentation and/or oth= er materials provided with the distribution.=0AX *=0AX * THIS SOFTWARE IS P= ROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND=0AX * ANY EXPRESS OR I= MPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE=0AX * IMPLIED WARRANT= IES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE=0AX * ARE DISCL= AIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE=0AX * FOR AN= Y DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL=0AX * = DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS=0AX= * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)=0A= X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT=0AX * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN= ANY WAY=0AX * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSS= IBILITY OF=0AX * SUCH DAMAGE.=0AX */=0AX#include =0AX__FBSDID(= "$FreeBSD$");=0AX=0AX#include =0AX#include =0AX#inc= lude =0AX#include =0AX#include =0AX#include =0AX#include =0AX=0AX#include =0AX=0AX#define PAM_= SM_AUTH=0AX#define PAM_SM_CRED=0AX#include =0AX#includ= e =0AX#include =0AX=0AXsta= tic const char superuser[] =3D "root";=0AX=0AXstatic long get_target_princi= pal(krb5_context, const char *, const char *,=0AX char **su, krb5_prin= cipal *);=0AXstatic int auth_krb5(pam_handle_t *, krb5_context, const char = *,=0AX krb5_principal);=0AX=0AXstatic struct opttab other_options[] = =3D {=0AX { NULL, 0 }=0AX};=0AX=0AX=0AXPAM_EXTERN int=0AXpam_sm_authenticat= e(pam_handle_t *pamh, int flags __unused, int ac __unused,=0AX const cha= r *av[] __unused)=0AX{=0AX struct options options;=0AX krb5_context conte= xt;=0AX krb5_principal suprinc;=0AX const char *user, *ruser;=0AX char *s= u;=0AX long rv;=0AX int pamret;=0AX =0AX pam_std_option(&options, other= _options, ac, av);=0AX PAM_LOG("pam_ksu: Options processed");=0AX pamret = =3D pam_get_user(pamh, &user, NULL);=0AX if (pamret !=3D PAM_SUCCESS)=0AX = return (pamret);=0AX PAM_LOG("Got user: %s", user);=0AX pamret =3D pam_get_= item(pamh, PAM_RUSER, (const void **)&ruser);=0AX if (pamret !=3D PAM_SUCCE= SS)=0AX return (pamret);=0AX PAM_LOG("Got ruser: %s", ruser);=0AX rv =3D k= rb5_init_context(&context);=0AX if (rv !=3D 0) {=0AX PAM_LOG("krb5_init_co= ntext failed: %s", error_message(rv));=0AX return (PAM_SERVICE_ERR);=0AX }= =0AX rv =3D get_target_principal(context, user, ruser, &su, &suprinc);=0AX = if (rv !=3D 0)=0AX return (PAM_AUTH_ERR);=0AX PAM_LOG("kuserok: %s -> %s",= su, user);=0AX rv =3D krb5_kuserok(context, suprinc, user);=0AX pamret =3D= rv ? auth_krb5(pamh, context, su, suprinc) : PAM_AUTH_ERR;=0AX free(su);= =0AX krb5_free_principal(context, suprinc);=0AX krb5_free_context(context);= =0AX return (pamret);=0AX}=0AX=0AXPAM_EXTERN int=0AXpam_sm_setcred(pam_hand= le_t *pamh __unused, int flags __unused,=0AX int ac __unused, const char= *av[] __unused)=0AX{=0AX return (PAM_SUCCESS);=0AX}=0AX=0AX/* Authenticate= using Kerberos 5.=0AX * pamh -- The PAM handle.=0AX * context -- An= initialized krb5_context.=0AX * su -- The target principal name, us= ed only for password prompts.=0AX * If NULL, the password prom= pts will not include a principal=0AX * name.=0AX * suprinc -= - The target krb5_principal.=0AX * Note that a valid keytab in the default = location with a host entry=0AX * must be available, and that the PAM applic= ation must have sufficient=0AX * privileges to access it.=0AX * Returns PAM= _SUCCESS if authentication was successful, or an appropriate=0AX * PAM erro= r code if it was not.=0AX */=0AXstatic int=0AXauth_krb5(pam_handle_t *pamh,= krb5_context context, const char *su,=0AX krb5_principal suprinc)=0AX{= =0AX krb5_creds creds;=0AX krb5_get_init_creds_opt gic_opt;=0AX krb5_verif= y_init_creds_opt vic_opt;=0AX const char *pass;=0AX char *prompt;=0AX long= rv;=0AX int pamret;=0AX=0AX prompt =3D NULL;=0AX krb5_get_init_creds_o= pt_init(&gic_opt);=0AX krb5_verify_init_creds_opt_init(&vic_opt);=0AX if (s= u !=3D NULL)=0AX (void)asprintf(&prompt, "Password for %s:", su);=0AX else= =0AX (void)asprintf(&prompt, "Password:");=0AX if (prompt =3D=3D NULL)=0AX= return (PAM_BUF_ERR);=0AX pass =3D NULL;=0AX (void)pam_get_item(pamh, PAM= _AUTHTOK, (const void **)&pass);=0AX free(prompt);=0AX if (pass =3D=3D NULL= ) {=0AX pamret =3D pam_get_authtok(pamh, PAM_AUTHTOK, &pass, prompt);=0AX = if (pamret !=3D PAM_SUCCESS)=0AX return (pamret);=0AX }=0AX rv =3D krb5_= get_init_creds_password(context, &creds, suprinc,=0AX pass, NULL, NULL,= 0, NULL, &gic_opt);=0AX if (rv !=3D 0) {=0AX PAM_LOG("krb5_get_init_creds= _password: %s", error_message(rv));=0AX return (PAM_AUTH_ERR);=0AX }=0AX k= rb5_verify_init_creds_opt_set_ap_req_nofail(&vic_opt, 1);=0AX rv =3D krb5_v= erify_init_creds(context, &creds, NULL, NULL, NULL,=0AX &vic_opt);=0AX = krb5_free_cred_contents(context, &creds);=0AX if (rv !=3D 0) {=0AX PAM_LOG= ("krb5_verify_init_creds: %s", error_message(rv));=0AX return (PAM_AUTH_ER= R);=0AX }=0AX return (PAM_SUCCESS);=0AX}=0AX=0AX/* Determine the target pri= ncipal given the current user and the target user.=0AX * context -- An in= itialized krb5_context.=0AX * user -- The target username.=0AX * rus= er -- The current username.=0AX * su -- (out) The target principal= name.=0AX * suprinc -- (out) The target krb5_principal.=0AX * When the t= arget user is `root', the target principal will be a `root=0AX * instance',= e.g. `luser/root@REA.LM'. Otherwise, the target principal=0AX * will simp= ly be the current user's default principal name. Note that=0AX * in any ca= se, if KRB5CCNAME is set and a credentials cache exists, the=0AX * principa= l name found there will be the `starting point', rather than=0AX * the ruse= r parameter.=0AX *=0AX * Returns 0 for success, or a com_err error code on = failure.=0AX */=0AXstatic long=0AXget_target_principal(krb5_context context= , const char *user, const char *ruser,=0AX char **su, krb5_principal *su= princ)=0AX{=0AX krb5_principal princ;=0AX krb5_ccache ccache;=0AX char *= unparsed, *p;=0AX long rv;=0AX uid_t euid;=0AX=0AX *suprinc =3D NULL;= =0AX princ =3D NULL;=0AX /* Unless KRB5CCNAME was explicitly set, we won't = really be able=0AX * to look at the credentials cache since krb5_cc_defaul= t will=0AX * look at getuid().=0AX */=0AX if (getenv("KRB5CCNAME") !=3D N= ULL) {=0AX /* Lower privs while messing about with the credentials=0AX *= cache.=0AX */=0AX euid =3D geteuid();=0AX rv =3D seteuid(getuid());=0A= X if (rv !=3D 0)=0AX return (errno);=0AX rv =3D krb5_cc_default(context= , &ccache);=0AX if (rv =3D=3D 0) {=0AX rv =3D krb5_cc_get_principal(cont= ext, ccache, &princ);=0AX krb5_cc_close(context, ccache);=0AX if (rv != =3D 0)=0AX princ =3D NULL; /* just to be safe */=0AX }=0AX rv =3D sete= uid(euid);=0AX if (rv !=3D 0)=0AX return (errno);=0AX }=0AX if (princ = =3D=3D NULL) {=0AX rv =3D krb5_make_principal(context, &princ, NULL, ruser= , NULL);=0AX if (rv !=3D 0) {=0AX PAM_LOG("Could not determine default p= rincipal name.");=0AX return (rv);=0AX }=0AX }=0AX /* Now that we have s= ome principal, if the target account is=0AX * `root', then transform it in= to a `root' instance, e.g.=0AX * `user@REA.LM' -> `user/root@REA.LM'.=0AX = */=0AX rv =3D krb5_unparse_name(context, princ, &unparsed);=0AX krb5_free_= principal(context, princ);=0AX if (rv !=3D 0) {=0AX PAM_LOG("krb5_unparse_= name: %s", error_message(rv));=0AX return (rv);=0AX }=0AX PAM_LOG("Default= principal name: %s", unparsed);=0AX if (strcmp(user, superuser) =3D=3D 0) = {=0AX p =3D strrchr(unparsed, '@');=0AX if (p =3D=3D NULL) {=0AX PAM_LO= G("malformed principal name `%s'", unparsed);=0AX free(unparsed);=0AX r= eturn (rv);=0AX }=0AX *p++ =3D '\0';=0AX *su =3D NULL;=0AX (void)asprin= tf(su, "%s/%s@%s", unparsed, superuser, p);=0AX free(unparsed);=0AX } else= =0AX *su =3D unparsed;=0AX=0AX if (*su =3D=3D NULL)=0AX return errno;=0A= X rv =3D krb5_parse_name(context, *su, &princ);=0AX if (rv !=3D 0) {=0AX P= AM_LOG("krb5_parse_name `%s': %s", *su, error_message(rv));=0AX free(*su);= =0AX return (rv);=0AX }=0AX PAM_LOG("Target principal name: %s", *su);=0AX= *suprinc =3D princ;=0AX return 0;=0AX}=0AEND-of-pam_ksu/pam_ksu.c=0Aexit= =0A=0A --dDRMvlgZJXvWKvBx-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 16 14:14:26 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.k12us.com (mail.k12us.com [65.112.222.15]) by hub.freebsd.org (Postfix) with SMTP id 083A037B404 for ; Thu, 16 May 2002 14:14:22 -0700 (PDT) Received: (qmail 24090 invoked by uid 1001); 16 May 2002 21:14:13 -0000 Date: Thu, 16 May 2002 17:14:13 -0400 From: Christopher Weimann To: Thomas David Rivers Cc: tlambert2@mindspring.com, audit@FreeBSD.ORG, current@FreeBSD.ORG, fenner@research.att.com, knu@iDaemons.org Subject: Re: moused(8): char signed-ness problem with gcc 3.1 Message-ID: <20020516171413.B61691@mail.k12us.com> References: <3CE33321.B2FBD340@mindspring.com> <200205161047.g4GAldU47929@lakes.dignus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200205161047.g4GAldU47929@lakes.dignus.com>; from rivers@dignus.com on Thu, May 16, 2002 at 06:47:39AM -0400 X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.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, May 16, 2002 at 06:47:39AM -0400, Thomas David Rivers wrote: > > Terry Lambert wrote: > > RS/6000's didn't used to use PPC processors at all; so it's > > probably intentional software compatability. > > I'm confused then - the one we have here seems to. There > was a version of something very RS/6000-like that didn't, > but I thought RS/6000s did... > RS/6000s used to use Power before there was PowerPC. I'm doubting there is much difference between the two from a software point of view. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message