Skip site navigation (1)Skip section navigation (2)
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
Message-ID:  <19970501093129.LO56219@uriah.heep.sax.de>
In-Reply-To: <87rafr6a0o.fsf@erlenstar.demon.co.uk>; from Andrew Gierth on May 1, 1997 06:23:19 %2B0100
References:  <87rafr6a0o.fsf@erlenstar.demon.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
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. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970501093129.LO56219>