ports/155543: [bsd.port.mk] [patch] currently id -0 is run a number of times despite
Eitan Adler
lists at eitanadler.com
Sun Mar 13 21:10:12 UTC 2011
>Number: 155543
>Category: ports
>Synopsis: [bsd.port.mk] [patch] currently id -0 is run a number of times despite
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Mar 13 21:10:11 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Eitan Adler
>Release:
>Organization:
>Environment:
>Description:
id -u is run a number of times throughout bsd.port.mk. The first time the value gets stored into a variable UID. The attached patch attempts to use the cached value instead of running id multiple times.
Aside from the typical exp-run required this patch needs to be tested when installing by a non-root user and when switching back and forth (via su_cmd).
>How-To-Repeat:
>Fix:
Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.674
diff -u -r1.674 bsd.port.mk
--- bsd.port.mk 7 Mar 2011 07:32:05 -0000 1.674
+++ bsd.port.mk 13 Mar 2011 20:41:51 -0000
@@ -3655,7 +3655,7 @@
fi; \
done
.if !defined(EXTRACT_PRESERVE_OWNERSHIP)
- @if [ `${ID} -u` = 0 ]; then \
+ @if [ ${UID} = 0 ]; then \
${CHMOD} -R ug-s ${WRKDIR}; \
${CHOWN} -R 0:0 ${WRKDIR}; \
fi
@@ -4076,7 +4076,7 @@
.if !target(install-mtree)
install-mtree:
@${MKDIR} ${PREFIX}
- @if [ `${ID} -u` != 0 ]; then \
+ @if [ ${UID} != 0 ]; then \
if [ -w ${PREFIX}/ ]; then \
${ECHO_MSG} "Warning: not superuser, you may get some errors during installation."; \
else \
@@ -4085,7 +4085,7 @@
fi; \
fi
.if !defined(NO_MTREE)
- @if [ `${ID} -u` = 0 ]; then \
+ @if [ ${UID} = 0 ]; then \
if [ ! -f ${MTREE_FILE} ]; then \
${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
${ECHO_MSG} "Copy it from a suitable location (e.g., /usr/src/etc/mtree) and try again."; \
@@ -6135,7 +6135,7 @@
${ECHO_CMD} WITHOUT_$${i}=true >> $${TMPOPTIONSFILE}; \
fi; \
done; \
- if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
+ if [ ${UID} != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
${ECHO_MSG} "===> Switching to root credentials to write ${OPTIONSFILE}"; \
${SU_CMD} "${CAT} $${TMPOPTIONSFILE} > ${OPTIONSFILE}"; \
${ECHO_MSG} "===> Returning to user credentials"; \
@@ -6228,7 +6228,7 @@
.if defined(OPTIONS) && exists(${OPTIONSFILE})
-@${ECHO_MSG} "===> Removing user-configured options for ${PKGNAME}"; \
optionsdir=${OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \
- if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
+ if [ ${UID} != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
${ECHO_MSG} "===> Switching to root credentials to remove ${OPTIONSFILE} and $${optionsdir}"; \
${SU_CMD} "${RM} -f ${OPTIONSFILE} ; \
${RMDIR} $${optionsdir}"; \
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list