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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!netnews.upenn.edu!netnews.cc.lehigh.edu!usenet
  2. From: lusol@Lehigh.EDU (Stephen O. Lidie)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: "Secure" way to find out hostname
  5. Message-ID: <1993Jan6.140149.11253@Lehigh.EDU>
  6. Date: 6 Jan 93 14:01:49 GMT
  7. References: <1id258INN8j6@nntp1.radiomail.net>
  8. Sender: usenet@Lehigh.EDU
  9. Organization: Lehigh University, Bethlehem PA
  10. Lines: 34
  11. Nntp-Posting-Host: meatball.cc.lehigh.edu
  12.  
  13. In article <1id258INN8j6@nntp1.radiomail.net> hogan@radiomail.net (Emmett
  14. Hogan) writes:
  15. >Hi All,
  16. >
  17. >Quick and hopefully easy question:
  18. >
  19. >Is there an acceptable way to find out your machine's hostname in a setuid  
  20. >PERL script?  When I try this: $host = `/bin/hostname` I get INSECURE  
  21. >path.
  22. >
  23. >Any ideas?
  24. >
  25. >Thanks in advance,
  26. >Emmett
  27. >
  28. Now, I've only written one setuid Perl program but I had the same problem.
  29. Never did figure out 'the right way' to do it, but did get around it by doing
  30. all my initialization under the user's id:
  31.  
  32. $euid = $>;               # user  
  33. $> = $<;          
  34. ..
  35. chop($hostname = `/bin/hostname`);
  36. ..
  37. $> = $euid;               # back to root or whatever
  38.  
  39.  
  40. OK you Perl heavies, let's hear the full 'how to untaint' story....
  41.  
  42.  
  43.  
  44. SOL
  45.  
  46. system( 'telnet Turkey.CC.Lehigh.EDU 4031' ); # JAPH
  47.