diff --git a/acl.y b/acl.y index 85245b4..acd2d42 100644 --- a/acl.y +++ b/acl.y @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1997 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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. */ @@ -16,8 +26,8 @@ #include #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" static int yyerror(char *); static int yylex(void); diff --git a/acl_scan.l b/acl_scan.l index 2b0fa6b..3237320 100644 --- a/acl_scan.l +++ b/acl_scan.l @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1997 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 diff --git a/archive.c b/archive.c index 0dcce46..bbf3138 100644 --- a/archive.c +++ b/archive.c @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include @@ -14,8 +24,8 @@ #include #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" int ArchiveMail(const struct Mail * MailStruct, const char * listname) diff --git a/argvSetDebugLevel.c b/argvSetDebugLevel.c index 9c9c3ab..8dd2b4c 100644 --- a/argvSetDebugLevel.c +++ b/argvSetDebugLevel.c @@ -1,19 +1,27 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996,97 CyberSolutions GmbH. - * All rights reserved. - * - * - Set debug-level for various modules from the command line. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include -#include -#include +#include "debug.h" +#include "libargv/argv.h" #ifdef DEBUG @@ -43,6 +51,10 @@ extern const char * const ModuleTable[]; REQUIRES: extern const char * const ModuleTable[] */ + +/* let's define ModuleTable here */ +MODULE_TABLE + int 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; 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), ",/:"); DebugLevel = strtok(NULL, ",/:"); if (ModuleName == NULL || DebugLevel == NULL diff --git a/authen.c b/authen.c index c35b78f..4af751a 100644 --- a/authen.c +++ b/authen.c @@ -1,17 +1,27 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" int FindBodyPassword(struct Mail * MailStruct) diff --git a/config.c b/config.c index bef83fa..13baa3b 100644 --- a/config.c +++ b/config.c @@ -1,20 +1,30 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include #include -#include -#include -#include +#include "liblists/lists.h" +#include "libconfigfile/configfile.h" +#include "petidomo.h" static struct PD_Config * MasterConfig; List ListConfigs; @@ -25,7 +35,7 @@ List ListConfigs; static char * fqdn = NULL; static char * master_password = NULL; 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 show_stats = TRUE; diff --git a/exit.c b/exit.c index fd22f36..47bf7ef 100644 --- a/exit.c +++ b/exit.c @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include @@ -13,8 +23,8 @@ #include #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" static char * s_crash_filename = NULL; diff --git a/filter.c b/filter.c index 510e3e2..9662bca 100644 --- a/filter.c +++ b/filter.c @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include @@ -14,7 +24,7 @@ #include #include -#include +#include "petidomo.h" #define READ 0 #define WRITE 1 diff --git a/handleacl.c b/handleacl.c index e4c8b94..615de2e 100644 --- a/handleacl.c +++ b/handleacl.c @@ -1,15 +1,24 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 - -#include +#include "petidomo.h" /* Returncodes have the following meaning: '-1' == Error, '0' == Proceed, '1' == Mail has been taken care of. */ diff --git a/help.c b/help.c index 252bf98..27b6a67 100644 --- a/help.c +++ b/help.c @@ -1,14 +1,24 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ -#include -#include + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 SendHelp(struct Mail * MailStruct, diff --git a/hermes.c b/hermes.c index cd177d6..9004e64 100644 --- a/hermes.c +++ b/hermes.c @@ -1,18 +1,28 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include +#include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" int hermes_main(char * incoming_mail, const char * listname) @@ -51,6 +61,10 @@ hermes_main(char * incoming_mail, const char * listname) /* Do sanity checks. */ + if (MailStruct->Envelope == NULL) { + syslog(LOG_NOTICE, "Received mail without a valid envelope."); + return 0; + } if (MailStruct->From == NULL) { syslog(LOG_NOTICE, "Received mail without From: line."); return 0; diff --git a/index.c b/index.c index 101c572..4f9272b 100644 --- a/index.c +++ b/index.c @@ -1,19 +1,29 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" int GenIndex(struct Mail * MailStruct, diff --git a/io.c b/io.c index 03fa234..beb2e41 100644 --- a/io.c +++ b/io.c @@ -1,17 +1,27 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1997 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include -#include +#include "petidomo.h" char * LoadFromDescriptor(int fd) diff --git a/listserv.c b/listserv.c index b4f1b3c..a6ec28b 100644 --- a/listserv.c +++ b/listserv.c @@ -1,17 +1,27 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" char * g_currLine; /* pointer to the line currently parsed */ @@ -45,6 +55,10 @@ listserv_main(char * incoming_mail, char * default_list) /* Do sanity checks. */ + if (MailStruct->Envelope == NULL) { + syslog(LOG_NOTICE, "Received mail without a valid envelope."); + return 0; + } if (MailStruct->From == NULL) { syslog(LOG_NOTICE, "Received mail without From: line."); return 0; diff --git a/mailer.c b/mailer.c index 7ee8b41..f7bdef0 100644 --- a/mailer.c +++ b/mailer.c @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include @@ -14,8 +24,8 @@ #include #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" #ifndef ARG_NUM_MAX # define ARG_NUM_MAX 4096 @@ -26,22 +36,22 @@ static char * my_strcpy(char * dst, const char * src) -{ + { while((*dst++ = *src++) != '\0') - ; + ; return dst-1; -} + } FILE * OpenMailer(const char * envelope, const char * recipients[]) -{ + { assert(1==0); return NULL; -} + } FILE * vOpenMailer(const char * envelope, ...) -{ + { const struct PD_Config * MasterConfig; va_list ap; FILE * fh; @@ -79,28 +89,32 @@ vOpenMailer(const char * envelope, ...) /* Copy the mta's options into the array, while replacing '%s' 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)); - if (options[0] == '%' && options[1] == 's') { + if (options[0] == '%' && options[1] == 's') + { p = my_strcpy(p, envelope); *p++ = ' '; options += 2; break; - } - else { + } + else + { debug((DEBUG_MAILER, 4, "Wrote '%c' to aray.", *options)); *p++ = *options++; + } } - } *p++ = ' '; /* Append the list of recipients. */ 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++ = ' '; - } + } p[-1] = '\0'; va_end(ap); @@ -108,35 +122,34 @@ vOpenMailer(const char * envelope, ...) fh = popen(cmdline, "w"); 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); return fh; -} + } int CloseMailer(FILE * fh) -{ + { return pclose(fh); -} - + } static int my_strlen(const char * p) -{ + { u_int i; for (i = 0; *p && !isspace((int)*p); p++) - i++; + i++; return i; -} + } #define MYPIPE_READ fildes[0] #define MYPIPE_WRITE fildes[1] int ListMail(const char * envelope, const char * listname, const struct Mail * MailStruct) -{ + { const struct PD_Config * MasterConfig = getMasterConfig(); char ** arguments; 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); listfile = loadfile(buffer); if (listfile == NULL) - return 1; + return 1; /* 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. */ @@ -176,86 +190,96 @@ ListMail(const char * envelope, const char * listname, const struct Mail * MailS debug((DEBUG_MAILER, 5, "MTA is \"%s\".", arguments[0])); sprintf(buffer, MasterConfig->mta_options, envelope); 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)); - if (isspace((int)*p)) { + if (isspace((int)*p)) + { *p++ = '\0'; debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p)); while(*p != '\0' && isspace((int)*p)) - p++; + p++; debug((DEBUG_MAILER, 9, "Left to parse: \"%s\".", p)); arguments[counter++] = p; + } } - } if (strlen(arguments[counter-1]) == 0) - counter--; + counter--; /* 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); 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)); 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)); break; - } + } currAddress[len] = '\0'; debug((DEBUG_MAILER, 8, "Address \"%s\" is %u byte long.", currAddress, len)); address_byte += len; arguments[counter++] = currAddress; - if (counter+8 >= arguments_num) { + if (counter+8 >= arguments_num) + { debug((DEBUG_MAILER, 1, "Enlarging internal array.")); arguments_num += 256; arguments = realloc(arguments, (arguments_num+1) * sizeof(char *)); if (arguments == NULL) - return -1; + return -1; + } } - } /* Deliver the mail. */ arguments[counter++] = NULL; - if (pipe(fildes) == -1) { + if (pipe(fildes) == -1) + { syslog(LOG_ERR, "Couldn't open a pipe to my child process: %m"); return -1; - } + } child_pid = fork(); - switch(child_pid) { - case 0: - /* Child */ - close(MYPIPE_WRITE); - if (dup2(MYPIPE_READ, STDIN_FILENO) == -1) { - syslog(LOG_ERR, "Child process couldn't read from pipe: %m"); - return -1; - } - close(MYPIPE_READ); - execv(MasterConfig->mta, arguments); - syslog(LOG_ERR, "Couldn't exec(\"%s\"): %m", MasterConfig->mta); - return -1; - case -1: - /* Error */ - syslog(LOG_ERR, "Couldn't fork: %m"); - return -1; - default: - /* everything is fine */ - close(MYPIPE_READ); - } + switch(child_pid) + { + case 0: + /* Child */ + close(MYPIPE_WRITE); + if (dup2(MYPIPE_READ, STDIN_FILENO) == -1) + { + syslog(LOG_ERR, "Child process couldn't read from pipe: %m"); + return -1; + } + close(MYPIPE_READ); + execv(MasterConfig->mta, arguments); + syslog(LOG_ERR, "Couldn't exec(\"%s\"): %m", MasterConfig->mta); + return -1; + case -1: + /* Error */ + syslog(LOG_ERR, "Couldn't fork: %m"); + return -1; + default: + /* everything is fine */ + close(MYPIPE_READ); + } write(MYPIPE_WRITE, MailStruct->Header, strlen(MailStruct->Header)); write(MYPIPE_WRITE, "\n", 1); write(MYPIPE_WRITE, MailStruct->Body, strlen(MailStruct->Body)); if (MailStruct->ListSignature != NULL) - write(MYPIPE_WRITE, MailStruct->ListSignature, strlen(MailStruct->ListSignature)); + write(MYPIPE_WRITE, MailStruct->ListSignature, strlen(MailStruct->ListSignature)); close(MYPIPE_WRITE); 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.", - WEXITSTATUS(child_status)); + WEXITSTATUS(child_status)); return -1; + } } - } return 0; -} + } diff --git a/main.c b/main.c index be04148..8396c8e 100644 --- a/main.c +++ b/main.c @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include @@ -13,9 +23,7 @@ #include #include -#include -#include -#include "version.h" +#include "petidomo.h" #ifndef LOG_PERROR # define LOG_PERROR 0 @@ -23,20 +31,22 @@ MODULE_TABLE /* defined in debug.h */ static char * listname = NULL; +#ifdef DEBUG static argv_array_t debug; +#endif int main(int argc, char * argv[]) -{ + { const struct PD_Config * MasterConfig; char * incoming_mail; char * programname; argv_t args[] = { #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."}, #endif - {ARGV_MAYBE, 0L, ARGV_CHARP, &listname, "listname", "Default mailing list."}, + {ARGV_MAYBE, 0L, ARGV_CHAR_P, &listname, "listname", "Default mailing list."}, {ARGV_LAST} }; int fd; @@ -69,8 +79,8 @@ main(int argc, char * argv[]) /* Parse the command line. */ - argv_help_string = "Petidomo Mailing List Server"; - argv_version_string = VERS; + argv_help_string = "OpenPetidomo Mailing List Server"; + argv_version_string = "OpenPetidomo"; argv_process(args, argc, argv); /* 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. */ if (strcasecmp("listserv", programname) == 0) - listserv_main(incoming_mail, listname); - else if (strcasecmp("hermes", programname) == 0) { + listserv_main(incoming_mail, listname); + else if (strcasecmp("hermes", programname) == 0) + { if (listname != NULL) - hermes_main(incoming_mail, listname); - else { + hermes_main(incoming_mail, listname); + else + { syslog(LOG_ERR, "Wrong command line syntax. \"hermes\" requires a parameter."); exit(1); + } } - } - else { + else if (strcasecmp("petidomo", programname) == 0) + { + /* do nothing */ + } + else + { syslog(LOG_ERR, "I have been called under an unknown name \"%s\".", programname); exit(1); - } + } /* Exit gracefully. */ RemoveRescueMail(); return 0; -} + } diff --git a/members.c b/members.c index 1d81891..77d9890 100644 --- a/members.c +++ b/members.c @@ -1,19 +1,29 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1997 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" int SendSubscriberList(struct Mail * MailStruct, diff --git a/parsearray.c b/parsearray.c index 75981c4..140f2c7 100644 --- a/parsearray.c +++ b/parsearray.c @@ -1,11 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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" diff --git a/password.c b/password.c index c4170a5..3972fd9 100644 --- a/password.c +++ b/password.c @@ -1,15 +1,24 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 - -#include +#include "petidomo.h" static const char * s_password = NULL; extern char * g_currLine; diff --git a/rfcparse.c b/rfcparse.c index 748eb0b..244f4d5 100644 --- a/rfcparse.c +++ b/rfcparse.c @@ -1,19 +1,29 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include -#include -#include -#include +#include "librfc822/rfc822.h" +#include "libtext/text.h" +#include "petidomo.h" void RemoveCarrigeReturns(char * buffer) @@ -343,6 +353,24 @@ ParseMail(struct Mail **result, char * incoming_mail, const char * fqdn) MailStruct->Subject += 1; 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; diff --git a/signature.c b/signature.c index 373858b..01d2919 100644 --- a/signature.c +++ b/signature.c @@ -1,40 +1,21 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (c) 1996-99 by CyberSolutions GmbH, Germany. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * 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. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include diff --git a/subscribe.c b/subscribe.c index 796e413..b40b4a8 100644 --- a/subscribe.c +++ b/subscribe.c @@ -1,15 +1,25 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 -#include -#include +#include "libtext/text.h" +#include "petidomo.h" int AddAddress(struct Mail * MailStruct, @@ -18,6 +28,7 @@ AddAddress(struct Mail * MailStruct, const char * defaultlist) { const struct List_Config * ListConfig; + const struct PD_Config * MasterConfig; FILE * fh; const char * address = NULL; const char * listname = NULL; @@ -58,7 +69,7 @@ AddAddress(struct Mail * MailStruct, } /* Initialize internal stuff. */ - + MasterConfig = getMasterConfig(); ListConfig = getListConfig(listname); sprintf(owner, "%s-owner@%s", listname, ListConfig->fqdn); sprintf(envelope, "%s-owner@%s", listname, ListConfig->fqdn); @@ -322,3 +333,4 @@ AddAddress(struct Mail * MailStruct, } return 0; } + diff --git a/tool.c b/tool.c index 5379488..3724a11 100644 --- a/tool.c +++ b/tool.c @@ -1,19 +1,29 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 #include #include #include -#include -#include +#include "libtext/text.h" +#include "petidomo.h" bool 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') { debug((DEBUG_COMMAND, 3, "Found address: \"%s\".", p)); } diff --git a/unsubscribe.c b/unsubscribe.c index 96be051..52539d8 100644 --- a/unsubscribe.c +++ b/unsubscribe.c @@ -1,15 +1,25 @@ /* - * $Source$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1996 by CyberSolutions GmbH. - * All rights reserved. - */ + $Source$ + $Revision$ + + Copyright (C) 2000 by CyberSolutions GmbH, Germany. + + 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 -#include -#include +#include "libtext/text.h" +#include "petidomo.h" int DeleteAddress(struct Mail * MailStruct,