From owner-freebsd-standards@FreeBSD.ORG Tue Sep 25 18:46:55 2007 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 339F816A41A for ; Tue, 25 Sep 2007 18:46:55 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [210.51.165.229]) by mx1.freebsd.org (Postfix) with ESMTP id 99E4F13C44B for ; Tue, 25 Sep 2007 18:46:54 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from localhost (tarsier.geekcn.org [210.51.165.229]) by tarsier.geekcn.org (Postfix) with ESMTP id 08286EB79B0; Wed, 26 Sep 2007 02:31:11 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([210.51.165.229]) by localhost (mail.geekcn.org [210.51.165.229]) (amavisd-new, port 10024) with ESMTP id 2xNT3izfmzjW; Wed, 26 Sep 2007 02:30:59 +0800 (CST) Received: from LI-Xins-MacBook.local (71.5.7.139.ptr.us.xo.net [71.5.7.139]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTP id 6A7BFEB7995; Wed, 26 Sep 2007 02:30:58 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:subject:references:in-reply-to:x-enigmail-version:openpgp:content-type; b=YPxvcEDiBiBuEpr9dsfMos+J/PZGm2kPYUOEZuBKeGLpXXKh+m3rhY/upyjNRKU1h WCX4d3HKsKqP4hkVhZwUg== Message-ID: <46F953C4.1030707@delphij.net> Date: Tue, 25 Sep 2007 11:30:28 -0700 From: LI Xin Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: freebsd-stable@FreeBSD.ORG, torfinn.ingolfsen@broadpark.no References: <200709251743.l8PHhvlP012244@lurza.secnetix.de> In-Reply-To: <200709251743.l8PHhvlP012244@lurza.secnetix.de> X-Enigmail-Version: 0.95.3 OpenPGP: url=http://www.delphij.net/delphij.asc Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig75FE4668FDDB8DE1C013E831" X-Mailman-Approved-At: Wed, 26 Sep 2007 12:40:36 +0000 Cc: Subject: Re: rm(1) bug, possibly serious X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Sep 2007 18:46:55 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig75FE4668FDDB8DE1C013E831 Content-Type: multipart/mixed; boundary="------------000106020508020706020709" This is a multi-part message in MIME format. --------------000106020508020706020709 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I think this is a bug, here is a fix obtained from NetBSD. The reasoning (from NetBSD's rm.c,v 1.16): Strip trailing slashes of operands in checkdot(). POSIX.2 requires that if "." or ".." are specified as the basename portion of an operand, a diagnostic message be written to standard error, etc. We strip the slashes because POSIX.2 defines basename as the final portion of a pathname after trailing slashes have been removed. This also makes rm "perform actions equivalent to" the POSIX.1 rmdir() and unlink() functions when removing directories and files, even when they do not follow POSIX.1's pathname resolution semantics (which require trailing slashes be ignored). If nobody complains about this I will request for commit approval from re= @. Cheers, --=20 Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! --------------000106020508020706020709 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="rm-posix.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="rm-posix.diff" Index: rm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/bin/rm/rm.c,v retrieving revision 1.58 diff -u -p -r1.58 rm.c --- rm.c 31 Oct 2006 02:22:36 -0000 1.58 +++ rm.c 25 Sep 2007 18:26:52 -0000 @@ -558,6 +558,14 @@ check2(char **argv) return (first =3D=3D 'y' || first =3D=3D 'Y'); } =20 +/* + * POSIX.2 requires that if "." or ".." are specified as the basename + * portion of an operand, a diagnostic message be written to standard + * error and nothing more be done with such operands. + * + * Since POSIX.2 defines basename as the final portion of a path after + * trailing slashes have been removed, we'll remove them here. + */ #define ISDOT(a) ((a)[0] =3D=3D '.' && (!(a)[1] || ((a)[1] =3D=3D '.' &&= !(a)[2]))) void checkdot(char **argv) @@ -567,10 +575,17 @@ checkdot(char **argv) =20 complained =3D 0; for (t =3D argv; *t;) { + /* strip trailing slashes */ + p =3D strrchr(*t, '\0'); + while (--p > *t && *p =3D=3D '/') + *p =3D '\0'; + + /* extract basename */ if ((p =3D strrchr(*t, '/')) !=3D NULL) ++p; else p =3D *t; + if (ISDOT(p)) { if (!complained++) warnx("\".\" and \"..\" may not be removed"); --------------000106020508020706020709-- --------------enig75FE4668FDDB8DE1C013E831 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG+VPFOfuToMruuMARCg5cAJ4o9qjqfuupAuXj4Zl2/E5qdxGXHQCgi68U E9tNjSg+Y83rzdt3HU+mh5g= =tjXg -----END PGP SIGNATURE----- --------------enig75FE4668FDDB8DE1C013E831--