head 1.22; access; symbols petidomo-2-2:1.1.1.1 petidomo:1.1.1; locks; strict; comment @ * @; 1.22 date 2001.01.20.13.26.00; author simons; state dead; branches; next 1.21; 1.21 date 2001.01.19.20.51.11; author simons; state Exp; branches; next 1.20; 1.20 date 2001.01.19.15.26.53; author simons; state Exp; branches; next 1.19; 1.19 date 2001.01.19.14.56.33; author rse; state Exp; branches; next 1.18; 1.18 date 2001.01.19.13.12.46; author simons; state Exp; branches; next 1.17; 1.17 date 2001.01.18.20.30.50; author rse; state Exp; branches; next 1.16; 1.16 date 2001.01.18.14.41.28; author rse; state Exp; branches; next 1.15; 1.15 date 2001.01.15.17.19.36; author simons; state Exp; branches; next 1.14; 1.14 date 2001.01.15.16.55.45; author simons; state Exp; branches; next 1.13; 1.13 date 2001.01.15.16.35.06; author simons; state Exp; branches; next 1.12; 1.12 date 2001.01.15.16.29.11; author simons; state Exp; branches; next 1.11; 1.11 date 2001.01.11.14.17.53; author simons; state Exp; branches; next 1.10; 1.10 date 2001.01.10.16.34.00; author simons; state Exp; branches; next 1.9; 1.9 date 2001.01.08.20.36.19; author simons; state Exp; branches; next 1.8; 1.8 date 2001.01.08.15.55.07; author simons; state Exp; branches; next 1.7; 1.7 date 2001.01.06.14.12.21; author simons; state Exp; branches; next 1.6; 1.6 date 2000.12.15.17.27.53; author simons; state Exp; branches; next 1.5; 1.5 date 2000.12.15.16.16.07; author simons; state Exp; branches; next 1.4; 1.4 date 2000.12.15.16.03.15; author simons; state Exp; branches; next 1.3; 1.3 date 2000.12.15.15.48.00; author simons; state Exp; branches; next 1.2; 1.2 date 2000.12.13.15.35.14; author simons; state Exp; branches; next 1.1; 1.1 date 2000.12.13.13.19.22; author simons; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2000.12.13.13.19.22; author simons; state Exp; branches; next ; desc @@ 1.22 log @Renamed the followings tags in petidomo.conf MTA_Options --> MTAOptions List_Directory --> ListDirectory Ack_Queue_Directory --> AckQueueDirectory for consistency reasons. While I was at it, I also renamed the source file from config.c to config-files.c, because the module config.c is generally associated with GNU autoconf and this has nothing to do with it. @ text @/* $Source: /e/ossp/cvs/ossp-pkg/petidomo/config.c,v $ $Revision: 1.21 $ Copyright (C) 2000 by CyberSolutions GmbH, Germany. This file is part of Petidomo. Petidomo 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. Petidomo 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 "liblists/lists.h" #include "libconfigfile/configfile.h" #include "petidomo.h" static struct PD_Config * MasterConfig; List ListConfigs; /* These variables need to be static/global, so that the addresses as used in MasterCF are known at compile time. */ static char* fqdn = NULL; static char* master_password = NULL; static char* mta = NULL; 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 "/lists"; static char* ack_queue_dir = LOCALSTATEDIR "/ack_queue"; int InitPetidomo(const char* masterconfig_path) { int rc; /* Format description of our global config file. */ struct ConfigFile MasterCF[] = { { "Hostname", CF_STRING, &fqdn }, { "AdminPassword", CF_STRING, &master_password }, { "MTA", CF_STRING, &mta }, { "MTA_Options", CF_STRING, &mta_options }, { "Help_File", CF_STRING, &help_file }, { "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} }; /* Allocate memory for the global config structure. */ MasterConfig = calloc(sizeof(struct PD_Config), 1); if (MasterConfig == NULL) { syslog(LOG_ERR, "Failed to allocate %d byte of memory.", sizeof(struct PD_Config)); return -1; } /* Init the list of read list configs. */ ListConfigs = InitList(NULL); /* Parse the config file. */ rc = ReadConfig(masterconfig_path, MasterCF); if (rc != 0) { syslog(LOG_ERR, "Failed to parse the master config file."); return -1; } /* Do consistency checks. */ if (fqdn == NULL) { syslog(LOG_ERR, "The master config file \"%s\" doesn't set the host name.", masterconfig_path); return -1; } if (mta == NULL) { syslog(LOG_ERR, "The master config file \"%s\" doesn't set the MTA.", masterconfig_path); return -1; } if (master_password == NULL) { syslog(LOG_ERR, "The master config file \"%s\" doesn't set the admin password.", masterconfig_path); return -1; } if (strstr(mta_options, "%s") == NULL) { syslog(LOG_ERR, "The argument to MTA_Options in the master config file is invalid."); return -1; } /* Copy the results to the structure. */ MasterConfig->fqdn = fqdn; MasterConfig->master_password = master_password; MasterConfig->mta = mta; MasterConfig->mta_options = mta_options; MasterConfig->help_file = help_file; MasterConfig->acl_file = acl_file; MasterConfig->index_file = index_file; MasterConfig->list_dir = list_dir; MasterConfig->ack_queue_dir = ack_queue_dir; return 0; } const struct PD_Config* getMasterConfig(void) { return MasterConfig; } static char* list_fqdn; static char* admin_password; static char* posting_password; static char* listtype; static char* reply_to; static char* postingfilter; static char* archivepath; static char* subtype; static bool allowmembers; static char* intro_file; static char* sig_file; static char* desc_file; static char* header_file; static char* list_acl_file; static char* address_file; static char* ack_file; const struct List_Config* getListConfig(const char * listname) { struct List_Config * ListConfig; Node node; int rc; char * buffer; struct stat sb; char* this_list_dir; /* Format description of our global config file. */ struct ConfigFile ListCF[] = { { "ListType", CF_STRING, &listtype }, { "SubscriptionType", CF_STRING, &subtype }, { "AllowMembersCommand", CF_YES_NO, &allowmembers }, { "ReplyTo", CF_STRING, &reply_to }, { "Hostname", CF_STRING, &list_fqdn }, { "AdminPassword", CF_STRING, &admin_password }, { "PostingPassword", CF_STRING, &posting_password }, { "PostingFilter", CF_STRING, &postingfilter }, { "Archive", CF_STRING, &archivepath }, { "IntroductionFile", CF_STRING, &intro_file }, { "SignatureFile", CF_STRING, &sig_file }, { "DescriptionFile", CF_STRING, &desc_file }, { "HeaderFile", CF_STRING, &header_file }, { "ACLFile", CF_STRING, &list_acl_file }, { "AddressFile", CF_STRING, &address_file }, { "AcknowledgementFile", CF_STRING, &ack_file }, { NULL, 0, NULL} }; /* Set the defaults. */ list_fqdn = NULL; admin_password = NULL; posting_password = NULL; listtype = "open"; reply_to = NULL; postingfilter = NULL; archivepath = NULL; subtype = "public"; allowmembers = FALSE; intro_file = "introduction"; sig_file = "signature"; desc_file = "description"; header_file = "header"; list_acl_file = "acl"; address_file = "list"; ack_file = "acks"; /* Did we read this config file already? */ node = FindNodeByKey(ListConfigs, listname); if (node != NULL) return getNodeData(node); /* No? Then read the config file. */ buffer = text_easy_sprintf("%s/%s/config", MasterConfig->list_dir, listname); this_list_dir = text_easy_sprintf("%s/%s", MasterConfig->list_dir, listname); if (stat(buffer, &sb) != 0) { free(buffer); buffer = text_easy_sprintf("%s/%s/conf", MasterConfig->list_dir, listname); if (stat(buffer, &sb) != 0) { free(buffer); buffer = text_easy_sprintf("%s/%s.config", MasterConfig->list_dir, listname); this_list_dir = MasterConfig->list_dir; if (stat(buffer, &sb) != 0) { free(buffer); buffer = text_easy_sprintf("%s/%s.conf", MasterConfig->list_dir, listname); if (stat(buffer, &sb) != 0) { syslog(LOG_ERR, "Can't find a config file for list \"%s\".", listname); exit(1); } } } } rc = ReadConfig(buffer, ListCF); if (rc != 0) { syslog(LOG_ERR, "Failed to parse the list \"%s\"'s config file.", listname); exit(1); } /* Do consistency checks. */ if (listtype == NULL) { syslog(LOG_ERR, "List \"%s\" doesn't have a valid type in config file.", listname); exit(1); } /* Set up the list config structure. */ ListConfig = calloc(sizeof(struct List_Config), 1); if (ListConfig == NULL) { syslog(LOG_ERR, "Failed to allocate %d byte of memory.", sizeof(struct List_Config)); exit(1); } if (!strcasecmp(listtype, "open")) ListConfig->listtype = LIST_OPEN; else if (!strcasecmp(listtype, "closed")) ListConfig->listtype = LIST_CLOSED; else if (!strcasecmp(listtype, "moderated")) ListConfig->listtype = LIST_MODERATED; else if (!strcasecmp(listtype, "acknowledged") || !strcasecmp(listtype, "acked")) ListConfig->listtype = LIST_ACKED; else if (!strcasecmp(listtype, "acknowledged-once") || !strcasecmp(listtype, "acked-once")) ListConfig->listtype = LIST_ACKED_ONCE; else { syslog(LOG_ERR, "List \"%s\" doesn't have a valid type in config file.", listname); exit(1); } if (!strcasecmp(subtype, "public")) ListConfig->subtype = SUBSCRIPTION_PUBLIC; else if (!strcasecmp(subtype, "admin")) ListConfig->subtype = SUBSCRIPTION_ADMIN; else if (!strcasecmp(subtype, "acknowledged") || !strcasecmp(subtype, "acked")) ListConfig->subtype = SUBSCRIPTION_ACKED; else { syslog(LOG_ERR, "List \"%s\" doesn't have a valid subscription type in config file.", listname); exit(1); } ListConfig->allowmembers = allowmembers; ListConfig->fqdn = (list_fqdn) ? list_fqdn : MasterConfig->fqdn; ListConfig->reply_to = reply_to; if (reply_to != NULL && strcasecmp(reply_to, "none")) CanonizeAddress(&(ListConfig->reply_to), ListConfig->fqdn); ListConfig->admin_password = admin_password; ListConfig->posting_password = posting_password; ListConfig->postingfilter = postingfilter; ListConfig->list_dir = this_list_dir; #define EXPAND(dst, src) \ if (src == NULL || src[0] == '/') \ ListConfig->dst = src; \ else \ ListConfig->dst = text_easy_sprintf("%s/%s", ListConfig->list_dir, src); EXPAND(archivepath, archivepath); EXPAND(intro_file, intro_file); EXPAND(desc_file, desc_file); EXPAND(sig_file, sig_file); EXPAND(header_file, header_file); EXPAND(acl_file, list_acl_file); EXPAND(address_file, address_file); EXPAND(ack_file, ack_file); AppendNode(ListConfigs, xstrdup(listname), ListConfig); return ListConfig; } @ 1.21 log @The module contains the static variable MasterConfig, which all other Petidomo routines can access via getMasterConfig(). The routine getListConfig(), which is defined in config.c, too, used the "correct" mechanism to access MasterConfig, even though it could access it directly. Since I chose the same name ("MasterConfig" :->) for the local copy of the pointer, gcc warns that this variable shadows the static one. To get rid of this warning, and since it doesn't make one bit a difference, getListConfig() accessse the static variable directly now. @ text @d3 1 a3 1 $Revision: 1.20 $ @ 1.20 log @Due to a mix-up in the variable names, Petidomo expanded all list config file paths incorrectly when the list has a flat hierarchy. That is fixed now. @ text @d3 1 a3 1 $Revision: 1.19 $ a150 1 const struct PD_Config * MasterConfig; a198 4 /* Get the master configuration. */ MasterConfig = getMasterConfig(); @ 1.19 log @Get rid of all complaints from GCC 2.97 (except for two things which I do not want to change on my own) @ text @d3 1 a3 1 $Revision: 1.18 $ d223 1 a223 1 list_dir = MasterConfig->list_dir; @ 1.18 log @Mailing list config files may now have the suffix ".config" or ".conf". Similarly, if the list config file is in a separate directory, it may be called /config or /conf. @ text @d3 1 a3 1 $Revision: 1.17 $ d157 1 a157 1 char* list_dir; d214 1 a214 1 list_dir = text_easy_sprintf("%s/%s", MasterConfig->list_dir, listname); d296 1 a296 1 ListConfig->list_dir = list_dir; @ 1.17 log @As we agreed today, Petidomo is now open because licensed under GPL and always will be licensed under GPL, so use "Petidomo" as the program name everywhere and consistently. @ text @d3 1 a3 1 $Revision: 1.16 $ d218 1 a218 2 buffer = text_easy_sprintf("%s/%s.config", MasterConfig->list_dir, listname); list_dir = MasterConfig->list_dir; d221 13 a233 2 syslog(LOG_ERR, "Can't find a config file for list \"%s\".", listname); exit(1); @ 1.16 log @ListACLFile -> ACLFile @ text @d3 1 a3 1 $Revision: 1.15 $ d7 1 a7 1 This file is part of OpenPetidomo. d9 1 a9 1 OpenPetidomo is free software; you can redistribute it and/or modify d14 1 a14 1 OpenPetidomo is distributed in the hope that it will be useful, but @ 1.15 log @- ListType is no longer a required parameter; it now defaults to "open". @ text @d2 2 a3 2 $Source: /d1/e/petidomo/cvs/petidomo/source/config.c,v $ $Revision: 1.14 $ d176 1 a176 1 { "ListACLFile", CF_STRING, &list_acl_file }, @ 1.14 log @List's "AllowPublicSubscripiton" does not exist anymore. Now we have "SubscriptionType" with valid values "public", "admin" or "acknowledged". @ text @d3 1 a3 1 $Revision: 1.13 $ d187 1 a187 1 listtype = NULL; d191 1 a191 1 subtype = NULL; d266 1 a266 1 ListConfig->listtype = SUBSCRIPTION_PUBLIC; d268 1 a268 1 ListConfig->listtype = SUBSCRIPTION_ADMIN; d270 6 a275 1 ListConfig->listtype = SUBSCRIPTION_ACKED; @ 1.13 log @Removed the whole concept of "alien subscription". It was stupid to begin with and now that we'll have acknowledged subscriptions, it is useless, too. @ text @d3 1 a3 1 $Revision: 1.12 $ d139 1 a139 1 static bool allowpubsub; d164 1 a164 1 { "AllowPublicSubscription", CF_YES_NO, &allowpubsub }, d191 1 a191 1 allowpubsub = TRUE; d255 4 d264 8 a271 1 ListConfig->allowpubsub = allowpubsub; @ 1.12 log @Implemented spooling mechanism for requests and postings that need an acknowledgement to be processed. The code is there, it just isn't called yet. @ text @d3 1 a3 1 $Revision: 1.11 $ a139 1 static bool allowaliensub; a164 1 { "AllowAlienSubscription", CF_YES_NO, &allowaliensub }, a191 1 allowaliensub = TRUE; a260 1 ListConfig->allowaliensub = allowaliensub; @ 1.11 log @Added config entry "AcknowledgementFile" to the mailing list's config file. @ text @d3 1 a3 1 $Revision: 1.10 $ d43 2 a44 1 static char* list_dir = LOCALSTATEDIR; d62 1 d121 1 @ 1.10 log @Removed debugging output. @ text @d3 1 a3 1 $Revision: 1.9 $ d145 1 d177 1 d199 1 d286 1 @ 1.9 log @Rewrote Petidomo so that virtually any file's path can be configured at run-time now. @ text @d3 1 a3 1 $Revision: 1.8 $ a282 9 printf("archivepath: %s\n", ListConfig->archivepath); printf("intro_file: %s\n", ListConfig->intro_file); printf("desc_file: %s\n", ListConfig->desc_file); printf("sig_file: %s\n", ListConfig->sig_file); printf("header_file: %s\n", ListConfig->header_file); printf("acl_file: %s\n", ListConfig->acl_file); printf("address_file: %s\n", ListConfig->address_file); @ 1.8 log @Petidomo will now expect its master config file at SYSCONFDIR/petidomo.conf. This location can be changed at run-time with the command line parameter --masterconf. @ text @d3 1 a3 1 $Revision: 1.7 $ d23 1 d25 1 d38 1 a38 1 static char* mta = "/usr/sbin/sendmail"; d40 4 d57 4 d93 5 d115 4 d129 16 a144 11 static char* list_fqdn = NULL; static char* admin_password = NULL; static char* posting_password = NULL; static char* listtype = NULL; static char* reply_to = NULL; static char* postingfilter = NULL; static char* archivepath = NULL; static bool allowpubsub = TRUE; static bool allowaliensub = TRUE; static bool allowmembers = FALSE; static bool showonindex = TRUE; d152 3 a154 1 char buffer[4096]; a163 1 { "ShowOnIndex", CF_YES_NO, &showonindex }, d170 6 d179 19 d210 13 a222 1 sprintf(buffer, "lists/%s/config", listname); a259 1 ListConfig->showonindex = showonindex; d267 26 a292 1 ListConfig->archivepath = archivepath; @ 1.7 log @Replaced the old basedir-mechanism in Petidomo, which used to be the home directory of the petidomo user. Now, Petidomo expects its master config file in ETCDIR, which is '/etc' per default. All other paths will be set there at run-time. @ text @d3 1 a3 1 $Revision: 1.6 $ d39 1 a39 1 int InitPetidomo(void) d69 1 a69 1 rc = ReadConfig(ETCDIR "/petidomo.conf", MasterCF); d80 1 a80 1 syslog(LOG_ERR, "The master config file \"petidomo.conf\" doesn't set the host name."); d85 1 a85 1 syslog(LOG_ERR, "The master config file \"petidomo.conf\" doesn't set the admin password."); @ 1.6 log @Hardcoded the base directory /usr/local/petidomo for the moment. @ text @d3 1 a3 1 $Revision: 1.5 $ d34 8 a41 10 static char * fqdn = NULL; static char * master_password = NULL; static char * mta = "/usr/sbin/sendmail"; static char * mta_options = "-i -f%s"; int InitPetidomo(void) { char * basedir = "/usr/local/petidomo"; int rc; d45 2 a46 1 struct ConfigFile MasterCF[] = { d52 1 a52 1 }; d57 2 a58 1 if (MasterConfig == NULL) { d61 1 a61 1 } a66 8 /* chdir() into the base directory. */ rc = chdir(basedir); if (rc != 0) { syslog(LOG_ERR, "Failed to change current directory to \"%s\": %m", basedir); return -1; } d69 4 a72 3 rc = ReadConfig("etc/petidomo.conf", MasterCF); if (rc != 0) { syslog(LOG_ERR, "Failed to parse the master config file \"petidomo.conf\""); d74 1 a74 1 } d78 2 a79 1 if (fqdn == NULL) { d82 3 a84 2 } if (master_password == NULL) { d87 3 a89 2 } if (strstr(mta_options, "%s") == NULL) { d92 1 a92 1 } a95 1 MasterConfig->basedir = basedir; d102 1 a102 1 } d104 2 a105 3 const struct PD_Config * getMasterConfig(void) { d107 2 a108 1 } d110 14 a123 15 static char * list_fqdn = NULL; static char * admin_password = NULL; static char * posting_password = NULL; static char * listtype = NULL; static char * reply_to = NULL; static char * postingfilter = NULL; static char * archivepath = NULL; static bool allowpubsub = TRUE; static bool allowaliensub = TRUE; static bool allowmembers = FALSE; static bool showonindex = TRUE; const struct List_Config * getListConfig(const char * listname) { d132 2 a133 1 struct ConfigFile ListCF[] = { d146 1 a146 1 }; d156 1 a156 1 return getNodeData(node); d162 2 a163 1 if (rc != 0) { d166 1 a166 1 } d170 2 a171 1 if (listtype == NULL) { d174 1 a174 1 } d179 2 a180 1 if (ListConfig == NULL) { d183 1 a183 1 } d185 1 a185 1 ListConfig->listtype = LIST_OPEN; d187 1 a187 1 ListConfig->listtype = LIST_CLOSED; d189 3 a191 2 ListConfig->listtype = LIST_MODERATED; else { d194 1 a194 1 } d202 1 a202 1 CanonizeAddress(&(ListConfig->reply_to), ListConfig->fqdn); d210 1 a210 1 } @ 1.5 log @Removed the signature code and all code that depended on it. In the new Petidomo, the signature mechanism for server mails will work differently. @ text @d3 1 a3 1 $Revision: 1.4 $ a22 1 #include a41 1 struct passwd * pwd; a65 12 /* First of all, determine the home directory of the "petidomo" user. This will be our base directory for all operations. */ pwd = getpwnam("petidomo"); if (pwd != NULL) { if (strcmp(basedir, pwd->pw_dir) != 0) basedir = xstrdup(pwd->pw_dir); /* Replace the default above. */ endpwent(); } else syslog(LOG_WARNING, "User \"petidomo\" not found."); @ 1.4 log @Removed the global configuration options "DetachImmediately" and "ShowStatistics". Consequently removed all code that deals with these options, too. @ text @d3 1 a3 1 $Revision: 1.3 $ a38 1 static bool detach = FALSE; @ 1.3 log @ - Removed all debugging code. Now that Petidomo will be "rewritten" in C++, I need a new paradigm for debugging anyway and the old solution of mine was to messy for my taste anyway. - Petidomo no longer cares under what name it has been started. The different modes of operation will now be distinguished by a mandatory command line parameter. @ text @d3 1 a3 1 $Revision: 1.2 $ a39 1 static bool show_stats = TRUE; a54 2 { "DetachImmediately", CF_YES_NO, &detach }, { "ShowStatistics", CF_YES_NO, &show_stats }, a119 2 MasterConfig->detach = detach; MasterConfig->show_stats = show_stats; @ 1.2 log @ - Added correct GNU GPL copyright statements to the files. - Removed unnecessary include statements. @ text @d2 2 a3 2 $Source$ $Revision$ a75 1 debug((DEBUG_CONFIG, 9, "Looking for the home directory of user petidomo.")); a77 1 debug((DEBUG_CONFIG, 8, "Home directory of petidomo is \"%s\".", pwd->pw_dir)); a83 1 debug((DEBUG_CONFIG, 8, "Will use basedir \"%s\".", basedir)); a185 1 debug((DEBUG_CONFIG, 6, "getListConfig(): Loading config file \"%s\".", buffer)); a205 2 debug((DEBUG_CONFIG, 6, "Loaded config file successfully.")); debug((DEBUG_CONFIG, 4, "Read listtype is \"%s\".", listtype)); @ 1.1 log @Initial revision @ text @d2 17 a18 7 * $Source: /usr/local/libdata/cvs/simons/petidomo/src/petidomo/config.c,v $ * $Revision: 1.27 $ * $Date: 1998/06/01 21:17:43 $ * * Copyright (C) 1996 by CyberSolutions GmbH. * All rights reserved. */ d25 3 a27 3 #include #include #include d38 1 a38 1 static char * mta_options = "-f%s"; @ 1.1.1.1 log @Imported Petidomo 2.2 as found on www.petidomo.com. @ text @@