Networker

Re: [Networker] Still can't do this in Perl

2004-11-26 18:20:55
Subject: Re: [Networker] Still can't do this in Perl
From: Darren Dunham <ddunham AT TAOS DOT COM>
To: NETWORKER AT LISTMAIL.TEMPLE DOT EDU
Date: Fri, 26 Nov 2004 15:45:32 -0800
> Okay, I tried suggested code, but with taint mode turned on as shown
> below and invoked as: 'script.pl name client'.
> I have a question, though, about how to NOT invoke shell (security) as
> discussed further down, but I may be confused on this issue.
>
> #!/usr/bin/perl -wT
> use strict;
>
> $ENV{PATH} = '/usr/sbin';
> my $name=$ARGV[0];
> my $type=$ARGV[1];
>
> use IPC::Open2;
> my $pid = open2(\*RDRFH, \*WTRFH, "nsradmin -s orion -i -");

It happens here becuase you're passing the command and arguments as a
single string, the shell is invoked to parse the bits.  You can parse
them yourself and pass them as an array rather than a string.

my @cmd = qw(nsradmin -s orion -i -);
my $pid = open2(\*RDRFH, \*WTRFH, @cmd);

This is now more of a perl discussion than anything to do with networker
though..


--
Darren Dunham                                           ddunham AT taos DOT com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

--
Note: To sign off this list, send a "signoff networker" command via email
to listserv AT listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list. Questions regarding this list
should be sent to stan AT temple DOT edu
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=