head 1.7; access; symbols PETIDOMO_4_0b6:1.7 PETIDOMO_4_0b5:1.7 PETIDOMO_4_0b4:1.7 PETIDOMO_4_0b3:1.7 BEFORETHL:1.7 petidomo-2-2:1.1.1.1 petidomo:1.1.1; locks; strict; comment @ * @; 1.7 date 2001.01.18.20.30.50; author rse; state Exp; branches; next 1.6; 1.6 date 2001.01.16.10.49.08; 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 2001.01.06.10.11.58; 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.7 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 @/* $Source: /e/ossp/cvs/ossp-pkg/petidomo/handleacl.c,v $ $Revision: 1.6 $ 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 "petidomo.h" /* Returncodes have the following meaning: '-1' == Error, '0' == Proceed, '1' == Mail has been taken care of. */ int handleACL(struct Mail * MailStruct, const char * listname, int operation, char * parameter) { const struct PD_Config * MasterConfig; const struct List_Config * ListConfig = NULL; FILE * fh; char * buffer; char envelope[1024]; char owner[1024]; int rc; assert(MailStruct != NULL); MasterConfig = getMasterConfig(); if (listname != NULL) { ListConfig = getListConfig(listname); sprintf(envelope, "%s-owner@@%s", listname, ListConfig->fqdn); sprintf(owner, "%s-owner@@%s", listname, ListConfig->fqdn); } else { sprintf(envelope, "petidomo-manager@@%s", MasterConfig->fqdn); sprintf(owner, "petidomo-manager@@%s", MasterConfig->fqdn); } /* Check for authorization. */ switch(operation) { case ACL_NONE: break; case ACL_PASS: break; case ACL_APPROVE: MailStruct->Approve = MasterConfig->master_password; break; case ACL_DROP: return 1; case ACL_REJECTWITH: assert(parameter != NULL); case ACL_REJECT: fh = vOpenMailer(envelope, owner, (MailStruct->Reply_To) ? (MailStruct->Reply_To) : (MailStruct->From), NULL); if (fh == NULL) { syslog(LOG_ERR, "Failed to open mailer for redirection."); return -1; } fprintf(fh, "From: %s (Petidomo Mailing List Server)\n", owner); fprintf(fh, "To: %s\n", (MailStruct->Reply_To) ? (MailStruct->Reply_To) : (MailStruct->From)); fprintf(fh, "Cc: %s\n", owner); if (listname != NULL) fprintf(fh, "Subject: Petidomo: BOUNCE %s@@%s: Rejected due to ACL\n", listname, ListConfig->fqdn); else fprintf(fh, "Subject: Petidomo: BOUNCE: Rejected due to ACL\n"); fprintf(fh, "Precedence: junk\n"); fprintf(fh, "Sender: %s\n", owner); fprintf(fh, "\n"); if (operation == ACL_REJECTWITH && (buffer = loadfile(parameter)) != NULL) { fprintf(fh, "%s\n", buffer); free(buffer); } else { if (listname != NULL) fprintf(fh, "The following posting was rejected by Petidomo, due to\n" "the access control list (ACL) rules for list `%s@@%s'.\n", listname, ListConfig->fqdn); else fprintf(fh, "The following posting was rejected by Petidomo, due to\n" \ "the global access control list (ACL) rules.\n\n"); } fprintf(fh, "%s\n", MailStruct->Header); fprintf(fh, "%s", MailStruct->Body); CloseMailer(fh); return 1; case ACL_REDIRECT: assert(parameter != NULL); syslog(LOG_INFO, "Mail is redirected to \"%s\" due to access control.", parameter); fh = vOpenMailer(MailStruct->Envelope, parameter, NULL); if (fh == NULL) { syslog(LOG_ERR, "Failed to open mailer for redirection."); return -1; } fprintf(fh, "%s\n", MailStruct->Header); fprintf(fh, "%s", MailStruct->Body); CloseMailer(fh); return 1; case ACL_FORWARD: assert(parameter != NULL); syslog(LOG_INFO, "Mail is forwarded to \"%s\" due to access control.", parameter); fh = vOpenMailer(envelope, parameter, NULL); if (fh == NULL) { syslog(LOG_ERR, "Failed to open mailer for redirection."); return -1; } fprintf(fh, "From: %s (Petidomo Mailing List Server)\n", owner); fprintf(fh, "To: %s\n", parameter); if (listname != NULL) fprintf(fh, "Subject: Petidomo: BOUNCE %s@@%s: Forwarded due to ACL\n", listname, ListConfig->fqdn); else fprintf(fh, "Subject: Petidomo: BOUNCE: Forwarded due to ACL\n"); fprintf(fh, "Precedence: junk\n"); fprintf(fh, "Sender: %s\n", owner); fprintf(fh, "\n"); if (listname != NULL) fprintf(fh, "The following posting was forwarded to you by Petidomo, due to\n" "the access control list (ACL) rules for list `%s@@%s'.\n", listname, ListConfig->fqdn); else fprintf(fh, "The following posting was forwarded to you by Petidomo, due to\n" \ "the global access control list (ACL) rules.\n"); fprintf(fh, "If you approve this posting, pipe this mail through `petidomo-approve'.\n" "If you do not approve this posting, just do nothing.\n\n"); fprintf(fh, "%s\n", MailStruct->Header); fprintf(fh, "%s", MailStruct->Body); CloseMailer(fh); return 1; case ACL_FILTER: assert(parameter != NULL); syslog(LOG_INFO, "Mail is filtered through \"%s\" due to access control.", parameter); rc = MailFilter(MailStruct, parameter); if (rc != 0) { syslog(LOG_ERR, "Mail filter \"%s\" returned error code %d.", parameter, rc); return -1; } break; default: syslog(LOG_CRIT, "Internal error: Unexpected return code %d from checkACL()", operation); return -1; } if (parameter != NULL) free(parameter); return 0; } @ 1.6 log @Added new action keyword to the Access Control Language: approve. This keyword will -- unlike to "pass" -- not only pass the mail, but will also make sure that the mail passes all other authorization controls. This means, the mail will be treated as if the Petidomo master password had been given in the header. @ text @d2 2 a3 2 $Source: /d1/e/petidomo/cvs/petidomo/source/handleacl.c,v $ $Revision: 1.5 $ 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.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 $ d56 3 @ 1.4 log @The local List_Config variable was potentially used uninitialized. Fixed that. @ text @d3 1 a3 1 $Revision: 1.3 $ d73 1 a73 1 fprintf(fh, "Subject: Your posting to list \"%s\" was rejected\n", listname); d75 1 a75 1 fprintf(fh, "Subject: Your petidomo request was rejected\n"); d83 4 d88 3 a90 1 fprintf(fh, "Your article was rejected by the access control rules:\n\n"); d118 1 a118 2 fprintf(fh, "Subject: Disallowed posting from \"%s\" to list \"%s\"\n", MailStruct->From, listname); d120 1 a120 2 fprintf(fh, "Subject: Disallowed petidomo request from \"%s\"\n", MailStruct->From); d124 8 a131 2 fprintf(fh, "The following article was forwarded to you, due to the\n" \ "access control rules:\n\n"); @ 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 $ d30 1 a30 1 const struct List_Config * ListConfig; @ 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_ACL, 4, "No ACL statement matched the mail.")); a55 1 debug((DEBUG_ACL, 4, "Mail passed access control.")); a57 1 syslog(LOG_INFO, "Mail is dropped due to access control."); a61 1 syslog(LOG_INFO, "Mail is rejected due to access control."); a130 1 debug((DEBUG_ACL, 3, "Mail filter \"%s\" returned %d.", parameter, rc)); a142 10 #ifdef DEBUG if (listname != NULL) { debug((DEBUG_ACL, 3, "\"%s\" is authorized to post to \"%s\".", MailStruct->From, listname)); } else { debug((DEBUG_ACL, 3, "Request from \"%s\" is okay, says ACL", MailStruct->From)); } #endif @ 1.1 log @Initial revision @ text @d2 17 a18 7 * $Source: /usr/local/libdata/cvs/simons/petidomo/src/petidomo/handleacl.c,v $ * $Revision: 1.7 $ * $Date: 1997/10/19 13:52:51 $ * * Copyright (C) 1996 by CyberSolutions GmbH. * All rights reserved. */ d21 1 a21 2 #include @ 1.1.1.1 log @Imported Petidomo 2.2 as found on www.petidomo.com. @ text @@