head 1.23; access; symbols PETIDOMO_4_0b6:1.23 PETIDOMO_4_0b5:1.22 PETIDOMO_4_0b4:1.22 PETIDOMO_4_0b3:1.22 BEFORETHL:1.22 petidomo-2-2:1.1.1.1 petidomo:1.1.1; locks; strict; comment @ * @; 1.23 date 2004.03.19.15.39.21; author thl; state Exp; branches; next 1.22; 1.22 date 2001.01.20.15.03.11; author rse; state Exp; branches; next 1.21; 1.21 date 2001.01.20.14.08.25; author rse; state Exp; branches; next 1.20; 1.20 date 2001.01.20.13.52.41; author rse; state Exp; branches; next 1.19; 1.19 date 2001.01.19.14.56.33; author rse; state Exp; branches; next 1.18; 1.18 date 2001.01.19.14.28.08; author simons; state Exp; branches; next 1.17; 1.17 date 2001.01.19.14.18.43; author simons; state Exp; branches; next 1.16; 1.16 date 2001.01.19.13.31.11; author simons; state Exp; branches; next 1.15; 1.15 date 2001.01.18.20.30.50; author rse; state Exp; branches; next 1.14; 1.14 date 2001.01.16.12.09.12; author simons; state Exp; branches; next 1.13; 1.13 date 2001.01.16.11.57.51; author simons; state Exp; branches; next 1.12; 1.12 date 2001.01.15.18.47.32; author simons; state Exp; branches; next 1.11; 1.11 date 2001.01.15.17.56.33; author simons; state Exp; branches; next 1.10; 1.10 date 2001.01.15.16.55.45; author simons; state Exp; branches; next 1.9; 1.9 date 2001.01.15.16.35.06; author simons; state Exp; branches; next 1.8; 1.8 date 2001.01.10.17.12.40; author simons; state Exp; branches; next 1.7; 1.7 date 2001.01.10.17.08.22; author simons; state Exp; branches; next 1.6; 1.6 date 2001.01.08.20.36.19; author simons; state Exp; branches; next 1.5; 1.5 date 2001.01.06.11.05.08; author simons; state Exp; branches; next 1.4; 1.4 date 2000.12.15.16.16.07; author simons; state Exp; branches; next 1.3; 1.3 date 2000.12.15.15.48.00; author simons; state Exp; branches; next 1.2; 1.2 date 2000.12.13.15.35.14; author simons; state Exp; branches; next 1.1; 1.1 date 2000.12.13.13.19.25; author simons; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2000.12.13.13.19.25; author simons; state Exp; branches; next ; desc @@ 1.23 log @split cookies on (un)subscription, too - found and fixed by tho @ text @/* $Source: /e/ossp/cvs/ossp-pkg/petidomo/subscribe.c,v $ $Revision: 1.22 $ Copyright (C) 2000 by CyberSolutions GmbH, Germany. This file is part of Petidomo. Petidomo is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Petidomo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #include #include #include "libtext/text.h" #include "petidomo.h" int AddAddress(struct Mail * MailStruct, const char * param1, const char * param2, const char * defaultlist) { const struct PD_Config * MasterConfig; const struct List_Config * ListConfig; FILE * fh; const char * address = NULL; const char * listname = NULL; char owner[4096]; char envelope[4096]; char * buffer; char * originator; char * p; /* Initialize internal stuff from master config file. */ MasterConfig = getMasterConfig(); sprintf(envelope, "petidomo-manager@@%s", MasterConfig->fqdn); originator = (MailStruct->Reply_To) ? MailStruct->Reply_To : MailStruct->From; /* Try to find out, which parameter is what. */ if (param1 != NULL) { if (isValidListName(param1) == TRUE) listname = param1; else if (isRFC822Address(param1) == TRUE) address = param1; if (param2 != NULL) { if (listname == NULL && isValidListName(param2) == TRUE) listname = param2; else if (address == NULL && isRFC822Address(param2) == TRUE) address = param2; } } if (address == NULL) address = (MailStruct->Reply_To) ? MailStruct->Reply_To : MailStruct->From; assert(address != NULL); if (listname == NULL) { if (defaultlist != NULL) listname = defaultlist; else { syslog(LOG_INFO, "%s: subscribe-command invalid: No list specified.", MailStruct->From); fh = vOpenMailer(envelope, originator, NULL); if (fh != NULL) { fprintf(fh, "From: petidomo@@%s (Petidomo Mailing List Server)\n", MasterConfig->fqdn); fprintf(fh, "To: %s\n", originator); fprintf(fh, "Subject: Petidomo: Your request \"subscribe %s\"\n", address); 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"); buffer = text_easy_sprintf("You tried to subscribe the address \"%s\" to a mailing list. " \ "Unfortunately, your request could not be processed, because " \ "you did not specify a valid mailing list name to which the " \ "address should be subscribed to. You may use the command INDEX " \ "to receive an overview of the available mailing lists. Also, " \ "use the command HELP to verify that you got the command syntax " \ "right.", address); text_wordwrap(buffer, 70); fprintf(fh, "%s\n", buffer); CloseMailer(fh); } else syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); return 0; } } /* Initialize internal stuff again from list config. */ ListConfig = getListConfig(listname); sprintf(owner, "%s-owner@@%s", listname, ListConfig->fqdn); sprintf(envelope, "%s-owner@@%s", listname, ListConfig->fqdn); /* Check whether the request is authorized at all. */ if (isValidAdminPassword(getPassword(), listname) == FALSE) { /* No valid password, check further. */ if (ListConfig->subtype == SUBSCRIPTION_ADMIN) { /* Access was unauthorized, notify the originator. */ syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" rejected due to lack of " \ "a correct admin password.", MailStruct->From, address, listname); 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 \"subscribe %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"); buffer = text_easy_sprintf( "The mailing list \"%s\" is a closed forum and only the maintainer may " \ "subscribe addresses. Your request has been forwarded to the " \ "appropriate person, so please don't send any further mail. You will " \ "be notified as soon as possible.", listname); text_wordwrap(buffer, 70); fprintf(fh, "%s\n", buffer); CloseMailer(fh); } else syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); /* Notify the owner. */ fh = vOpenMailer(envelope, owner, NULL); if (fh != NULL) { fprintf(fh, "From: %s-request@@%s (Petidomo Mailing List Server)\n", listname, ListConfig->fqdn); fprintf(fh, "To: %s\n", owner); fprintf(fh, "Subject: Petidomo: APPROVE %s@@%s: Unauthorized 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( "\"%s\" tried to subscribe the address \"%s\" to the \"%s\" mailing list, " \ "but couldn't provide the correct password. To subscribe him, send the " \ "following commands to the server:", originator, address, listname); text_wordwrap(buffer, 70); fprintf(fh, "%s\n\n", buffer); fprintf(fh, "password \n"); fprintf(fh, "subscribe %s %s\n", address, listname); CloseMailer(fh); } else { syslog(LOG_ERR, "Failed to send email to \"%s\"!", owner); return -1; } return 0; } } /* Check whether the address is subscribed already. */ if (isSubscribed(listname, address, NULL, NULL, FALSE) == TRUE) { syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" rejected, because the " \ "address is already on the list.", MailStruct->From, address, listname); /* Notify the originator, that the address is already a member. */ 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 \"subscribe %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 \"%s\" is already subscribed to list \"%s\".\n", address, listname); CloseMailer(fh); } else { syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); return -1; } return 0; } if (isValidAdminPassword(getPassword(), listname) == FALSE && ListConfig->subtype == SUBSCRIPTION_ACKED && !g_is_approved) { /* Require approval. */ char* command; char c; char* cookie; syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" deferred, because the " \ "request must be acknowledged first.", MailStruct->From, address, listname); command = text_easy_sprintf("subscribe %s %s", address, listname); cookie = queue_command(MailStruct, command); /* Send request for approval to the user. */ 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); if (strcasecmp(address, originator) == 0) fprintf(fh, "Subject: Petidomo: APPROVE %s@@%s: Your request \"subscribe %s\"\n", listname, ListConfig->fqdn, listname); else fprintf(fh, "Subject: Petidomo: APPROVE %s@@%s: Request \"subscribe %s\" from \"%s\"\n", listname, ListConfig->fqdn, listname, originator); fprintf(fh, "Precedence: junk\n"); fprintf(fh, "Sender: %s\n", envelope); fprintf(fh, "\n"); if (strcasecmp(address, originator) == 0) buffer = text_easy_sprintf("You requested that the address \"%s\" should be subscribed to " \ "the mailing list \"%s\". This will not happen unless you approve the " \ "request by replying to this mail and concatenating the following two strings into one", address, listname); else 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 approve the " \ "request by replying to this mail and concatenating the following two strings into one", originator, address, listname); text_wordwrap(buffer, 70); fprintf(fh, "%s\n", buffer); fprintf(fh, "\n"); c = cookie[16]; cookie[16] = '\0'; fprintf(fh, " %s\n", &cookie[ 0]); cookie[16] = c; fprintf(fh, " %s\n", &cookie[16]); fprintf(fh, "\n"); fprintf(fh, "in your reply.\n"); CloseMailer(fh); /* If the request for approval has been sent to an address different to that of the originator, notify him what happened. */ if (strcasecmp(address, originator) != 0) { 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 \"subscribe %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, "Subscribing the address \"%s\" to the list \"%s\"\n", address, listname); fprintf(fh, "requires additional approval by \"%s\". A request\n", address); fprintf(fh, "has been sent to this address. We are now awaiting the approval.\n"); CloseMailer(fh); } else { syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); return -1; } } } else { syslog(LOG_ERR, "Failed to send email to \"%s\"!", owner); return -1; } return 0; } /* Okay, add the address to the list. */ syslog(LOG_INFO, "%s: Okay; subscribing address \"%s\" to list \"%s\".", MailStruct->From, address, listname); fh = fopen(ListConfig->address_file, "a"); if (fh == NULL) { syslog(LOG_ERR, "Failed to open file \"%s\" for writing: %s", ListConfig->address_file, strerror(errno)); return -1; } fprintf(fh, "%s\n", address); fclose(fh); /* Send success notification to the originator and the new subscriber */ if (!strcasecmp(address, originator) == TRUE) fh = vOpenMailer(envelope, address, NULL); else fh = vOpenMailer(envelope, address, originator, NULL); if (fh != NULL) { fprintf(fh, "From: %s-request@@%s (Petidomo Mailing List Server)\n", listname, ListConfig->fqdn); fprintf(fh, "To: %s\n", address); if (strcasecmp(address, originator) == TRUE) fprintf(fh, "Cc: %s\n", originator); fprintf(fh, "Subject: Petidomo: Request \"subscribe %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"); if (!strcasecmp(address, originator) == TRUE) { buffer = text_easy_sprintf( "Per your request, the address \"%s\" has been subscribed to the " \ "\"%s\" mailing list. If you want to unsubscribe later, you can " \ "do so by sending the following command to \"%s-request@@%s\":", address, listname, listname, ListConfig->fqdn); } else { buffer = text_easy_sprintf( "Per request from \"%s\", the address \"%s\" has been subscribed to the " \ "\"%s\" mailing list. If you want to unsubscribe later, you can " \ "do so by sending the following command to \"%s-request@@%s\":", originator, address, listname, listname, ListConfig->fqdn); } text_wordwrap(buffer, 70); fprintf(fh, "%s\n\n", buffer); fprintf(fh, "unsubscribe %s\n\n", address); fprintf(fh, "Please save a copy of this mail, to make sure you remember how " \ "to\nunsubscribe!\n"); CloseMailer(fh); } else { syslog(LOG_ERR, "Failed to send email to \"%s\"!", address); return -1; } /* Send success notification to the list owner */ fh = vOpenMailer(envelope, owner, NULL); if (fh != NULL) { fprintf(fh, "From: %s-request@@%s (Petidomo Mailing List Server)\n", listname, ListConfig->fqdn); fprintf(fh, "To: %s\n", owner); fprintf(fh, "Subject: Petidomo: SUBSCRIBE %s@@%s: %s\n", listname, ListConfig->fqdn, address); 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"); if (!strcasecmp(address, originator) == TRUE) { buffer = text_easy_sprintf( "Per request from the subscriber, the address \"%s\"\n" "has been subscribed to the \"%s\" mailing list.\n", address, listname, ListConfig->fqdn); } else { buffer = text_easy_sprintf( "Per request from \"%s\", the address \"%s\"\n" "has been subscribed to the \"%s\" mailing list.\n", originator, address, listname, ListConfig->fqdn); } text_wordwrap(buffer, 75); fprintf(fh, "%s\n", buffer); fprintf(fh, "No action is required on your part.\n"); CloseMailer(fh); } else { syslog(LOG_ERR, "Failed to send email to \"%s\"!", owner); return -1; } /* Send introduction text to the new member. */ p = loadfile(ListConfig->intro_file); if (p != NULL) { fh = vOpenMailer(envelope, address, NULL); if (fh != NULL) { fprintf(fh, "From: %s-request@@%s (Petidomo Mailing List Server)\n", listname, ListConfig->fqdn); fprintf(fh, "To: %s\n", address); fprintf(fh, "Subject: Petidomo: Welcome to \"%s@@%s\"!\n", listname, ListConfig->fqdn); 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, "%s\n", p); CloseMailer(fh); free(p); } else { free(p); syslog(LOG_ERR, "Failed to send introduction mail to \"%s\"!", address); return -1; } } return 0; } @ 1.22 log @Sorry, I still inist that Petidomo visually resembles Majordomo as close as possible: now Petidomo no longer just sends a carbon-copy of the final "successful" mail after subscribe/unsubscribe operations to the list owner. Instead the list owner gets an own dedicated mail. The most important thing is that those mails have "SUBSCRIBE" and "UNSUBSCRIBE" tags in their Subject so one can easily monitor those operations as the list owner. @ text @d3 1 a3 1 $Revision: 1.21 $ d218 1 d244 1 a244 1 "request by replying to this mail and citing the string", d249 1 a249 1 "request by replying to this mail and citing the string", d253 5 a257 1 fprintf(fh, "\n %s\n\n", cookie); @ 1.21 log @More information in message @ text @d3 1 a3 1 $Revision: 1.20 $ d306 1 a306 2 /* Send success notification to the originator, the new subscriber, and the owner. */ d309 1 a309 1 fh = vOpenMailer(envelope, address, owner, NULL); d311 1 a311 1 fh = vOpenMailer(envelope, address, originator, owner, NULL); d317 2 a318 4 if (!strcasecmp(address, originator) == TRUE) fprintf(fh, "Cc: %s\n", owner); else fprintf(fh, "Cc: %s, %s\n", originator, owner); d350 1 a350 1 syslog(LOG_ERR, "Failed to send email to \"%s\"!", owner); d353 35 @ 1.20 log @First bunch of cosmetic adjustments to text messages. Additionally --masterconf=FILE is also passed through to files created in acknowledge directory. @ text @d3 1 a3 1 $Revision: 1.19 $ d201 1 a201 1 fprintf(fh, "The address is subscribed to this list already.\n"); @ 1.19 log @Get rid of all complaints from GCC 2.97 (except for two things which I do not want to change on my own) @ text @d3 1 a3 1 $Revision: 1.18 $ d91 1 a91 1 "you didn't specify a valid mailing list name to which the " \ d93 1 a93 1 "to receive an overview over the available mailing lists. Also, " \ d215 1 a215 1 /* Require confirmation. */ d226 1 a226 1 /* Send request for confirmation to the user. */ d233 4 a236 1 fprintf(fh, "Subject: Petidomo: CONFIRM %s@@%s: Request from \"%s\"\n", listname, ListConfig->fqdn, originator); d242 1 a242 1 "the mailing list \"%s\". This will not happen unless you confirm the " \ d247 1 a247 1 "the mailing list \"%s\". This will not happen unless you confirm the " \ d256 1 a256 1 /* If the request for confirmation has been sent to an d273 3 a275 2 fprintf(fh, "Subscribing the address will need confirmation. Such a\n"); fprintf(fh, "request has been sent to the address already, so don't move!\n"); d368 1 a368 1 fprintf(fh, "Subject: Petidomo: Welcome to the \"%s\" mailing list!\n", listname); @ 1.18 log @Fixed the spelling of the newly added syslog messages. @ text @d3 1 a3 1 $Revision: 1.17 $ d21 2 d296 1 a296 1 syslog(LOG_ERR, "Failed to open file \"%s\" for writing: %m", ListConfig->address_file); @ 1.17 log @Greatly enhanced the log messages Petidomo writes. Made the existing messages more helpful, added lots of new ones, generally made things real perfect. Remember: Life is BEAUTIFUL. @ text @d3 1 a3 1 $Revision: 1.16 $ d182 1 a182 1 syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" rejected because the " \ d218 1 a218 1 syslog(LOG_INFO, "%s: Attempt to subscribe \"%s\" to list \"%s\" deferred because the " \ @ 1.16 log @When a un-/subscribe command needs confirmation, the request for confirmation is sent to the address that is supposed to added to or removed from the list. If, and only if, this address is different than the one from which the request came, a short mail is sent to the requestor to inform him what is going on. @ text @d3 1 a3 1 $Revision: 1.15 $ d75 1 a75 1 syslog(LOG_NOTICE, "%s: subscribe-command invalid: No list specified.", MailStruct->From); d120 2 a121 2 syslog(LOG_INFO, "\"%s\" tried to subscribe \"%s\" to list \"%s\", but couldn't " \ "provide the correct password.", originator, address, listname); d145 1 a145 2 syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); d182 3 d215 8 a222 2 char* command = text_easy_sprintf("subscribe %s %s", address, listname); char* cookie = queue_command(MailStruct, command); d288 2 @ 1.15 log @As we agreed today, Petidomo is now open because licensed under GPL and always will be licensed under GPL, so use "Petidomo" as the program name everywhere and consistently. @ text @d3 1 a3 1 $Revision: 1.14 $ d216 1 a216 1 /* Notify the owner. */ d227 10 a236 4 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); d243 5 a247 2 fh = vOpenMailer(envelope, originator, NULL); if (fh != NULL) d249 20 a268 16 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 \"subscribe %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, "Subscribing the address will need confirmation. Such a\n"); fprintf(fh, "request has been sent to the address already, so don't move!\n"); CloseMailer(fh); } else { syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); return -1; @ 1.14 log @When a request for confirmation is required, the originator of the command will receive a short mail, telling him that this is so, so that he knows what's going on. @ text @d2 2 a3 2 $Source: /d1/e/petidomo/cvs/petidomo/source/subscribe.c,v $ $Revision: 1.13 $ d7 1 a7 1 This file is part of OpenPetidomo. d9 1 a9 1 OpenPetidomo is free software; you can redistribute it and/or modify d14 1 a14 1 OpenPetidomo is distributed in the hope that it will be useful, but @ 1.13 log @Delayed the processing of the acknowledgment-requirement so that you don't have to ack commands that will fail anyways. @ text @d3 1 a3 1 $Revision: 1.12 $ d189 1 a189 2 fprintf(fh, "From: %s-request@@%s (Petidomo Mailing List Server)\n", listname, ListConfig->fqdn); d191 1 a191 2 fprintf(fh, "Subject: Petidomo: Your request \"subscribe %s %s\"\n", address, listname); d236 21 a262 1 @ 1.12 log @The call to queue_command() had the command wrong. @ text @d3 1 a3 1 $Revision: 1.11 $ a176 37 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; } d207 38 @ 1.11 log @Added code that will send the "request for confirmation" mail out when apropriate. @ text @d3 1 a3 1 $Revision: 1.10 $ d182 1 a182 1 char* command = text_easy_sprintf("unsubscribe %s %s", address, listname); @ 1.10 log @List's "AllowPublicSubscripiton" does not exist anymore. Now we have "SubscriptionType" with valid values "public", "admin" or "acknowledged". @ text @d3 1 a3 1 $Revision: 1.9 $ d175 37 @ 1.9 log @Removed the whole concept of "alien subscription". It was stupid to begin with and now that we'll have acknowledged subscriptions, it is useless, too. @ text @d3 1 a3 1 $Revision: 1.8 $ d116 1 a116 1 if (ListConfig->allowpubsub == FALSE) @ 1.8 log @Set the right margin for word-wrapping to 70 characters instead of 75. @ text @d3 1 a3 1 $Revision: 1.7 $ a163 65 text_wordwrap(buffer, 70); fprintf(fh, "%s\n\n", buffer); fprintf(fh, "password \n"); fprintf(fh, "subscribe %s %s\n", address, listname); CloseMailer(fh); } else { syslog(LOG_ERR, "Failed to send email to \"%s\"!", owner); return -1; } return 0; } if (ListConfig->allowaliensub == FALSE && (MailStruct->From == NULL || !strcasecmp(address, MailStruct->From) == FALSE) && (MailStruct->Reply_To == NULL || !strcasecmp(address, MailStruct->Reply_To) == FALSE)) { /* Trying to subscribe something different than himself. */ syslog(LOG_INFO, "\"%s\" tried to subscribe \"%s\" to list \"%s\", but the list " \ "type doesn't allow this.", originator, address, listname); 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 \"subscribe %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"); buffer = text_easy_sprintf( "The mailing list \"%s\" does not allow to automatically subscribe or unsubscribe an " \ "address not equal to the one, you are mailing from. Your request has been forwarded " \ "to the list administrator, so please don't send any futher mail. You will be notified " \ "as soon as possible.", listname); text_wordwrap(buffer, 70); fprintf(fh, "%s\n", buffer); CloseMailer(fh); } else syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); /* Notify the owner. */ fh = vOpenMailer(envelope, owner, NULL); if (fh != NULL) { fprintf(fh, "From: %s-request@@%s (Petidomo Mailing List Server)\n", listname, ListConfig->fqdn); fprintf(fh, "To: %s\n", owner); fprintf(fh, "Subject: Petidomo: APPROVE %s@@%s: Unauthorized 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( "\"%s\" tried to subscribe the address \"%s\" to the \"%s\" mailing list. " \ "The list type does not allow subscribing addresses not equal to the From: " \ "address, though, so the request has been denied. To subscribe this person " \ "manually, send the following commands to the server:", originator, address, listname); @ 1.7 log @The requestor will now receive a mail telling him something went wrong when he tries to subscribe an address without specifying a list name. @ text @d3 1 a3 1 $Revision: 1.6 $ d94 1 a94 1 text_wordwrap(buffer, 75); d140 1 a140 1 text_wordwrap(buffer, 75); d164 1 a164 1 text_wordwrap(buffer, 75); d204 1 a204 1 text_wordwrap(buffer, 75); d229 1 a229 1 text_wordwrap(buffer, 75); d324 1 a324 1 text_wordwrap(buffer, 75); @ 1.6 log @Rewrote Petidomo so that virtually any file's path can be configured at run-time now. @ text @d3 1 a3 1 $Revision: 1.5 $ d29 2 a30 1 { a31 1 const struct PD_Config * MasterConfig; d41 6 d49 2 a50 1 if (param1 != NULL) { d52 1 a52 1 listname = param1; d54 1 a54 1 address = param1; d56 7 a62 5 if (param2 != NULL) { if (isValidListName(param2) == TRUE) listname = param2; else if (isRFC822Address(param2) == TRUE) address = param2; a63 1 } d66 39 a104 9 address = (MailStruct->Reply_To) ? MailStruct->Reply_To : MailStruct->From; if (listname == NULL && defaultlist != NULL) listname = defaultlist; if (address == NULL || listname == NULL) { syslog(LOG_NOTICE, "%s: subscribe-command invalid: No list specified.", MailStruct->From); return 0; } a105 2 /* Initialize internal stuff. */ MasterConfig = getMasterConfig(); a108 1 originator = (MailStruct->Reply_To) ? MailStruct->Reply_To : MailStruct->From; d112 2 a113 2 if (isValidAdminPassword(getPassword(), listname) == FALSE) { d116 2 a117 2 if (ListConfig->allowpubsub == FALSE) { d121 1 a121 1 "provide the correct password.", originator, address, listname); d124 2 a125 1 if (fh != NULL) { d131 1 a131 1 fprintf(fh, "In-Reply-To: %s\n", MailStruct->Message_Id); d136 4 a139 4 "The mailing list \"%s\" is a closed forum and only the maintainer may " \ "subscribe addresses. Your request has been forwarded to the " \ "appropriate person, so please don't send any further mail. You will " \ "be notified as soon as possible.", listname); d143 1 a143 1 } d145 2 a146 2 syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); d151 2 a152 1 if (fh != NULL) { d161 3 a163 3 "\"%s\" tried to subscribe the address \"%s\" to the \"%s\" mailing list, " \ "but couldn't provide the correct password. To subscribe him, send the " \ "following commands to the server:", originator, address, listname); d169 3 a171 2 } else { d174 2 a176 2 return 0; } d180 2 a181 2 (MailStruct->Reply_To == NULL || !strcasecmp(address, MailStruct->Reply_To) == FALSE)) { d185 1 a185 1 "type doesn't allow this.", originator, address, listname); d188 2 a189 1 if (fh != NULL) { d195 1 a195 1 fprintf(fh, "In-Reply-To: %s\n", MailStruct->Message_Id); d200 4 a203 4 "The mailing list \"%s\" does not allow to automatically subscribe or unsubscribe an " \ "address not equal to the one, you are mailing from. Your request has been forwarded " \ "to the list administrator, so please don't send any futher mail. You will be notified " \ "as soon as possible.", listname); d207 1 a207 1 } d209 2 a210 2 syslog(LOG_ERR, "Failed to send email to \"%s\" concerning his request.", originator); d215 2 a216 1 if (fh != NULL) { d225 4 a228 4 "\"%s\" tried to subscribe the address \"%s\" to the \"%s\" mailing list. " \ "The list type does not allow subscribing addresses not equal to the From: " \ "address, though, so the request has been denied. To subscribe this person " \ "manually, send the following commands to the server:", originator, address, listname); d234 3 a236 2 } else { d239 2 a241 1 return 0; a242 1 } d246 2 a247 2 if (isSubscribed(listname, address, NULL, NULL, FALSE) == TRUE) { d252 2 a253 1 if (fh != NULL) { d260 1 a260 1 fprintf(fh, "In-Reply-To: %s\n", MailStruct->Message_Id); d266 3 a268 2 } else { d271 2 a273 2 return 0; } d278 2 a279 1 if (fh == NULL) { d282 1 a282 1 } d290 1 a290 1 fh = vOpenMailer(envelope, address, owner, NULL); d292 3 a294 2 fh = vOpenMailer(envelope, address, originator, owner, NULL); if (fh != NULL) { d299 1 a299 1 fprintf(fh, "Cc: %s\n", owner); d301 1 a301 1 fprintf(fh, "Cc: %s, %s\n", originator, owner); d304 1 a304 1 fprintf(fh, "In-Reply-To: %s\n", MailStruct->Message_Id); d308 2 a309 1 if (!strcasecmp(address, originator) == TRUE) { d311 7 a317 6 "Per your request, the address \"%s\" has been subscribed to the " \ "\"%s\" mailing list. If you want to unsubscribe later, you can " \ "do so by sending the following command to \"%s-request@@%s\":", address, listname, listname, ListConfig->fqdn); } else { d319 5 a323 5 "Per request from \"%s\", the address \"%s\" has been subscribed to the " \ "\"%s\" mailing list. If you want to unsubscribe later, you can " \ "do so by sending the following command to \"%s-request@@%s\":", originator, address, listname, listname, ListConfig->fqdn); } d330 3 a332 2 } else { d335 1 a335 1 } d340 2 a341 1 if (p != NULL) { d343 2 a344 1 if (fh != NULL) { d350 1 a350 1 fprintf(fh, "In-Reply-To: %s\n", MailStruct->Message_Id); d357 3 a359 2 } else { d363 1 d365 1 a366 2 return 0; } @ 1.5 log @- Added a "Petidomo:" prefix to all subject lines, to distinguish them from regular mail. Rejection mails furthermore have the prefix "BOUNCE :", mails that need approval have the prefix "APROVE :". - When a mail is rejected due to ACL, the mail body will tell you whether the global acl file or the list's local acl file hit. - If a file "lists//header" exists, it contents will be added to the headers of the article posted to the list. Be careful not to have blank lines in there, as this will screw the whole message up. - When generating the index of available mailing lists, the list type will now be typeset in brackets, e.g.: "(public mailing list)". - The index will no longer contain tabs in the mail body. @ text @d3 1 a3 1 $Revision: 1.4 $ d234 1 a234 2 buffer = text_easy_sprintf("lists/%s/list", listname); fh = fopen(buffer, "a"); d236 1 a236 1 syslog(LOG_ERR, "Failed to open file \"%s\" for writing: %m", buffer); d291 1 a291 2 buffer = text_easy_sprintf("lists/%s/introduction", listname); p = loadfile(buffer); @ 1.4 log @Removed the signature code and all code that depended on it. In the new Petidomo, the signature mechanism for server mails will work differently. @ text @d3 1 a3 1 $Revision: 1.3 $ d93 1 a93 1 fprintf(fh, "Subject: Your request \"subscribe %s %s\"\n", address, listname); d119 1 a119 1 fprintf(fh, "Subject: Unauthorized request from \"%s\"\n", originator); d154 1 a154 1 fprintf(fh, "Subject: Your request \"subscribe %s %s\"\n", address, listname); d180 1 a180 1 fprintf(fh, "Subject: Unauthorized request from \"%s\"\n", originator); d215 1 a215 1 fprintf(fh, "Subject: Your request \"subscribe %s %s\"\n", d258 1 a258 1 fprintf(fh, "Subject: Request \"subscribe %s %s\"\n", address, listname); d300 1 a300 1 fprintf(fh, "Subject: Welcome to the \"%s\" mailing list!\n", listname); a317 1 @ 1.3 log @ - Removed all debugging code. Now that Petidomo will be "rewritten" in C++, I need a new paradigm for debugging anyway and the old solution of mine was to messy for my taste anyway. - Petidomo no longer cares under what name it has been started. The different modes of operation will now be distinguished by a mandatory command line parameter. @ text @d3 1 a3 1 $Revision: 1.2 $ a105 1 AppendSignature(fh); a130 1 AppendSignature(fh); a166 1 AppendSignature(fh); a192 1 AppendSignature(fh); a222 1 AppendSignature(fh); a282 1 AppendSignature(fh); @ 1.2 log @ - Added correct GNU GPL copyright statements to the files. - Removed unnecessary include statements. @ text @d2 2 a3 2 $Source$ $Revision$ a40 3 debug((DEBUG_COMMAND, 3, "AddAddress(\"%s\", \"%s\") with default list \"%s\".", param1, param2, defaultlist)); a74 2 debug((DEBUG_COMMAND, 1, "Subscribing \"%s\" to list \"%s\".", address, listname)); a80 3 debug((DEBUG_COMMAND, 5, "The mail didn't contain any admin password. " \ "Checking for authorization...")); a209 2 debug((DEBUG_COMMAND, 2, "\"%s\" is already subscribed to list \"%s\".", address, listname)); a302 2 debug((DEBUG_COMMAND, 5, "Sending \"%s\" as welcome mail to the new " \ "subscriber.", buffer)); @ 1.1 log @Initial revision @ text @d2 17 a18 7 * $Source: /usr/local/libdata/cvs/simons/petidomo/src/petidomo/subscribe.c,v $ * $Revision: 1.10 $ * $Date: 1997/12/09 21:18:47 $ * * Copyright (C) 1996 by CyberSolutions GmbH. * All rights reserved. */ d21 2 a22 2 #include #include d31 1 d72 1 a72 1 d336 1 @ 1.1.1.1 log @Imported Petidomo 2.2 as found on www.petidomo.com. @ text @@