Index: ossp-pkg/petidomo/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/petidomo/Makefile.in,v rcsdiff -q -kk '-r1.22' '-r1.23' -u '/v/ossp/cvs/ossp-pkg/petidomo/Makefile.in,v' 2>/dev/null --- Makefile.in 2001/01/15 16:29:11 1.22 +++ Makefile.in 2001/01/15 18:48:49 1.23 @@ -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 + queue_posting.o approve.o LIBS = librfc822/librfc822.a libmpools/libmpools.a liblists/liblists.a libargv/libargv.a \ libconfigfile/libconfigfile.a libtext/libtext.a Index: ossp-pkg/petidomo/approve.c RCS File: /v/ossp/cvs/ossp-pkg/petidomo/approve.c,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/petidomo/approve.c,v' | diff -u /dev/null - -L'ossp-pkg/petidomo/approve.c' 2>/dev/null --- ossp-pkg/petidomo/approve.c +++ - 2024-05-14 08:06:39.667973296 +0200 @@ -0,0 +1,83 @@ +/* + $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 "petidomo.h" +#include +#include +#include + +int approve_main(char* mail) + { + const struct PD_Config* MasterConfig = getMasterConfig(); + static const char* cookie_regex = "[0-9a-f]{32}"; + regex_t preg; + regmatch_t match[3]; + int offset; + + if (chdir(MasterConfig->ack_queue_dir) == -1) + { + syslog(LOG_ERR, "Can't change directory to \"%s\": %m", MasterConfig->ack_queue_dir); + exit(1); + } + + if (regcomp(&preg, cookie_regex, REG_EXTENDED | REG_ICASE) != 0) + { + syslog(LOG_CRIT, "Can't compile my internal regular expressions. This is serious!"); + exit(1); + } + + offset = 0; + while(regexec(&preg, mail + offset, sizeof(match)/sizeof(regmatch_t), match, 0) == 0) + { + struct stat sb; + char buffer[33]; + char* src; + char* dst = buffer; + unsigned int i; + + /* Copy found string into buffer. */ + + src = mail + offset + match[0].rm_so; + for (i = 0; i < 32; ++i) + *dst++ = *src++; + *dst = '\0'; + + /* Correct offset for the next match. */ + + offset += match[0].rm_so + 1; + + /* Do we have a hit here? If, execute the file and remove it. + Then go on. */ + + if (stat(buffer, &sb) == 0) + { + char cmd[128]; + + sprintf(cmd, "/bin/sh %s && /bin/rm -f %s", buffer, buffer); + if (((signed char)system(cmd)) == -1) + { + syslog(LOG_ERR, "system() failed: %m", MasterConfig->ack_queue_dir); + exit(1); + } + } + + } + + return 0; + } Index: ossp-pkg/petidomo/main.c RCS File: /v/ossp/cvs/ossp-pkg/petidomo/main.c,v rcsdiff -q -kk '-r1.7' '-r1.8' -u '/v/ossp/cvs/ossp-pkg/petidomo/main.c,v' 2>/dev/null --- main.c 2001/01/15 17:06:48 1.7 +++ main.c 2001/01/15 18:48:49 1.8 @@ -91,6 +91,10 @@ exit(1); } } + else if (strcasecmp("approve", mode) == 0) + { + approve_main(incoming_mail); + } else { syslog(LOG_ERR, "I don't know anything about mode \"%s\".", mode); Index: ossp-pkg/petidomo/petidomo.h RCS File: /v/ossp/cvs/ossp-pkg/petidomo/petidomo.h,v rcsdiff -q -kk '-r1.12' '-r1.13' -u '/v/ossp/cvs/ossp-pkg/petidomo/petidomo.h,v' 2>/dev/null --- petidomo.h 2001/01/15 17:06:48 1.12 +++ petidomo.h 2001/01/15 18:48:49 1.13 @@ -191,6 +191,10 @@ int listserv_main(char *incoming_mail, char *default_list); +/********** approve.c **********/ + +int approve_main(char *incoming_mail); + /********** mailer.c **********/ FILE *OpenMailer(const char *envelope, const char *recipients[]);