Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 May 2011 04:21:40 -0700 (PDT)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        roam@FreeBSD.org, ale@FreeBSD.org
Subject:   ports/157206: [PATCH] mail/vpopmail{, -devel}: use USERs/GROUPs and ...
Message-ID:  <4dd64ec4.0cb6e30a.6557.ffffd42e@mx.google.com>
Resent-Message-ID: <201105201130.p4KBUC17068520@freefall.freebsd.org>

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

>Number:         157206
>Category:       ports
>Synopsis:       [PATCH] mail/vpopmail{,-devel}: use USERs/GROUPs and ...
>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:   Fri May 20 11:30:11 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Baptiste Daroussin
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
>Environment:
System: FreeBSD azathoth.lan 8.2-STABLE FreeBSD 8.2-STABLE #0 r219454M: Thu Mar 10 20:09:22 CET
>Description:
Make it use the USERs/GROUPs macros, and workaround the hardcoded UIDs in code.

This prevent depending on perl and remove a unsupported perl install script.

this should also apply to mail/vpopmail-devel

of course this needs to be better tested than what I did :)

Removed file(s):
- pkg-install

Port maintainers (roam@FreeBSD.org and ale@FreeBSD.org) are cc'd.


Generated with FreeBSD Port Tools 0.99
>How-To-Repeat:
>Fix:

--- vpopmail-5.4.32_1.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/mail/vpopmail/Makefile,v
retrieving revision 1.85
diff -u -u -r1.85 Makefile
--- Makefile	10 Jan 2011 08:30:52 -0000	1.85
+++ Makefile	20 May 2011 11:16:24 -0000
@@ -28,7 +28,9 @@
 
 GNU_CONFIGURE=	YES
 USE_GMAKE=	YES
-USE_PERL5=	YES
+
+USERS=		vpopmail
+GROUPS=		vchkpw
 
 VCFGDIR?=	${WRKDIR}/vcfg
 VCFGFILES?=	inc_deps lib_deps tcp.smtp
@@ -38,7 +40,9 @@
 CONFIGURE_ARGS=	--enable-qmaildir=${QMAIL_PREFIX} \
 		--enable-tcprules-prog=${LOCALBASE}/bin/tcprules \
 		--enable-tcpserver-file=${PREFIX}/vpopmail/etc/tcp.smtp \
-		--enable-non-root-build
+		--enable-non-root-build \
+		--enable-vpopuser=${USERS} \
+		--enable-vpopgroup=${GROUPS}
 
 #
 # User-configurable variables
@@ -91,8 +95,6 @@
 # WITH_SQL_LOG_REMOVE_DELETED - remove log entries for deleted users/domains
 # QMAIL_PREFIX  - location of qmail directory
 # PREFIX	- installation area for vpopmail (see comment below)
-# VCHKPW_GID	- the group ID of the new vchkpw group (89)
-# VPOPMAIL_UID	- the user ID of the new vpopmail user (89)
 #
 # PostgreSQL database configuration options
 #
@@ -367,7 +369,9 @@
 #
 
 pre-configure:
-	@PKG_PREFIX=${PREFIX} ${PERL5} ${PKGINSTALL}
+	${AWK} -F: '/^${USERS}:/ { print $$3 }' ${UID_FILES} > ${WRKSRC}/vpopmail.uid
+	${AWK} -F: '/^${USERS}:/ { sub(/\/usr\/local/, "${PREFIX}", $$9); print $$9 }' ${UID_FILES} > ${WRKSRC}/vpopmail.dir
+	${AWK} -F: '/^${GROUPS}:/ { print $$3 }' ${GID_FILES} > ${WRKSRC}/vpopmail.gid
 .if defined(WITH_PGSQL)
 .if defined(WITH_PGSQL_DB)
 	${REINPLACE_CMD} -E -e "s/(#define DB.*)vpopmail(.*)/\1${WITH_PGSQL_DB}\2/" ${WRKSRC}/vpgsql.h
Index: pkg-install
===================================================================
RCS file: pkg-install
diff -N pkg-install
--- pkg-install	23 Sep 2006 12:38:02 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,109 +0,0 @@
-#!/usr/bin/perl
-#
-
-@groups = ("vchkpw");
-%users = ('vpopmail', "vchkpw");
-# daemon, local, pop, queue, remote, deliver, respectively.
-# alias is a special case above...
-%gids = ("vchkpw", 89);
-%uids = ('vpopmail', 89);
-
-sub checkenv () {
-	my ($u, $g);
-
-	# Users
-	foreach $u (keys %users) {
-		$var = uc($u)."_UID";
-		if (defined($ENV{$var})) {
-			$uids{$u} = $ENV{$var};
-		}
-	}
-
-	# Groups
-	foreach $g (@groups) {
-		$var = uc($g)."_GID";
-		if (defined($ENV{$var})) {
-			$gids{$g} = $ENV{$var};
-		}
-	}
-}
-
-if ($ENV{PACKAGE_BUILDING} || $ARGV[1] eq "PRE-INSTALL") {
-	$doguid=1;  # Make sure we get the assigned guids.
-}
-
-checkenv();
-
-foreach $group (@groups) {
-	if (! getgrnam ($group)) {
-		do checkrpw;  # May exit
-
-		$x = "-g $gids{$group}";
-		$result = system ("/usr/sbin/pw groupadd $group $x");
-		if ($result) {
-			die "Failed to add group $group as gid $gids{$group}\n";
-		}
-	}
-}
-
-if (! getpwnam ("alias")) {
-	do checkrpw;  # May exit
-
-	$x = "-u $uids{'alias'}";
-	$result = system ("/usr/sbin/pw useradd alias -g qnofiles -d \"$ENV{PKG_PREFIX}/vpopmail/alias\" -s /nonexistent $x");
-	if ($result) {
-		die "Failed to add user alias as uid $uids{'alias'}\n";
-	}
-}
-
-foreach $user (keys %users) {
-	if (! getpwnam ($user)) {
-		do checkrpw;  # May exit
-
-		$x = "-u $uids{$user}";
-		$result = system ("/usr/sbin/pw useradd $user -g $users{$user} -d \"$ENV{PKG_PREFIX}/vpopmail\" -s /nonexistent $x");
-		if ($result) {
-			die "Failed to add user $user as uid $uids{$user}\n";
-		}
-	}
-}
-
-# Check that all gids/uids are as they should be...
-# If we are being installed as a package...
-if ($doguid) {
-	foreach $group (@groups) {
-		if (getgrnam($group) != $gids{$group}) {
-			die "Group $group should have gid $gids{$group}\n";
-		}
-	}
-
-	foreach $user (keys %users) {
-		if (getpwnam($user) != $uids{$user}) {
-			die "User $user should have uid $uids{$user}\n";
-		}
-	}
-}
-
-exit 0;
-
-sub checkrpw {
-	if (! -x "/usr/sbin/pw") {
-		print <<'EOM';
-This system looks like a pre-2.2 version of FreeBSD.  We see that it
-is missing the "pw" utility.  We need this utility.  Please get and
-install it, and try again.  You can get the source from:
-
-  ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/usr.sbin/pw.tar.gz
-
-EOM
-		die "No /usr/sbin/pw";
-	}
-
-	if ($> != 0) {
-		print "It is necessary to add missing vpopmail users/groups at";
-		print "this stage.  Please either add them manually or retry";
-		print "as root.";
-		# Let pw(1) signal the failure so the user can see which
-		# group/user is actually missing.
-	}
-}
Index: files/patch-configure
===================================================================
RCS file: /home/pcvs/ports/mail/vpopmail/files/patch-configure,v
retrieving revision 1.18
diff -u -u -r1.18 patch-configure
--- files/patch-configure	13 Sep 2010 09:57:47 -0000	1.18
+++ files/patch-configure	20 May 2011 11:16:24 -0000
@@ -1,19 +1,5 @@
-Description: Configure for the FreeBSD ports build system.
- Add the --enable-spam-threshold and --enable-spam-junkfolder options.
- Do not try to create the etc/vpopmail directory and tcp.smtp in place,
- this is done by the port at install time.
- FreeBSD does not have libresolv.
- Pass the correct compiler and linker flags to the cdb build.
- FreeBSD does not need -R $libdir (a.k.a. --rpath) - the MySQL client
- library is added to ldconfig's search path in its own startup script.
-Forwarded: not-needed
-Author: Peter Pentchev <roam@FreeBSD.org>,
-	Alex Dupre <ale@FreeBSD.org>,
-	Renato Botelho <garga@FreeBSD.org>
-Last-Update: 2010-09-13
-
---- a/configure
-+++ b/configure
+--- configure.orig	2010-11-08 16:02:52.000000000 +0100
++++ configure	2011-05-20 12:21:34.314930656 +0200
 @@ -1403,6 +1403,8 @@
    --enable-onchange-script   Enable onchange script. See README.onchange for more info.
    --enable-spamassassin      Enable spamassassin. See  README.spamassassin for more info.
@@ -23,7 +9,108 @@
    --enable-maildrop          Enable maildrop. See  README.maildrop for more info.
    --enable-maildrop-prog=PATH    Full path to maildrop program /usr/{local/}bin/maildrop.
    --enable-domainquotas      Enable non-system domain quotas. See README.quotas for more info.
-@@ -5785,27 +5787,6 @@
+@@ -5663,100 +5665,6 @@
+ 
+ fi
+ 
+-
+-
+-cat >>confdefs.h <<_ACEOF
+-#define VPOPGROUP "$vpopgroup"
+-_ACEOF
+-
+-
+-
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+-$as_echo "yes" >&6; }
+-
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether password file entry for the vpopmail user exists" >&5
+-$as_echo_n "checking whether password file entry for the vpopmail user exists... " >&6; }
+-if test "$cross_compiling" = yes; then :
+-  as_fn_error "Could not compile and run even a trivial ANSI C program - check CC." "$LINENO" 5
+-
+-else
+-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+-/* end confdefs.h.  */
+-
+-  #include <stdio.h>
+-  #include <pwd.h>
+-  #include <stdlib.h>
+-
+-  int main() {
+-    struct passwd *pw;
+-    char tmpbuf[100];
+-    FILE *f;
+-
+-        unlink("vpopmail.dir");
+-        unlink("vpopmail.uid");
+-        unlink("vpopmail.gid");
+-
+-        if ( (f=fopen("vpopusername","r+"))==NULL) {
+-                printf("No vpopmail user found.\n");
+-                printf("Please add the vchkpw group and\n");
+-                printf("vpopmail user. Then run configure again\n");
+-                return(-1);
+-        }
+-
+-        fgets(tmpbuf,100,f);
+-        fclose(f);
+-        tmpbuf[strlen(tmpbuf)-1] = 0;
+-
+-        if (( pw=getpwnam(tmpbuf)) != 0 ) {
+-                f=fopen("vpopmail.dir","a+");
+-                fprintf(f,"%s\n", pw->pw_dir);
+-                fclose(f);
+-
+-                f=fopen("vpopmail.uid", "a+");
+-                fprintf(f,"%d\n", pw->pw_uid);
+-                fclose(f);
+-
+-                f=fopen("vpopmail.gid", "a+");
+-                fprintf(f,"%d\n", pw->pw_gid);
+-                fclose(f);
+-        } else {
+-                printf("No vpopmail user found.\n");
+-                printf("Please add the vchkpw group and\n");
+-                printf("vpopmail user. Then run configure again\n");
+-                return(-1);
+-        }
+-        return(0);
+-  }
+-
+-_ACEOF
+-if ac_fn_c_try_run "$LINENO"; then :
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+-$as_echo "yes" >&6; }
+-else
+-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-    as_fn_error "Could not compile and run even a trivial ANSI C program - check CC." "$LINENO" 5
+-fi
+-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+-  conftest.$ac_objext conftest.beam conftest.$ac_ext
+-fi
+-
+-
+-if test ! -f vpopmail.uid
+-then
+-        as_fn_error "No vpopmail user." "$LINENO" 5
+-fi
+-
+-if test ! -f vpopmail.gid
+-then
+-        as_fn_error "No vpopmail group." "$LINENO" 5
+-fi
+-
+-if test ! -f vpopmail.dir
+-then
+-        as_fn_error "No vpopmail home directory" "$LINENO" 5
+-fi
+-
+ vpopmaildir=`cat vpopmail.dir`
+ 
+ 
+@@ -5785,27 +5693,6 @@
  
  #----------------------------------------------------------------------
  
@@ -51,7 +138,7 @@
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether roaming-users has been enabled" >&5
  $as_echo_n "checking whether roaming-users has been enabled... " >&6; }
  # Check whether --enable-roaming-users was given.
-@@ -5888,28 +5869,11 @@
+@@ -5888,28 +5775,11 @@
      # Check whether --enable-tcpserver_file was given.
  if test "${enable_tcpserver_file+set}" = set; then :
    enableval=$enable_tcpserver_file; tcpserver_file="$enableval"
@@ -81,7 +168,7 @@
      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
  $as_echo "yes" >&6; }
  
-@@ -6414,6 +6378,44 @@
+@@ -6414,6 +6284,44 @@
  #define SPAMC_PROG "$spamc_prog"
  _ACEOF
  
@@ -126,7 +213,7 @@
  
        ;;
  esac
-@@ -6664,7 +6666,7 @@
+@@ -6664,7 +6572,7 @@
          as_fn_error "Unable to find your MySQL lib dir, specify --enable-libdir." "$LINENO" 5
      fi
  
@@ -135,7 +222,7 @@
  
      ;;
  
-@@ -6727,7 +6729,7 @@
+@@ -6727,7 +6635,7 @@
  #define USE_LDAP $USE_LDAP
  _ACEOF
  
@@ -144,7 +231,7 @@
  
      auth_inc="-I/usr/local/include"
  
-@@ -9029,8 +9031,8 @@
+@@ -9029,8 +8937,8 @@
      ;;
  esac
  
--- vpopmail-5.4.32_1.patch ends here ---

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4dd64ec4.0cb6e30a.6557.ffffd42e>