2001-01-15 16:29:11 +00:00
|
|
|
/*
|
|
|
|
|
$Source$
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2000 by Peter Simons <simons@computer.org>.
|
|
|
|
|
|
2001-01-18 20:30:50 +00:00
|
|
|
This file is part of Petidomo.
|
2001-01-15 16:29:11 +00:00
|
|
|
|
2001-01-18 20:30:50 +00:00
|
|
|
Petidomo is free software; you can redistribute it and/or modify
|
2001-01-15 16:29:11 +00:00
|
|
|
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.
|
|
|
|
|
|
2001-01-18 20:30:50 +00:00
|
|
|
Petidomo is distributed in the hope that it will be useful, but
|
2001-01-15 16:29:11 +00:00
|
|
|
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"
|
|
|
|
|
|
2001-01-15 16:58:58 +00:00
|
|
|
char* queue_command(const struct Mail* mail, const char* command)
|
2001-01-15 16:29:11 +00:00
|
|
|
{
|
|
|
|
|
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");
|
2001-01-19 14:53:23 +00:00
|
|
|
fprintf(fh, "%s --mode=listserv --approved <<[end-of-%s-marker]\n", who_am_i, cookie);
|
2001-01-15 16:29:11 +00:00
|
|
|
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);
|
2001-01-19 14:53:23 +00:00
|
|
|
fprintf(fh, "[end-of-%s-marker]\n", cookie);
|
2001-01-15 16:29:11 +00:00
|
|
|
fclose(fh);
|
|
|
|
|
chmod(buffer, 0755);
|
|
|
|
|
free(buffer);
|
2001-01-15 16:58:58 +00:00
|
|
|
return cookie;
|
2001-01-15 16:29:11 +00:00
|
|
|
}
|