From owner-freebsd-questions Wed May 15 8: 3: 6 2002 Delivered-To: freebsd-questions@freebsd.org Received: from uk2.kanda-systems.net (uk2.kanda-systems.net [193.195.117.202]) by hub.freebsd.org (Postfix) with ESMTP id AFEB537B403 for ; Wed, 15 May 2002 08:02:58 -0700 (PDT) Received: by uk2.kanda-systems.net (Postfix, from userid 1001) id 66C853C42D; Wed, 15 May 2002 16:04:19 +0100 (BST) Date: Wed, 15 May 2002 16:04:19 +0100 From: Jason Taylor To: freebsd-questions@freebsd.org Subject: Re: su and the ``-c'' option. Message-ID: <20020515150418.GD6657@uk2.kanda-systems.net> Reply-To: Jason Taylor Mail-Followup-To: Jason Taylor , freebsd-questions@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.99i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Forgot to cc list. ----- Forwarded message from Jason Taylor ----- Date: Wed, 15 May 2002 15:57:25 +0100 From: Jason Taylor To: "Chris J. Mutter" Subject: Re: su and the ``-c'' option. Reply-To: Jason Taylor In-Reply-To: <200205141228.OAA19282@terminal.sil.at> User-Agent: Mutt/1.3.99i On Tue, May 14, 2002 at 02:28:51PM +0200, Chris J. Mutter wrote: > hi, > > why is the ``-c'' (execute command) option of the ``su'' needed when i want > to execute a command as a different user? and why is this option not in the > manpage (its only found in the EXAMPLES section of su(1)): Well any non - commands when presented to the shell are expected to be a script to execute. To demonstrate this create a test script. # echo "env" > /tmp/testscript && chmod 444 /tmp/testscript Then try running the script from the command prompt: # /tmp/testscript ->/tmp/testscript: Permission denied. Obviously with no execute permission theres no way this script will run.. well not quite, try: # /bin/sh /tmp/testscript ->@@ GIVES ENV OUTPUT@@ Now try: # /usr/bin/su [someuser] /tmp/testscript The same result.. Hopefully this should make it clear why the shells need the -c command. This has really got nothing to do with su except that su kindly passes on all the additional arguments for the shell to process. Remeber that these options are shell dependant and therefore should not form part of the su documentation. Take a look at the manpage for nologin(8). You'll notice that nologin does not accept the -c option :) Jason ==================================================================== Jason Taylor. Kanda Systems Ltd. Tel: +44/0 1970 621030 Systems Manager. Unit 17 Glanyrafon Fax: +44/0 1970 621040 jason@kanda.com. Enterprise Park. Mobile: +44/0 7976 926918 http://www.kanda.com. Ceredigion, UK http://shop.kanda.com ==================================================================== ----- End forwarded message ----- -- ==================================================================== Jason Taylor. Kanda Systems Ltd. Tel: +44/0 1970 621030 Systems Manager. Unit 17 Glanyrafon Fax: +44/0 1970 621040 jason@kanda.com. Enterprise Park. Mobile: +44/0 7976 926918 http://www.kanda.com. Ceredigion, UK http://shop.kanda.com ==================================================================== To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message