Index: ossp-pkg/petidomo/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/petidomo/Makefile.in,v rcsdiff -q -kk '-r1.23' '-r1.24' -u '/v/ossp/cvs/ossp-pkg/petidomo/Makefile.in,v' 2>/dev/null --- Makefile.in 2001/01/15 18:48:49 1.23 +++ Makefile.in 2001/01/16 11:33:36 1.24 @@ -27,7 +27,7 @@ filter.o handleacl.o help.o hermes.o index.o io.o listserv.o \ mailer.o members.o parsearray.o password.o rfcparse.o \ subscribe.o tool.o unsubscribe.o main.o queue_command.o \ - queue_posting.o approve.o + queue_posting.o approve.o address-db.o LIBS = librfc822/librfc822.a libmpools/libmpools.a liblists/liblists.a libargv/libargv.a \ libconfigfile/libconfigfile.a libtext/libtext.a Index: ossp-pkg/petidomo/address-db.c RCS File: /v/ossp/cvs/ossp-pkg/petidomo/address-db.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/petidomo/address-db.c,v' | diff -u /dev/null - -L'ossp-pkg/petidomo/address-db.c' 2>/dev/null --- ossp-pkg/petidomo/address-db.c +++ - 2024-05-15 15:31:41.416192772 +0200 @@ -0,0 +1,78 @@ +/* + $Source$ + $Revision$ + + Copyright (C) 2000 by Peter Simons + + This file is part of OpenPetidomo. + + OpenPetidomo 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. + + OpenPetidomo 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 +#include "libtext/text.h" +#include "petidomo.h" + +/* + * rc == 0: Address is not on list. + * rc == -1: Error occured while reading the file. + * rc == 1: Address is on list. + */ +int is_address_on_list(const char* file, const char* address) + { + char * list; + char * p; + unsigned int len; + int rc; + + list = loadfile(file); + if (list == NULL) + { + if (errno == ENOENT) + return 0; + else + return -1; + } + + for (len = strlen(address), p = list; *p != '\0'; p = text_find_next_line(p)) + { + if (strncasecmp(p, address, len) == 0 && + (p == list || p[-1] == '\n') && + (isspace((int)p[len]) || p[len] == '\0')) + { + break; + } + } + + rc = ((*p != '\0') ? 1 : 0); + free(list); + return rc; + } + +int add_address(const char* file, const char* address) + { + FILE* fh; + int rc = is_address_on_list(file, address); + if (rc != 0) + return rc; + + fh = fopen(file, "a"); + if (fh == NULL) + { + syslog(LOG_ERR, "Failed to open file \"%s\" for writing: %m", file); + return -1; + } + fprintf(fh, "%s\n", address); + fclose(fh); + return 0; + } Index: ossp-pkg/petidomo/hermes.c RCS File: /v/ossp/cvs/ossp-pkg/petidomo/hermes.c,v rcsdiff -q -kk '-r1.10' '-r1.11' -u '/v/ossp/cvs/ossp-pkg/petidomo/hermes.c,v' 2>/dev/null --- hermes.c 2001/01/16 10:45:21 1.10 +++ hermes.c 2001/01/16 11:33:36 1.11 @@ -199,6 +199,60 @@ } return 0; } + + else if (ListConfig->listtype == LIST_ACKED_ONCE) + { + /* First posting needs an acknowledgement. */ + + if (g_is_approved) + { + int rc = add_address(ListConfig->ack_file, MailStruct->From); + if (rc < 0) + { + syslog(LOG_ERR, "Can't add address to ack file."); + return -1; + } + } + else + { + int rc = is_address_on_list(ListConfig->ack_file, MailStruct->From); + if (rc == 0) + rc = is_address_on_list(ListConfig->ack_file, MailStruct->Envelope); + if (rc < 0) + { + syslog(LOG_ERR, "Can't verify whether address \"%s\" needs to be acknowledged or not.", MailStruct->From); + return -1; + } + else if (rc == 0) + { + char* cookie = queue_posting(MailStruct, listname); + fh = vOpenMailer(owner, MailStruct->Envelope, NULL); + if (fh != NULL) + { + fprintf(fh, "From: petidomo-approve@%s (Petidomo Mailing List Server)\n", ListConfig->fqdn); + fprintf(fh, "To: %s\n", MailStruct->Envelope); + fprintf(fh, "Subject: Petidomo: CONFIRM %s@%s: Your posting to list \"%s\"\n", + listname, ListConfig->fqdn, listname); + fprintf(fh, "Precedence: junk\n"); + fprintf(fh, "Sender: %s\n", owner); + fprintf(fh, "\n"); + fprintf(fh, "Your posting needs to be confirmed. Do this by replying\n"); + fprintf(fh, "to this mail and citing the string\n"); + fprintf(fh, "\n"); + fprintf(fh, " %s\n", cookie); + fprintf(fh, "\n"); + fprintf(fh, "in your reply. You won't have to do that again.\n"); + CloseMailer(fh); + } + else + { + syslog(LOG_ERR, "Failed to send email to \"%s\" concerning this request.", owner); + return -1; + } + return 0; + } + } + } } /* Copy the desired headers from the original mail to our own Index: ossp-pkg/petidomo/petidomo.h RCS File: /v/ossp/cvs/ossp-pkg/petidomo/petidomo.h,v rcsdiff -q -kk '-r1.14' '-r1.15' -u '/v/ossp/cvs/ossp-pkg/petidomo/petidomo.h,v' 2>/dev/null --- petidomo.h 2001/01/16 10:49:08 1.14 +++ petidomo.h 2001/01/16 11:33:36 1.15 @@ -251,4 +251,9 @@ char* queue_command(const struct Mail* mail, const char* command); +/********** address_db.c **********/ + +int is_address_on_list(const char* file, const char* address); +int add_address(const char* file, const char* address); + #endif /* !defined(__PETIDOMO_H__) */