Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Nov 2010 22:32:27 +0100 (CET)
From:      Olli Hauer <ohauer@FreeBSD.org>
To:        <FreeBSD-gnats-submit@FreeBSD.org>
Cc:        ohauer@gmx.de
Subject:   ports/152498: [patch] ports/Mk bsd.port.mk order if groups/users are created by package
Message-ID:  <20101122213228.2A8EF204E6@u18-124.dslaccess.de>
Resent-Message-ID: <201011222140.oAMLe8iK009811@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         152498
>Category:       ports
>Synopsis:       [patch] ports/Mk bsd.port.mk order if groups/users are created by package
>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:   Mon Nov 22 21:40:08 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Olli Hauer <ohauer@FreeBSD.org>
>Release:        
>Organization:
>Environment:


>Description:
According to pkg_create(1) and the porters-handbook/users-and-groups.html
it is expected groups/users are created in a early install state.
In further steps these accounts can be used to set permissions etc.
Even pkg_add should stop if the requested accounts cannot be created. 

This is true as long the port is installed from the source, the resulting
package creates the accounts in one of the last steps.

The workaround is at the moment to create the groups/users via the
pkg-install script.

The following simple patch solve this issue.

>How-To-Repeat:
A small demo port is here available:
http://people.freebsd.org/~ohauer/shar/guid-package-test.shar

>Fix:
The following patch is also here affable:
http://people.freebsd.org/~ohauer/diffs/patch-Mk__bsd.port.mk

--- patch_ports-MK__bsd.port.mk.txt begins here ---
Index: Mk/bsd.port.mk
===================================================================
RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.655
diff -u -r1.655 bsd.port.mk
--- Mk/bsd.port.mk	17 Nov 2010 21:06:43 -0000	1.655
+++ Mk/bsd.port.mk	17 Nov 2010 21:34:56 -0000
@@ -2481,6 +2481,7 @@
 PKGMESSAGE?=	${PKGDIR}/pkg-message
 
 TMPPLIST?=	${WRKDIR}/.PLIST.mktmp
+TMPGUCMD?=	${WRKDIR}/.PLIST.gucmd
 
 .for _CATEGORY in ${CATEGORIES}
 PKGCATEGORY?=	${_CATEGORY}
@@ -4126,7 +4127,7 @@
 		else \
 			${ECHO_MSG} "Using existing group \`$$group'."; \
 		fi; \
-		${ECHO_CMD} "@exec if ! ${PW} groupshow $$group >/dev/null 2>&1; then ${PW} groupadd $$group -g $$gid; fi" >> ${TMPPLIST}; \
+		${ECHO_CMD} "@exec if ! ${PW} groupshow $$group >/dev/null 2>&1; then ${PW} groupadd $$group -g $$gid; fi" >> ${TMPGUCMD}; \
 	done
 .endfor
 .endif
@@ -4154,8 +4155,8 @@
 		else \
 			${ECHO_MSG} "Using existing user \`$$login'."; \
 		fi; \
-		${ECHO_CMD} "@exec if ! ${PW} usershow $$login >/dev/null 2>&1; then ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell; fi" >> ${TMPPLIST}; \
-		case $$homedir in /nonexistent|/var/empty) ;; *) ${ECHO_CMD} "@exec ${INSTALL} -d -g $$gid -o $$uid $$homedir" >> ${TMPPLIST};; esac; \
+		${ECHO_CMD} "@exec if ! ${PW} usershow $$login >/dev/null 2>&1; then ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell; fi" >> ${TMPGUCMD}; \
+		case $$homedir in /nonexistent|/var/empty) ;; *) ${ECHO_CMD} "@exec ${INSTALL} -d -g $$gid -o $$uid $$homedir" >> ${TMPGUCMD};; esac; \
 	done
 .endfor
 .if defined(GROUPS)
@@ -4167,7 +4168,7 @@
 			list=`${PW} usershow $${_login} -P | ${SED} -ne 's/.*Groups: //p'`; \
 			${ECHO_MSG} "Setting \`$${_login}' groups to \`$$list$${list:+,}${_group}'."; \
 			${PW} usermod $${_login} -G $$list$${list:+,}${_group}; \
-			${ECHO_CMD} "@exec list=\`${PW} usershow $${_login} -P | ${SED} -ne 's/.*Groups: //p'\`; ${PW} usermod $${_login} -G \$${list},${_group}" >> ${TMPPLIST}; \
+			${ECHO_CMD} "@exec list=\`${PW} usershow $${_login} -P | ${SED} -ne 's/.*Groups: //p'\`; ${PW} usermod $${_login} -G \$${list},${_group}" >> ${TMPGUCMD}; \
 		done; \
 	done
 .endfor
@@ -4177,6 +4178,7 @@
 	@${DO_NADA}
 .endif
 .endif
+	@${CAT} ${TMPPLIST} >> ${TMPGUCMD} && ${MV} ${TMPGUCMD} ${TMPPLIST}
 
 .if !defined(DISABLE_SECURITY_CHECK)
 .if !target(security-check)
--- patch_ports-MK__bsd.port.mk.txt ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101122213228.2A8EF204E6>