home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7684 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.6 KB

  1. Path: sparky!uunet!enterpoop.mit.edu!senator-bedfellow.mit.edu!athena.mit.edu!ckclark
  2. From: ckclark@athena.mit.edu (Calvin Clark)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: "Secure" way to find out hostname
  5. Date: 6 Jan 1993 17:22:54 GMT
  6. Organization: Massachusetts Institute of Technology
  7. Lines: 37
  8. Message-ID: <CKCLARK.93Jan6122253@w20-575-84.mit.edu>
  9. References: <1id258INN8j6@nntp1.radiomail.net> <1993Jan6.140149.11253@Lehigh.EDU>
  10. Reply-To: ckclark@mit.edu
  11. NNTP-Posting-Host: w20-575-84.mit.edu
  12. In-reply-to: lusol@Lehigh.EDU's message of 6 Jan 93 14:01:49 GMT
  13.  
  14. In article <1993Jan6.140149.11253@Lehigh.EDU> lusol@Lehigh.EDU (Stephen O. Lidie) writes:
  15.  
  16.  
  17.    $euid = $>;               # user  
  18.    $> = $<;          
  19.    ..
  20.    chop($hostname = `/bin/hostname`);
  21.    ..
  22.    $> = $euid;               # back to root or whatever
  23.  
  24.  
  25.    OK you Perl heavies, let's hear the full 'how to untaint' story....
  26.  
  27. A full enough story is in the perl man page.  The likely problem here is
  28. that taintperl does not trust $PATH inherited from the environment, and
  29. if you try to set $ENV{'PATH'}, it cannot reference any variable
  30. previously marked as tainted.  So this is okay:
  31.  
  32.     $ENV{'PATH'} = "/bin:/usr/bin";
  33.     chop($hostname = `/bin/hostname`);
  34.  
  35. but this bad:
  36.  
  37.     $oldpath = $ENV{'PATH'};
  38.     $ENV{'PATH'} = "/bin:/usr/bin:$oldpath";
  39.     chop($hostname = `/bin/hostname`);
  40.  
  41. Simply specifing /bin/hostname is not good enough for taintperl, since
  42. it doesn't know that /bin/hostname won't execvp() or system() or
  43. popen() some random command using the user-specified path.
  44.  
  45. A fairly complete explanation of what you have to do to your scripts is
  46. given in the Camel Book.
  47.  
  48. -Calvin
  49. --
  50. Calvin Clark <ckclark@mit.edu>
  51.