ports/165040: [PATCH] mail/sqlgrey: improve port

Martin Matuska mm at FreeBSD.org
Sun Feb 12 16:30:11 UTC 2012


>Number:         165040
>Category:       ports
>Synopsis:       [PATCH] mail/sqlgrey: improve port
>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:   Sun Feb 12 16:30:10 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Martin Matuska
>Release:        FreeBSD 9.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD neo.vx.sk 9.0-STABLE FreeBSD 9.0-STABLE #14 r231187M: Wed Feb  8 08:19:42
>Description:
Use UID/GID framework from ports, set uid/gid to 226.
Add rcng pidfile control and pidfile support from command line.
Add support to listen on UNIX sockets.

Added file(s):
- files/patch-pidfile
- files/patch-unixsockets

Port maintainer (chifeng at gmail.com) is cc'd.

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

--- sqlgrey-1.8.0.r2.patch begins here ---
Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/mail/sqlgrey/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- Makefile	3 Jun 2011 11:25:11 -0000	1.19
+++ Makefile	12 Feb 2012 16:19:17 -0000
@@ -22,12 +22,12 @@
 NO_BUILD=	yes
 
 ETCFILES=	clients_fqdn_whitelist clients_ip_whitelist dyn_fqdn.regexp smtp_server.regexp sqlgrey.conf
-SGY_USERNAME?=	sqlgrey
-SGY_GROUPNAME?=	${SGY_USERNAME}
+USERS=		sqlgrey
+GROUPS=		${USERS}
 ETCDIR?=	etc/sqlgrey
 
 SUB_FILES=	pkg-install
-MY_SUB_LIST=	ETCDIR=${ETCDIR} ETCFILES="${ETCFILES}" USER=${SGY_USERNAME} GROUP=${SGY_GROUPNAME} PERL=${PERL}
+MY_SUB_LIST=	ETCDIR=${ETCDIR} ETCFILES="${ETCFILES}" USER=${USERS} GROUP=${GROUPS} PERL=${PERL}
 SUB_LIST+=	${MY_SUB_LIST}
 PLIST_SUB=	TOUCH=${TOUCH} ${MY_SUB_LIST}
 
Index: files/patch-pidfile
===================================================================
RCS file: files/patch-pidfile
diff -N files/patch-pidfile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-pidfile	12 Feb 2012 16:19:17 -0000
@@ -0,0 +1,23 @@
+--- sqlgrey.orig	2010-02-01 10:59:53.000000000 +0100
++++ sqlgrey	2012-02-12 17:14:41.328884011 +0100
+@@ -2542,7 +2542,7 @@
+     # options parsing
+     my %opt = ();
+     GetOptions(\%opt, 'help|h', 'man', 'version', 'configfile|f=s',
+-	'daemonize|d', 'kill|k')
++	'daemonize|d', 'kill|k', 'pidfile|p=s')
+ 	or exit(1);
+ 
+     if ($opt{help})    { pod2usage(1) }
+@@ -2564,6 +2564,11 @@
+             $dflt{dont_db_clean} = (-e $dflt{conf_dir}."/dont_db_clean");
+     }
+ 
++    # Check pidfile from command line arguments
++    if (defined $opt{pidfile}) {
++	$dflt{pidfile} = $opt{pidfile};
++    }
++
+     # Are we on a killing spray ?
+     if (defined $opt{kill}) {
+ 	my $pidfile = $dflt{pidfile};
Index: files/patch-unixsockets
===================================================================
RCS file: files/patch-unixsockets
diff -N files/patch-unixsockets
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-unixsockets	12 Feb 2012 16:19:17 -0000
@@ -0,0 +1,70 @@
+--- etc/sqlgrey.conf.orig	2010-02-01 10:59:53.000000000 +0100
++++ etc/sqlgrey.conf	2012-02-12 16:52:18.757881415 +0100
+@@ -66,6 +66,8 @@
+ # On which socket do SQLgrey wait for queries
+ # use the following if you need to bind on a public IP address
+ # inet = <public_ip>:2501
++# to bind on a UNIX socket, use the following:
++# unix = /path/to/socket
+ # default :
+ # inet = 2501    # bind to localhost:2501
+ 
+--- sqlgrey.orig	2010-02-01 10:59:53.000000000 +0100
++++ sqlgrey	2012-02-12 17:03:56.689885169 +0100
+@@ -58,7 +58,8 @@
+ $dflt{loglevel}           = 2; # used for $dflt{log} entries in read_conffile()
+ $dflt{user}               = 'sqlgrey';
+ $dflt{group}              = 'sqlgrey';
+-$dflt{inet}               = '2501';
++$dflt{proto}              = 'tcp';
++$dflt{port}               = 'localhost:2501';
+ $dflt{pidfile}            = '/var/run/sqlgrey.pid';
+ $dflt{conf_dir}           = '/etc/sqlgrey';
+ $dflt{reconnect_delay}    = 5;            # 5 minutes
+@@ -2578,8 +2579,16 @@
+     }
+ 
+     # bind only localhost if no host is specified
+-    if(defined $dflt{inet} and $dflt{inet}=~/^\d+$/) {
+-        $dflt{inet} = "localhost:$dflt{inet}";
++    if(defined $dflt{inet}) {
++	$dflt{proto} = "tcp";
++	if ($dflt{inet}=~/^\d+$/) {
++	    $dflt{port} = "localhost:$dflt{inet}";
++	} else {
++	    $dflt{port} = $dflt{inet};
++	}
++    } elsif (defined $dflt{unix}) {
++	$dflt{proto} = "unix";
++	$dflt{port} = $dflt{unix} ."|unix";
+     }
+ 
+     # set the actual reject code values
+@@ -2604,8 +2613,8 @@
+     my $server = bless {
+         server => {
+             commandline     => [ $0, @ARGV_saved ],
+-            port            => [ $dflt{inet} ],
+-            proto           => 'tcp',
++            port            => [ $dflt{port} ],
++            proto           => $dflt{proto},
+             user            => $dflt{user},
+ 	    group           => $dflt{group},
+             setsid          => $opt{daemonize} ? 1 : undef,
+@@ -2675,6 +2684,16 @@
+ ## Net::Server::Multiplex methods ##
+ ####################################
+ 
++sub post_bind_hook()
++{
++    my ($self) = @_;
++
++    # unix socket permissions should be 666
++    if($self->{server}{port}[0] =~ /^(.*)\|unix$/) {
++	chmod 0666, $1;
++    }
++}
++
+ # Called before the first query comes.
+ sub pre_loop_hook() {
+     my $self = shift;
Index: files/pkg-install.in
===================================================================
RCS file: /home/pcvs/ports/mail/sqlgrey/files/pkg-install.in,v
retrieving revision 1.2
diff -u -r1.2 pkg-install.in
--- files/pkg-install.in	6 Nov 2006 19:46:25 -0000	1.2
+++ files/pkg-install.in	12 Feb 2012 16:19:17 -0000
@@ -15,23 +15,6 @@
 	    exit 1
 	fi
 
-	# Create group if required
-	if /usr/sbin/pw group show "%%GROUP%%" >/dev/null 2>&1; then
-	    echo "---> Using existing group \"%%GROUP%%\""
-	else
-	    echo "---> Adding group \"%%GROUP%%\""
-	    /usr/sbin/pw groupadd %%GROUP%% || exit 1
-	fi
-
-	# Create user if required
-	if /usr/sbin/pw user show "%%USER%%" >/dev/null 2>&1; then
-	    echo "---> Using existing user \"%%USER%%\""
-	else
-	    echo "---> Adding user \"%%USER%%\""
-	    /usr/sbin/pw useradd "%%USER%%" -g "%%GROUP%%" -h - \
-	    -d "%%DATADIR%%" -s "/sbin/nologin" -c "Sqlgrey Owner" || exit 1
-	fi
-
 	# Create home directory if required
 	if [ -d "%%DATADIR%%" ]; then
 	    echo "---> Using existing Sqlgrey database directory (%%DATADIR%%)"
@@ -47,14 +30,8 @@
 
     POST-DEINSTALL)
 
-	echo "---> Please, remember to remove the user and the group with :"
-	if /usr/sbin/pw user show "%%USER%%" >/dev/null 2>&1; then
-	    echo "       /usr/sbin/pw userdel -n %%USER%%"
-	fi
-	if /usr/sbin/pw group show "%%GROUP%%" >/dev/null 2>&1; then
-	    echo "       /usr/sbin/pw groupdel -n %%GROUP%%"
-	fi
-	echo "     as well as the databases."
+	echo "---> Please, remember to remove the database directory:"
+	echo "     %%DATADIR%%"
 	echo "     If you're only updating, you can leave the things as they are."
     ;;
 
Index: files/sqlgrey.in
===================================================================
RCS file: /home/pcvs/ports/mail/sqlgrey/files/sqlgrey.in,v
retrieving revision 1.3
diff -u -r1.3 sqlgrey.in
--- files/sqlgrey.in	14 Jan 2012 08:56:05 -0000	1.3
+++ files/sqlgrey.in	12 Feb 2012 16:19:18 -0000
@@ -24,16 +24,17 @@
 
 stop_postcmd=${name}_poststop
 
-sqlgrey_poststop()
-{
-	rm -f $pidfile
-}
-
 load_rc_config $name
 
 sqlgrey_enable=${sqlgrey_enable-"NO"}
 required_files=${sqlgrey_config-"%%PREFIX%%/%%ETCDIR%%/sqlgrey.conf"}
+pidfile=${sqlgrey_pidfile-"/var/run/sqlgrey.pid"}
 
-command_args="--configfile=${required_files} --daemonize"
+command_args="--configfile=${required_files} --pidfile=${pidfile} --daemonize"
+
+sqlgrey_poststop()
+{
+	rm -f $pidfile
+}
 
 run_rc_command "$1"
Index: UIDs
===================================================================
RCS file: /home/pcvs/ports/UIDs,v
retrieving revision 1.185
diff -u -r1.185 UIDs
--- UIDs	2 Feb 2012 13:05:18 -0000	1.185
+++ UIDs	12 Feb 2012 14:51:07 -0000
@@ -116,6 +116,7 @@
 drizzle:*:213:213::0:0:Drizzle daemon:/var/db/drizzle:/usr/sbin/nologin
 bs:*:220:220::0:0:Big Sister:/usr/local/bigsister:/bin/sh
 postgrey:*:225:225::0:0:Postgrey Owner:/nonexistent:/usr/sbin/nologin
+sqlgrey:*:226:226::0:0:SQLgrey Owner:/nonexistent:/usr/sbin/nologin
 aprsd:*:240:240::0:0:aprsd:/nonexistent:/bin/sh
 tnc:*:241:241::0:0:aprsd:/nonexistent:/bin/sh
 prosody:*:242:242::0:0:Prosody Jabber Server:/nonexistent:/usr/sbin/nologin
Index: GIDs
===================================================================
RCS file: /home/pcvs/ports/GIDs,v
retrieving revision 1.163
diff -u -r1.163 GIDs
--- GIDs	12 Jan 2012 13:14:44 -0000	1.163
+++ GIDs	12 Feb 2012 14:51:07 -0000
@@ -109,6 +109,7 @@
 drizzle:*:213:
 bs:*:220:
 postgrey:*:225:
+sqlgrey:*:226:
 kismet:*:229:
 aprsd:*:240:
 tnc:*:241:
--- sqlgrey-1.8.0.r2.patch ends here ---

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



More information about the freebsd-ports-bugs mailing list