git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Git <git@vger.kernel.org>
Subject: [BUG] 'make install' may overwrite existing directories
Date: Thu, 20 Oct 2022 12:58:00 +0200	[thread overview]
Message-ID: <a49c95b2-4468-e510-957a-427f9ce8763d@gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1438 bytes --]

Hi,

The project Makefile defines the install target as:

$ sed -n '3236,3245p' Makefile

install: all
	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
	$(INSTALL) $(INSTALL_STRIP) $(PROGRAMS) 
'$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
	$(INSTALL) $(SCRIPTS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
	$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
	$(INSTALL) $(INSTALL_STRIP) $(install_bindir_xprograms) 
'$(DESTDIR_SQ)$(bindir_SQ)'
	$(INSTALL) $(BINDIR_PROGRAMS_NO_X) '$(DESTDIR_SQ)$(bindir_SQ)'


Notice that the directories are being installed even if they already 
exist.  This may be problematic in case the existing directories have a 
different mode, or have SELinux security contexts, or any other 
characteristic that install(1) would overwrite.

A similar bug report in an NGINX project can be found here:

<https://github.com/nginx/unit/issues/769>

The two solutions available are:

- Make the install target be a dummy target that depends on the files 
being installed, and write proper make(1) rules for those targets.  This 
would be preferred.  You can check the Linux man-pages Makefile for an 
implementation of the 'install' target that does this.

- test(1) if the directory exists before actually creating it.  This is 
a simple workaround.


Cheers,

Alex


-- 
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

                 reply	other threads:[~2022-10-20 10:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a49c95b2-4468-e510-957a-427f9ce8763d@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).