Implemented spooling mechanism for requests and postings that need an

acknowledgement to be processed. The code is there, it just isn't
called yet.
This commit is contained in:
Peter Simons 2001-01-15 16:29:11 +00:00
parent 40c7ea336b
commit f5a3d6dbe8
5 changed files with 127 additions and 14 deletions

View File

@ -9,14 +9,6 @@ libexecdir = @libexecdir@/petidomo
datadir = @datadir@/petidomo
sysconfdir = @sysconfdir@
localstatedir = @localstatedir@/petidomo
# delete me
#sharedstatedir = @sharedstatedir@
#sbindir = @sbindir@
#libdir = @libdir@/petidomo
#infodir = @infodir@
#mandir = @mandir@
#includedir = @includedir@
# delete me
CC = @CC@
AR = ar
@ -27,13 +19,15 @@ INSTALL = ../etc/install-sh -c
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)\" -DLIBEXECDIR=\"$(libexecdir)\" \
-DDATADIR=\"$(datadir)\" -DLOCALSTATEDIR=\"$(localstatedir)\"
-DDATADIR=\"$(datadir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" \
-DBINDIR=\"$(bindir)\"
LDFLAGS = @LDFLAGS@
OBJS = acl.o archive.o authen.o config.o generate_cookie.o \
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
subscribe.o tool.o unsubscribe.o main.o queue_command.o \
queue_posting.o
LIBS = librfc822/librfc822.a libmpools/libmpools.a liblists/liblists.a libargv/libargv.a \
libconfigfile/libconfigfile.a libtext/libtext.a
@ -67,7 +61,8 @@ $(LIBS):
install: petidomo
@if [ ! -d $(bindir) ]; then $(INSTALL) -d $(bindir); fi
@if [ ! -d $(sysconfdir) ]; then $(INSTALL) -d $(sysconfdir); fi
@if [ ! -d $(localstatedir) ]; then $(INSTALL) -d $(localstatedir); fi
@if [ ! -d $(localstatedir)/lists ]; then $(INSTALL) -d $(localstatedir)/lists; fi
@if [ ! -d $(localstatedir)/ack_queue ]; then $(INSTALL) -d $(localstatedir)/ack_queue; fi
@if [ ! -d $(datadir) ]; then $(INSTALL) -d $(datadir); fi
@if [ ! -d $(libexecdir) ]; then $(INSTALL) -d $(libexecdir); fi
$(INSTALL) -s -m 555 petidomo $(bindir)

View File

@ -40,7 +40,8 @@ static char* mta_options = "-i -f%s";
static char* help_file = DATADIR "/petidomo.conf";
static char* acl_file = SYSCONFDIR "/petidomo.acl";
static char* index_file = LOCALSTATEDIR "/index";
static char* list_dir = LOCALSTATEDIR;
static char* list_dir = LOCALSTATEDIR "/lists";
static char* ack_queue_dir = LOCALSTATEDIR "/ack_queue";
int InitPetidomo(const char* masterconfig_path)
{
@ -58,6 +59,7 @@ int InitPetidomo(const char* masterconfig_path)
{ "Acl_File", CF_STRING, &acl_file },
{ "Index_File", CF_STRING, &index_file },
{ "List_Directory", CF_STRING, &list_dir },
{ "Ack_Queue_Directory", CF_STRING, &ack_queue_dir },
{ NULL, 0, NULL}
};
@ -116,6 +118,7 @@ int InitPetidomo(const char* masterconfig_path)
MasterConfig->acl_file = acl_file;
MasterConfig->index_file = index_file;
MasterConfig->list_dir = list_dir;
MasterConfig->ack_queue_dir = ack_queue_dir;
return 0;
}

View File

@ -57,6 +57,7 @@ struct PD_Config
char * mta;
char * mta_options;
char * list_dir;
char * ack_queue_dir;
char * help_file;
char * acl_file;
char * index_file;
@ -176,7 +177,7 @@ int savefile(const char *filename, const char *buffer);
/********** listserv.c **********/
int listserv_main(char *incoming_mail, char *default_list);
int listserv_main(char *incoming_mail, char *default_list, char);
/********** mailer.c **********/
@ -206,7 +207,7 @@ int DeleteAddress(struct Mail *MailStruct, const char *param1, const char *param
/********** hermes.c **********/
int hermes_main(char *incoming_mail, const char *listname);
int hermes_main(char *incoming_mail, const char *listname, char);
/********** subscribe.c **********/
@ -225,4 +226,12 @@ extern struct Parse ParseArray[];
char* generate_cookie(const char*);
/********** queue_posting.c **********/
void queue_posting(const struct Mail* mail, const char* listname);
/********** queue_command.c **********/
void queue_command(const struct Mail* mail, const char* command);
#endif /* !defined(__PETIDOMO_H__) */

57
queue_command.c Normal file
View File

@ -0,0 +1,57 @@
/*
$Source$
$Revision$
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 <sys/types.h>
#include <sys/stat.h>
#include "libtext/text.h"
#include "petidomo.h"
void queue_command(const struct Mail* mail, const char* command)
{
const struct PD_Config * MasterConfig = getMasterConfig();
char* buffer;
char* cookie;
FILE* fh;
cookie = generate_cookie(mail->Header);
buffer = text_easy_sprintf("%s/%s", MasterConfig->ack_queue_dir, cookie);
fh = fopen(buffer, "w");
if (fh == NULL)
{
syslog(LOG_ERR, "Opening ack spool file \"%s\" failed: %m", buffer);
exit(1);
}
fprintf(fh, "#! /bin/sh\n");
fprintf(fh, "\n");
fprintf(fh, BINDIR "/petidomo --mode=listserv --approved <<[end-of-mail-marker]\n");
fprintf(fh, "Sender: %s\n", mail->Envelope);
fprintf(fh, "From: %s\n", mail->From);
if (mail->Reply_To)
fprintf(fh, "Reply-To: %s\n", mail->Reply_To);
if (mail->Message_Id)
fprintf(fh, "Message-Id: %s\n", mail->Message_Id);
if (mail->Approve)
fprintf(fh, "Approve: %s\n", mail->Approve);
fprintf(fh, "\n");
fprintf(fh, "%s\n", command);
fprintf(fh, "[end-of-mail-marker]\n");
fclose(fh);
chmod(buffer, 0755);
free(buffer);
}

49
queue_posting.c Normal file
View File

@ -0,0 +1,49 @@
/*
$Source$
$Revision$
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 <sys/types.h>
#include <sys/stat.h>
#include "libtext/text.h"
#include "petidomo.h"
void queue_posting(const struct Mail* mail, const char* listname)
{
const struct PD_Config * MasterConfig = getMasterConfig();
char* buffer;
char* cookie;
FILE* fh;
cookie = generate_cookie(mail->Header);
buffer = text_easy_sprintf("%s/%s", MasterConfig->ack_queue_dir, cookie);
fh = fopen(buffer, "w");
if (fh == NULL)
{
syslog(LOG_ERR, "Opening ack spool file \"%s\" failed: %m", buffer);
exit(1);
}
fprintf(fh, "#! /bin/sh\n");
fprintf(fh, "\n");
fprintf(fh, BINDIR "/petidomo --mode=deliver --listname=%s --approved <<[end-of-mail-marker]\n", listname);
fprintf(fh, "%s\n", mail->Header);
fprintf(fh, "%s", mail->Body);
fprintf(fh, "[end-of-mail-marker]\n");
fclose(fh);
chmod(buffer, 0755);
free(buffer);
}