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
    • Normal
    • Regression
    • sst_pt_libraries
    • ssg_platform_tools
    • 23
    • 24
    • 1
    • False
    • Hide

      None

      Show
      None
    • Yes
    • Red Hat Enterprise Linux
    • 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

            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: