/* * $Id: server-config.c,v 0.33 1994/10/24 00:38:57 ceder Exp $ * Copyright (C) 1991, 1992, 1993, 1994 Lysator Academic Computer Association. * * This file is part of the LysKOM server. * * LysKOM 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 1, or (at your option) * any later version. * * LysKOM 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. * * You should have received a copy of the GNU General Public License * along with LysKOM; see the file COPYING. If not, write to * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN, * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, * MA 02139, USA. * * Please mail bug reports to bug-lyskom@lysator.liu.se. */ /* * server-config.c * * This is in a .c file to make it possible to change a value without having * to recompile the entire server (or, in fact, anything!) * * Compile with -DDEFAULT_PREFIX='"/usr/lyskom"' or something similar. */ static char *rcsid = "$Id: server-config.c,v 0.33 1994/10/24 00:38:57 ceder Exp $"; #include "rcs.h" USE(rcsid); #include #include #include #include #include #include "config.h" #include "server-config.h" #include "misc-types.h" #include "s-string.h" #include "kom-types.h" #include "param.h" #include "conf-file.h" #include "admin.h" #include "log.h" #include "manipulate.h" #include "lyskomd.h" static Success log_param(const char *val, const struct parameter *par); static Success jubel(const char *val, const struct parameter *par); static Success ident_param(const char *val, const struct parameter *par); /* See lyskomd.8 for more info about the parameters. Please remember to update lyskomd.8 if you add more parameters! Try to keep this list and the list in lyskomd.8 in the same order. */ static const struct parameter parameters[] = { /* "Normal" configuration */ {"Locale", assign_string, 0, 1, NULL, ¶m.use_locale}, {"Force ISO 8859-1", assign_bool, 0, 1, "no", ¶m.force_iso_8859_1}, {"Prefix", assign_string, 0, 1, DEFAULT_PREFIX, ¶m.dbase_dir}, {"Send async", assign_bool, 0, 1, "1", ¶m.send_async_messages}, {"Client port", assign_string, 1, 1, NULL, ¶m.ip_client_port}, {"Mux port", assign_string, 1, 1, NULL, ¶m.ip_mux_port}, {"Presentation of conferences", assign_conf_no, 0, 1, "1", &kom_info.conf_pres_conf}, {"Presentation of persons", assign_conf_no, 0, 1, "2", &kom_info.pers_pres_conf}, {"Motd-conference", assign_conf_no, 0, 1, "3", &kom_info.motd_conf}, {"News-conference", assign_conf_no, 0, 1, "4", &kom_info.kom_news_conf}, {"Message of the day", assign_text_no, 0, 1, "0", &kom_info.motd_of_lyskom}, #ifndef NDEBUG {"Never save", assign_bool, 0, 1, "no", ¶m.never_save}, #endif #ifdef LOGACCESSES {"Log accesses", assign_string, 0, 1, NULL, ¶m.logaccess_file}, #endif /* The database files. */ {"Data file", assign_string, 0, 1, "db/lyskomd-data", ¶m.datafile_name}, {"Backup file", assign_string, 0, 1, "db/lyskomd-backup", ¶m.backupfile_name}, {"Text file", assign_string, 0, 1, "db/lyskomd-texts", ¶m.textfile_name}, {"Text backup file", assign_string, 0, 1, "db/lyskomd-texts-backup", ¶m.textbackupfile_name}, /* Various log files */ {"Log file", assign_string, 0, 1, "etc/server-log", ¶m.logfile_name}, {"Log statistics", assign_string, 0, 1, "etc/lyskomd-log", ¶m.statistic_name}, {"Pid file", assign_string, 0, 1, "etc/pid", ¶m.pid_name}, {"Memory usage file", assign_string, 0, 1, "etc/memory-usage", ¶m.memuse_name}, /* Performance tuning parameters (milliseconds) */ {"Idle timeout", assign_int, 0, 1, "120000", ¶m.timeout}, {"Garb timeout", assign_int, 0, 1, "100", ¶m.garbtimeout}, {"Sync timeout", assign_int, 0, 1, "0", ¶m.synctimeout}, /* Performance tuning parameters (minutes) */ {"Garb interval", assign_int, 0, 1, "1440", ¶m.garb_interval}, {"Sync interval", assign_int, 0, 1, "5", ¶m.sync_interval}, {"Sync retry interval", assign_int, 0, 1, "1", ¶m.sync_retry_interval}, /* String limits */ {"Max conference name length", assign_int, 0, 1, "60", ¶m.conf_name_len}, {"Max password length", assign_int, 0, 1, "128", ¶m.pwd_len}, {"Max what am I doing length", assign_int, 0, 1, "60", ¶m.what_do_len}, {"Max username length", assign_int, 0, 1, "128", ¶m.username_len}, {"Max text length", assign_int, 0, 1, "131072", ¶m.text_len}, {"Max broadcaset length", assign_int, 0, 1, "1024", ¶m.broadcast_len}, {"Max regexp length", assign_int, 0, 1, "1024", ¶m.regexp_len}, /* Text_stat limits */ {"Max marks per person", assign_int, 0, 1, "2048", ¶m.max_marks_person}, {"Max marks per text", assign_int, 0, 1, "1024", ¶m.max_marks_text}, {"Max recipients per text", assign_int, 0, 1, "512", ¶m.max_recipients}, {"Max comments per text", assign_int, 0, 1, "128", ¶m.max_comm}, {"Max footnotes per text", assign_int, 0, 1, "32", ¶m.max_foot}, {"Max links per text", assign_int, 0, 1, "512", ¶m.max_crea_misc}, /* Other client-visible configuration */ {"Max mark_as_read chunks", assign_int, 0, 1, "128", ¶m.mark_as_read_chunk}, {"Max super_conf loop", assign_int, 0, 1, "17", ¶m.max_super_conf_loop}, {"Default garb nice", assign_int, 0, 1, "77", ¶m.default_nice}, {"Max client transmit queue", assign_int, 0, 1, "300", ¶m.maxqueuedsize}, {"Max simultaneous client replies", assign_int, 0, 1, "10", ¶m.maxdequeuelen}, {"Open files", assign_int, 0, 1, "-1", ¶m.no_files}, /* Security options */ {"Anyone can create new persons", assign_bool, 0, 1, "yes", ¶m.anyone_can_create_new_persons}, {"Anyone can create new conferences", assign_bool, 0, 1, "yes", ¶m.anyone_can_create_new_confs}, {"Allow creation of persons before login", assign_bool, 0, 1, "yes", ¶m.create_person_before_login}, {"Default change name capability", assign_bool, 0, 1, "on", ¶m.default_change_name}, {"Log login", assign_bool, 0, 1, "off", ¶m.log_login}, /* Cache configuration */ {"Cache conference limit", assign_int, 0, 1, "20", ¶m.cache_conferences}, {"Cache person limit", assign_int, 0, 1, "20", ¶m.cache_persons}, {"Cache text_stat limit", assign_int, 0, 1, "20", ¶m.cache_text_stats}, /* Echo the value to the log. */ {"Echo", log_param, 0, -1, NULL, NULL}, /* Register a forbidden text number. */ {"Jubel", jubel, 0, -1, NULL, NULL}, {"Ident-authentication", ident_param, 0, 1, "try", ¶m.authentication_level}, /* end marker */ {NULL, NULL, 0, 0, NULL, NULL}}; /* Where to save things. These are used by lyskomd and dbck. */ /* * DEFAULT_DBASE_DIR can be overriden in the config file. The default * config file is found in DEFAULT_DBASE_DIR/CONFIG_FILE (before * DEFAULT_DBASE_DIR is overriden, of course). */ const char * DEFAULT_DBASE_DIR = DEFAULT_PREFIX; const char *CONFIG_FILE = "etc/config"; /* * The following should always be true: * 0 <= SYNCTIMEOUT <= GARBTIMEOUT <= TIMEOUT * Times in milliseconds. */ /* * MAX_NO_OF_CONNECTIONS must be small enough. See comment in config.h. */ #if defined(HAVE_GETDTABLESIZE) || defined(HAVE_SYSCONF) int MAX_NO_OF_CONNECTIONS = 0; /* Initialized by main(). */ #else const int MAX_NO_OF_CONNECTIONS = (OPEN_MAX - PROTECTED_FDS); #endif /* What is whitespace? */ const unsigned char *WHITESPACE = (const unsigned char *)" \t\f\n\r"; static Success log_param(const char *val, const struct parameter *par) { if (val != NULL) log ("config: %s\n", val); return OK; } static Success jubel(const char *val, const struct parameter *par) { long a, b, c; int res; if (val == NULL) return OK; res = sscanf(val, "%ld %ld %ld", &a, &b, &c); switch (res) { case 3: register_jubel (a, b, c); break; case 2: register_jubel (a, 0, b); break; default: log ("%s expecting 2 or 3 integers as args\n", par->name); return FAILURE; } return OK; } static Success ident_param(const char *val, const struct parameter *par) { if (val == NULL) restart_kom("ident_param(): val == NULL\n"); if (!strcmp(val, "off") || !strcmp(val, "never")) { *(int*)par->value = 0; } else if (!strcmp(val, "on") || !strcmp(val, "try")) { *(int*)par->value = 1; } else if (!strcmp(val, "require") || !strcmp(val, "required")) { *(int*)par->value = 2; } else { log ("%s expects \"never\", \"try\" or \"required\" as argument\n", par->name); return FAILURE; } return OK; } void read_configuration(const char *conf_file) { read_config(conf_file, parameters); /* FIXME///+++ Check config parameters for sanity */ }