Subscriber other (was: Moderator subscription)
PATCH 1/1 Subscriber other (was: Moderator subscription)
Quoted 3 lines · Mads Martin Joergensen
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:
[email protected] (i added unsubscribe too).
As you can see the @ in [email protected] 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 [email protected] 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?
src/listcontrol.c +66 -43
@@ -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);
Hi Magnus,
Quoted 4 lines · Magnus Naeslund(k)
Quoted 1 line · Mads Martin Joergensen
Absolutely they will. Patches are ALWAYS more than welcome :)
I'll make you eat those words :)
Haha :)
Quoted 1 line
This is an initial patch for the functionality that I was asking about.
Thanks. The patch looks fine, but you'll probably have to resubmit it a few days after mlmmj-1.2.12 is out. We are known for ignoring patches ;)
[snip]
Quoted 2 lines
So if this patch is near lift off, I'll patch up the -help text to display help for this command.
Yep, help text is a good idea.
Quoted 2 lines
P.S. I noticed that the "param" variable is sometimes freed, but sometimes not. What is the rule here?
Well, the rule is to free all memory. But IIRC every case ends with an execlp(), so it will not matter. It's just for the sake of Valgrind and me.
Morten
Signature · 2 lines
Morten K. Poulsen <[email protected]> http://www.afdelingp.dk/