From owner-freebsd-hackers Thu May 1 05:09:00 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA20573 for hackers-outgoing; Thu, 1 May 1997 05:09:00 -0700 (PDT) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id FAA20550 for ; Thu, 1 May 1997 05:08:57 -0700 (PDT) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by who.cdrom.com (8.8.5/8.6.11) with SMTP id AAA10325 for ; Thu, 1 May 1997 00:50:44 -0700 (PDT) Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id JAA28513; Thu, 1 May 1997 09:50:37 +0200 Received: (from j@localhost) by uriah.heep.sax.de (8.8.5/8.8.5) id JAA02956; Thu, 1 May 1997 09:31:29 +0200 (MET DST) Message-ID: <19970501093129.LO56219@uriah.heep.sax.de> Date: Thu, 1 May 1997 09:31:29 +0200 From: j@uriah.heep.sax.de (J Wunsch) To: hackers@freebsd.org Cc: andrew@erlenstar.demon.co.uk (Andrew Gierth) Subject: Re: /bin/sh -c and ENV References: <87rafr6a0o.fsf@erlenstar.demon.co.uk> X-Mailer: Mutt 0.60_p2-3,5,8-9 Mime-Version: 1.0 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <87rafr6a0o.fsf@erlenstar.demon.co.uk>; from Andrew Gierth on May 1, 1997 06:23:19 +0100 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk As Andrew Gierth wrote: > Just noticed that /bin/sh is executing the ENV file even when invoked with > the -c option. Is this a bug or a feature? :-) Feature. > (Executing the ENV file in calls to system(3) or popen(3) could be considered > a Bad Thing, even in non-suid programs, and the last system I used where > system and popen invoked a Posix shell specifically disabled the ENV file > if the -c option was used.) . Suid programs that do system() deserve to be shot immediately; this can simply be achieved by converting them to suidperl scripts, and leave it to suidperl to complain about your stupid use of a shell inside a setuid program. :-) . If the shell detects that the real and effective UID are different, option -p is in effect, and no $ENV processing happens anyway. . If your $ENV file is not bulletproof, go back 10 or 15 years in history, go to Berkeley, you'll certainly use a csh. You'll then learn how to write .cshrc files that don't depend on the interactive- ness of the shell. :-) For .cshrc: if ($?prompt) then # This part only executed in an interactive shell: alias m less set history = 100 set filec endif For $ENV: case "$-" in *i*) # This part only executed in an interactive shell: alias m=less set hmm you can't set history here (though you have one) :-) set nor do you have filec :-O esac -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)