From owner-freebsd-questions@FreeBSD.ORG Sat Aug 29 03:18:39 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 009D6106566C for ; Sat, 29 Aug 2009 03:18:39 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from poseidon.ceid.upatras.gr (poseidon.ceid.upatras.gr [150.140.141.169]) by mx1.freebsd.org (Postfix) with ESMTP id 6F2D48FC1F for ; Sat, 29 Aug 2009 03:18:38 +0000 (UTC) Received: from mail.ceid.upatras.gr (unknown [10.1.0.143]) by poseidon.ceid.upatras.gr (Postfix) with ESMTP id A0AB2EB4EE9; Sat, 29 Aug 2009 06:18:37 +0300 (EEST) Received: from localhost (europa.ceid.upatras.gr [127.0.0.1]) by mail.ceid.upatras.gr (Postfix) with ESMTP id 95FF245088; Sat, 29 Aug 2009 06:18:37 +0300 (EEST) X-Virus-Scanned: amavisd-new at ceid.upatras.gr Received: from mail.ceid.upatras.gr ([127.0.0.1]) by localhost (europa.ceid.upatras.gr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MyGtM4wK9RF0; Sat, 29 Aug 2009 06:18:37 +0300 (EEST) Received: from kobe.laptop (adsl42-116.kln.forthnet.gr [77.49.169.116]) by mail.ceid.upatras.gr (Postfix) with ESMTP id 52E834503F; Sat, 29 Aug 2009 06:18:37 +0300 (EEST) Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id n7T3Ia7G021871 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 29 Aug 2009 06:18:36 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id n7T3IYvB021870; Sat, 29 Aug 2009 06:18:35 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: rwmaillists@googlemail.com References: <87y6p4pbd0.fsf@kobe.laptop> <20090829022431.5841d4de@gumby.homeunix.com> Date: Sat, 29 Aug 2009 06:18:34 +0300 In-Reply-To: <20090829022431.5841d4de@gumby.homeunix.com> (RW's message of "Sat, 29 Aug 2009 02:24:31 +0100") Message-ID: <8763c7gved.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: 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: Sat, 29 Aug 2009 03:18:39 -0000 On Sat, 29 Aug 2009 02:24:31 +0100, RW wrote: >On Fri, 28 Aug 2009 11:54:19 +0300 Giorgos Keramidas wrote: >>On Fri, 28 Aug 2009 09:24:35 +0100, Jeronimo Calvo wrote: >>> As far as i know, using SUID, script must runs with root >>> permissions... so i shoudnt get "Permission denied", what im doing >>> wrong?? >> >> No it must not. There are security reasons why shell scripts are not >> setuid-capable. You can find some of them in the archives of the >> mailing list, going back at least until 1997. > > I'm bit puzzled by this, previous threads have given the impression > that this is a myth, for example: > > http://www.mail-archive.com/freebsd-questions@freebsd.org/msg185134.html > > So are scripts actually incapable of running setuid? If you hack at the kernel it may still be possible to run a script with setuid or setgid permissions. IMO there is still the possibility for many things to go wrong, especially with "quick and dirty" scripts. For example, what do you think will happen if a setuid script forgets to properly quote filenames in commands like: foo=$1 pidfile=/tmp/$foo.pid echo $$ > $pidfile # cleanup my pidfile truncate -s $pidfile and then I run the script with: setuid.sh " /etc/master.passwd /tmp/foo" If you guessed that the pid value was not saved anywhere, that because of the lack of error checking nobody noticed, and that the final truncate command may have just wiped your `master.passwd' file your guess is probably right.