From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Dec 21 19:00:30 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 450CE1065697 for ; Wed, 21 Dec 2011 19:00:30 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BF7298FC34 for ; Wed, 21 Dec 2011 19:00:25 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBLJ0Pro000839 for ; Wed, 21 Dec 2011 19:00:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBLJ0PJO000837; Wed, 21 Dec 2011 19:00:25 GMT (envelope-from gnats) Resent-Date: Wed, 21 Dec 2011 19:00:25 GMT Resent-Message-Id: <201112211900.pBLJ0PJO000837@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Chris Rees Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9301106566B for ; Wed, 21 Dec 2011 18:57:39 +0000 (UTC) (envelope-from crees@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CD0F38FC13 for ; Wed, 21 Dec 2011 18:57:39 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBLIvdMt000717 for ; Wed, 21 Dec 2011 18:57:39 GMT (envelope-from crees@freefall.freebsd.org) Received: (from crees@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBLIvdXZ000716; Wed, 21 Dec 2011 18:57:39 GMT (envelope-from crees) Message-Id: <201112211857.pBLIvdXZ000716@freefall.freebsd.org> Date: Wed, 21 Dec 2011 18:57:39 GMT From: Chris Rees To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: ports/163511: [PATCH] bsd.port.mk: Allow existing users on system to be used by ports X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Chris Rees List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2011 19:00:30 -0000 >Number: 163511 >Category: ports >Synopsis: [PATCH] bsd.port.mk: Allow existing users on system to be used by ports >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: Wed Dec 21 19:00:25 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Chris Rees >Release: FreeBSD 8.2-STABLE i386 >Organization: >Environment: System: FreeBSD freefall.freebsd.org 8.2-STABLE FreeBSD 8.2-STABLE #5 r227907: Wed Nov 23 21:55:50 UTC 2011 simon@freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386 >Description: Currently one must ensure that a user in USERS= in a port Makefile is included in ${UID_FILES}. This of course is important when a port defines a standard username, but when it allows the username to be customised it results in inflexibility (ports/162934). Instead of guessing anything, it's still an error if no such user exists, but if the user does exist it uses those details to program the package to create the user. >How-To-Repeat: >Fix: - Detect and use groups and users present on system - Correct uses of ECHO_MSG - Correct sample master.passwd line --- bsd-port-mk-users-existing.diff begins here --- Index: bsd.port.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.port.mk,v retrieving revision 1.699 diff -u -r1.699 bsd.port.mk --- bsd.port.mk 9 Nov 2011 08:53:12 -0000 1.699 +++ bsd.port.mk 18 Dec 2011 15:55:27 -0000 @@ -4102,23 +4102,28 @@ .endif .if !target(create-users-groups) +GETUSER= ${SH} -c '${GREP} -h ^$${0}: ${UID_FILES} \ + || (/usr/bin/getent passwd $${0} \ + | ${SED} "s/^\([^:]*:\)\{4\}/&:0:0:/")' +GETGROUP= ${SH} -c '${GREP} -h ^$${0}: ${GID_FILES} \ + || /usr/bin/getent group $${0}' create-users-groups: .if defined(GROUPS) || defined(USERS) .if defined(GROUPS) .for _file in ${GID_FILES} .if !exists(${_file}) - @${ECHO_CMD} "** ${_file} doesn't exist. Exiting."; exit 1 + @${ECHO_MSG} "** ${_file} doesn't exist. Exiting."; exit 1 .endif .endfor @${ECHO_MSG} "===> Creating users and/or groups." @${ECHO_CMD} "@exec echo \"===> Creating users and/or groups.\"" >> ${TMPPLIST} .for _group in ${GROUPS} # _bgpd:*:130: - @if ! ${GREP} -h ^${_group}: ${GID_FILES} >/dev/null 2>&1; then \ - ${ECHO_CMD} "** Cannot find any information about group \`${_group}' in ${GID_FILES}."; \ + @if ! ${GETGROUP} ${_group} >/dev/null 2>&1; then \ + ${ECHO_MSG} "** Cannot find any information about group \`${_group}' in ${GID_FILES}."; \ exit 1; \ fi - @IFS=":"; ${GREP} -h ^${_group}: ${GID_FILES} | head -n 1 | while read group foo gid members; do \ + @IFS=":"; ${GETGROUP} ${_group} | head -n 1 | while read group foo gid members; do \ gid=$$(($$gid+${GID_OFFSET})); \ if ! ${PW} groupshow $$group >/dev/null 2>&1; then \ ${ECHO_MSG} "Creating group \`$$group' with gid \`$$gid'."; \ @@ -4135,16 +4140,16 @@ .if defined(USERS) .for _file in ${UID_FILES} .if !exists(${_file}) - @${ECHO_CMD} "** ${_file} doesn't exist. Exiting."; exit 1 + @${ECHO_MSG} "** ${_file} doesn't exist. Exiting."; exit 1 .endif .endfor .for _user in ${USERS} -# _bgpd:*:130:130:BGP Daemon:/var/empty:/sbin/nologin - @if ! ${GREP} -h ^${_user}: ${UID_FILES} >/dev/null 2>&1; then \ - ${ECHO_CMD} "** Cannot find any information about user \`${_user}' in ${UID_FILES}."; \ +# _bgpd:*:130:130::0:0:BGP Daemon:/var/empty:/sbin/nologin + @if ! ${GETUSER} ${_user} >/dev/null 2>&1; then \ + ${ECHO_MSG} "** Cannot find any information about user \`${_user}' in ${UID_FILES}."; \ exit 1; \ fi - @IFS=":"; ${GREP} -h ^${_user}: ${UID_FILES} | head -n 1 | while read login passwd uid gid class change expire gecos homedir shell; do \ + @IFS=":"; ${GETUSER} ${_user} | head -n 1 | while read login passwd uid gid class change expire gecos homedir shell; do \ uid=$$(($$uid+${UID_OFFSET})); \ gid=$$(($$gid+${GID_OFFSET})); \ class="$${class:+-L }$$class"; \ @@ -4166,7 +4171,7 @@ .if defined(GROUPS) .for _group in ${GROUPS} # mail:*:6:postfix,clamav - @IFS=":"; ${GREP} -h ^${_group}: ${GID_FILES} | head -n 1 | while read group foo gid members; do \ + @IFS=":"; ${GETGROUP} ${_group} | head -n 1 | while read group foo gid members; do \ gid=$$(($$gid+${GID_OFFSET})); \ IFS=","; for _login in $$members; do \ for _user in ${USERS}; do \ --- bsd-port-mk-users-existing.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: