From owner-freebsd-questions@FreeBSD.ORG Sun Aug 30 08:07:25 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AEED7106566B for ; Sun, 30 Aug 2009 08:07:25 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 3EFD08FC1A for ; Sun, 30 Aug 2009 08:07:25 +0000 (UTC) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id n7U87HNo014396; Sun, 30 Aug 2009 09:07:18 +0100 (BST) (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.8.3 smtp.infracaninophile.co.uk n7U87HNo014396 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1251619638; bh=iICdzuNe44EiUe7JFm67YGBltvH/W3kfQVcbjlOvQWU=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Cc:Content-Type:Date:From:In-Reply-To: Message-ID:Mime-Version:References:To; z=Message-ID:=20<4A9A332F.8070300@infracaninophile.co.uk>|Date:=20S un,=2030=20Aug=202009=2009:07:11=20+0100|From:=20Matthew=20Seaman= 20|Organization:=20Infracaninophi le|User-Agent:=20Thunderbird=202.0.0.23=20(X11/20090823)|MIME-Vers ion:=201.0|To:=20perryh@pluto.rain.com|CC:=20rwmaillists@googlemai l.com,=20freebsd-questions@freebsd.org|Subject:=20Re:=20SUID=20per mission=20on=20Bash=20script|References:=20=09<87y6p4pbd0.fsf@kobe.lapto p>=09<20090829022431.5841d4de@gumby.homeunix.com>=09<4A98A8A1.7070 305@prgmr.com>=09<4a98d375.W9fcoTOIN1DqRk/3%perryh@pluto.rain.com> =09<20090829134436.4461d8c9@gumby.homeunix.com>=20<4a9a0627.zA4OPJ f/w06lQj0a%perryh@pluto.rain.com>|In-Reply-To:=20<4a9a0627.zA4OPJf /w06lQj0a%perryh@pluto.rain.com>|X-Enigmail-Version:=200.95.6|Cont ent-Type:=20multipart/signed=3B=20micalg=3Dpgp-sha256=3B=0D=0A=20p rotocol=3D"application/pgp-signature"=3B=0D=0A=20boundary=3D"----- -------enig7D43180CF0BC19960A8DF5C3"; b=s9ZZydnPGqPhqy2WSB8uXVdT+/5fbYUN5BIf2s4GkM66cLEF3PJJLzkeQTBayI64s 036CXH99r+C382S+D+SmuDrNkFBh35iDIRRhtc8y/qnHd0FfCDAd06r8Bn3P55Ferk +ADcM3pXQsZd3B1IcEHvdzWxh6TTgqSNjlX4YsJw= X-Authentication-Warning: happy-idiot-talk.infracaninophile.co.uk: Host localhost [IPv6:::1] claimed to be happy-idiot-talk.infracaninophile.co.uk Message-ID: <4A9A332F.8070300@infracaninophile.co.uk> Date: Sun, 30 Aug 2009 09:07:11 +0100 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.23 (X11/20090823) MIME-Version: 1.0 To: perryh@pluto.rain.com References: <87y6p4pbd0.fsf@kobe.laptop> <20090829022431.5841d4de@gumby.homeunix.com> <4A98A8A1.7070305@prgmr.com> <4a98d375.W9fcoTOIN1DqRk/3%perryh@pluto.rain.com> <20090829134436.4461d8c9@gumby.homeunix.com> <4a9a0627.zA4OPJf/w06lQj0a%perryh@pluto.rain.com> In-Reply-To: <4a9a0627.zA4OPJf/w06lQj0a%perryh@pluto.rain.com> X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig7D43180CF0BC19960A8DF5C3" X-Virus-Scanned: clamav-milter 0.95.2 at happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: rwmaillists@googlemail.com, freebsd-questions@freebsd.org Subject: Re: SUID permission on Bash script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Aug 2009 08:07:25 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig7D43180CF0BC19960A8DF5C3 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable perryh@pluto.rain.com wrote: > RW wrote: >> On Sat, 29 Aug 2009 00:06:29 -0700 >> perryh@pluto.rain.com wrote: >>> Actually, absent some careful cooperation between the >>> kernel and the interpreter to prevent a race condition ... >> isn't that the same issue that Matthew Seaman was saying >> was fixed years ago ... and is described in the follow-up: >> http://www.mail-archive.com/freebsd-questions@freebsd.org/msg185145.ht= ml >> >> That's entirely in the kernel, it doesn't require interpreter >> support. >=20 > Er, I'm pretty sure it _does_ require support in the interpreter. >=20 > It would do no good for the kernel to hand the interpreter an open > descriptor if the interpreter did not somehow know to read the > script from that open descriptor instead of opening the script file > by name. This approach is exactly the "careful cooperation between > the kernel and the interpreter" that I was referring to. Errr -- no. That's what fdescfs(5) is for. When the kernel execs=20 the interpreter, it tells the script to open /dev/fd/5 (for example) and doing that just connects the script to the open file descriptor the kernel used previously to taste the magic number and the #! line=20 of the script. As fdescfs(5) says: [...] the call: fd =3D open("/dev/fd/0", mode); and the call: fd =3D fcntl(0, F_DUPFD, 0); are equivalent. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enig7D43180CF0BC19960A8DF5C3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAkqaMzUACgkQ8Mjk52CukIzwDQCfR5dUD0TcnPPGzsW93ImEff6t SqsAni19AbAwlF3WLpTlxk4VO2aMEwCW =lhjq -----END PGP SIGNATURE----- --------------enig7D43180CF0BC19960A8DF5C3--