bugmake - Bugs: bug #62200, Make tries to execute directories...

 
 

bug #62200: Make tries to execute directories name as commands instead of using shell PATH resulting failure with permission denied

Submitter:  None
Submitted:  Fri 18 Mar 2022 09:00:15 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Duplicate Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.3 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 19 Mar 2022 07:51:58 AM UTC, comment #6: 

Hi,

I have part of a story to share, and I apologise that I am very confused and scared when I share it.

I went through an experience of severe abuse where my devices were maliciously controlled to limit my freedom. When I see a "permission denied" error that has no apparent cause, this is very terrifying to me, and I experience flashbacks, and I do not know if I will be harmed if I continue to pursue my task.

I would request that, even if EACCES is the correct error code, that the cases of it where it is not actually a permission error, be given a different error message that helps the user discover what is really going on. Even giving the full path of failing execution would help so much here.

I would also request that some reference to my story be in the commit message, so people understand that gnu respects people and does not support sustaining delusions of power nor helplessness.

I expect my expression may be met with defensiveness or concerns. I am just taking the time to try to talk, when it is very very hard for me to do so. If I have upset you, I apologise.

If my expression belongs at a dependent project such as gnulib, it would be kind if somebody could copy-paste it to them, because it is very very hard for me to reference this.

Thank you for reading.

Baffo32 <baffo32>
Sat 19 Mar 2022 12:55:19 AM UTC, comment #5: 


> typed the recipe command line into your shell prompt

I see the point but I'm not sure I'd put it quite that way.  Didn't bash win the Shell Wars?


martind@sirius:~/tmp/make-62200$ PATH=$(pwd):$PATH /bin/sh -c asdf
/bin/sh: 1: asdf: Permission denied
martind@sirius:~/tmp/make-62200$ PATH=$(pwd):$PATH /bin/bash -c asdf
/bin/bash: asdf: command not found
martind@sirius:~/tmp/make-62200$


Perhaps someone else thought the message was worth customizing, probably with their own localization, as the capitalization, for one thing, suggests it's not an errno.  Huh, I see we have some commented-out localization for "Command not found", which goes back in the Gnu Make source to 1992's:


roland@redhat.com   d2e5ab8c57d613ce8955a08fce5c0e453b3038e6:
  if (!search_path (argv[0], path, program))
    error ("%s: Command not found", argv[0]);


> If you rebuild your GNU make 4.3 with the latest gnulib

That would intimidate me and I've submitted patches.  README.git has been tractable in recent years.  Paul would hate to suggest that you use an earlier version, because he's more aware than anyone of all the bugs fixed since, but...

>> I don't have in my PATH the $(pwd) folder

Sorry, I should have been explicit that I didn't want asdf in /usr/local/bin (and like to promote the semicolon recipe separator), so had changed my test case to:


martind@sirius:~/tmp/make-62200$ mkdir asdf
martind@sirius:~/tmp/make-62200$ echo 'all:; asdf' > Makefile
martind@sirius:~/tmp/make-62200$ PATH=$(pwd):$PATH ~/download/make/make
asdf
make: asdf: Permission denied
make: *** [Makefile:1: all] Error 127
martind@sirius:~/tmp/make-62200$


I don't think that's materially different from your original asdf case, though, as Paul says, the cp case is likely to be different - that already-fixed, but after 4.3, bug #57962.

Martin Dorey <mdorey>
Sat 19 Mar 2022 12:33:05 AM UTC, comment #4: 

Thanks for the explanation this made things very clearer to me, I fixed my issue with building gcc that had a 'cp' directory by building the latest version of make from git, when is the next release scheduled because since January 2020 there has been no new release so far.

Lahfa Samy <akechishiro>
Fri 18 Mar 2022 11:45:30 PM UTC, comment #3: 

It's important to understand that the issue you originally described, where there's a "cp" directory, and the issue you actually provided a test case for, and for which Martin replied, where there's some random directory, are very very different.

In the original issue, with a "cp" directory, GNU make used to get the right behavior (that is ignore the "cp" directory and continue searching the PATH and find the right "cp" program) up until GNU make 4.3.  In GNU make 4.3 we started using a gnulib method to find programs on PATH, and there was a bug in it.  That bug has been fixed in gnulib.  If you rebuild your GNU make 4.3 with the latest gnulib, you won't see this problem.

The issue that you actually provided, where make invokes a random directory name that is on the PATH, is very different: in this situation make will always report the "permission denied" error as Martin suggests and this is the correct behavior (or at least the behavior required by POSIX).  That's because make will continue to search the path, discover there is actually no program with the random name, so it will assume you really wanted to run the directory it found and report that error.

Basically, make should always behave "as if" you typed the recipe command line into your shell prompt.  In your example, if you do that, you'll see:


$ /bin/sh -c 'asdf'
/bin/sh: 1: asdf: Permission denied


and that's exactly what make tells you as well.

For more details see bug #57962

Paul D. Smith <psmith>
Group administrator
Fri 18 Mar 2022 11:34:43 PM UTC, comment #2: 

So what should be done to fix this problem for a build such as gcc ?

This bug is stated as fixed : https://savannah.gnu.org/bugs/index.php?57962

So why am I encountering it again ? What should be done to mitigate the bug, also I don't have in my PATH the $(pwd) folder, hence I don't understand why fails for that.

Lahfa Samy <akechishiro>
Fri 18 Mar 2022 11:15:50 PM UTC, comment #1: 

Oh no, not error 127 again.  The error message here is the strerror form of EACCES, which currently seems to come (on my build on reasonably modern Linux, with findprog-in and posix_spawn) from this change:

https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=6e6abd0cdfe4bb96f6412aebc511f10bf254a820

... which was from this email discussion:

https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00248.html

... which was a continuation of a discussion inspired by a similar-sounding Gnu Make issue:

https://savannah.gnu.org/bugs/index.php?57962

... when a directory called perl stopped us from finding the executable later in the PATH.

The behavior, though, is much older than the current implementation, going back at least 15 years:


(ia32)martind@sirius:~/tmp/make-62200$ PATH=$(pwd):$PATH make
asdf
make: execvp: asdf: Permission denied
make: *** [all] Error 127
(ia32)martind@sirius:~/tmp/make-62200$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i486-pc-linux-gnu
(ia32)martind@sirius:~/tmp/make-62200$


All that's different with today's git version is that the "execvp: " piece has gone.


martind@sirius:~/tmp/make-62200$ PATH=$(pwd):$PATH ~/download/make/make
asdf
make: asdf: Permission denied
make: *** [Makefile:1: all] Error 127
martind@sirius:~/tmp/make-62200$ ~/download/make/make --version
GNU Make 4.3.90
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
martind@sirius:~/tmp/make-62200$


That's arguably mandated by:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html

... which sayeth:

> [EACCES]
> The new process image file is not a regular file and the implementation does not support execution of files of its type.


So I fear this is destined for not-a-bug status, sorry.

Martin Dorey <mdorey>
Fri 18 Mar 2022 09:00:15 PM UTC, original submission:  

I've been trying to build a big project and exchanging back and forth with the community, we have created a minimal Makefile for what we think is a bug and not an intended feature.

If a binary is named 'cp' and a directory is named 'cp', then the make build fails with "cp: permission denied", if the directory is renamed, then the build will go on, I met this issue whilst trying to build gcc from source.


Reproduce the bug with a minimal Makefile:

sudo mkdir /usr/local/bin/asdf
echo -e 'all:\n\tasdf' > Makefile
make


Output:

asdf
make: asdf: Permission denied
make: *** [Makefile:2: all] Error 127


I don't think this should be happening, if it should, this should be documented and maybe the error message should be more helpful, the current error leads someone to think there are permissions issues when it is not a permission issue.


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by baffo32 (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by akechishiro (Posted a comment)
  • -email is unavailable- added by akechishiro
  • -email is unavailable- added by mdorey (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-03-18 psmith StatusNone Duplicate
        Open/ClosedOpen Closed
    2022-03-18 akechishiro Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code