X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fctdlproto%2Fserv_session.c;h=fa8186635381a62e51bccfd064165f57d6c4ee66;hb=50ff39d933b7178377b3a67f8edc31ffa42ffd28;hp=4aaba407226199187b100748f5114bf486e06a92;hpb=0475c981817d12900332693297a77a9ae7168129;p=citadel.git diff --git a/citadel/modules/ctdlproto/serv_session.c b/citadel/modules/ctdlproto/serv_session.c index 4aaba4072..fa8186635 100644 --- a/citadel/modules/ctdlproto/serv_session.c +++ b/citadel/modules/ctdlproto/serv_session.c @@ -1,7 +1,7 @@ /* * Server functions which perform operations on user objects. * - * Copyright (c) 1987-2015 by the citadel.org team + * Copyright (c) 1987-2019 by the citadel.org team * * This program is open source software; you can redistribute it and/or * modify it under the terms of the GNU General Public License, version 3. @@ -14,12 +14,12 @@ #include #include - #include "citserver.h" #include "svn_revision.h" #include "ctdl_module.h" #include "config.h" + void cmd_noop(char *argbuf) { cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() ); @@ -31,6 +31,7 @@ void cmd_qnop(char *argbuf) /* do nothing, this command returns no response */ } + /* * Set or unset asynchronous protocol mode */ @@ -46,9 +47,8 @@ void cmd_asyn(char *argbuf) } - /* - * cmd_info() - tell the client about this server + * cmd_info() - Identify this server and its capabilities to the client */ void cmd_info(char *cmdbuf) { cprintf("%d Server info:\n", LISTING_FOLLOWS); @@ -83,12 +83,11 @@ void cmd_info(char *cmdbuf) { cprintf("%s\n", CtdlGetConfigStr("c_default_cal_zone")); - /* thread load averages -- temporarily disabled during refactoring of this code */ - cprintf("0\n"); /* load average */ - cprintf("0\n"); /* worker average */ - cprintf("0\n"); /* thread count */ - + cprintf("0\n"); /* load average (no longer used) */ + cprintf("0\n"); /* worker average (no longer used) */ + cprintf("0\n"); /* thread count (no longer used) */ cprintf("1\n"); /* yes, Sieve mail filtering is supported */ + cprintf("%d\n", CtdlGetConfigInt("c_enable_fulltext")); cprintf("%s\n", svn_revision()); @@ -100,10 +99,10 @@ void cmd_info(char *cmdbuf) { } cprintf("%d\n", CtdlGetConfigInt("c_guest_logins")); - cprintf("000\n"); } + /* * echo */ @@ -112,6 +111,7 @@ void cmd_echo(char *etext) cprintf("%d %s\n", CIT_OK, etext); } + /* * get the paginator prompt */ @@ -125,7 +125,6 @@ void cmd_more(char *argbuf) { */ void cmd_iden(char *argbuf) { - CitContext *CCC = MyContext(); int dev_code; int cli_code; int rev_level; @@ -146,41 +145,38 @@ void cmd_iden(char *argbuf) from_host[sizeof from_host - 1] = 0; if (num_parms(argbuf)>=5) extract_token(from_host, argbuf, 4, '|', sizeof from_host); - CCC->cs_clientdev = dev_code; - CCC->cs_clienttyp = cli_code; - CCC->cs_clientver = rev_level; - safestrncpy(CCC->cs_clientname, desc, sizeof CCC->cs_clientname); - CCC->cs_clientname[31] = 0; - - /* For local sockets and public clients, trust the hostname supplied by the client */ - if ( (CCC->is_local_socket) || (CtdlIsPublicClient()) ) { - safestrncpy(CCC->cs_host, from_host, sizeof CCC->cs_host); - CCC->cs_host[sizeof CCC->cs_host - 1] = 0; - CCC->cs_addr[0] = 0; + CC->cs_clientdev = dev_code; + CC->cs_clienttyp = cli_code; + CC->cs_clientver = rev_level; + safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname); + CC->cs_clientname[31] = 0; + + /* For local sockets, allow the client to supply the user's origin address */ + if (CC->is_local_socket) { + safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host); + CC->cs_host[sizeof CC->cs_host - 1] = 0; + CC->cs_addr[0] = 0; } - syslog(LOG_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n", + syslog(LOG_NOTICE, "session: client %d/%d/%01d.%02d (%s) from %s", dev_code, cli_code, (rev_level / 100), (rev_level % 100), desc, - CCC->cs_host + CC->cs_host ); cprintf("%d Ok\n",CIT_OK); } + /* * Terminate another running session */ void cmd_term(char *cmdbuf) { - int session_num; - int terminated = 0; - - session_num = extract_int(cmdbuf, 0); - - terminated = CtdlTerminateOtherSession(session_num); + int session_num = extract_int(cmdbuf, 0); + int terminated = CtdlTerminateOtherSession(session_num); if (terminated < 0) { cprintf("%d You can't kill your own session.\n", ERROR + ILLEGAL_VALUE); @@ -192,8 +188,7 @@ void cmd_term(char *cmdbuf) cprintf("%d Session terminated.\n", CIT_OK); } else { - cprintf("%d You are not allowed to do that.\n", - ERROR + HIGHER_ACCESS_REQUIRED); + cprintf("%d You are not allowed to do that.\n", ERROR + HIGHER_ACCESS_REQUIRED); } } else { @@ -204,23 +199,21 @@ void cmd_term(char *cmdbuf) void cmd_time(char *argbuf) { - time_t tv; - struct tm tmp; - - tv = time(NULL); - localtime_r(&tv, &tmp); - - /* timezone and daylight global variables are not portable. */ + time_t tv; + struct tm tmp; + + tv = time(NULL); + localtime_r(&tv, &tmp); + + /* timezone and daylight global variables are not portable. */ #ifdef HAVE_STRUCT_TM_TM_GMTOFF - cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst, server_startup_time); + cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst, server_startup_time); #else - cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst, server_startup_time); + cprintf("%d %ld|%ld|%d|%ld\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst, server_startup_time); #endif } - - /*****************************************************************************/ /* MODULE INITIALIZATION STUFF */ /*****************************************************************************/ @@ -230,14 +223,12 @@ CTDL_MODULE_INIT(serv_session) if (!threading) { CtdlRegisterProtoHook(cmd_noop, "NOOP", "no operation"); CtdlRegisterProtoHook(cmd_qnop, "QNOP", "no operation with no response"); -; CtdlRegisterProtoHook(cmd_asyn, "ASYN", "enable asynchronous server responses"); CtdlRegisterProtoHook(cmd_info, "INFO", "fetch server capabilities and configuration"); CtdlRegisterProtoHook(cmd_echo, "ECHO", "echo text back to the client"); CtdlRegisterProtoHook(cmd_more, "MORE", "fetch the paginator prompt"); CtdlRegisterProtoHook(cmd_iden, "IDEN", "identify the client software and location"); CtdlRegisterProtoHook(cmd_term, "TERM", "terminate another running session"); - CtdlRegisterProtoHook(cmd_time, "TIME", "fetch the date and time from the server"); } /* return our id for the Log */