Bug 120505 - [maintainer] net/phpldapadmin, net/phpldapadmin098 -- use /usr/ports/UIDs, etc.
Summary: [maintainer] net/phpldapadmin, net/phpldapadmin098 -- use /usr/ports/UIDs, etc.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Rong-En Fan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-10 15:30 UTC by Matthew Seaman
Modified: 2008-03-09 04:50 UTC (History)
0 users

See Also:


Attachments
UIDs.patch (566 bytes, patch)
2008-02-10 15:30 UTC, Matthew Seaman
no flags Details | Diff
phpldapadmin098.diff (10.84 KB, patch)
2008-02-10 15:30 UTC, Matthew Seaman
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Seaman 2008-02-10 15:30:01 UTC
	

This is an update to the ports only -- no updates to either of
the phpldapadmin applications themselves.

Changes:

* When installed using WITH_SUPHP use a fixed username/UID from
/usr/ports/UIDs. There's no equivalent /usr/ports/GIDs entry
because it defaults to group 'www'.

* Consequently change the default username from pldapadm to _pla
and add an entry to /usr/ports/UIDs:

  _pla:*:636:80:phpLDAPAdmin Owner:/nonexistent:/usr/sbin/nologin

Both net/phpldapadmin and net/phpldapadmin098 use the same UID, hence
both patch-sets in the same PR.

* Use the standard $WWWDIR for PLIST_SUB and SUB_LIST, instead of
rolling my own equivalent.

* Various internal code changes and clean-up

Note: the changes here mostly affect compilation with WITH_SUPHP
defined. If you're not a suPHP user, then there's very little
ultimately that has changed.

Fix: diff -Nur /usr/ports/net/phpldapadmin/Makefile phpldapadmin/Makefile
--- /usr/ports/net/phpldapadmin/Makefile	2008-02-06 07:14:43.000000000 +0000
+++ phpldapadmin/Makefile	2008-02-10 15:15:16.000000000 +0000
@@ -7,6 +7,7 @@
 
 PORTNAME=	phpldapadmin
 PORTVERSION=	1.1.0.5
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	net www
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
@@ -21,36 +22,54 @@
 DEFAULT_PHP_VER=	5
 IGNORE_WITH_PHP=	4
 
-.if defined(WITH_SUPHP)
+.if defined(WITH_SUPHP) && !defined(WITHOUT_SUPHP)
 
 PKGNAMESUFFIX+=	-suphp
 RUN_DEPENDS+=	${LOCALBASE}/sbin/suphp:${PORTSDIR}/www/suphp
 WANT_PHP_CGI=	yes
 
-PLAUSR?=	pldapadm
-
-SUB_LIST+=	PLAUSR=${PLAUSR} \
-		PLAGRP=${PLAGRP}
-SUB_FILES+=	pkg-install  pkg-deinstall
-
 .else
 
 WANT_PHP_WEB=	yes
 
 .endif
 
-# PLAUSR is only used WITH_SUPHP
-PLADIR?=	www/${PORTNAME}
-PLAGRP?=	${WWWGRP}
+# PLA_USR is only used WITH_SUPHP
+PLA_GRP?=	${WWWGRP}
+PLA_GID?=	${_PLA_GID}
 CFGDIR=		config
 CFGFILE=	config.php
 
-SUB_LIST+=	PKGNAME=${PKGNAME} \
-		PLADIR=${PLADIR}
+PLIST=		${WRKDIR}/plist
+PLIST_SUB+=	PLA_GRP=${PLA_GRP}
+
+.if defined(WITH_SUPHP) && !defined(WITHOUT_SUPHP)
+
+PLA_USR?=	_pla
+PLA_UID?=	636
+PLA_GCOS?=	"phpLDAPAdmin Owner"
+PLA_HOME?=	/nonexistent
+PLA_SHELL?=	/usr/sbin/nologin
+
+SUB_LIST+=	PLA_USR=${PLA_USR}    \
+		PLA_UID=${PLA_UID}    \
+		PLA_GRP=${PLA_GRP}    \
+		PLA_GID=${PLA_GID}    \
+		PLA_GCOS=${PLA_GCOS}  \
+		PLA_HOME=${PLA_HOME}  \
+		PLA_SHELL=${PLA_SHELL}
+SUB_FILES+=	pkg-install pkg-deinstall
+
+.endif
+
+SUB_LIST+=	PKGNAME=${PKGNAME}
 SUB_FILES+=	pkg-message
 
-PLIST=		${WRKDIR}/plist
-PLIST_SUB+=	PLADIR=${PLADIR} PLAGRP=${PLAGRP}
+.include <bsd.port.pre.mk>
+_PLA_GID!=	/usr/sbin/pw group show -n ${PLA_GRP} | ${CUT} -d : -f 3
+.if empty(_PLA_GID)
+_PLA_GID=	80
+.endif
 
 .SILENT:
 
@@ -64,16 +83,25 @@
 	${ECHO_MSG} "This port is PHP5 specific. If you need PHP4 support,"
 	${ECHO_MSG} "please use the net/phpldapadmin098 port instead."
 	${ECHO_MSG} ""
+.if defined(WITH_SUPHP) && !defined(WITHOUT_SUPHP)
+	@if /usr/sbin/pw show -n pldapadm >/dev/null 2>&1 ; then	      \
+	    ${ECHO_MSG} "===> WARNING ******************************" ;	      \
+	    ${ECHO_MSG} "The default username used by ${PKNAME} has changed"; \
+	    ${ECHO_MSG} "to ${PLA_USR} -- you should delete the old user:" ;  \
+	    ${ECHO_MSG} "  # /usr/sbin/pw user del -n pldapadm" ;	      \
+	    ${ECHO_MSG} "" ;						      \
+	fi
+.endif
 
 post-patch:
-	cd ${WRKSRC} ;                                                      \
+	cd ${WRKSRC} ;							    \
 	${FIND} . ! -type d ! -name ${CFGFILE}.example ! -name .cvsignore | \
-	    ${SORT} | ${SED} -e "s!^\.!%%PLADIR%%!"             >${PLIST} ; \
-	${CAT} ${PKGDIR}/pkg-plist-chunk                       >>${PLIST} ; \
-	${FIND} . -type d | ${SORT} -r | ${SED}                             \
-	    -e 's!^\./${CFGDIR}$$!@dirrmtry %%PLADIR%%/${CFGDIR}!'          \
-	    -e 's!^\.$$!@dirrmtry %%PLADIR%%!'                              \
-	    -e 's!^\.!@dirrm %%PLADIR%%!'                      >>${PLIST}
+	    ${SORT} | ${SED} -e "s!^\.!%%WWWDIR%%!"		>${PLIST} ; \
+	${CAT} ${PKGDIR}/pkg-plist-chunk		       >>${PLIST} ; \
+	${FIND} . -type d | ${SORT} -r | ${SED}				    \
+	    -e 's!^\./${CFGDIR}$$!@dirrmtry %%WWWDIR%%/${CFGDIR}!'	    \
+	    -e 's!^\.$$!@dirrmtry %%WWWDIR%%!'				    \
+	    -e 's!^\.!@dirrm %%WWWDIR%%!'		       >>${PLIST}
 
 pre-install:
 .if defined(WITH_SUPHP)
@@ -85,18 +113,18 @@
 install-app:
 	cd ${WRKSRC} ; \
 	for src in $$( ${FIND} . ! -name .cvsignore  ) ; do \
-	    dst=${PREFIX}/${PLADIR}$${src#.} ; \
+	    dst=${WWWDIR}$${src#.} ; \
 	    if ${TEST} -d $$src ; then \
-	        ${MKDIR} $$dst ; \
+		${MKDIR} $$dst ; \
 	    else \
-	        ${INSTALL_DATA} $$src $$dst ; \
+		${INSTALL_DATA} $$src $$dst ; \
 	    fi \
 	done
 
 install-conf:
-	cd ${PREFIX}/${PLADIR}/${CFGDIR} ; \
+	cd ${WWWDIR}/${CFGDIR} ; \
 	${CHMOD} 0640 ${CFGFILE}.example ; \
-	${CHGRP} ${PLAGRP} ${CFGFILE}.example ; \
+	${CHGRP} ${PLA_GRP} ${CFGFILE}.example ; \
 	if ${TEST} ! -f ${CFGFILE} ; then \
 	    ${CP} -p ${CFGFILE}.example ${CFGFILE} ; \
 	fi
@@ -107,4 +135,4 @@
 .endif
 	${CAT} ${PKGMESSAGE}
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -Nur /usr/ports/net/phpldapadmin/files/pkg-deinstall.in phpldapadmin/files/pkg-deinstall.in
--- /usr/ports/net/phpldapadmin/files/pkg-deinstall.in	2005-12-11 23:51:12.000000000 +0000
+++ phpldapadmin/files/pkg-deinstall.in	2008-02-10 12:34:31.000000000 +0000
@@ -9,13 +9,13 @@
 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 %%PLA_USR%% account, which can be done with
 the following command:
 
-    # pw userdel %%PLAUSR%%
+    # pw userdel %%PLA_USR%%
 EOMSG
-    if [ -d %%PREFIX%%/%%PLADIR%% ] ; then
-	echo "    # rm -rf %%PREFIX%%/%%PLADIR%%/"
+    if [ -d %%WWWDIR%% ] ; then
+	echo "    # rm -rf %%WWWDIR%%/"
     fi
     echo
     ;;
diff -Nur /usr/ports/net/phpldapadmin/files/pkg-install.in phpldapadmin/files/pkg-install.in
--- /usr/ports/net/phpldapadmin/files/pkg-install.in	2005-12-11 23:51:12.000000000 +0000
+++ phpldapadmin/files/pkg-install.in	2008-02-10 12:32:44.000000000 +0000
@@ -1,70 +1,87 @@
 #!/bin/sh
 #
-# $FreeBSD: ports/net/phpldapadmin/files/pkg-install.in,v 1.1 2005/12/11 23:51:12 lawrance Exp $
+# $FreeBSD$
 #
 
 PATH=/usr/sbin:/usr/bin:/bin ; export PATH
 
-pladir=%%PREFIX%%/%%PLADIR%%
-plausr=%%PLAUSR%%
-plagrp=%%PLAGRP%%
-
-plagcos="phpLDAPadmin Owner"
-plahome=/nonexistent
-plashell=/sbin/nologin
+pla_dir=%%WWWDIR%%
+pla_usr=%%PLA_USR%%
+pla_uid=%%PLA_UID%%
+pla_grp=%%PLA_GRP%%
+pla_gid=%%PLA_GID%%
+
+pla_gcos="%%PLA_GCOS%%"
+pla_home=%%PLA_HOME%%
+pla_shell=%%PLA_SHELL%%
 
 create_group() {
-    local user group gcos home shell
+    local user uid group gid gcos home shell
 
     user=$1
-    group=$2
-    gcos=$3
-    home=$4
-    shell=$5
+    uid=$2
+    group=$3
+    gid=$4
+    gcos=$5
+    home=$6
+    shell=$7
 
-    if pw groupadd -n $group ; then
-	echo "===> Group $group created"
+
+    if pw group show -n $group >/dev/null 2>&1 ; then
+	echo "===> Using pre-existing group $group"
     else
-	cat <<-EOERRORMSG
-	*** Failed to create the $group group.
+	if pw groupadd -n $group -g $gid ; 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:
+		Please add the $user user and $group group
+		manually with the commands:
+
+		    pw groupadd -n $group -g $gid
+		    pw useradd -n $user -u $uid -g $group -c "$gcos" \\
+		        -d $home -s $shell -h -
 
-	    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
+		and retry installing this package.
+		EOERRORMSG
+	    exit 1
+	fi
     fi
+
 }
 
 
 create_user() {
-    local user group gcos home shell
+    local user uid group gid gcos home shell
 
     user=$1
-    group=$2
-    gcos=$3
-    home=$4
-    shell=$5
+    uid=$2
+    group=$3
+    gid=$4
+    gcos=$5
+    home=$6
+    shell=$7
 
-    if pw useradd -n $user -g $group -c "$gcos" -d $home -s $shell -h - ; then
-	echo "===> Created $user user"
+    if pw user show -n $user >/dev/null 2>&1 ; then
+	echo "===> Using pre-existing user $user"
     else
-	cat <<-EOERRORMSG
-	*** Failed to create the $user user.
+	if pw useradd -n $user -u $uid -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:
+		Please add the $user user manually with the command:
 
-	    pw useradd -n $user -g $group -c "$gcos" \\
-		        -d $home -s $shell -h -
+		    pw useradd -n $user -u $uid -g $group -c "$gcos" \\
+		       -d $home -s $shell -h -
 
-	and retry installing this package.
-	EOERRORMSG
-	exit 1
+		and retry installing this package.
+		EOERRORMSG
+	    exit 1
+	fi
     fi
 }
 
@@ -73,23 +90,18 @@
     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
+	create_group $pla_usr $pla_uid $pla_grp $pla_gid \
+                     "$pla_gcos" $pla_home $pla_shell
+	create_user  $pla_usr $pla_uid $pla_grp $pla_gid \
+                     "$pla_gcos" $pla_home $pla_shell
 	;;
+
     POST-INSTALL)
 
-    	# Change ownership of the phpLDAPadmin directory
+    	# Change ownership of the phpMyAdm directory
 
-        echo "===> Adjusting file ownership in $pladir"
-        chown -R $plausr:$plagrp $pladir || exit 1
+        echo "===> Adjusting file ownership in $pla_dir"
+        chown -R $pla_usr:$pla_grp $pla_dir || exit 1
 	;;
 esac
 
diff -Nur /usr/ports/net/phpldapadmin/files/pkg-message.in phpldapadmin/files/pkg-message.in
--- /usr/ports/net/phpldapadmin/files/pkg-message.in	2006-05-28 17:59:00.000000000 +0100
+++ phpldapadmin/files/pkg-message.in	2008-02-10 15:13:14.000000000 +0000
@@ -1,16 +1,16 @@
 
 %%PKGNAME%% has been installed into:
 
-    %%PREFIX%%/%%PLADIR%%
+    %%WWWDIR%%
 
 Please edit config.php to suit your needs.
 
 To make phpLDAPadmin available through your web site, I suggest that
-you add something like following to httpd.conf:
+you add something like the following to httpd.conf:
 
-    Alias /phpldapadmin/ "%%PREFIX%%/%%PLADIR%%/htdocs"
+    Alias /phpldapadmin/ "%%WWWDIR%%/htdocs"
 
-    <Directory "%%PREFIX%%/%%PLADIR%%/htdocs">
+    <Directory "%%WWWDIR%%/htdocs">
         Options none
         AllowOverride none
 
@@ -24,10 +24,9 @@
 need to modify your apache configuration and merge the settings from
 your original configuration file:
 
-    %%PREFIX%%/%%PLADIR%%/config.php
+    %%WWWDIR%%/config.php
 
  to
 
-   %%PREFIX%%/%%PLADIR%%/config/config.php
-
+    %%WWWDIR%%/config/config.php
 
diff -Nur /usr/ports/net/phpldapadmin/pkg-plist-chunk phpldapadmin/pkg-plist-chunk
--- /usr/ports/net/phpldapadmin/pkg-plist-chunk	2005-12-11 23:51:12.000000000 +0000
+++ phpldapadmin/pkg-plist-chunk	2008-02-10 13:10:58.000000000 +0000
@@ -1,7 +1,7 @@
 @mode 640
-@group %%PLAGRP%%
-@unexec if cmp -s %D/%%PLADIR%%/config/config.php.example %D/%%PLADIR%%/config/config.php ; then rm -f %D/%%PLADIR%%/config/config.php ; fi
-%%PLADIR%%/config/config.php.example
+@group %%PLA_GRP%%
+@unexec if cmp -s %D/%%WWWDIR%%/config/config.php.example %D/%%WWWDIR%%/config/config.php ; then rm -f %D/%%WWWDIR%%/config/config.php ; fi
+%%WWWDIR%%/config/config.php.example
 @exec [ ! -f %B/config.php ] && cp -p %B/%f %B/config.php || true
 @mode
 @group
--- phpldapadmin.diff ends here ---
Comment 1 Matthew Seaman 2008-03-08 16:20:42 UTC
Matthew Seaman wrote:
>> Number:         120505
>> Category:       ports
>> Synopsis:       [maintainer] net/phpldapadmin, net/phpldapadmin098 -- use /usr/ports/UIDs, etc.


Is there some problem with this PR? It's been a month since I submitted
it, and no sign of any activity yet.

	Cheers,

	Matthew


-- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW
Comment 2 Rong-En Fan freebsd_committer 2008-03-08 18:31:19 UTC
Responsible Changed
From-To: freebsd-ports-bugs->rafan

I'll take it.
Comment 3 dfilter service freebsd_committer 2008-03-09 04:43:51 UTC
rafan       2008-03-09 04:43:45 UTC

  FreeBSD ports repository

  Modified files:
    .                    UIDs 
  Log:
  - Register UID for net/phpldapadmin, net/phpldapadmin098
  
  PR:             120505
  
  Revision  Changes    Path
  1.62      +2 -1      ports/UIDs
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 4 Rong-En Fan freebsd_committer 2008-03-09 04:45:43 UTC
State Changed
From-To: open->closed

Committed. Thanks!
Comment 5 dfilter service freebsd_committer 2008-03-09 04:45:43 UTC
rafan       2008-03-09 04:45:39 UTC

  FreeBSD ports repository

  Modified files:
    net/phpldapadmin     Makefile pkg-plist-chunk 
    net/phpldapadmin/files pkg-deinstall.in pkg-install.in 
                           pkg-message.in 
    net/phpldapadmin098  Makefile pkg-plist-chunk 
    net/phpldapadmin098/files pkg-deinstall.in pkg-install.in 
                              pkg-message.in 
  Log:
  - Use fixed UID when WITH_SUPHP
  - Use WWWDIR for PLIST_SUB and SUB_LIST
  - Various port clean-up
  
  PR:             ports/120505
  Submitted by:   Matthew Seaman <m.seaman at infracaninophile.co.uk> (maintainer)
  
  Revision  Changes    Path
  1.24      +55 -27    ports/net/phpldapadmin/Makefile
  1.2       +5 -5      ports/net/phpldapadmin/files/pkg-deinstall.in
  1.2       +66 -54    ports/net/phpldapadmin/files/pkg-install.in
  1.4       +6 -7      ports/net/phpldapadmin/files/pkg-message.in
  1.3       +3 -3      ports/net/phpldapadmin/pkg-plist-chunk
  1.20      +55 -29    ports/net/phpldapadmin098/Makefile
  1.2       +5 -5      ports/net/phpldapadmin098/files/pkg-deinstall.in
  1.2       +66 -54    ports/net/phpldapadmin098/files/pkg-install.in
  1.5       +5 -5      ports/net/phpldapadmin098/files/pkg-message.in
  1.3       +3 -3      ports/net/phpldapadmin098/pkg-plist-chunk
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"