Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 May 2002 18:56:44 -0500 (CDT)
From:      "Scot W. Hetzel" <hetzels@westbend.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/38435: mail/cyrus: Need to modify cyrus user to have a shell
Message-ID:  <200205222356.g4MNui6x098917@wbiW009.westbend.net>

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

>Number:         38435
>Category:       ports
>Synopsis:       mail/cyrus: Need to modify cyrus user to have a shell
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 22 17:00:06 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Scot W. Hetzel
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
West Bend Internet
>Environment:
System: FreeBSD wbiW009.westbend.net 4.5-STABLE FreeBSD 4.5-STABLE #7: Wed Apr 24 10:46:07 CDT 2002 root@wbiW009.westbend.net:/usr/obj/usr/src/sys/GENERIC-SMP i386


>Description:
	Some of the Cyrus-IMAPd utilities need to be run as the cyrus user.  But
	currently, both the Cyrus-SASL and Cyrus-IMAPd modify the cyrus user to
	not have a shell.

	The Cyrus-SASL iport can't assign a shell to the cyrus user as it may be
	used on a system that doesn't have Cyrus-IMAPd installed.

>How-To-Repeat:
	Install the Cyrus-SASL port, give the cyrus user a shell, then install
	the Cyrus port.  The cyrus user will no longer have a shell.

>Fix:

	- removed creation of cyrus user from pkg-install
	- added a modify_cyrus_user to both pkg-deinstall/pkg-install

	Changed Files:
		Makefile
		pkg-deinstall
		pkg-install

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/mail/cyrus/Makefile,v
retrieving revision 1.40
diff -u -r1.40 Makefile
--- Makefile	29 Jan 2002 11:45:16 -0000	1.40
+++ Makefile	22 May 2002 22:38:34 -0000
@@ -39,7 +39,6 @@
 
 pre-install:
 		@ ${CP} ${WRKSRC}/man/quota.8 ${WRKSRC}/man/cyrquota.8
-		@${PKGINSTALL} ${PKGNAME} PRE-INSTALL
 
 DOCS=	README acl-extension anoncvs bugs changes copyrights install \
 	mailing-list overview quota-extension server-design
Index: pkg-deinstall
===================================================================
RCS file: /home/ncvs/ports/mail/cyrus/pkg-deinstall,v
retrieving revision 1.2
diff -u -r1.2 pkg-deinstall
--- pkg-deinstall	7 Feb 2002 01:03:48 -0000	1.2
+++ pkg-deinstall	22 May 2002 23:33:05 -0000
@@ -35,6 +35,28 @@
 	fi
 }
 
+#
+# Modify the 'cyrus' user created from the cyrus-sasl port
+#
+
+modify_cyrus_user() {
+	USER=cyrus
+	PW=/usr/sbin/pw
+	if [ -x /sbin/nologin ]; then
+		shell=/sbin/nologin
+	else
+		shell=/nonexistent
+	fi
+	uhome=/nonexistent
+
+	if ! ${PW} mod user ${USER} -d "${uhome}" -s "${shell}" \ ; then
+		e=$?
+		echo "*** Failed to update user \`${USER}'."
+		exit ${e}
+	fi
+	echo "*** Updated user \`${USER}'."
+}
+
 case $2 in
 	DEINSTALL)
 		cd ${PKG_PREFIX}
@@ -42,6 +64,7 @@
 		checkfile ${PKG_PREFIX}/etc/imapd.conf
 		;;
 	POST-DEINSTALL)
+		modify_cyrus_user
 		;;
 
 esac
Index: pkg-install
===================================================================
RCS file: /home/ncvs/ports/mail/cyrus/pkg-install,v
retrieving revision 1.3
diff -u -r1.3 pkg-install
--- pkg-install	21 Dec 2000 08:25:47 -0000	1.3
+++ pkg-install	22 May 2002 23:33:20 -0000
@@ -7,61 +7,21 @@
 PKG_PREFIX=${PKG_PREFIX:=/usr/local}
 
 #
-# create 'cyrus' user and group before installing
+# Modify the 'cyrus' user created from the cyrus-sasl port
 #
 
-create() {
-	if [ ! -x /usr/sbin/pw ]; then
-		echo "*** Please add a user and a group named \`cyrus' before installing this package."
-		exit 69
-	fi
+modify_cyrus_user() {
+	USER=cyrus
+	PW=/usr/sbin/pw
+	shell=/bin/csh
+	uhome=${PKG_PREFIX}/cyrus
 
-	if ! pw show group cyrus -q >/dev/null; then
-		gid=60
-		while pw show group -g ${gid} -q >/dev/null; do
-			gid=`expr ${gid} + 1`
-		done
-		if ! pw add group cyrus -g ${gid}; then
+	if ! ${PW} mod user ${USER} -d "${uhome}" -s "${shell}" \ ; then
 			e=$?
-			echo "*** Failed to add group \`cyrus'. Please add it manually."
+			echo "*** Failed to update user \`${USER}'."
 			exit ${e}
-		fi
-		echo "*** Added group \`cyrus' (id ${gid})"
-	else
-		gid=`pw show group cyrus 2>/dev/null | cut -d: -f3`
-	fi
-
-	if [ -x /sbin/nologin ]; then
-		shell=/sbin/nologin
-	else
-		shell=/nonexistent
-	fi
-	if ! pw show user cyrus -q >/dev/null; then
-		uid=60
-		while pw show user -u ${uid} -q >/dev/null; do
-			uid=`expr ${uid} + 1`
-		done
-		if ! pw add user cyrus -u ${uid} -g ${gid} -d "/nonexistent" \
-				-c "the cyrus mail server" -s "${shell}" -p "*" \
-				; then
-			e=$?
-			echo "*** Failed to add user \`cyrus'. Please add it manually."
-			exit ${e}
-		fi
-		echo "*** Added user \`cyrus' (id ${uid})"
-	else
-		if ! pw mod user cyrus -g ${gid} -d "/nonexistent" \
-				-c "the cyrus mail server" -s "${shell}" -p "*" \
-				; then
-			e=$?
-			echo "*** Failed to update user \`cyrus'."
-			exit ${e}
-		fi
-		echo "*** Updated user \`cyrus'."
-	fi
-	if ! pw group mod cyrus -m daemon; then
-		echo "*** can't add user \`daemon' to group \`cyrus'"
 	fi
+	echo "*** Updated user \`${USER}'."
 }
 
 
@@ -90,10 +50,10 @@
 
 case $2 in
 	PRE-INSTALL)
-		create
 		;;
 
 	POST-INSTALL)
+		modify_cyrus_user
 		cd ${PKG_PREFIX}
 		cyrus_conf
 		checkfile ${PKG_PREFIX}/etc/imapd.conf
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




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