home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / bugs / 4bsd / 246 < prev    next >
Encoding:
Internet Message Format  |  1993-01-26  |  1.8 KB

  1. Xref: sparky comp.bugs.4bsd:246 comp.unix.bsd:11824
  2. Path: sparky!uunet!spool.mu.edu!howland.reston.ans.net!usc!enterpoop.mit.edu!senator-bedfellow.mit.edu!athena.mit.edu!ckclark
  3. From: ckclark@athena.mit.edu (Calvin Clark)
  4. Newsgroups: comp.bugs.4bsd,comp.unix.bsd
  5. Subject: script(1) requires absolute path, hardcodes argv[0] to "sh"
  6. Date: 26 Jan 1993 06:02:29 GMT
  7. Organization: Massachusetts Institute of Technology
  8. Lines: 56
  9. Distribution: world
  10. Message-ID: <CKCLARK.93Jan26010229@augmented.mit.edu>
  11. Reply-To: ckclark@mit.edu
  12. NNTP-Posting-Host: augmented.mit.edu
  13.  
  14. Description:
  15.     
  16.     If the SHELL environment variable isn't an explicit path,
  17. script(1) won't find it.  Also, it sets argv[0] in the new shell to
  18. `sh', regardless of the name of the shell.
  19.  
  20.     It's not a setuid program and it doesn't have to be so
  21. restrictive.
  22.  
  23. Repeat-by:
  24.  
  25.     First problem:
  26.  
  27.     $ SHELL=sh; export SHELL
  28.     $ script
  29.     Script started, file is typescript
  30.     sh: No such file or directory
  31.     Script done, file is typescript
  32.     $
  33.  
  34.     Second problem:
  35.  
  36.     $ ln -s /bin/sh /tmp/foo
  37.     $ SHELL=/tmp/foo; export SHELL
  38.     $ script
  39.     Script started, file is typescript
  40.     $ echo $0
  41.     sh
  42.  
  43. Fix:
  44.  
  45. *** script.c.old    Tue Jan 26 00:14:02 1993
  46. --- script.c    Tue Jan 26 00:20:05 1993
  47. ***************
  48. *** 194,200 ****
  49.       (void) dup2(slave, 1);
  50.       (void) dup2(slave, 2);
  51.       (void) close(slave);
  52. !     execl(shell, "sh", "-i", 0);
  53.       perror(shell);
  54.       fail();
  55.   }
  56. --- 194,200 ----
  57.       (void) dup2(slave, 1);
  58.       (void) dup2(slave, 2);
  59.       (void) close(slave);
  60. !     execlp(shell, shell, "-i", 0);
  61.       perror(shell);
  62.       fail();
  63.   }
  64.  
  65. --
  66. Calvin Clark <ckclark@mit.edu>                                    : MIT
  67. For the network challenged: / uunet!mit-eddie!mit-athena!ckclark  : Academic 
  68.                             \ ckclark%mit.edu@MITVMA.bitnet       : Computing
  69. For the hopeless bureaucrat:  Calvin_Clark@MIT.EDU                : Services
  70.