Check-in Number:
|
281 | |
Date: |
2001-Jan-15 19:48:49 (local)
2001-Jan-15 18:48:49 (UTC) |
User: | simons |
Branch: | |
Comment: |
Implemented the approve mode, where incoming mails are searched for
confirmation cookies and the apropriate queue entries will be
executed. |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/petidomo/Makefile.in 1.22 -> 1.23
--- 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
|
|
ossp-pkg/petidomo/approve.c -> 1.1
*** /dev/null Sat Nov 23 01:39:28 2024
--- - Sat Nov 23 01:39:44 2024
***************
*** 0 ****
--- 1,83 ----
+ /*
+ $Source: /v/ossp/cvs/ossp-pkg/petidomo/approve.c,v $
+ $Revision: 1.1 $
+
+ Copyright (C) 2000 by Peter Simons <simons@computer.org>.
+
+ 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 <regex.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+
+ 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;
+ }
|
|
ossp-pkg/petidomo/main.c 1.7 -> 1.8
--- main.c 2001/01/15 17:06:48 1.7
+++ main.c 2001/01/15 18:48:49 1.8
@@ -1,6 +1,6 @@
/*
$Source: /v/ossp/cvs/ossp-pkg/petidomo/main.c,v $
- $Revision: 1.7 $
+ $Revision: 1.8 $
Copyright (C) 2000 by CyberSolutions GmbH, Germany.
@@ -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);
|
|
ossp-pkg/petidomo/petidomo.h 1.12 -> 1.13
--- petidomo.h 2001/01/15 17:06:48 1.12
+++ petidomo.h 2001/01/15 18:48:49 1.13
@@ -1,6 +1,6 @@
/*
$Source: /v/ossp/cvs/ossp-pkg/petidomo/petidomo.h,v $
- $Revision: 1.12 $
+ $Revision: 1.13 $
Copyright (C) 2000 by CyberSolutions GmbH, Germany.
@@ -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[]);
|
|