Package: mlmmj
Severity: normal
Tags: patch

looks like the original submitter never "got around" to a patch,
and the problem is still present in version 1.2.17-2.
recently i've run into the same (two) problems and so i've created 
a patch fixing them; would you please forward the patch upstream, too?

let's quickly recap the issues (this bug report is 2 years old) and 
my solutions:

* first, the cmdline mlmmj-sub command behaves badly when submod is on: it 
sends a "please wait" mail to the email in question (undesirable if we're
subscribing somebody in an automated fashion) and a "sub mod required" to 
the admin - and then all progress stalls until the admin responds to the 
sub mod email. this is bad because it makes automating subscriptions
via the cmdline tool impossible.

solution: i added the -X option to mlmmj-sub which disables submod for 
this run of mlmmj-sub. so, with -X given (by a human admin) mlmmj-sub lets
you subscribe somebody on the go. without -X you geht the normal behaviour 
just like before. i've updated the manpage, too.

* second, when subscriptions are handled via email, one cannot
switch off the welcome/goodbye emails that the subscriber receives.
(on the command line mlmmj-sub/unsub can be told not to send greetings by
leaving out the -c option.) 

solution: i've added a boolean tunable called nogreetings (plus docs) which,
when set and only if nosubconfirm is on as well, prevents the welcome/goodbye
messages. why did i decide to make this conditional on nosubconfirm?
rule of least surprise. without nosubconfirm the subscriber has to go 
through challenge/confirmation anyway, so first having them jump through 
these hoops and then not telling them about the success of the procedure 
seems silly. 

note: nogreetings doesn't affect submod and its "please wait" mail - i'm 
undecided as to whether it should or not.

regards
az
#! /bin/sh /usr/share/dpatch/dpatch-run
## 10_submod_cmdline.dpatch by  <a...@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: fix for #519931, submod vs. greeting messages and submod vs. cmdline

@DPATCH@
diff -urNad mlmmj-1.2.17~/TUNABLES mlmmj-1.2.17/TUNABLES
--- mlmmj-1.2.17~/TUNABLES	2011-04-13 20:16:51.000000000 +1000
+++ mlmmj-1.2.17/TUNABLES	2011-04-13 20:16:55.523783579 +1000
@@ -34,6 +34,16 @@
    If there are emailaddresses in this file, then these will be used
    instead of owner.
 
+ · nogreetings			(boolean)
+
+   If this file is present, then no welcome or goodbye messages will be
+   sent when somebody is (un)subscribed. This option is only active when
+   nosubconfirm is also active. It does not affect mlmmj-sub/mlmmj-unsub
+   when you run them from the command line (where the -c option 
+   is authoritative).
+
+   The default behaviour is to send welcome and goodbye messages.
+
  · tocc				(boolean)
 
    If this file is present, the list address does not have to be in the To:
diff -urNad mlmmj-1.2.17~/man/mlmmj-sub.1 mlmmj-1.2.17/man/mlmmj-sub.1
--- mlmmj-1.2.17~/man/mlmmj-sub.1	2011-04-13 20:16:51.000000000 +1000
+++ mlmmj-1.2.17/man/mlmmj-sub.1	2011-04-13 20:16:55.523783579 +1000
@@ -4,7 +4,7 @@
 .SH SYNOPSIS
 .B mlmmj-sub
 \fI-L /path/to/list -a j...@doe.org \fR[\fI-c\fR | \fI-C\fR] \fR[\fI-d\fR | \fI-n\fR]
-[\fI-h\fR] [\fI-U\fR] [\fI-V\fR]
+[\fI-h\fR] [\fI-U\fR] [\fI-X\fR]
 .HP
 \fB\-a\fR: Email address to subscribe
 .HP
@@ -26,6 +26,8 @@
 .HP
 \fB\-U\fR: Don't switch to the user id of the listdir owner
 .HP
+\fB\-X\fR: Temporarily override the \(lqsubmod\(rq list option
+.HP
 \fB\-V\fR: Print version
 .SH DESCRIPTION
 This utility is used to subscribe people to the specified mailinglist. It will
@@ -36,6 +38,13 @@
 owning the list directory. This is done to make sure that new files created are
 having correct permissions.
 
+If the list option \(lqsubmod\(rq is set, then \fBall\fR subscription 
+requests are moderated. This applies even when you run this utility 
+directly from the command line, which makes it impossible to automate 
+subscriptions without moderator email-interaction. The presence of 
+the \fB\-X\fR switch disables subscription moderation for this one run 
+of the utility.
+
 The nomail version of the list is a list version where people are subscribed
 like usual, but they won't recieve any postings to the list. This is useful for
 people who read the mailinglist through a news gateway, but want to be able to
diff -urNad mlmmj-1.2.17~/src/listcontrol.c mlmmj-1.2.17/src/listcontrol.c
--- mlmmj-1.2.17~/src/listcontrol.c	2011-04-13 20:16:51.000000000 +1000
+++ mlmmj-1.2.17/src/listcontrol.c	2011-04-13 20:18:00.039782157 +1000
@@ -107,7 +107,9 @@
 	char *bouncenr, *tmpstr;
 	char *param = NULL, *conffilename, *moderatefilename;
 	char *c, *archivefilename, *sendfilename;
-	const char *subswitch;
+	const char *subswitch=NULL, *greetingswitch="-c";
+	/* NULL: inelegant but works fine as long as 
+	   greetingswitch/subswitch is last arg to execlp */
 	struct stat stbuf;
 	int closedlist, nosubconfirm, tmpfd, noget, i, closedlistsub,
 	    subonlyget = 0;
@@ -123,11 +125,17 @@
 	closedlistsub = statctrl(listdir, "closedlistsub");
 
 	nosubconfirm = statctrl(listdir, "nosubconfirm");
-	if(nosubconfirm)
-		subswitch = "-c";
-	else
+	if(!nosubconfirm)
 		subswitch = "-C";
-	
+
+	else
+	{
+		/* if no confirmations wanted then check if we 
+		   should possibly also not greet/say goodbye */
+		if (statctrl(listdir,"nogreetings"))
+			greetingswitch=NULL;
+	}
+
 #if 0
 	log_error(LOG_ARGS, "controlstr = [%s]\n", controlstr);
 	log_error(LOG_ARGS, "fromemails->emaillist[0] = [%s]\n",
@@ -221,7 +229,8 @@
 				"-L", listdir,
 				"-a", fromemails->emaillist[0],
 				"-d",
-				subswitch, (char *)NULL);
+				subswitch!=NULL?subswitch:greetingswitch, /* confirm, if not maybe greet */
+                                (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 					mlmmjsub);
 		exit(EXIT_FAILURE);
@@ -258,7 +267,8 @@
 				"-L", listdir,
 				"-a", fromemails->emaillist[0],
 				"-n",
-				subswitch, (char *)NULL);
+		       subswitch!=NULL?subswitch:greetingswitch, /* confirm, if not maybe greet */
+		       (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 					mlmmjsub);
 		exit(EXIT_FAILURE);
@@ -286,7 +296,8 @@
 		execlp(mlmmjsub, mlmmjsub,
 				"-L", listdir,
 				"-a", fromemails->emaillist[0],
-				subswitch, (char *)NULL);
+				subswitch!=NULL?subswitch:greetingswitch, /* confirm, if not maybe greet */
+				(char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 					mlmmjsub);
 		exit(EXIT_FAILURE);
@@ -314,7 +325,7 @@
 				"-L", listdir,
 				"-a", tmpstr,
 				"-d",
-				"-c", (char *)NULL);
+				greetingswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjsub);
 		exit(EXIT_FAILURE);
@@ -342,7 +353,7 @@
 				"-L", listdir,
 				"-a", tmpstr,
 				"-n",
-				"-c", (char *)NULL);
+				greetingswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjsub);
 		exit(EXIT_FAILURE);
@@ -370,7 +381,7 @@
 		execlp(mlmmjsub, mlmmjsub,
 				"-L", listdir,
 				"-a", tmpstr,
-				"-c", (char *)NULL);
+				greetingswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjsub);
 		exit(EXIT_FAILURE);
@@ -399,7 +410,8 @@
 				"-L", listdir,
 				"-a", fromemails->emaillist[0],
 				"-d",
-				subswitch, (char *)NULL);
+				subswitch!=NULL?subswitch:greetingswitch, /* confirm, if not maybe greet */
+				(char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjunsub);
 		exit(EXIT_FAILURE);
@@ -428,7 +440,8 @@
 				"-L", listdir,
 				"-a", fromemails->emaillist[0],
 				"-n",
-				subswitch, (char *)NULL);
+				subswitch!=NULL?subswitch:greetingswitch, /* confirm, if not maybe greet */
+				(char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjunsub);
 		exit(EXIT_FAILURE);
@@ -456,7 +469,8 @@
 		execlp(mlmmjunsub, mlmmjunsub,
 				"-L", listdir,
 				"-a", fromemails->emaillist[0],
-				subswitch, (char *)NULL);
+				subswitch!=NULL?subswitch:greetingswitch, /* confirm, if not maybe greet */
+				(char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjunsub);
 		exit(EXIT_FAILURE);
@@ -490,7 +504,7 @@
 				"-L", listdir,
 				"-a", tmpstr,
 				"-d",
-				"-c", (char *)NULL);
+				greetingswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjunsub);
 		exit(EXIT_FAILURE);
@@ -524,7 +538,7 @@
 				"-L", listdir,
 				"-a", tmpstr,
 				"-n",
-				"-c", (char *)NULL);
+				greetingswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjunsub);
 		exit(EXIT_FAILURE);
@@ -558,7 +572,7 @@
 		execlp(mlmmjunsub, mlmmjunsub,
 				"-L", listdir,
 				"-a", tmpstr,
-				"-c", (char *)NULL);
+				greetingswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjunsub);
 		exit(EXIT_FAILURE);
@@ -600,7 +614,7 @@
 			execlp(mlmmjsub, mlmmjsub,
 					"-L", listdir,
 					"-m", param,
-					"-c", (char *)NULL);
+					greetingswitch, (char *)NULL);
 		}
 
 		sendfilename = concatstr(2, moderatefilename, ".sending");
diff -urNad mlmmj-1.2.17~/src/mlmmj-sub.c mlmmj-1.2.17/src/mlmmj-sub.c
--- mlmmj-1.2.17~/src/mlmmj-sub.c	2011-04-13 20:16:51.000000000 +1000
+++ mlmmj-1.2.17/src/mlmmj-sub.c	2011-04-13 20:16:55.531782748 +1000
@@ -429,7 +429,7 @@
 static void print_help(const char *prg)
 {
 	printf("Usage: %s -L /path/to/list [-a j...@doe.org | -m str]"
-	       "[-c] [-C] [-h]\n       [-L] [-d | -n] [-s] [-U] [-V]\n"
+	       "[-c] [-C] [-h]\n       [-L] [-d | -n] [-s] [-U] [-X] [-V]\n"
 	       " -a: Email address to subscribe \n"
 	       " -c: Send welcome mail\n"
 	       " -C: Request mail confirmation\n"
@@ -440,6 +440,7 @@
 	       " -n: Subscribe to no mail version of list\n", prg);
 	printf(" -s: Don't send a mail to subscriber if already subscribed\n"
 	       " -U: Don't switch to the user id of the listdir owner\n"
+	       " -X: Disable \"submod\" list option temporarily\n"
 	       " -V: Print version\n"
 	       "When no options are specified, subscription silently "
 	       "happens\n");
@@ -487,6 +488,7 @@
 	int subconfirm = 0, confirmsub = 0, opt, subfilefd, lock, notifysub;
 	int changeuid = 1, status, digest = 0, nomail = 0, i = 0, submod = 0;
 	int groupwritable = 0, sublock, sublockfd, nogensubscribed = 0, subbed;
+	int overridesubmod=0;
 	size_t len;
 	struct stat st;
 	pid_t pid, childpid;
@@ -501,7 +503,7 @@
 	mlmmjsend = concatstr(2, bindir, "/mlmmj-send");
 	myfree(bindir);
 
-	while ((opt = getopt(argc, argv, "hcCdm:nsVUL:a:")) != -1) {
+	while ((opt = getopt(argc, argv, "hcCdm:nsVUL:a:X")) != -1) {
 		switch(opt) {
 		case 'a':
 			address = optarg;
@@ -533,6 +535,9 @@
 		case 'U':
 			changeuid = 0;
 			break;
+		case 'X':
+			overridesubmod=1;
+			break;
 		case 'V':
 			print_version(argv[0]);
 			exit(0);
@@ -681,7 +686,7 @@
 			generate_subconfirm(listdir, listaddr, listdelim,
 					    address, mlmmjsend, typesub);
 		} else {
-			if(submod) {
+			if(submod && !overridesubmod) {
 				close(subfilefd);
 				close(sublockfd);
 				unlink(sublockname);

Reply via email to