[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#33315: exec*() familly bugs when parsing a bad $PATH



Package: libc6
Version: 2.0.7.19981211-4

It seems exec*() is having problems with entries in the PATH pointing
to an file instead of a directory. It should skip those bad entries
(like it does for missing directories), but instead it stop at those
ones and never try the next directories. For exemple, in a bash shell :

(note: I've used tar+gzip in this example, but every program which
spawn, exec* or popen another prog will fail in the same way)

~/src $ which gzip  
/bin/gzip

~/src $ PATH=/bin tar tvzf gnupg-0.9.2.tar.gz
-rw-r--r-- 501/501       12046 1999-01-20 22:45 gnupg-0.9.2/Makefile.in
-rw-r--r-- 501/501       17563 1999-01-13 12:48 gnupg-0.9.2/README
[...blablabla...]

~/src $ PATH="/etc/passwd:/bin" tar tvzf gnupg-0.9.2.tar.gz
tar (child): Cannot exec gzip: Not a directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error exit delayed from previous errors

~/src $ PATH="/some/missing/dir:/bin" tar tvzf gnupg-0.9.2.tar.gz
-rw-r--r-- 501/501       12046 1999-01-20 22:45 gnupg-0.9.2/Makefile.in
-rw-r--r-- 501/501       17563 1999-01-13 12:48 gnupg-0.9.2/README
[...blablabla...]

~/src $ PATH="/bin:/etc/passwd" tar tvzf gnupg-0.9.2.tar.gz
-rw-r--r-- 501/501       12046 1999-01-20 22:45 gnupg-0.9.2/Makefile.in
-rw-r--r-- 501/501       17563 1999-01-13 12:48 gnupg-0.9.2/README
[...blablabla...]


Here's a little strace witch shows that exec* functions are stopping
their search when a file is in the PATH :

~/src $ PATH="usr/local/bin:/usr/bin:/etc/passwd:/bin" strace -f tar tvzf gnupg-0.9.2.tar.gz
execve("/bin/tar", ["tar", "tvzf", "gnupg-0.9.2.tar.gz"], [/* 34 vars */]) = 0
[...]
pipe([3, 4])                            = 0
fork()                                  = 1761
[...]
[pid  1761] execve("/usr/local/bin/gzip", ["gzip", "-d"], [/* 34 vars */]) = -1 ENOENT (No such file or directory)
[pid  1761] execve("/usr/bin/gzip", ["gzip", "-d"], [/* 34 vars */]) = -1 ENOENT (No such file or directory)
[pid  1761] execve("/etc/passwd/gzip", ["gzip", "-d"], [/* 34 vars */]) = -1 ENOTDIR (Not a directory)
[pid  1761] write(2, "tar (child): ", 13) = 13
[pid  1761] write(2, "Cannot exec gzip", 16) = 16
[pid  1761] write(2, ": Not a directory", 17) = 17
[pid  1761] write(2, "\n", 1)           = 1
[pid  1761] write(2, "tar (child): ", 13) = 13
[pid  1761] write(2, "Error is not recoverable: exitin"..., 37) = 37
[pid  1761] write(2, "\n", 1)           = 1
[pid  1761] _exit(2)                    = ?
<... read resumed> "", 10240)           = 0
--- SIGCHLD (Child exited) ---

-- 
Rémi        <rguyom@mail.dotcom.fr> | Don't waste your computer's time :
    PGP-encrypt anything important: | http://www.distributed.net/
   www.gnupg.org - KeyID:0x85BD8B1B | http://www.distributed.net/cores/

Attachment: pgp4nHjiyAqlV.pgp
Description: PGP signature


Reply to: