- Added correct GNU GPL copyright statements to the files.

- Removed unnecessary include statements.
This commit is contained in:
Peter Simons 2000-12-13 15:35:14 +00:00
parent bda7a0d438
commit 5ad045c241
24 changed files with 584 additions and 324 deletions

28
acl.y
View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1997 by CyberSolutions GmbH.
* All rights reserved. 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.
*/
%{ %{
/* Definitions we need in the parser. */ /* Definitions we need in the parser. */
@ -16,8 +26,8 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <errno.h> #include <errno.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
static int yyerror(char *); static int yyerror(char *);
static int yylex(void); static int yylex(void);

View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1997 by CyberSolutions GmbH.
* All rights reserved. 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 <ctype.h> #include <ctype.h>

View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -14,8 +24,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
int int
ArchiveMail(const struct Mail * MailStruct, const char * listname) ArchiveMail(const struct Mail * MailStruct, const char * listname)

View File

@ -1,19 +1,27 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996,97 CyberSolutions GmbH.
* All rights reserved. This file is part of OpenPetidomo.
*
* - Set debug-level for various modules from the command line. 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 <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <debug.h> #include "debug.h"
#include <argv.h> #include "libargv/argv.h"
#ifdef DEBUG #ifdef DEBUG
@ -43,6 +51,10 @@ extern const char * const ModuleTable[];
REQUIRES: extern const char * const ModuleTable[] REQUIRES: extern const char * const ModuleTable[]
*/ */
/* let's define ModuleTable here */
MODULE_TABLE
int int
argvSetDebugLevel(argv_array_t debug /* parameter array as returned by the argv routines */ argvSetDebugLevel(argv_array_t debug /* parameter array as returned by the argv routines */
) )
@ -51,7 +63,7 @@ argvSetDebugLevel(argv_array_t debug /* parameter array as returned by the argv
char * DebugLevel; char * DebugLevel;
unsigned int count, i; unsigned int count, i;
for (count = 0; count < debug.aa_entryn; count++) { for (count = 0; count < debug.aa_entry_n; count++) {
ModuleName = strtok(ARGV_ARRAY_ENTRY(debug, char *, count), ",/:"); ModuleName = strtok(ARGV_ARRAY_ENTRY(debug, char *, count), ",/:");
DebugLevel = strtok(NULL, ",/:"); DebugLevel = strtok(NULL, ",/:");
if (ModuleName == NULL || DebugLevel == NULL if (ModuleName == NULL || DebugLevel == NULL

View File

@ -1,17 +1,27 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
int int
FindBodyPassword(struct Mail * MailStruct) FindBodyPassword(struct Mail * MailStruct)

View File

@ -1,20 +1,30 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <pwd.h> #include <pwd.h>
#include <lists.h> #include "liblists/lists.h"
#include <configfile.h> #include "libconfigfile/configfile.h"
#include <petidomo.h> #include "petidomo.h"
static struct PD_Config * MasterConfig; static struct PD_Config * MasterConfig;
List ListConfigs; List ListConfigs;
@ -25,7 +35,7 @@ List ListConfigs;
static char * fqdn = NULL; static char * fqdn = NULL;
static char * master_password = NULL; static char * master_password = NULL;
static char * mta = "/usr/sbin/sendmail"; static char * mta = "/usr/sbin/sendmail";
static char * mta_options = "-f%s"; static char * mta_options = "-i -f%s";
static bool detach = FALSE; static bool detach = FALSE;
static bool show_stats = TRUE; static bool show_stats = TRUE;

28
exit.c
View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -13,8 +23,8 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
static char * s_crash_filename = NULL; static char * s_crash_filename = NULL;

View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdlib.h> #include <stdlib.h>
#include <sys/wait.h> #include <sys/wait.h>
@ -14,7 +24,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <petidomo.h> #include "petidomo.h"
#define READ 0 #define READ 0
#define WRITE 1 #define WRITE 1

View File

@ -1,15 +1,24 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdlib.h> #include <stdlib.h>
#include "petidomo.h"
#include <petidomo.h>
/* Returncodes have the following meaning: '-1' == Error, '0' == /* Returncodes have the following meaning: '-1' == Error, '0' ==
Proceed, '1' == Mail has been taken care of. */ Proceed, '1' == Mail has been taken care of. */

28
help.c
View File

@ -1,14 +1,24 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
*
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved.
*/
#include <text.h> Copyright (C) 2000 by CyberSolutions GmbH, Germany.
#include <petidomo.h>
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 "libtext/text.h"
#include "petidomo.h"
int int
SendHelp(struct Mail * MailStruct, SendHelp(struct Mail * MailStruct,

View File

@ -1,18 +1,28 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
int int
hermes_main(char * incoming_mail, const char * listname) hermes_main(char * incoming_mail, const char * listname)
@ -51,6 +61,10 @@ hermes_main(char * incoming_mail, const char * listname)
/* Do sanity checks. */ /* Do sanity checks. */
if (MailStruct->Envelope == NULL) {
syslog(LOG_NOTICE, "Received mail without a valid envelope.");
return 0;
}
if (MailStruct->From == NULL) { if (MailStruct->From == NULL) {
syslog(LOG_NOTICE, "Received mail without From: line."); syslog(LOG_NOTICE, "Received mail without From: line.");
return 0; return 0;

28
index.c
View File

@ -1,19 +1,29 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
int int
GenIndex(struct Mail * MailStruct, GenIndex(struct Mail * MailStruct,

26
io.c
View File

@ -1,17 +1,27 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1997 by CyberSolutions GmbH.
* All rights reserved. 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 <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <petidomo.h> #include "petidomo.h"
char * char *
LoadFromDescriptor(int fd) LoadFromDescriptor(int fd)

View File

@ -1,17 +1,27 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
char * g_currLine; /* pointer to the line currently parsed */ char * g_currLine; /* pointer to the line currently parsed */
@ -45,6 +55,10 @@ listserv_main(char * incoming_mail, char * default_list)
/* Do sanity checks. */ /* Do sanity checks. */
if (MailStruct->Envelope == NULL) {
syslog(LOG_NOTICE, "Received mail without a valid envelope.");
return 0;
}
if (MailStruct->From == NULL) { if (MailStruct->From == NULL) {
syslog(LOG_NOTICE, "Received mail without From: line."); syslog(LOG_NOTICE, "Received mail without From: line.");
return 0; return 0;

170
mailer.c
View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
@ -14,8 +24,8 @@
#include <unistd.h> #include <unistd.h>
#include <ctype.h> #include <ctype.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
#ifndef ARG_NUM_MAX #ifndef ARG_NUM_MAX
# define ARG_NUM_MAX 4096 # define ARG_NUM_MAX 4096
@ -26,22 +36,22 @@
static char * static char *
my_strcpy(char * dst, const char * src) my_strcpy(char * dst, const char * src)
{ {
while((*dst++ = *src++) != '\0') while((*dst++ = *src++) != '\0')
; ;
return dst-1; return dst-1;
} }
FILE * FILE *
OpenMailer(const char * envelope, const char * recipients[]) OpenMailer(const char * envelope, const char * recipients[])
{ {
assert(1==0); assert(1==0);
return NULL; return NULL;
} }
FILE * FILE *
vOpenMailer(const char * envelope, ...) vOpenMailer(const char * envelope, ...)
{ {
const struct PD_Config * MasterConfig; const struct PD_Config * MasterConfig;
va_list ap; va_list ap;
FILE * fh; FILE * fh;
@ -79,28 +89,32 @@ vOpenMailer(const char * envelope, ...)
/* Copy the mta's options into the array, while replacing '%s' /* Copy the mta's options into the array, while replacing '%s'
with the envelope. */ with the envelope. */
for (options = MasterConfig->mta_options; *options != '\0'; ) { for (options = MasterConfig->mta_options; *options != '\0'; )
{
debug((DEBUG_MAILER, 4, "Parsing '%c' character.", *options)); debug((DEBUG_MAILER, 4, "Parsing '%c' character.", *options));
if (options[0] == '%' && options[1] == 's') { if (options[0] == '%' && options[1] == 's')
{
p = my_strcpy(p, envelope); p = my_strcpy(p, envelope);
*p++ = ' '; *p++ = ' ';
options += 2; options += 2;
break; break;
} }
else { else
{
debug((DEBUG_MAILER, 4, "Wrote '%c' to aray.", *options)); debug((DEBUG_MAILER, 4, "Wrote '%c' to aray.", *options));
*p++ = *options++; *p++ = *options++;
}
} }
}
*p++ = ' '; *p++ = ' ';
/* Append the list of recipients. */ /* Append the list of recipients. */
va_start(ap, envelope); va_start(ap, envelope);
while ((q = va_arg(ap, const char *)) != NULL) { while ((q = va_arg(ap, const char *)) != NULL)
{
p = my_strcpy(p, q); p = my_strcpy(p, q);
*p++ = ' '; *p++ = ' ';
} }
p[-1] = '\0'; p[-1] = '\0';
va_end(ap); va_end(ap);
@ -108,35 +122,34 @@ vOpenMailer(const char * envelope, ...)
fh = popen(cmdline, "w"); fh = popen(cmdline, "w");
if (fh == NULL) if (fh == NULL)
syslog(LOG_ERR, "Failed opening pipe to \"%s\": %m", cmdline); syslog(LOG_ERR, "Failed opening pipe to \"%s\": %m", cmdline);
free(cmdline); free(cmdline);
return fh; return fh;
} }
int int
CloseMailer(FILE * fh) CloseMailer(FILE * fh)
{ {
return pclose(fh); return pclose(fh);
} }
static int static int
my_strlen(const char * p) my_strlen(const char * p)
{ {
u_int i; u_int i;
for (i = 0; *p && !isspace((int)*p); p++) for (i = 0; *p && !isspace((int)*p); p++)
i++; i++;
return i; return i;
} }
#define MYPIPE_READ fildes[0] #define MYPIPE_READ fildes[0]
#define MYPIPE_WRITE fildes[1] #define MYPIPE_WRITE fildes[1]
int int
ListMail(const char * envelope, const char * listname, const struct Mail * MailStruct) ListMail(const char * envelope, const char * listname, const struct Mail * MailStruct)
{ {
const struct PD_Config * MasterConfig = getMasterConfig(); const struct PD_Config * MasterConfig = getMasterConfig();
char ** arguments; char ** arguments;
u_int arguments_num = 256; u_int arguments_num = 256;
@ -164,11 +177,12 @@ ListMail(const char * envelope, const char * listname, const struct Mail * MailS
sprintf(buffer, "lists/%s/list", listname); sprintf(buffer, "lists/%s/list", listname);
listfile = loadfile(buffer); listfile = loadfile(buffer);
if (listfile == NULL) if (listfile == NULL)
return 1; return 1;
/* Now go into delivery loop until we're finished. */ /* Now go into delivery loop until we're finished. */
for(counter = 0, currAddress = listfile; *currAddress != '\0'; counter = 0) { for(counter = 0, currAddress = listfile; *currAddress != '\0'; counter = 0)
{
/* Set up the call to the MTA, including options. */ /* Set up the call to the MTA, including options. */
@ -176,86 +190,96 @@ ListMail(const char * envelope, const char * listname, const struct Mail * MailS
debug((DEBUG_MAILER, 5, "MTA is \"%s\".", arguments[0])); debug((DEBUG_MAILER, 5, "MTA is \"%s\".", arguments[0]));
sprintf(buffer, MasterConfig->mta_options, envelope); sprintf(buffer, MasterConfig->mta_options, envelope);
debug((DEBUG_MAILER, 5, "MTA options are \"%s\".", buffer)); debug((DEBUG_MAILER, 5, "MTA options are \"%s\".", buffer));
for (p = buffer, arguments[counter++] = buffer; *p != '\0'; p++) { for (p = buffer, arguments[counter++] = buffer; *p != '\0'; p++)
{
debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p)); debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p));
if (isspace((int)*p)) { if (isspace((int)*p))
{
*p++ = '\0'; *p++ = '\0';
debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p)); debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p));
while(*p != '\0' && isspace((int)*p)) while(*p != '\0' && isspace((int)*p))
p++; p++;
debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p)); debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p));
arguments[counter++] = p; arguments[counter++] = p;
}
} }
}
if (strlen(arguments[counter-1]) == 0) if (strlen(arguments[counter-1]) == 0)
counter--; counter--;
/* Append as many recipients as fit. */ /* Append as many recipients as fit. */
for (address_byte = 0; *currAddress != '\0' ; currAddress = nextAddress) { for (address_byte = 0; *currAddress != '\0' ; currAddress = nextAddress)
{
nextAddress = text_find_next_line(currAddress); nextAddress = text_find_next_line(currAddress);
len = my_strlen(currAddress); len = my_strlen(currAddress);
if (address_byte + len > max_address_byte) { if (address_byte + len > max_address_byte)
{
debug((DEBUG_MAILER, 1, "Sending early, command line exceeds %d characters.", ARG_MAX)); debug((DEBUG_MAILER, 1, "Sending early, command line exceeds %d characters.", ARG_MAX));
break; break;
} }
if (counter > ARG_NUM_MAX) { if (counter > ARG_NUM_MAX)
{
debug((DEBUG_MAILER, 1, "Sending early, command line exceeds %d arguments.", ARG_NUM_MAX)); debug((DEBUG_MAILER, 1, "Sending early, command line exceeds %d arguments.", ARG_NUM_MAX));
break; break;
} }
currAddress[len] = '\0'; currAddress[len] = '\0';
debug((DEBUG_MAILER, 8, "Address \"%s\" is %u byte long.", currAddress, len)); debug((DEBUG_MAILER, 8, "Address \"%s\" is %u byte long.", currAddress, len));
address_byte += len; address_byte += len;
arguments[counter++] = currAddress; arguments[counter++] = currAddress;
if (counter+8 >= arguments_num) { if (counter+8 >= arguments_num)
{
debug((DEBUG_MAILER, 1, "Enlarging internal array.")); debug((DEBUG_MAILER, 1, "Enlarging internal array."));
arguments_num += 256; arguments_num += 256;
arguments = realloc(arguments, (arguments_num+1) * sizeof(char *)); arguments = realloc(arguments, (arguments_num+1) * sizeof(char *));
if (arguments == NULL) if (arguments == NULL)
return -1; return -1;
}
} }
}
/* Deliver the mail. */ /* Deliver the mail. */
arguments[counter++] = NULL; arguments[counter++] = NULL;
if (pipe(fildes) == -1) { if (pipe(fildes) == -1)
{
syslog(LOG_ERR, "Couldn't open a pipe to my child process: %m"); syslog(LOG_ERR, "Couldn't open a pipe to my child process: %m");
return -1; return -1;
} }
child_pid = fork(); child_pid = fork();
switch(child_pid) { switch(child_pid)
case 0: {
/* Child */ case 0:
close(MYPIPE_WRITE); /* Child */
if (dup2(MYPIPE_READ, STDIN_FILENO) == -1) { close(MYPIPE_WRITE);
syslog(LOG_ERR, "Child process couldn't read from pipe: %m"); if (dup2(MYPIPE_READ, STDIN_FILENO) == -1)
return -1; {
} syslog(LOG_ERR, "Child process couldn't read from pipe: %m");
close(MYPIPE_READ); return -1;
execv(MasterConfig->mta, arguments); }
syslog(LOG_ERR, "Couldn't exec(\"%s\"): %m", MasterConfig->mta); close(MYPIPE_READ);
return -1; execv(MasterConfig->mta, arguments);
case -1: syslog(LOG_ERR, "Couldn't exec(\"%s\"): %m", MasterConfig->mta);
/* Error */ return -1;
syslog(LOG_ERR, "Couldn't fork: %m"); case -1:
return -1; /* Error */
default: syslog(LOG_ERR, "Couldn't fork: %m");
/* everything is fine */ return -1;
close(MYPIPE_READ); default:
} /* everything is fine */
close(MYPIPE_READ);
}
write(MYPIPE_WRITE, MailStruct->Header, strlen(MailStruct->Header)); write(MYPIPE_WRITE, MailStruct->Header, strlen(MailStruct->Header));
write(MYPIPE_WRITE, "\n", 1); write(MYPIPE_WRITE, "\n", 1);
write(MYPIPE_WRITE, MailStruct->Body, strlen(MailStruct->Body)); write(MYPIPE_WRITE, MailStruct->Body, strlen(MailStruct->Body));
if (MailStruct->ListSignature != NULL) if (MailStruct->ListSignature != NULL)
write(MYPIPE_WRITE, MailStruct->ListSignature, strlen(MailStruct->ListSignature)); write(MYPIPE_WRITE, MailStruct->ListSignature, strlen(MailStruct->ListSignature));
close(MYPIPE_WRITE); close(MYPIPE_WRITE);
waitpid(child_pid, &child_status, 0); waitpid(child_pid, &child_status, 0);
if (!(WIFEXITED(child_status) && WEXITSTATUS(child_status) == 0)) { if (!(WIFEXITED(child_status) && WEXITSTATUS(child_status) == 0))
{
syslog(LOG_ERR, "The executed mail agent return error %d, aborting.", syslog(LOG_ERR, "The executed mail agent return error %d, aborting.",
WEXITSTATUS(child_status)); WEXITSTATUS(child_status));
return -1; return -1;
}
} }
}
return 0; return 0;
} }

63
main.c
View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -13,9 +23,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <argv.h> #include "petidomo.h"
#include <petidomo.h>
#include "version.h"
#ifndef LOG_PERROR #ifndef LOG_PERROR
# define LOG_PERROR 0 # define LOG_PERROR 0
@ -23,20 +31,22 @@
MODULE_TABLE /* defined in debug.h */ MODULE_TABLE /* defined in debug.h */
static char * listname = NULL; static char * listname = NULL;
#ifdef DEBUG
static argv_array_t debug; static argv_array_t debug;
#endif
int int
main(int argc, char * argv[]) main(int argc, char * argv[])
{ {
const struct PD_Config * MasterConfig; const struct PD_Config * MasterConfig;
char * incoming_mail; char * incoming_mail;
char * programname; char * programname;
argv_t args[] = { argv_t args[] = {
#ifdef DEBUG #ifdef DEBUG
{'d', "debug", ARGV_CHARP | ARGV_ARRAY , &debug, "debug", {'d', "debug", ARGV_CHAR_P | ARGV_FLAG_ARRAY , &debug, "debug",
"Set debug level per module."}, "Set debug level per module."},
#endif #endif
{ARGV_MAYBE, 0L, ARGV_CHARP, &listname, "listname", "Default mailing list."}, {ARGV_MAYBE, 0L, ARGV_CHAR_P, &listname, "listname", "Default mailing list."},
{ARGV_LAST} {ARGV_LAST}
}; };
int fd; int fd;
@ -69,8 +79,8 @@ main(int argc, char * argv[])
/* Parse the command line. */ /* Parse the command line. */
argv_help_string = "Petidomo Mailing List Server"; argv_help_string = "OpenPetidomo Mailing List Server";
argv_version_string = VERS; argv_version_string = "OpenPetidomo";
argv_process(args, argc, argv); argv_process(args, argc, argv);
/* Set debug level according to the wishes of the user. */ /* Set debug level according to the wishes of the user. */
@ -125,22 +135,29 @@ main(int argc, char * argv[])
/* Now decide what we actually do with the mail. */ /* Now decide what we actually do with the mail. */
if (strcasecmp("listserv", programname) == 0) if (strcasecmp("listserv", programname) == 0)
listserv_main(incoming_mail, listname); listserv_main(incoming_mail, listname);
else if (strcasecmp("hermes", programname) == 0) { else if (strcasecmp("hermes", programname) == 0)
{
if (listname != NULL) if (listname != NULL)
hermes_main(incoming_mail, listname); hermes_main(incoming_mail, listname);
else { else
{
syslog(LOG_ERR, "Wrong command line syntax. \"hermes\" requires a parameter."); syslog(LOG_ERR, "Wrong command line syntax. \"hermes\" requires a parameter.");
exit(1); exit(1);
}
} }
} else if (strcasecmp("petidomo", programname) == 0)
else { {
/* do nothing */
}
else
{
syslog(LOG_ERR, "I have been called under an unknown name \"%s\".", programname); syslog(LOG_ERR, "I have been called under an unknown name \"%s\".", programname);
exit(1); exit(1);
} }
/* Exit gracefully. */ /* Exit gracefully. */
RemoveRescueMail(); RemoveRescueMail();
return 0; return 0;
} }

View File

@ -1,19 +1,29 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1997 by CyberSolutions GmbH.
* All rights reserved. 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/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#include <ctype.h> #include <ctype.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
int int
SendSubscriberList(struct Mail * MailStruct, SendSubscriberList(struct Mail * MailStruct,

View File

@ -1,11 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 "petidomo.h"

View File

@ -1,15 +1,24 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <ctype.h> #include <ctype.h>
#include "petidomo.h"
#include <petidomo.h>
static const char * s_password = NULL; static const char * s_password = NULL;
extern char * g_currLine; extern char * g_currLine;

View File

@ -1,19 +1,29 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <rfc822.h> #include "librfc822/rfc822.h"
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
void void
RemoveCarrigeReturns(char * buffer) RemoveCarrigeReturns(char * buffer)
@ -343,6 +353,24 @@ ParseMail(struct Mail **result, char * incoming_mail, const char * fqdn)
MailStruct->Subject += 1; MailStruct->Subject += 1;
debug((DEBUG_RFCPARSE, 5, "Subject: is \"%s\".", MailStruct->Subject)); debug((DEBUG_RFCPARSE, 5, "Subject: is \"%s\".", MailStruct->Subject));
} }
else if (strncasecmp("Sender:", currLine, strlen("Sender:")) == 0) {
if (MailStruct->Envelope != NULL)
syslog(LOG_NOTICE, "Received mail with multiple sender addresses.");
MailStruct->Envelope = &currLine[strlen("Sender:")];
if (*MailStruct->Envelope == ' ')
MailStruct->Envelope += 1;
debug((DEBUG_RFCPARSE, 5, "Sender: is \"%s\".", MailStruct->Envelope));
}
else if (strncasecmp("Return-Path:", currLine, strlen("Return-Path:")) == 0 &&
MailStruct->Envelope == NULL)
{
if (MailStruct->Envelope != NULL)
syslog(LOG_NOTICE, "Received mail with multiple sender addresses.");
MailStruct->Envelope = &currLine[strlen("Return-Path:")];
if (*MailStruct->Envelope == ' ')
MailStruct->Envelope += 1;
debug((DEBUG_RFCPARSE, 5, "Return-Path: is \"%s\".", MailStruct->Envelope));
}
} }
*result = MailStruct; *result = MailStruct;

View File

@ -1,40 +1,21 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (c) 1996-99 by CyberSolutions GmbH, Germany.
* All rights reserved. This file is part of OpenPetidomo.
*
* Redistribution and use in source and binary forms, with or without OpenPetidomo is free software; you can redistribute it and/or modify
* modification, are permitted provided that the following conditions it under the terms of the GNU General Public License as published by
* are met: the Free Software Foundation; either version 2, or (at your option)
* any later version.
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. OpenPetidomo is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* 2. Redistributions in binary form must reproduce the above copyright MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* notice, this list of conditions and the following disclaimer in the General Public License for more details.
* documentation and/or other materials provided with the distribution. */
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by CyberSolutions GmbH.
*
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>

View File

@ -1,15 +1,25 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <string.h> #include <string.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
int int
AddAddress(struct Mail * MailStruct, AddAddress(struct Mail * MailStruct,
@ -18,6 +28,7 @@ AddAddress(struct Mail * MailStruct,
const char * defaultlist) const char * defaultlist)
{ {
const struct List_Config * ListConfig; const struct List_Config * ListConfig;
const struct PD_Config * MasterConfig;
FILE * fh; FILE * fh;
const char * address = NULL; const char * address = NULL;
const char * listname = NULL; const char * listname = NULL;
@ -58,7 +69,7 @@ AddAddress(struct Mail * MailStruct,
} }
/* Initialize internal stuff. */ /* Initialize internal stuff. */
MasterConfig = getMasterConfig();
ListConfig = getListConfig(listname); ListConfig = getListConfig(listname);
sprintf(owner, "%s-owner@%s", listname, ListConfig->fqdn); sprintf(owner, "%s-owner@%s", listname, ListConfig->fqdn);
sprintf(envelope, "%s-owner@%s", listname, ListConfig->fqdn); sprintf(envelope, "%s-owner@%s", listname, ListConfig->fqdn);
@ -322,3 +333,4 @@ AddAddress(struct Mail * MailStruct,
} }
return 0; return 0;
} }

30
tool.c
View File

@ -1,19 +1,29 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
bool bool
isSubscribed(const char * listname, const char * address, isSubscribed(const char * listname, const char * address,
@ -57,7 +67,7 @@ isSubscribed(const char * listname, const char * address,
} }
} }
#if DEBUG #ifdef DEBUG
if (*p != '\0') { if (*p != '\0') {
debug((DEBUG_COMMAND, 3, "Found address: \"%s\".", p)); debug((DEBUG_COMMAND, 3, "Found address: \"%s\".", p));
} }

View File

@ -1,15 +1,25 @@
/* /*
* $Source$ $Source$
* $Revision$ $Revision$
* $Date$
* Copyright (C) 2000 by CyberSolutions GmbH, Germany.
* Copyright (C) 1996 by CyberSolutions GmbH.
* All rights reserved. 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 <string.h> #include <string.h>
#include <text.h> #include "libtext/text.h"
#include <petidomo.h> #include "petidomo.h"
int int
DeleteAddress(struct Mail * MailStruct, DeleteAddress(struct Mail * MailStruct,