All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Magnus Naeslund(k)" <mag@kite.se>
To: mlmmj@mlmmj.org
Subject: [PATCH] Subscriber other (was: Moderator subscription)
Date: Mon, 25 Sep 2006 20:05:10 +0000	[thread overview]
Message-ID: <45183676.9010702@kite.se> (raw)

Mads Martin Joergensen wrote:
> 
> Absolutely they will. Patches are ALWAYS more than welcome :)
>

I'll make you eat those words :)

This is an initial patch for the functionality that I was asking about.
This adds an "subscribe other emailadress" option ala ezmlm using this syntax:
list-subscribe-user=host.com@listhost.com (i added unsubscribe too).
As you can see the @ in user@host.com is replaced with an = to make it passable to the mailing list manager.

Later I plan to add something like this: if a moderator does the same thing, the user@host.com will not be sent an confirmation mail. I think the moderator will have to get it, otherwise you can forge From:, right?

So if this patch is near lift off, I'll patch up the -help text to display help for this command.

Regards,
Magnus Näslund

P.S. I noticed that the "param" variable is sometimes freed, but sometimes not. What is the rule here?





diff -urx '*~' mlmmj-1.2.12-RC3-vanilla/src/listcontrol.c mlmmj-1.2.12-RC3/src/listcontrol.c
--- mlmmj-1.2.12-RC3-vanilla/src/listcontrol.c	2006-09-04 00:04:11.000000000 +0200
+++ mlmmj-1.2.12-RC3/src/listcontrol.c	2006-09-25 21:34:08.000000000 +0200
@@ -68,32 +68,39 @@
 	CTRL_END  /* end marker, must be last */
 };
 
+enum param_type {
+        PARAM_NONE = 0,
+        PARAM_MANDATORY,
+        PARAM_OPTIONAL
+};
+
+
 struct ctrl_command {
 	char *command;
-	unsigned int accepts_parameter;
+	enum param_type accepts_parameter;
 };
 
 /* Must match the enum. CAREFUL when using commands that are substrings
  * of other commands. In that case the longest one have to be listed
  * first to match correctly. */
 static struct ctrl_command ctrl_commands[] = {
-	{ "subscribe-digest",   0 },
-	{ "subscribe-nomail",   0 },
-	{ "subscribe",          0 },
-	{ "confsub-digest",     1 },
-	{ "confsub-nomail",     1 },
-	{ "confsub",            1 },
-	{ "unsubscribe-digest", 0 },
-	{ "unsubscribe-nomail", 0 },
-	{ "unsubscribe",        0 },
-	{ "confunsub-digest",   1 },
-	{ "confunsub-nomail",   1 },
-	{ "confunsub",          1 },
-	{ "bounces",            1 },
-	{ "moderate",           1 },
-	{ "help",               0 },
-	{ "get",                1 },
-	{ "list",               0 }
+	{ "subscribe-digest",   PARAM_NONE },
+	{ "subscribe-nomail",   PARAM_NONE },
+	{ "subscribe",          PARAM_OPTIONAL },
+	{ "confsub-digest",     PARAM_MANDATORY },
+	{ "confsub-nomail",     PARAM_MANDATORY },
+	{ "confsub",            PARAM_MANDATORY },
+	{ "unsubscribe-digest", PARAM_NONE },
+	{ "unsubscribe-nomail", PARAM_NONE },
+	{ "unsubscribe",        PARAM_OPTIONAL },
+	{ "confunsub-digest",   PARAM_MANDATORY },
+	{ "confunsub-nomail",   PARAM_MANDATORY },
+	{ "confunsub",          PARAM_MANDATORY },
+	{ "bounces",            PARAM_MANDATORY },
+	{ "moderate",           PARAM_MANDATORY },
+	{ "help",               PARAM_NONE },
+	{ "get",                PARAM_MANDATORY },
+	{ "list",               PARAM_NONE }
 };
 
 
@@ -136,26 +143,26 @@
 		if (strncmp(controlstr, ctrl_commands[ctrl].command, cmdlen)
 				= 0) {
 
-			if (ctrl_commands[ctrl].accepts_parameter) {
-				if (controlstr[cmdlen] != '-') {
-					errno = 0;
-					log_error(LOG_ARGS, "Command \"%s\""
-						" requires a parameter, but no"
-						" parameter was given."
-						" Ignoring mail",
-						ctrl_commands[ctrl].command);
-					return -1;
+			if (ctrl_commands[ctrl].accepts_parameter != PARAM_NONE) {
+                                if (controlstr[cmdlen] = '-') {
+                                        param = mystrdup(controlstr + cmdlen + 1);
+                                        MY_ASSERT(param);
+                                        if (strchr(param, '/')) {
+                                                errno = 0;
+                                                log_error(LOG_ARGS, "Slash (/) in"
+                                                          " list control request,"
+                                                          " discarding mail");
+                                                return -1;
+                                        }
+                                } else if (ctrl_commands[ctrl].accepts_parameter != PARAM_OPTIONAL){
+                                        errno = 0;
+                                        log_error(LOG_ARGS, "Command \"%s\""
+                                                  " requires a parameter, but no"
+                                                  " parameter was given."
+                                                  " Ignoring mail",
+                                                  ctrl_commands[ctrl].command);
+                                        return -1;
                                 }
-				param = mystrdup(controlstr + cmdlen + 1);
-				MY_ASSERT(param);
-				if (strchr(param, '/')) {
-					errno = 0;
-					log_error(LOG_ARGS, "Slash (/) in"
-						" list control request,"
-						" discarding mail");
-					return -1;
-				}
-
 			} else {
 				if (controlstr[cmdlen] != '\0') {
 					errno = 0;
@@ -254,7 +261,15 @@
 				" sent to a closed list. Ignoring mail");
 			return -1;
 		}
-		if (!strchr(fromemails->emaillist[0], '@')) {
+
+	        if (param && (c = strchr(param, '=')) != NULL){
+                        /* Replace = with @, if no = is found it'll get caught later on*/
+                        *c = '@';
+		}
+                    
+                c = param ? param : fromemails->emaillist[0];
+                    
+		if (!strchr(c, '@')) {
 			/* Not a valid From: address */
 			errno = 0;
 			log_error(LOG_ARGS, "A subscribe request was"
@@ -264,10 +279,10 @@
 		}
 		log_oper(listdir, OPLOGFNAME, "mlmmj-sub: request for regular"
 					" subscription from %s",
-					fromemails->emaillist[0]);
+					c);
 		execlp(mlmmjsub, mlmmjsub,
 				"-L", listdir,
-				"-a", fromemails->emaillist[0],
+				"-a", c,
 				subswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 					mlmmjsub);
@@ -424,7 +439,15 @@
 				" sent to a closed list. Ignoring mail");
 			return -1;
 		}
-		if (!strchr(fromemails->emaillist[0], '@')) {
+                    
+	        if (param && (c = strchr(param, '=')) != NULL){
+                        /* Replace = with @, if no = is found it'll get caught later on*/
+                        *c = '@';
+		}
+                    
+                c = param ? param : fromemails->emaillist[0];
+                    
+		if (!strchr(c, '@')) {
 			/* Not a valid From: address */
 			errno = 0;
 			log_error(LOG_ARGS, "An unsubscribe request was"
@@ -434,10 +457,10 @@
 		}
 		log_oper(listdir, OPLOGFNAME, "mlmmj-unsub: %s requests"
 					" unsubscribe from regular list",
-					fromemails->emaillist[0]);
+					c);
 		execlp(mlmmjunsub, mlmmjunsub,
 				"-L", listdir,
-				"-a", fromemails->emaillist[0],
+				"-a", c,
 				subswitch, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 				mlmmjunsub);

             reply	other threads:[~2006-09-25 20:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25 20:05 Magnus Naeslund(k) [this message]
2006-09-25 20:49 ` [PATCH] Subscriber other (was: Moderator subscription) Morten K. Poulsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45183676.9010702@kite.se \
    --to=mag@kite.se \
    --cc=mlmmj@mlmmj.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.