From 95ea9d1899733270e254980df3c04c606f0a495f Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Tue, 16 Jan 2001 11:57:51 +0000 Subject: [PATCH] Delayed the processing of the acknowledgment-requirement so that you don't have to ack commands that will fail anyways. --- subscribe.c | 75 ++++++++++++++++++++++++++------------------------- unsubscribe.c | 70 +++++++++++++++++++++++------------------------ 2 files changed, 73 insertions(+), 72 deletions(-) diff --git a/subscribe.c b/subscribe.c index 414af24..9b78eae 100644 --- a/subscribe.c +++ b/subscribe.c @@ -174,43 +174,6 @@ AddAddress(struct Mail * MailStruct, } return 0; } - - else if (ListConfig->subtype == SUBSCRIPTION_ACKED && !g_is_approved) - { - /* Require confirmation. */ - - char* command = text_easy_sprintf("subscribe %s %s", address, listname); - char* cookie = queue_command(MailStruct, command); - - /* Notify the owner. */ - - fh = vOpenMailer(envelope, address, NULL); - if (fh != NULL) - { - fprintf(fh, "From: petidomo-approve@%s (Petidomo Mailing List Server)\n", ListConfig->fqdn); - fprintf(fh, "To: %s\n", address); - fprintf(fh, "Subject: Petidomo: CONFIRM %s@%s: Request from \"%s\"\n", listname, ListConfig->fqdn, originator); - fprintf(fh, "Precedence: junk\n"); - fprintf(fh, "Sender: %s\n", envelope); - fprintf(fh, "\n"); - buffer = text_easy_sprintf("Per request from \"%s\", the address \"%s\" should be subscribed to " \ - "the mailing list \"%s\". This will not happen unless you confirm the " \ - "request by replying to this mail and citing the string", - originator, address, listname); - text_wordwrap(buffer, 70); - fprintf(fh, "%s\n", buffer); - fprintf(fh, "\n %s\n\n", cookie); - fprintf(fh, "in your reply.\n"); - CloseMailer(fh); - } - else - { - syslog(LOG_ERR, "Failed to send email to \"%s\"!", owner); - return -1; - } - - return 0; - } } /* Check whether the address is subscribed already. */ @@ -244,6 +207,44 @@ AddAddress(struct Mail * MailStruct, return 0; } + if (isValidAdminPassword(getPassword(), listname) == FALSE && + ListConfig->subtype == SUBSCRIPTION_ACKED && !g_is_approved) + { + /* Require confirmation. */ + + char* command = text_easy_sprintf("subscribe %s %s", address, listname); + char* cookie = queue_command(MailStruct, command); + + /* Notify the owner. */ + + fh = vOpenMailer(envelope, address, NULL); + if (fh != NULL) + { + fprintf(fh, "From: petidomo-approve@%s (Petidomo Mailing List Server)\n", ListConfig->fqdn); + fprintf(fh, "To: %s\n", address); + fprintf(fh, "Subject: Petidomo: CONFIRM %s@%s: Request from \"%s\"\n", listname, ListConfig->fqdn, originator); + fprintf(fh, "Precedence: junk\n"); + fprintf(fh, "Sender: %s\n", envelope); + fprintf(fh, "\n"); + buffer = text_easy_sprintf("Per request from \"%s\", the address \"%s\" should be subscribed to " \ + "the mailing list \"%s\". This will not happen unless you confirm the " \ + "request by replying to this mail and citing the string", + originator, address, listname); + text_wordwrap(buffer, 70); + fprintf(fh, "%s\n", buffer); + fprintf(fh, "\n %s\n\n", cookie); + fprintf(fh, "in your reply.\n"); + CloseMailer(fh); + } + else + { + syslog(LOG_ERR, "Failed to send email to \"%s\"!", owner); + return -1; + } + + return 0; + } + /* Okay, add the address to the list. */ fh = fopen(ListConfig->address_file, "a"); diff --git a/unsubscribe.c b/unsubscribe.c index 6ce792b..a2d8692 100644 --- a/unsubscribe.c +++ b/unsubscribe.c @@ -176,8 +176,42 @@ DeleteAddress(struct Mail * MailStruct, } return 0; } + } - else if (ListConfig->subtype == SUBSCRIPTION_ACKED && !g_is_approved) + /* Okay, remove the address from the list. */ + + if (isSubscribed(listname, address, &list, &p, FALSE) == FALSE) + { + /* Notify the originator, that the address is not subscribed at + all. */ + + fh = vOpenMailer(envelope, originator, NULL); + if (fh != NULL) + { + fprintf(fh, "From: %s-request@%s (Petidomo Mailing List Server)\n", + listname, ListConfig->fqdn); + fprintf(fh, "To: %s\n", originator); + fprintf(fh, "Subject: Petidomo: Your request \"unsubscribe %s %s\"\n", + address, listname); + if (MailStruct->Message_Id != NULL) + fprintf(fh, "In-Reply-To: %s\n", MailStruct->Message_Id); + fprintf(fh, "Precedence: junk\n"); + fprintf(fh, "Sender: %s\n", envelope); + fprintf(fh, "\n"); + fprintf(fh, "The address is not subscribed to this list.\n"); + CloseMailer(fh); + } + else + { + syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", + originator); + return -1; + } + } + else + { + if (isValidAdminPassword(getPassword(), listname) == FALSE && + ListConfig->subtype == SUBSCRIPTION_ACKED && !g_is_approved) { /* Require confirmation. */ @@ -214,40 +248,6 @@ DeleteAddress(struct Mail * MailStruct, return 0; } - } - - /* Okay, remove the address from the list. */ - - if (isSubscribed(listname, address, &list, &p, FALSE) == FALSE) - { - /* Notify the originator, that the address is not subscribed at - all. */ - - fh = vOpenMailer(envelope, originator, NULL); - if (fh != NULL) - { - fprintf(fh, "From: %s-request@%s (Petidomo Mailing List Server)\n", - listname, ListConfig->fqdn); - fprintf(fh, "To: %s\n", originator); - fprintf(fh, "Subject: Petidomo: Your request \"unsubscribe %s %s\"\n", - address, listname); - if (MailStruct->Message_Id != NULL) - fprintf(fh, "In-Reply-To: %s\n", MailStruct->Message_Id); - fprintf(fh, "Precedence: junk\n"); - fprintf(fh, "Sender: %s\n", envelope); - fprintf(fh, "\n"); - fprintf(fh, "The address is not subscribed to this list.\n"); - CloseMailer(fh); - } - else - { - syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", - originator); - return -1; - } - } - else - { fh = fopen(ListConfig->address_file, "w"); if (fh == NULL) {