X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=server%2Fstatserv.c;h=e0798669823d5f4c93b2cb4e4362aa7764ee4b0d;hb=61662168d4d4c1f7edb38cccac4b4a24dcecc58e;hp=b7759f3f6d36245631ac62c7e3942d5b71350758;hpb=26fdcc5e41254131ef755b14243c19d202b14d8e;p=yaz-moved-to-github.git diff --git a/server/statserv.c b/server/statserv.c index b7759f3..e079866 100644 --- a/server/statserv.c +++ b/server/statserv.c @@ -7,7 +7,18 @@ * Chas Woodfield, Fretwell Downing Datasystems. * * $Log: statserv.c,v $ - * Revision 1.53 1999-02-02 13:57:39 adam + * Revision 1.56 1999-06-10 11:45:30 adam + * Added bend_start, bend_stop handlers and removed pre_init. + * Handlers bend_start/bend_stop are called when service/daemon is + * started/stopped. + * + * Revision 1.55 1999/06/10 09:18:54 adam + * Modified so that pre_init is called when service/server is started. + * + * Revision 1.54 1999/04/16 14:45:55 adam + * Added interface for tcpd wrapper for access control. + * + * Revision 1.53 1999/02/02 13:57:39 adam * Uses preprocessor define WIN32 instead of WINDOWS to build code * for Microsoft WIN32. * @@ -187,7 +198,6 @@ * */ -#include #include #include #ifdef WIN32 @@ -203,9 +213,9 @@ #include #include -#include #include #include +#include #ifdef USE_XTIMOSI #include #endif @@ -232,8 +242,11 @@ statserv_options_block control_block = { 1024*1024, /* maximum PDU size (approx.) to allow */ "default-config", /* configuration name to pass to backend */ "", /* set user id */ - NULL, /* pre init handler */ + 0, /* bend_start handler */ + 0, /* bend_stop handler */ check_options, /* Default routine, for checking the run-time arguments */ + check_ip_tcpd, + "", 0 /* default value for inet deamon */ #ifdef WIN32 @@ -398,6 +411,8 @@ void statserv_closedown() free(pThreadHandles); } + if (control_block.bend_stop) + (*control_block.bend_stop)(&control_block); /* No longer require the critical section, since all threads are dead */ DeleteCriticalSection(&Thread_CritSect); } @@ -509,19 +524,6 @@ void statserv_closedown() iochan_destroy(p); } -static int check_ip(void *cd, const char *addr, int len, int type) -{ - const unsigned char *ip = (const unsigned char *) addr; - int i; - char str[64]; - - sprintf (str, "%u", *ip); - for (i = 1; i<4; i++) - sprintf (str + strlen(str), ".%u", ip[i]); - logf (LOG_DEBUG, "ip %s", str); - return 0; -} - static void listener(IOCHAN h, int event) { COMSTACK line = (COMSTACK) iochan_getdata(h); @@ -589,7 +591,8 @@ static void listener(IOCHAN h, int event) return; } } - if ((res = cs_listen_check(line, 0, 0, check_ip, 0)) < 0) + if ((res = cs_listen_check(line, 0, 0, control_block.check_ip, + control_block.daemon_name)) < 0) { logf(LOG_WARN, "cs_listen failed"); return; @@ -808,13 +811,13 @@ int statserv_start(int argc, char **argv) if (control_block.options_func(argc, argv)) return(1); + if (control_block.bend_start) + (*control_block.bend_start)(&control_block); #ifndef WIN32 if (control_block.inetd) inetd_connection(control_block.default_proto); else { - if (control_block.pre_init) - (*control_block.pre_init)(&control_block); if (control_block.dynamic) signal(SIGCHLD, catchchld); } @@ -855,7 +858,7 @@ int check_options(int argc, char **argv) int ret = 0, r; char *arg; - while ((ret = options("a:iszSl:v:u:c:w:t:k:", argv, argc, &arg)) != -2) + while ((ret = options("a:iszSl:v:u:c:w:t:k:d:", argv, argc, &arg)) != -2) { switch (ret) { @@ -888,6 +891,9 @@ int check_options(int argc, char **argv) case 'c': strcpy(control_block.configname, arg ? arg : ""); break; + case 'd': + strcpy(control_block.daemon_name, arg ? arg : ""); + break; case 't': if (!arg || !(r = atoi(arg))) { @@ -899,7 +905,7 @@ int check_options(int argc, char **argv) case 'k': if (!arg || !(r = atoi(arg))) { - fprintf(stderr, "%s: Specify positive timeout for -t.\n", me); + fprintf(stderr, "%s: Specify positive size for -k.\n", me); return(1); } control_block.maxrecordsize = r * 1024; @@ -917,7 +923,7 @@ int check_options(int argc, char **argv) default: fprintf(stderr, "Usage: %s [ -i -a -v " " -l -u -c -t " - " -k " + " -k -d " " -zsS -w ... ]\n", me); return(1); }