bug-make
[Top][All Lists]
Advanced

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

[bug #53201] Target runs incorrect command when shebang line exceeds ker


From: Casey McGinty
Subject: [bug #53201] Target runs incorrect command when shebang line exceeds kernel limit
Date: Wed, 21 Feb 2018 02:35:15 -0500 (EST)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?53201>

                 Summary: Target runs incorrect command when shebang line
exceeds kernel limit
                 Project: make
            Submitted by: cmcginty
            Submitted on: Wed 21 Feb 2018 07:35:13 AM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 3.81
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

I have a Python script (in ./env/bin/pip) generated by virtualenv with a very
long shebang line. The virtualenv is active and the PATH env contains
"./env/bin;...." before all other paths. When I run "pip" from the system
shell I see the following error:

```
... /bin/python: can't open file 'pip': [Errno 2] No such file or directory
```

This error is expected because the shebang line is beyond the limit allowed by
the kernel.

However when the same command runs in Make, it does NOT fail. Instead, it
succeeds by running /bin/pip. This is very unusual since the local script
`./env/bin/pip` is first in the PATH . The problem with running the system pip
is that this should never happen as the local environment thinks it is inside
of Python virtualenv. By running the system pip, we are tainting the system
Python runtime environment with unwanted packages.

Some debugging with strace revealed exactly what Make is doing:

```
[pid  8578] execve("/var/lib/jenkins/workspace/..../env/bin/pip", ["pip",
"list"], [/* 26 vars */]) = -1 ENOENT (No such file or directory)
[pid  8578] execve("/sbin/pip", ["pip", "list"], [/* 26 vars */]) = -1 ENOENT
(No such file or directory)
[pid  8578] execve("/bin/pip", ["pip", "list"], [/* 26 vars */] <unfinished
...>
```

Note that adding the .ONESHELL directive resolve the issue and causes Make
returns the expected error string above.

I think the proper fix is to stat() the file before accepting the ENOENT error
from execve. If the file exists and execve still returns an ENOENT error, Make
should fail the target and return the error to the user.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53201>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]