develooper Front page | perl.perl5.porters | Postings from May 2003

Re: [PATCH 5.8.1 @19053] Getopt::Std

Thread Previous | Thread Next
From:
Ilya Zakharevich
Date:
May 26, 2003 00:32
Subject:
Re: [PATCH 5.8.1 @19053] Getopt::Std
Message ID:
20030526073228.GA1302@math.berkeley.edu
On Sun, Apr 06, 2003 at 08:56:15PM +0100, Nicholas Clark wrote:
> > > > Tough luck.  IIUC, security considerations imply that the most we can
> > > > do with unprepared program is to put message on STDERR, and continue.
> > > 
> > > s/STDERR/STDOUT/;
> > > s/continue/die/;
> > 
> > Sorry, but my argument stands as is.  Unless we know that it is save
> > to let the user interrupt the script (by giving it options), or change
> > the STDOUT output, we should not.  It may be setuid or otherwise critical.

> You appear to be arguing that we mustn't add options to stop programs for
> the specific case of protecting programs which untrusted users are allowed
> to add arbitrary options to, where said programs are carefully designed so
> that no combination of options that can be added materially effect the
> intent of their outcome.
> 
> I'm arguing that the set of such programs running is such situations is
> very small. No sane sysadmin would do this.

Thinking about this yet a little bit more: I think the following patch
covers the case when your sysadmin is unsame, *and* works in the
standard way with very few exceptions (suid/sgid run as root):

--- ./lib/Getopt/Std.pm-try2	Mon Apr  7 16:33:58 2003
+++ ./lib/Getopt/Std.pm	Mon May 26 00:29:08 2003
@@ -71,8 +71,19 @@ and version_mess() with the switches str
 @ISA = qw(Exporter);
 @EXPORT = qw(getopt getopts);
 $VERSION = '1.04';
+
 # uncomment the next line to disable 1.03-backward compatibility paranoia
 # $STANDARD_HELP_VERSION = 1;
+
+# Enable standard behaviour if:
+#   a) we are root (or this does not make sense)
+#   b) or we are not suid/sgid (or this does not make sense)
+unless (defined $STANDARD_HELP_VERSION) {
+  $STANDARD_HELP_VERSION
+    =  (eval('$< == 0') || 1)
+   || !(   eval('$< != $>') 
+	|| eval('$( != $)') );
+}
 
 # Process single-character switches with switch clustering.  Pass one argument
 # which is a string containing all switches that take an argument.  For each

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About