Commit 3199915f authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(parameters): New file-local variable.

(CONFIG_FILE): New const.
(DATAFILE_NAME, BACKUPFILE_NAME, TEXTFILE_NAME, STATISTIC_NAME,
 PID_NAME, MEMUSE_NAME, DEFAULT_CLIENT_SERVICE,
 DEFAULT_MUX_SERVICE, TIMEOUT, GARBTIMEOUT, SYNCTIMEOUT,
 GARB_INTERVAL, SYNC_INTERVAL, SYNC_RETRY_INTERVAL, CONF_NAME_LEN,
 PWD_LEN, WHAT_DO_LEN, USERNAME_LEN, TEXT_LEN, BROADCAST_LEN,
 REGEXP_LEN, MAX_MARKS_PERSON, MAX_MARKS_TEXT, MAX_RECIPIENTS,
 MAX_COMM, MAX_FOOT, MAX_CREA_MISC, CACHE_CONFERENCES,
 CACHE_PERSONS, CACHE_TEXT_STATS, MARK_AS_READ_CHUNK,
 MAX_SUPER_CONF_LOOP, DEFAULT_NICE, MAXQUEUEDSIZE, MAXDEQUEUELEN):
 	Obsoleted by parameters. Removed.
(log_param, jubel, read_configuration): New file-local functions.
parent 7c016e48
/*
* $Id: server-config.c,v 0.23 1994/01/12 01:48:06 ceder Exp $
* $Id: server-config.c,v 0.24 1994/02/19 04:15:16 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,122 +23,189 @@
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* config.c
* server-config.c
*
* This is in a .c file to make it possible to change a value without having
* to recompile the entire server.
* to recompile the entire server (or, in fact, anything!)
*
*/
static char *rcsid = "$Id: server-config.c,v 0.23 1994/01/12 01:48:06 ceder Exp $";
static char *rcsid = "$Id: server-config.c,v 0.24 1994/02/19 04:15:16 ceder Exp $";
#include "rcs.h"
USE(rcsid);
#include <limits.h>
#include <stdio.h>
#include <sys/types.h>
#include <time.h>
#include <stdarg.h>
#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);
/* Default value for DEFAULT_DBASE_DIR. Since this is used in two
places in this file, use a define. */
/* FIXME: This should be set by autoconf. */
#define PREFIX "/usr/lyskom"
/* 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, &param.use_locale},
{"Prefix",
assign_string, 0, 1, PREFIX, &param.dbase_dir},
{"Send async",
assign_bool, 0, 1, "1", &param.send_async_messages},
{"Client port",
assign_string, 1, 1, NULL, &param.ip_client_port},
{"Mux port",
assign_string, 1, 1, NULL, &param.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},
#ifdef DEBUG
{"Never save",
assign_bool, 0, 1, "no", &param.never_save},
#endif
#ifdef LOGACCESSES
{"Log accesses",
assign_string, 0, 1, NULL, &param.logaccess_file},
#endif
/* The database files. */
{"Data file",
assign_string, 0, 1, "db/lyskomd-data", &param.datafile_name},
{"Backup file",
assign_string, 0, 1, "db/lyskomd-backup", &param.backupfile_name},
{"Text file",
assign_string, 0, 1, "db/lyskomd-texts", &param.textfile_name},
{"Text backup file",
assign_string, 0, 1, "db/lyskomd-texts", &param.textbackupfile_name},
/* Various log files */
{"Log statistics",
assign_string, 0, 1, "etc/lyskomd-log", &param.statistic_name},
{"Pid file",
assign_string, 0, 1, "etc/pid", &param.pid_name},
{"Memory usage file",
assign_string, 0, 1, "etc/memory-usage", &param.memuse_name},
/* Performance tuning parameters (milliseconds) */
{"Idle timeout",
assign_int, 0, 1, "120000", &param.timeout},
{"Garb timeout",
assign_int, 0, 1, "100", &param.garbtimeout},
{"Sync timeout",
assign_int, 0, 1, "0", &param.synctimeout},
/* Performance tuning parameters (minutes) */
{"Garb interval",
assign_int, 0, 1, "1440", &param.garb_interval},
{"Sync interval",
assign_int, 0, 1, "5", &param.sync_interval},
{"Sync retry interval",
assign_int, 0, 1, "1", &param.sync_retry_interval},
/* String limits */
{"Max conference name length",
assign_int, 0, 1, "60", &param.conf_name_len},
{"Max password length",
assign_int, 0, 1, "128", &param.pwd_len},
{"Max what am I doing length",
assign_int, 0, 1, "60", &param.what_do_len},
{"Max username length",
assign_int, 0, 1, "128", &param.username_len},
{"Max text length",
assign_int, 0, 1, "131072", &param.text_len},
{"Max broadcaset length",
assign_int, 0, 1, "1024", &param.broadcast_len},
{"Max regexp length",
assign_int, 0, 1, "1024", &param.regexp_len},
/* Text_stat limits */
{"Max marks per person",
assign_int, 0, 1, "2048", &param.max_marks_person},
{"Max marks per text",
assign_int, 0, 1, "1024", &param.max_marks_text},
{"Max recipients per text",
assign_int, 0, 1, "512", &param.max_recipients},
{"Max comments per text",
assign_int, 0, 1, "128", &param.max_comm},
{"Max footnotes per text",
assign_int, 0, 1, "32", &param.max_foot},
{"Max links per text",
assign_int, 0, 1, "512", &param.max_crea_misc},
/* Other client-visible configuration */
{"Max mark_as_read chunks",
assign_int, 0, 1, "128", &param.mark_as_read_chunk},
{"Max super_conf loop",
assign_int, 0, 1, "17", &param.max_super_conf_loop},
{"Default garb nice",
assign_int, 0, 1, "77", &param.default_nice},
{"Max client transmit queue",
assign_int, 0, 1, "300", &param.maxqueuedsize},
{"Max simultaneous client replies",
assign_int, 0, 1, "10", &param.maxdequeuelen},
/* Security options */
{"Anyone can create new persons",
assign_bool, 0, 1, "yes", &param.anyone_can_create_new_persons},
{"Anyone can create new conferences",
assign_bool, 0, 1, "yes", &param.anyone_can_create_new_confs},
{"Allow creation of persons before login",
assign_bool, 0, 1, "yes", &param.create_person_before_login},
{"Default change name capability",
assign_bool, 0, 1, "on", &param.default_change_name},
/* Cache configuration */
{"Cache conference limit",
assign_int, 0, 1, "20", &param.cache_conferences},
{"Cache person limit",
assign_int, 0, 1, "20", &param.cache_persons},
{"Cache text_stat limit",
assign_int, 0, 1, "20", &param.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},
/* 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.
* config file is found in DEFAULT_DBASE_DIR/CONFIG_FILE (before
* DEFAULT_DBASE_DIR is overriden, of course).
*/
const char * DEFAULT_DBASE_DIR = "/usr/lyskom";
const char * DEFAULT_DBASE_DIR = PREFIX;
const char *CONFIG_FILE = "etc/config";
/*
* Note: if you change any of the following three names you will have
* to change the name of the real files in db-nocrypt/db/ also.
*/
const char *DATAFILE_NAME = "db/lyskomd-data";
const char *BACKUPFILE_NAME = "db/lyskomd-backup";
const char *TEXTFILE_NAME = "db/lyskomd-texts";
const char *STATISTIC_NAME = "etc/lyskomd-log";
const char *PID_NAME = "etc/pid";
const char *MEMUSE_NAME = "etc/memory-usage";
/* Communications */
const char * DEFAULT_CLIENT_SERVICE = "lyskom"; /* Can be number! */
const char * DEFAULT_MUX_SERVICE = "lyskom-mux"; /* Can be number! */
/*
* The following should always be true:
* 0 <= SYNCTIMEOUT <= GARBTIMEOUT <= TIMEOUT
* Times in milliseconds.
*/
const int TIMEOUT = 120000; /* Timeout to select() when totally idle.
This shouldn't be too small, since
the various intervals below are
currently only checked this often. +++ */
const int GARBTIMEOUT = 100; /* Timeout to select() when garbing texts
but not syncing. */
const int SYNCTIMEOUT = 0; /* Timeout to select() when syncing. */
/* Times in minutes. */
const int GARB_INTERVAL = 60*24; /* Minutes between deletion of
expired texts. */
const int SYNC_INTERVAL = 30; /* Minutes between sync. */
const int SYNC_RETRY_INTERVAL = 5; /* 5 = Wait 5 minutes and retry after
an error while writing to disk. */
/* String limits */
const int CONF_NAME_LEN = 60; /* Conference (and Person) name */
const int PWD_LEN = 128; /* Password. It is not guaranteed that all
chars are significant. */
const int WHAT_DO_LEN = 60; /* what_am_i_doing */
const int USERNAME_LEN = 128; /* Max login-id from clients */
const int TEXT_LEN =131072;/* Max len of a text. */
const int BROADCAST_LEN = 1024; /* Max len of a broadcast message */
const int REGEXP_LEN = 1024; /* Max len of regexp. */
/* Text_stat limits */
const int MAX_MARKS_PERSON = 2048; /* Max marks per person */
const int MAX_MARKS_TEXT = 1024; /* Max marks per text */
const int MAX_RECIPIENTS = 256; /* Max recipients/cc_recipients per text */
const int MAX_COMM = 128; /* Max number of comments to a text */
const int MAX_FOOT = 32; /* Max number of footnotes to a text */
const int MAX_CREA_MISC = 512; /* Sum of recipients, cc_recipients, comm_to
* and footn_to must not exceed MAX_CREA_MISC
* when the text is created. */
/*
* Size of the cache. This tells us how many clean objects of each
* type to hold. Since all dirty items are also held in core, the
* actual size of the cache is bigger.
*/
const int CACHE_CONFERENCES = 20;
const int CACHE_PERSONS = 20;
const int CACHE_TEXT_STATS = 20;
/*
* Some other limits
*/
/*
* MAX_NO_OF_CONNECTIONS must be small enough. Each connection takes one
* file descriptor, and it is important that there are a few descriptors
* left so that it is possible to save the data base. lyskomd might crash
* if this number is too big and that many connectionattempts are made
* simultaneously.
*
* The following descriptors are open by LysKOM:
* stdin, stdout, stderr (stdin and stdout could probably be closed.
* The log() function prints to stderr.)
* TEXTFILE_NAME (always open)
* DATAFILE_NAME (often open)
* STATISTIC_NAME (open after a SIGUSR1)
* Thus, the max number of connections is the number of available file
* descriptors minus six. This has not been fully tested for a long
* while, so we subtract eight just to be on the safe side. That still
* gives 56 simultaneous users on a sun4, and that is enough for the
* time beeing. (If you need more connections you can ran a mux. Send
* mail to kom@lysator.liu.se for more info.)
* MAX_NO_OF_CONNECTIONS must be small enough. See comment in config.h.
*/
#if defined(HAVE_GETDTABLESIZE) || defined(HAVE_SYSCONF)
......@@ -147,26 +214,47 @@ int MAX_NO_OF_CONNECTIONS = 0; /* Initialized by main(). */
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";
const int MARK_AS_READ_CHUNK = 128; /* You can't mark more than this many
* texts as read in one call. */
/*
* Max number of nested super_confs a message will be forwarded before
* the server gives up.
*/
const int MAX_SUPER_CONF_LOOP = 17;
const int DEFAULT_NICE = 77; /* Number of days a text normally lives. */
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;
/* Max entries in the per-client transmit queue */
const int MAXQUEUEDSIZE = 300;
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;
}
/* Max entries in the per-client transmit queue to send at any one time */
const int MAXDEQUEUELEN = 10;
void
read_configuration(const char *conf_file)
{
read_config(conf_file, parameters);
/* FIXME///+++ Check config parameters for sanity */
}
/* What is whitespace? */
const unsigned char *WHITESPACE = (const unsigned char *)" \t\f\n\r";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment