Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Jan 2008 15:54:14 GMT
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/119825: [maintainer] databases/phpmyadmin -- use /usr/ports/UIDs, etc. 
Message-ID:  <200801201554.m0KFsE1L026990@happy-idiot-talk.infracaninophile.co.uk>
Resent-Message-ID: <200801201600.m0KG073V056054@freefall.freebsd.org>

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

>Number:         119825
>Category:       ports
>Synopsis:       [maintainer] databases/phpmyadmin -- use /usr/ports/UIDs, etc.
>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:   Sun Jan 20 16:00:06 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Seaman
>Release:        FreeBSD 7.0-PRERELEASE i386
>Organization:
Infracaninophile
>Environment:
System: FreeBSD happy-idiot-talk.infracaninophile.co.uk 7.0-PRERELEASE FreeBSD 7.0-PRERELEASE #22: Tue Jan 15 19:01:28 GMT 2008 root@happy-idiot-talk.infracaninophile.co.uk:/usr/obj/usr/src/sys/HAPPY-IDIOT-TALK i386


	
>Description:

This is an update to the port only -- no updates to phpMyAdmin
itself.

Changes:

    * When installed using WITH_SUPHP use a fix 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 phpmyadm to _pma
      and add an entry to /usr/ports/UIDs:

        _pma:*:336:80:phpMyAdmin Owner:/nonexistent:/sbin/nologin         

    * 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.

>How-To-Repeat:
	
>Fix:

	

--- UIDs._pma.diff begins here ---
--- UIDs.save	2008-01-20 14:58:41.000000000 +0000
+++ UIDs	2008-01-20 14:59:47.000000000 +0000
@@ -100,6 +100,7 @@
 prelude:*:281:281:Prelude user:/nonexistent:/usr/sbin/nologin
 _sphinx:*:312:312:Sphinxsearch Owner:/nonexistent:/usr/sbin/nologin
 dkfilter:*:325:325:DK Filter Owner:/nonexistent:/usr/sbin/nologin
+_pma:*:336:80:phpMyAdmin Owner:/nonexistent:/sbin/nologin
 wildfire:*:340:340:Wildfire Daemon:/nonexistent:/usr/sbin/nologin
 stunnel:*:341:341:Stunnel Daemon:/nonexistent:/usr/sbin/nologin
 _iodined:*:353:353:Iodine Daemon:/nonexistent:/usr/sbin/nologin
--- UIDs._pma.diff ends here ---

--- phpmyadmin.diff begins here ---
diff -Nur /usr/ports/databases/phpmyadmin/Makefile phpmyadmin/Makefile
--- /usr/ports/databases/phpmyadmin/Makefile	2008-01-13 10:57:18.000000000 +0000
+++ phpmyadmin/Makefile	2008-01-20 15:37:21.000000000 +0000
@@ -7,6 +7,7 @@
 
 PORTNAME=	phpMyAdmin
 DISTVERSION=	2.11.4
+PORTREVISION=	1
 CATEGORIES=	databases www
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	phpmyadmin
@@ -21,10 +22,6 @@
 USE_PHP=	ctype mysql pcre session
 .endif
 
-SUB_LIST+=	"MYADMDIR=${MYADMDIR}" \
-		"PKGNAME=${PKGNAME}"
-SUB_FILES=	pkg-message
-
 # Unfortunately can't make WITH_SUPHP part of the OPTIONS selection,
 # since it has to be processed before just about anything else.
 
@@ -34,18 +31,43 @@
 RUN_DEPENDS+=	${LOCALBASE}/sbin/suphp:${PORTSDIR}/www/suphp
 WANT_PHP_CGI=	yes
 
-MYADMUSR?=	phpmyadm
-
-SUB_LIST+=	"MYADMUSR=${MYADMUSR}" \
-		"MYADMGRP=${MYADMGRP}"
-SUB_FILES+=	pkg-install pkg-deinstall
-
 .else
 
 WANT_PHP_WEB=	yes
 
 .endif
 
+# PMA_USR is only used WITH_SUPHP
+
+PMA_GRP?=	${WWWGRP}
+PMA_GID?=	${_PMA_GID}
+CFGFILE=	config.inc.php
+
+PLIST=		${WRKDIR}/plist
+PLIST_SUB+=	PMA_GRP=${PMA_GRP}
+
+.if defined(WITH_SUPHP) && !defined(WITHOUT_SUPHP)
+
+PMA_USR?=	_pma
+PMA_UID?=	336
+PMA_GCOS?=	"phpMyAdmin Owner"
+PMA_HOME?=	/nonexistent
+PMA_SHELL?=	/sbin/nologin
+
+SUB_LIST+=	PMA_USR=${PMA_USR}    \
+		PMA_UID=${PMA_UID}    \
+		PMA_GRP=${PMA_GRP}    \
+		PMA_GID=${PMA_GID}    \
+		PMA_GCOS=${PMA_GCOS}  \
+		PMA_HOME=${PMA_HOME}  \
+		PMA_SHELL=${PMA_SHELL}
+SUB_FILES+=	pkg-install pkg-deinstall
+
+.endif
+
+SUB_LIST+=	PKGNAME=${PKGNAME}
+SUB_FILES+=	pkg-message
+
 # Copy the way lang/php{4,5}-extensions deals with its OPTIONS -- avoids
 # problems with include of bsd.port.pre.mk
 
@@ -82,13 +104,12 @@
 .endfor
 .endif
 
-# MYADMUSR is only used WITH_SUPHP
-MYADMDIR?=	www/phpMyAdmin
-MYADMGRP?=	${WWWGRP}
-CFGFILE=	config.inc.php
+.include <bsd.port.pre.mk>
 
-PLIST=		${WRKDIR}/plist
-PLIST_SUB+=	MYADMDIR=${MYADMDIR} MYADMGRP=${MYADMGRP}
+_PMA_GID!=	/usr/sbin/pw group show -n ${PMA_GRP} | ${CUT} -d : -f 3
+.if empty(_PMA_GID)
+_PMA_GID=	80
+.endif
 
 .SILENT:
 
@@ -109,6 +130,15 @@
 	${ECHO_MSG} "install lang/php4 before attempting to install"
 	${ECHO_MSG} "databases/phpmyadmin"
 	${ECHO_MSG} ""
+.if defined(WITH_SUPHP) && !defined(WITHOUT_SUPHP)
+	@if /usr/sbin/pw show -n phpmyadm >/dev/null 2>&1 ; then              \
+	    ${ECHO_MSG} "===> WARNING ******************************" ;       \
+	    ${ECHO_MSG} "The default username used by ${PKNAME} has changed"; \
+	    ${ECHO_MSG} "to ${PMA_USR} -- you should delete the old user:" ;  \
+	    ${ECHO_MSG} "  # /usr/sbin/pw user del -n phpmyadm" ;             \
+	    ${ECHO_MSG} "" ;                                                  \
+	fi
+.endif
 
 # When creating a package, empty directories will not be generated
 # from the pkg tarball.  Therefore make sure no directories are empty.
@@ -121,11 +151,11 @@
 	${CP} ${FILESDIR}/${CFGFILE}.sample ${WRKSRC}/${CFGFILE}.sample
 	cd ${WRKSRC} ; \
 	${FIND} . ! -type d ! -name ${CFGFILE}.sample | ${SORT} | \
-	    ${SED} -e "s,^\.,%%MYADMDIR%%,"           >${PLIST} ; \
+	    ${SED} -e "s,^\.,%%WWWDIR%%,"             >${PLIST} ; \
 	${CAT} ${PKGDIR}/pkg-plist-chunk             >>${PLIST} ; \
 	${FIND} . -type d | ${SORT} -r | ${SED} \
-	     -e "s,^\.$$,@dirrmtry %%MYADMDIR%%," \
-	     -e "s,^\.,@dirrm %%MYADMDIR%%,"         >>${PLIST}
+	     -e "s,^\.$$,@dirrmtry %%WWWDIR%%," \
+	     -e "s,^\.,@dirrm %%WWWDIR%%,"           >>${PLIST}
 
 pre-install:
 .if defined(WITH_SUPHP)
@@ -137,7 +167,7 @@
 install-app:
 	cd ${WRKSRC} ; \
 	for src in $$( ${FIND} . ! -name .cvsignore ) ; do \
-	    dst=${PREFIX}/${MYADMDIR}$${src#.} ; \
+	    dst=${WWWDIR}$${src#.} ; \
 	    if ${TEST} -d $$src ; then \
 	        ${MKDIR} $$dst ; \
 	    else \
@@ -146,9 +176,9 @@
 	done
 
 install-conf: install-app
-	cd ${PREFIX}/${MYADMDIR} ; \
+	cd ${WWWDIR} ; \
 	${CHMOD} 0640 ${CFGFILE}.sample ; \
-	${CHGRP} ${MYADMGRP} ${CFGFILE}.sample ; \
+	${CHGRP} ${PMA_GRP} ${CFGFILE}.sample ; \
 	if ${TEST} ! -f ${CFGFILE} ; then \
 	    ${CP} -p ${CFGFILE}.sample ${CFGFILE} ; \
 	fi
@@ -159,4 +189,4 @@
 .endif
 	${CAT} ${PKGMESSAGE}
 
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff -Nur /usr/ports/databases/phpmyadmin/files/pkg-deinstall.in phpmyadmin/files/pkg-deinstall.in
--- /usr/ports/databases/phpmyadmin/files/pkg-deinstall.in	2005-03-06 10:48:47.000000000 +0000
+++ phpmyadmin/files/pkg-deinstall.in	2008-01-20 11:38:31.000000000 +0000
@@ -9,13 +9,13 @@
 The phpMyAdmin-suphp port has been deleted.
 If you are not upgrading and don't intend to use
 phpMyAdmin any more then you may wish to delete
-the %%MYADMUSR%% account, which can be done with
+the %%PMA_USR%% account, which can be done with
 the following command:
 
-    # pw userdel %%MYADMUSR%%
+    # pw userdel %%PMA_USR%%
 EOMSG
-    if [ -d %%PREFIX%%/%%MYADMDIR%% ] ; then
-	echo "    # rm -rf %%PREFIX%%/%%MYADMDIR%%/"
+    if [ -d %%WWWDIR%% ] ; then
+	echo "    # rm -rf %%WWWDIR%%/"
     fi
     echo
     ;;
diff -Nur /usr/ports/databases/phpmyadmin/files/pkg-install.in phpmyadmin/files/pkg-install.in
--- /usr/ports/databases/phpmyadmin/files/pkg-install.in	2005-03-06 10:48:47.000000000 +0000
+++ phpmyadmin/files/pkg-install.in	2008-01-20 15:04:53.000000000 +0000
@@ -5,66 +5,83 @@
 
 PATH=/usr/sbin:/usr/bin:/bin ; export PATH
 
-myadmdir=%%PREFIX%%/%%MYADMDIR%%
-myadmusr=%%MYADMUSR%%
-myadmgrp=%%MYADMGRP%%
-
-myadmgcos="phpMyAdmin Owner"
-myadmhome=/nonexistent
-myadmshell=/sbin/nologin
+pma_dir=%%WWWDIR%%
+pma_usr=%%PMA_USR%%
+pma_uid=%%PMA_UID%%
+pma_grp=%%PMA_GRP%%
+pma_gid=%%PMA_GID%%
+
+pma_gcos="%%PMA_GCOS%%"
+pma_home=%%PMA_HOME%%
+pma_shell=%%PMA_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
 }
 
@@ -72,24 +89,19 @@
 case $2 in
     PRE-INSTALL)
 
-        # Create the myadm user and group if they do not already exist
-
-        if pw user show -n $myadmusr >/dev/null 2>&1 ; then
-	    echo "===> Using pre-existing user $myadmusr"
-	else
-	    if ! pw group show -n $myadmgrp >/dev/null 2>&1 ; then
-		create_group $myadmusr $myadmgrp "$myadmgcos" $myadmhome \
-		    $myadmshell
-	    fi
-	    create_user $myadmusr $myadmgrp "$myadmgcos" $myadmhome $myadmshell
-	fi
+        # Create the pma user and group if they do not already exist
+	create_group $pma_usr $pma_uid $pma_grp $pma_gid \
+                     "$pma_gcos" $pma_home $pma_shell
+	create_user  $pma_usr $pma_uid $pma_grp $pma_gid \
+                     "$pma_gcos" $pma_home $pma_shell
 	;;
+
     POST-INSTALL)
 
     	# Change ownership of the phpMyAdm directory
 
-        echo "===> Adjusting file ownership in $myadmdir"
-        chown -R $myadmusr:$myadmgrp $myadmdir || exit 1
+        echo "===> Adjusting file ownership in $pma_dir"
+        chown -R $pma_usr:$pma_grp $pma_dir || exit 1
 	;;
 esac
 
diff -Nur /usr/ports/databases/phpmyadmin/files/pkg-message.in phpmyadmin/files/pkg-message.in
--- /usr/ports/databases/phpmyadmin/files/pkg-message.in	2006-05-28 16:02:02.000000000 +0100
+++ phpmyadmin/files/pkg-message.in	2008-01-20 09:48:44.000000000 +0000
@@ -1,16 +1,16 @@
 
 %%PKGNAME%% has been installed into:
 
-    %%PREFIX%%/%%MYADMDIR%%
+    %%WWWDIR%%
 
 Please edit config.inc.php to suit your needs.
 
 To make phpMyAdmin available through your web site, I suggest
 that you add something like the following to httpd.conf:
 
-    Alias /phpmyadmin/ "%%PREFIX%%/%%MYADMDIR%%/"
+    Alias /phpmyadmin/ "%%WWWDIR%%/"
 
-    <Directory "%%PREFIX%%/%%MYADMDIR%%/">
+    <Directory "%%WWWDIR%%/">
 	Options none
 	AllowOverride Limit
 	
diff -Nur /usr/ports/databases/phpmyadmin/pkg-plist-chunk phpmyadmin/pkg-plist-chunk
--- /usr/ports/databases/phpmyadmin/pkg-plist-chunk	2004-05-20 17:29:49.000000000 +0100
+++ phpmyadmin/pkg-plist-chunk	2008-01-20 09:43:34.000000000 +0000
@@ -1,7 +1,7 @@
 @mode 640
-@group %%MYADMGRP%%
-@unexec if cmp -s %D/%%MYADMDIR%%/config.inc.php.sample %D/%%MYADMDIR%%/config.inc.php ; then rm -f %D/%%MYADMDIR%%/config.inc.php ; fi
-%%MYADMDIR%%/config.inc.php.sample
+@group %%PMA_GRP%%
+@unexec if cmp -s %%WWWDIR%%/config.inc.php.sample %%WWWDIR%%/config.inc.php ; then rm -f %%WWWDIR%%/config.inc.php ; fi
+%%WWWDIR%%/config.inc.php.sample
 @exec [ ! -f %B/config.inc.php ] && cp -p %B/%f %B/config.inc.php || true
 @mode
 @group
--- phpmyadmin.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?200801201554.m0KFsE1L026990>