home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.bugs.4bsd:246 comp.unix.bsd:11824
- Path: sparky!uunet!spool.mu.edu!howland.reston.ans.net!usc!enterpoop.mit.edu!senator-bedfellow.mit.edu!athena.mit.edu!ckclark
- From: ckclark@athena.mit.edu (Calvin Clark)
- Newsgroups: comp.bugs.4bsd,comp.unix.bsd
- Subject: script(1) requires absolute path, hardcodes argv[0] to "sh"
- Date: 26 Jan 1993 06:02:29 GMT
- Organization: Massachusetts Institute of Technology
- Lines: 56
- Distribution: world
- Message-ID: <CKCLARK.93Jan26010229@augmented.mit.edu>
- Reply-To: ckclark@mit.edu
- NNTP-Posting-Host: augmented.mit.edu
-
- Description:
-
- If the SHELL environment variable isn't an explicit path,
- script(1) won't find it. Also, it sets argv[0] in the new shell to
- `sh', regardless of the name of the shell.
-
- It's not a setuid program and it doesn't have to be so
- restrictive.
-
- Repeat-by:
-
- First problem:
-
- $ SHELL=sh; export SHELL
- $ script
- Script started, file is typescript
- sh: No such file or directory
- Script done, file is typescript
- $
-
- Second problem:
-
- $ ln -s /bin/sh /tmp/foo
- $ SHELL=/tmp/foo; export SHELL
- $ script
- Script started, file is typescript
- $ echo $0
- sh
-
- Fix:
-
- *** script.c.old Tue Jan 26 00:14:02 1993
- --- script.c Tue Jan 26 00:20:05 1993
- ***************
- *** 194,200 ****
- (void) dup2(slave, 1);
- (void) dup2(slave, 2);
- (void) close(slave);
- ! execl(shell, "sh", "-i", 0);
- perror(shell);
- fail();
- }
- --- 194,200 ----
- (void) dup2(slave, 1);
- (void) dup2(slave, 2);
- (void) close(slave);
- ! execlp(shell, shell, "-i", 0);
- perror(shell);
- fail();
- }
-
- --
- Calvin Clark <ckclark@mit.edu> : MIT
- For the network challenged: / uunet!mit-eddie!mit-athena!ckclark : Academic
- \ ckclark%mit.edu@MITVMA.bitnet : Computing
- For the hopeless bureaucrat: Calvin_Clark@MIT.EDU : Services
-