Makefile: be more cautious changing RUNUSR home dir

Don't update the home dir unless the user otherwise appears to be the
one that we created. Also warn if it has a login shell set.

Closes: https://trac.macports.org/ticket/70938
This commit is contained in:
Joshua Root
2025-05-23 11:57:04 +10:00
parent 5d107c1e6e
commit ad2f4ab4f9
+6 -1
View File
@@ -69,7 +69,12 @@ ifeq ($(DESTDIR),)
${DSCL} -q . -create "/Users/${RUNUSR}" UserShell /usr/bin/false ; \
fi ; \
RUNUSR_UID=$$(${DSCL} -q . -read "/Users/${RUNUSR}" UniqueID | /usr/bin/awk '{print $$2}'); \
if test "$$RUNUSR_UID" -gt 500; then \
RUNUSR_NAME=$$(${DSCL} -q . -read "/Users/${RUNUSR}" RealName | /usr/bin/awk '{print $$2}'); \
RUNUSR_SHELL=$$(${DSCL} -q . -read "/Users/${RUNUSR}" UserShell | /usr/bin/awk '{print $$2}'); \
if test "$$RUNUSR_SHELL" != "/usr/bin/false"; then \
echo "Warning: user '${RUNUSR}' appears to be a login user (should be unprivileged)" ; \
fi ; \
if test "$$RUNUSR_UID" -gt 500 -a "$$RUNUSR_SHELL" = "/usr/bin/false" -a "$$RUNUSR_NAME" = "MacPorts" ; then \
if test "$$(${DSCL} -q . -read "/Users/${RUNUSR}" NFSHomeDirectory)" != "NFSHomeDirectory: ${localstatedir}/macports/home" ; then \
echo "Updating home directory location for user \"${RUNUSR}\"" ; \
${DSCL} -q . -create "/Users/${RUNUSR}" NFSHomeDirectory "${localstatedir}/macports/home" ; \