git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] 'make install' may overwrite existing directories
@ 2022-10-20 10:58 Alejandro Colomar
  0 siblings, 0 replies; only message in thread
From: Alejandro Colomar @ 2022-10-20 10:58 UTC (permalink / raw)
  To: Git


[-- 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 --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-20 10:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-20 10:58 [BUG] 'make install' may overwrite existing directories Alejandro Colomar

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).