head 1.9; access; symbols PETIDOMO_4_0b6:1.9 PETIDOMO_4_0b5:1.9 PETIDOMO_4_0b4:1.9 PETIDOMO_4_0b3:1.9 BEFORETHL:1.8 petidomo-2-2:1.1.1.1 petidomo:1.1.1; locks; strict; comment @ * @; 1.9 date 2004.02.02.19.50.25; author thl; state Exp; branches; next 1.8; 1.8 date 2001.02.12.20.44.13; author simons; state Exp; branches; next 1.7; 1.7 date 2001.01.20.14.29.28; author simons; state Exp; branches; next 1.6; 1.6 date 2001.01.18.20.30.50; author rse; state Exp; branches; next 1.5; 1.5 date 2001.01.15.17.06.48; author simons; state Exp; branches; next 1.4; 1.4 date 2001.01.15.16.27.52; 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.23; author simons; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2000.12.13.13.19.23; author simons; state Exp; branches; next ; desc @@ 1.9 log @both peti and rse did overlapping work based on (untagged) 4.0b1; peti committed to the CVS first (no version created ever); this is an attempt to manually merge rse's acl pre/post changes in (claim themselfs to lead to 4.0b2 @ text @/* $Source: /e/ossp/cvs/ossp-pkg/petidomo/listserv.c,v $ $Revision: 1.8 $ 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" char * g_currLine; /* pointer to the line currently parsed */ void listserv_main(char * incoming_mail, char * default_list) { const struct List_Config * ListConfig; struct Mail * MailStruct; char * nextLine; char * parameter; char param1[512], param2[512]; char keyword[32]; int j, i, junklines, rc, found, operator; /* Initialize internals. */ if (default_list != NULL) ListConfig = getListConfig(default_list); else ListConfig = NULL; /* Parse the incoming mail. */ rc = ParseMail(&MailStruct, incoming_mail, (ListConfig != NULL) ? ListConfig->fqdn : NULL); if (rc != 0) { syslog(LOG_ERR, "Parsing the incoming mail failed."); exit(rc); } /* Do sanity checks. */ if (MailStruct->Envelope == NULL) { syslog(LOG_NOTICE, "Received mail without a valid envelope."); return; } if (MailStruct->From == NULL) { syslog(LOG_NOTICE, "Received mail without From: line."); return; } /* Do access control. */ if (checkACL(MailStruct, NULL, &operator, ¶meter, ACL_PRE) != 0) { syslog(LOG_ERR, "checkACL() failed with an error."); exit(1); } rc = handleACL(MailStruct, NULL, operator, parameter); switch(rc) { case -1: syslog(LOG_ERR, "handleACL() failed with an error."); exit(1); case 0: break; case 1: return; } if (checkACL(MailStruct, NULL, &operator, ¶meter, ACL_POST) != 0) { syslog(LOG_ERR, "checkACL() failed with an error."); exit(1); } rc = handleACL(MailStruct, NULL, operator, parameter); switch(rc) { case -1: syslog(LOG_ERR, "handleACL() failed with an error."); exit(1); case 0: break; case 1: return; } /* Parse the body and call the apropriate routines for each command. */ g_currLine = MailStruct->Body; if (*g_currLine == '\0') { SendHelp(MailStruct, NULL, NULL, default_list); return; } for (nextLine = text_find_next_line(g_currLine), junklines = 0, found = 0; *g_currLine != '\0' && junklines <= 7; g_currLine = nextLine, nextLine = text_find_next_line(g_currLine)) { /* remove trailing \n */ if (nextLine[-1] == '\n') nextLine[-1] = '\0'; /* Skip comments, signature and empty lines. */ if (*g_currLine == '\0' || *g_currLine == '#') continue; if (!strcmp(g_currLine, "-- ")) break; /* Log contents of current line. */ syslog(LOG_INFO, "%s: %s", ((MailStruct->Reply_To) ? MailStruct->Reply_To : MailStruct->From), g_currLine); /* Check whether we have a routine for that command. */ for (j = 0; !isspace((int)g_currLine[j]) && j < (sizeof(keyword)-1); j++) keyword[j] = g_currLine[j]; keyword[j] = '\0'; for (i = 0; (&(ParseArray[i]))->keyword != NULL; i++) { if (strcasecmp(keyword, (&(ParseArray[i]))->keyword) == 0) { /* hit */ rc = sscanf(g_currLine, "%*s%511s%511s", param1, param2); rc = ((&(ParseArray[i]))->handleCommand)(MailStruct, ((rc >= 1) ? param1 : NULL), ((rc == 2) ? param2 : NULL), default_list); if (rc != 0) { syslog(LOG_ERR, "Error occured while handling command."); exit(1); } found++; break; } } if ((&(ParseArray[i]))->keyword == NULL) { /* No valid command. */ junklines++; } } if (junklines > 7) syslog(LOG_INFO, "Too many junk lines, ignoring rest of the mail."); if (found == 0) { syslog(LOG_INFO, "No valid command found, sending help file back to \"%s\".", ((MailStruct->Reply_To) ? MailStruct->Reply_To : MailStruct->From)); Indecipherable(MailStruct, default_list); } } @ 1.8 log @Changed loglevel of sereval syslog() calls from NOTICE to INFO, because they do not really require the administrator's attention but are informational. @ text @d3 1 a3 1 $Revision: 1.7 $ d67 15 a81 1 if (checkACL(MailStruct, NULL, &operator, ¶meter) != 0) { @ 1.7 log @Since we never tested the return codes of *_main() anyway, don't pretend we do: Made listsern_main(), hermes_main() and approve_main() officially return "void". @ text @d3 1 a3 1 $Revision: 1.6 $ a86 1 syslog(LOG_NOTICE, "Received mail with empty body."); @ 1.6 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.5 $ d28 1 a28 2 int listserv_main(char * incoming_mail, char * default_list) d58 1 a58 1 return 0; d62 1 a62 1 return 0; d79 1 a79 1 return 0; d89 1 a89 1 return 0; a148 2 return 0; @ 1.5 log @Had to make is_approved a global variable, because it is actually tested in subroutines of listserv_main() and hermes_main(), like subscribe(), which's parameter list I don't want to change. @ text @d2 2 a3 2 $Source: /d1/e/petidomo/cvs/petidomo/source/listserv.c,v $ $Revision: 1.4 $ 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.4 log @Added --approved command line parameter, which is treated as a boolean. Whether it is set or not will be passed through to listserv_main() and to hermes_main(). The parameter will be used by the spooling mechanism. @ text @d3 1 a3 1 $Revision: 1.3 $ d29 1 a29 1 listserv_main(char * incoming_mail, char * default_list, char is_approved) @ 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 $ d29 1 a29 1 listserv_main(char * incoming_mail, char * default_list) @ 1.2 log @ - Added correct GNU GPL copyright statements to the files. - Removed unnecessary include statements. @ text @d2 2 a3 2 $Source$ $Revision$ a53 1 debug((DEBUG_LISTSERV, 3, "Parsed incoming mail successfully.")); d105 1 a105 2 if (!strcmp(g_currLine, "-- ")) { debug((DEBUG_LISTSERV, 6, "Ignoring trailing signature.")); a106 1 } a117 1 debug((DEBUG_LISTSERV, 5, "command is \"%s\".", keyword)); a119 1 debug((DEBUG_LISTSERV, 4, "Recognized command \"%s\".", keyword)); a137 1 debug((DEBUG_LISTSERV, 4, "Unrecognized command \"%s\".", keyword)); @ 1.1 log @Initial revision @ text @d2 17 a18 7 * $Source: /usr/local/libdata/cvs/simons/petidomo/src/petidomo/listserv.c,v $ * $Revision: 1.29 $ * $Date: 1998/08/14 22:54:39 $ * * Copyright (C) 1996 by CyberSolutions GmbH. * All rights reserved. */ d23 2 a24 2 #include #include d58 4 @ 1.1.1.1 log @Imported Petidomo 2.2 as found on www.petidomo.com. @ text @@