Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-22829

make tries to execute a "install" directory instead of "install" binary

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Normal Normal
    • rhel-9.4
    • rhel-9.3.0
    • make
    • None
    • make-4.3-8.el9
    • Yes
    • Moderate
    • Regression
    • rhel-sst-pt-libraries
    • ssg_platform_tools
    • 23
    • 24
    • 1
    • False
    • Hide

      None

      Show
      None
    • Yes
    • Red Hat Enterprise Linux
    • None
    • Bug Fix
    • Hide
      .`make` no longer tries to run directories

      Previously, `make` did not check if an executable it was trying to run was actually an executable. Consequently, if the path included a directory with the same name as the executable, `make` tried to run the directory instead. With this update, `make` now does additional checks when searching for an executable. As a result, `make` no longer tries to run directories.



      Show
      .`make` no longer tries to run directories Previously, `make` did not check if an executable it was trying to run was actually an executable. Consequently, if the path included a directory with the same name as the executable, `make` tried to run the directory instead. With this update, `make` now does additional checks when searching for an executable. As a result, `make` no longer tries to run directories.
    • Done
    • All
    • None

      What were you trying to do that didn't work?

      When PATH is set in make to execute local binaries (PATH=.:/usr/bin:...) and a install directory exists in current directory, make tries to execute the directory instead of install, which usually resides in /usr/bin:

      $ cat Makefile 
      export PATH := .:$(PATH)
      .PHONY: all
      all:
      	echo $(PATH)
      	install --help
      
      $ make all
      echo .:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
      .:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
      install --help
      make: install: Permission denied
      make: *** [Makefile:5: all] Error 127
      

      The root cause for this is child_execute_job() function, which was very simplistic on RHEL8, is now calling find_in_given_path() (guile project) to resolve the binary, but find_in_given_path() itself is buggy, since it considers every inode having eXecution access, not only files or symlinks resolving as files (line 211):

       74 const char *
       75 find_in_given_path (const char *progname, const char *path,
       76                     bool optimize_for_exec)
       77 {
       :
      207                 /* On systems which have the eaccess() system call, let's
      208                    use it.  On other systems, let's hope that this program
      209                    is not installed setuid or setgid, so that it is ok to
      210                    call access() despite its design flaw.  */
      211                 if (eaccess (progpathname, X_OK) == 0)
      212                   {
      213                     /* Found!  */
      214                     if (strcmp (progpathname, progname) == 0)
      215                       {
       :
      228                       }
       :
      230                     free (path_copy);
      231                     return progpathname;
      232                   }
       :
      

      This breaks customers projects, since customers then have to modify all occurrences of install into /usr/bin/install to avoid the issue.

      Please provide the package NVR for which bug is seen:

      make-4.3-7.el9

      How reproducible:

      Always

      Steps to reproduce

      1.  Create a dummy Makefile
        $ cat Makefile 
        export PATH := .:$(PATH)
        .PHONY: all
        all:
        	echo $(PATH)
        	install --help
      2.  Create a install directory in current directory
        $ mkdir install
      3.  Execute make all

      Expected results

      /usr/bin/install usage displayed

      Actual results

      Permission denied message

            [RHEL-22829] make tries to execute a "install" directory instead of "install" binary

            Since the problem described in this issue should be resolved in a recent advisory, it has been closed.

            For information on the advisory (make bug fix and enhancement update), and where to find the updated files, follow the link below.

            If the solution does not work for you, open a new bug report.
            https://access.redhat.com/errata/RHBA-2024:2492

            Errata Tool added a comment - Since the problem described in this issue should be resolved in a recent advisory, it has been closed. For information on the advisory (make bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2024:2492

            updating release note status

            Jacob Valdez (Inactive) added a comment - updating release note status

            DJ Delorie added a comment -

            One comment is the inconsistency of "the `make`" vs "`make`" (I prefer the second).  Another is the phrase "check if the install was executable".  Given the popular meaning of "the install" I would suggest an alternate text.  Also, the problem is not specific to the word "install" - it applies to any program `make` is trying to execute.

            Suggestion:

            Previously,`make` did not check if an executable it was trying to run was actually an executable. Consequently, if the path included a directory with the same name as the executable, `make` tries to run the directory instead. With this update, `make` now does additional checks when searching for an executable.

            DJ Delorie added a comment - One comment is the inconsistency of "the `make`" vs "`make`" (I prefer the second).  Another is the phrase "check if the install was executable".  Given the popular meaning of "the install" I would suggest an alternate text.  Also, the problem is not specific to the word "install" - it applies to any program `make` is trying to execute. Suggestion: Previously,`make` did not check if an executable it was trying to run was actually an executable. Consequently, if the path included a directory with the same name as the executable, `make` tries to run the directory instead. With this update, `make` now does additional checks when searching for an executable.

            Petr Hybl added a comment -

            HI rhn-engineering-dj, I have updated the docs text field can you provide me with SME review?

            Petr Hybl added a comment - HI rhn-engineering-dj , I have updated the docs text field can you provide me with SME review?

            Reproduced with make-4.3-7.el9 and verified with make-4.3-8.el9.

            Michal Kolar added a comment - Reproduced with make-4.3-7.el9 and verified with make-4.3-8.el9.

            gitlab-bot added a comment -

            DJ Delorie mentioned this issue in a merge request of Red Hat / centos-stream / rpms / make on branch dj-c9s-rhel22829:

            Don't try to execute directories (RHEL-22829)

            gitlab-bot added a comment - DJ Delorie mentioned this issue in a merge request of Red Hat / centos-stream / rpms / make on branch dj-c9s-rhel22829 : Don't try to execute directories ( RHEL-22829 )

            Workaround is to add this to Makefile:

            SHELL = /usr/bin/sh
            

            Florian Weimer added a comment - Workaround is to add this to Makefile : SHELL = /usr/bin/sh

            Fixed in this gnulib commit:

            commit 6e6abd0cdfe4bb96f6412aebc511f10bf254a820
            Author: Bruno Haible <bruno@clisp.org>
            Date:   Sat May 23 12:19:34 2020 +0200
            
                findprog-in: Ignore directories.
                
                Reported by Frederick Eaton via Dmitry Goncharov in
                <https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00003.html>.
                
                * lib/findprog-in.c (find_in_given_path): When the file found is a
                directory, set errno to EACCES and, during a PATH search, continue
                searching.
                * modules/findprog-in (Depends-on): Add sys_stat, stat.
            

            Florian Weimer added a comment - Fixed in this gnulib commit: commit 6e6abd0cdfe4bb96f6412aebc511f10bf254a820 Author: Bruno Haible <bruno@clisp.org> Date: Sat May 23 12:19:34 2020 +0200 findprog-in: Ignore directories. Reported by Frederick Eaton via Dmitry Goncharov in <https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00003.html>. * lib/findprog-in.c (find_in_given_path): When the file found is a directory, set errno to EACCES and, during a PATH search, continue searching. * modules/findprog-in (Depends-on): Add sys_stat, stat.

              rhn-engineering-dj DJ Delorie
              rhn-support-rmetrich Renaud Métrich
              DJ Delorie DJ Delorie
              Michal Kolar Michal Kolar
              Petr Hybl Petr Hybl
              Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

                Created:
                Updated:
                Resolved: