git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] 'make install' may overwrite existing directories

From
ACAlejandro Colomar <alx.manpages@gmail.com>
Date
Oct 20, 2022, 10:58 UTC
Message-ID
<a49c95b2-4468-e510-957a-427f9ce8763d@gmail.com>
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/>
Message 1 of 1 in “[BUG] 'make install' may overwrite existing directories”
  1. Alejandro ColomarOct 20, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.