Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 May 2004 15:40:24 +0100 (BST)
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/66758: [Maintainer update] net/phpldapadmin config file handling, WITH_SUPHP
Message-ID:  <200405171440.i4HEeOa1088962@happy-idiot-talk.infracaninophile.co.uk>
Resent-Message-ID: <200405171450.i4HEoCA2073300@freefall.freebsd.org>

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

>Number:         66758
>Category:       ports
>Synopsis:       [Maintainer update] net/phpldapadmin config file handling, WITH_SUPHP
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 17 07:50:12 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Seaman
>Release:        FreeBSD 4.10-PRERELEASE i386
>Organization:
Infracaninophile
>Environment:
System: FreeBSD happy-idiot-talk.infracaninophile.co.uk 4.10-PRERELEASE FreeBSD 4.10-PRERELEASE #68: Thu May 6 09:25:01 BST 2004 root@happy-idiot-talk.infracaninophile.co.uk:/usr/obj/usr/src/sys/HAPPY-IDIOT-TALK i386


>Description:

Apply some ideas developed for use with the phpmyadmin port over to
phpldapadmin:

	- Improve handling of config files, making them not world readable
	  by default.

	- Add a WITH_SUPHP option.

WITH_SUPHP gives a RUN_DEPENDS on www/suphp, and causes all of the web
content to be installed with pldapadm:www ownership.

    Files added:
        pkg-deinstall-suphp
        pkg-install-suphp
        pkg-plist-chunk
    Files modified
        Makefile
        pkg-message


>How-To-Repeat:
	
>Fix:

	

--- phpldapadmin.diff begins here ---
diff -Nur /usr/ports/net/phpldapadmin/Makefile phpldapadmin/Makefile
--- /usr/ports/net/phpldapadmin/Makefile	Sat May 15 09:19:04 2004
+++ phpldapadmin/Makefile	Mon May 17 15:20:44 2004
@@ -7,6 +7,7 @@
 
 PORTNAME=	phpldapadmin
 PORTVERSION=	0.9.4b
+PORTREVISION=	1
 CATEGORIES=	net www
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	phpldapadmin
@@ -14,33 +15,80 @@
 MAINTAINER=	m.seaman@infracaninophile.co.uk
 COMMENT=	A set of PHP-scripts to administer LDAP servers over the web
 
+NO_BUILD=	yes
+
+.if defined(WITH_SUPHP)
+
+RUN_DEPENDS=	${LOCALBASE}/sbin/suphp:${PORTSDIR}/www/suphp
+PKGNAMESUFFIX=	-suphp
+PKGINST_SKEL=	${PKGDIR}/pkg-install${PKGNAMESUFFIX}
+PKGINSTALL=	${WRKDIR}/pkg-install${PKGNAMESUFFIX}
+PKGDEINST_SKEL=	${PKGDIR}/pkg-deinstall${PKGNAMESUFFIX}
+PKGDEINSTALL=	${WRKDIR}/pkg-deinstall${PKGNAMESUFFIX}
+
+PLAUSR?=	pldapadm
+
+SED_SCRIPT=	-e 's,%%PREFIX%%,${PREFIX},g' \
+		-e 's,%%PLADIR%%,${PLADIR},g' \
+		-e 's,%%PLAUSR%%,${PLAUSR},g' \
+		-e 's,%%PLAGRP%%,${PLAGRP},g'
+
+.else
+
 USE_PHP=	yes
 WANT_PHP_WEB=	yes
-NO_BUILD=	yes
 
-WWWDIR?=	www/${PORTNAME}
+.endif
 
 MSG_SKEL=	${PKGDIR}/pkg-message
 PKGMESSAGE=	${WRKDIR}/pkg-message
+
+# PLAUSR is only used WITH_SUPHP
+PLADIR?=	www/${PORTNAME}
+PLAGRP?=	${WWWGRP}
+CFGFILE=	config.php
+
 PLIST=		${WRKDIR}/plist
-PLIST_SUB+=	WWWDIR=${WWWDIR}
+PLIST_SUB+=	PLADIR=${PLADIR} PLAGRP=${PLAGRP}
 
 .SILENT:
 
+pre-everything::
+	${ECHO_MSG} ""
+	${ECHO_MSG} "You may use the following build options:"
+	${ECHO_MSG} ""
+	${ECHO_MSG} "    WITH_SUPHP=yes   Install appropriately for use with"
+	${ECHO_MSG} "                     the www/suphp port [default: no]"
+	${ECHO_MSG} ""
+
 post-patch:
 	${RM} -f ${PLIST}
 	cd ${WRKSRC} ; \
-	${FIND} . ! -type d ! -name .cvsignore | ${SORT} | \
-	    ${SED} "s,^.,%%WWWDIR%%," >${PLIST} ; \
-	${FIND} . -type d | ${SORT} -r | \
-	    ${SED} "s,^.,@dirrm %%WWWDIR%%," >>${PLIST}
-	${SED} -e 's,%%WWWDIR%%,${WWWDIR},g' \
-	       -e 's,%%PREFIX%%,${PREFIX},g' ${MSG_SKEL} > ${PKGMESSAGE}
+	${FIND} . ! -type d ! -name ${CFGFILE}.example ! -name .cvsignore | \
+	    ${SORT} | ${SED} "s,^\.,%%PLADIR%%,"     >${PLIST} ; \
+	${CAT} ${PKGDIR}/pkg-plist-chunk            >>${PLIST} ; \
+	${FIND} . -type d | ${SORT} -r | ${SED} \
+	    -e "s,^\.$$,@unexec rmdir %D/%%PLADIR%% 2>/dev/null || true," \
+	    -e "s,^\.,@dirrm %%PLADIR%%,"           >>${PLIST}
+	${SED} -e 's,%%PKGNAME%%,${PKGNAME},g' \
+	       -e 's,%%PREFIX%%,${PREFIX},g'   \
+	       -e 's,%%PLADIR%%,${PLADIR},g'   ${MSG_SKEL} > ${PKGMESSAGE}
+.if defined(WITH_SUPHP)
+	${SED} ${SED_SCRIPT} ${PKGINST_SKEL}   > ${PKGINSTALL}
+	${SED} ${SED_SCRIPT} ${PKGDEINST_SKEL} > ${PKGDEINSTALL}
+.endif
+
+pre-install:
+.if defined(WITH_SUPHP)
+	${SETENV} ${SCRIPTS_ENV} ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
+.endif
 
-do-install:
+do-install: install-app install-conf
+
+install-app:
 	cd ${WRKSRC} ; \
 	for src in $$( ${FIND} . ! -name .cvsignore  ) ; do \
-	    dst=${PREFIX}/${WWWDIR}$${src#.} ; \
+	    dst=${PREFIX}/${PLADIR}$${src#.} ; \
 	    if ${TEST} -d $$src ; then \
 	        ${MKDIR} $$dst ; \
 	    else \
@@ -48,9 +96,18 @@
 	    fi \
 	done
 
+install-conf:
+	cd ${PREFIX}/${PLADIR} ; \
+	${CHMOD} 0640 ${CFGFILE}.example ; \
+	${CHGRP} ${PLAGRP} ${CFGFILE}.example ; \
+	if ${TEST} ! -f ${CFGFILE} ; then \
+	    ${CP} -p ${CFGFILE}.example ${CFGFILE} ; \
+	fi
+
 post-install:
-	${ECHO_MSG}
+.if defined(WITH_SUPHP)
+	${SETENV} ${SCRIPTS_ENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+.endif
 	${CAT} ${PKGMESSAGE}
-	${ECHO_MSG}
 
 .include <bsd.port.mk>
diff -Nur /usr/ports/net/phpldapadmin/pkg-deinstall-suphp phpldapadmin/pkg-deinstall-suphp
--- /usr/ports/net/phpldapadmin/pkg-deinstall-suphp	Thu Jan  1 01:00:00 1970
+++ phpldapadmin/pkg-deinstall-suphp	Mon May 17 15:22:06 2004
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+case $2 in
+    POST-DEINSTALL)
+    cat <<EOMSG
+The phpldapadmin-suphp port has been deleted.
+If you are not upgrading and don't intend to use
+phpLDAPadmin any more then you may wish to delete
+the %%PLAUSR%% account, which can be done with
+the following command:
+
+    # pw userdel %%PLAUSR%%
+EOMSG
+    if [ -d %%PREFIX%%/%%PLADIR%% ] ; then
+	echo "    # rm -rf %%PREFIX%%/%%PLADIR%%/"
+    fi
+    echo
+    ;;
+esac
+
+#
+# That's All Folks!
+#
diff -Nur /usr/ports/net/phpldapadmin/pkg-install-suphp phpldapadmin/pkg-install-suphp
--- /usr/ports/net/phpldapadmin/pkg-install-suphp	Thu Jan  1 01:00:00 1970
+++ phpldapadmin/pkg-install-suphp	Mon May 17 14:39:33 2004
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+PATH=/usr/sbin:/usr/bin:/bin ; export PATH
+
+pladir=%%PREFIX%%/%%PLADIR%%
+plausr=%%PLAUSR%%
+plagrp=%%PLAGRP%%
+
+plagcos="phpLDAPadmin Owner"
+plahome=/nonexistent
+plashell=/sbin/nologin
+
+create_group() {
+    local user group gcos home shell
+
+    user=$1
+    group=$2
+    gcos=$3
+    home=$4
+    shell=$5
+
+    if pw groupadd -n $group ; then
+	echo "===> Group $group created"
+    else
+	cat <<-EOERRORMSG
+	*** Failed to create the $group group.
+
+	Please add the $user user and $group group
+	manually with the commands:
+
+	    pw groupadd -n $group
+	    pw useradd -n $user -g $group -c "$gcos" \\
+	        -d $home -s $shell -h -
+	    
+	and retry installing this package.
+	EOERRORMSG
+	exit 1
+    fi
+}
+
+
+create_user() {
+    local user group gcos home shell
+
+    user=$1
+    group=$2
+    gcos=$3
+    home=$4
+    shell=$5
+
+    if pw useradd -n $user -g $group -c "$gcos" -d $home -s $shell -h - ; then
+	echo "===> Created $user user"
+    else
+	cat <<-EOERRORMSG
+	*** Failed to create the $user user.
+
+	Please add the $user user manually with the command:
+
+	    pw useradd -n $user -g $group -c "$gcos" \\
+		        -d $home -s $shell -h -
+
+	and retry installing this package.
+	EOERRORMSG
+	exit 1
+    fi
+}
+
+
+case $2 in
+    PRE-INSTALL)
+
+        # Create the pla user and group if they do not already exist
+
+        if pw user show -n $plausr >/dev/null 2>&1 ; then
+	    echo "===> Using pre-existing user $plausr"
+	else
+	    if ! pw group show -n $plagrp >/dev/null 2>&1 ; then
+		create_group $plausr $plagrp "$plagcos" $plahome \
+		    $plashell
+	    fi
+	    create_user $plausr $plagrp "$plagcos" $plahome $plashell
+	fi
+	;;
+    POST-INSTALL)
+
+    	# Change ownership of the phpLDAPadmin directory
+
+        echo "===> Adjusting file ownership in $pladir"
+        chown -R $plausr:$plagrp $pladir || exit 1
+	;;
+esac
+
+#
+# That's All Folks!
+#
diff -Nur /usr/ports/net/phpldapadmin/pkg-message phpldapadmin/pkg-message
--- /usr/ports/net/phpldapadmin/pkg-message	Sat May 15 09:19:04 2004
+++ phpldapadmin/pkg-message	Mon May 17 14:39:31 2004
@@ -1,17 +1,15 @@
 
-    phpLDAPadmin has been installed into:
+%%PKGNAME%% has been installed into:
 
-       %%PREFIX%%/%%WWWDIR%%
+    %%PREFIX%%/%%PLADIR%%
 
-    Please copy config.php.example to config.php and edit to suit
-    your needs.
+Please edit config.php and edit to suit your needs.
 
-    To make phpLDAPadmin available through your web site, I suggest
-    that you add the following to httpd.conf:
+To make phpLDAPadmin available through your web site, 
+I suggest that you add the following to httpd.conf:
 
-       Alias /phpldapadmin/ "%%PREFIX%%/%%WWWDIR%%/"
+    Alias /phpldapadmin/ "%%PREFIX%%/%%PLADIR%%/"
 
-    You will need a version of PHP with LDAP functionality enabled,
-    which is not the default.  If necessary, enable the 'OPENLDAP'
-    option in the www/mod_php4 port's configuration screen and
-    reinstall PHP.
+You will need a version of PHP with LDAP functionality enabled,
+which is not the default.  If necessary, enable the 'OPENLDAP'
+option in the PHP port's configuration screen and reinstall.
diff -Nur /usr/ports/net/phpldapadmin/pkg-plist-chunk phpldapadmin/pkg-plist-chunk
--- /usr/ports/net/phpldapadmin/pkg-plist-chunk	Thu Jan  1 01:00:00 1970
+++ phpldapadmin/pkg-plist-chunk	Mon May 17 14:53:54 2004
@@ -0,0 +1,7 @@
+@mode 640
+@group %%PLAGRP%%
+@unexec if cmp -s %D/%%PLADIR%%/config.php.example %D/%%PLADIR%%/config.php ; then rm -f %D/%%PLADIR%%/config.php ; fi
+%%PLADIR%%/config.php.example
+@exec [ ! -f %B/config.php ] && cp -p %B/%f %B/config.php || true
+@mode
+@group
--- phpldapadmin.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



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