From 1fee2a05df6383f00214b7681a0be120f6fc7e1f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 24 Jan 2018 10:47:07 -0500 Subject: [PATCH] more trimming away of ignet stuffs --- citadel/Makefile.in | 4 +- citadel/context.c | 10 +-- citadel/context.h | 2 - citadel/include/ctdl_module.h | 9 --- citadel/modules/ctdlproto/serv_file.c | 108 ------------------------- citadel/modules/network/serv_network.c | 27 ------- citadel/netconfig.c | 73 +---------------- citadel/nttlist.c | 93 --------------------- citadel/scripts/mk_module_init.sh | 2 +- citadel/server.h | 1 - 10 files changed, 7 insertions(+), 322 deletions(-) delete mode 100644 citadel/nttlist.c diff --git a/citadel/Makefile.in b/citadel/Makefile.in index 24bb68f4e..edcdd66d3 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -81,7 +81,7 @@ SOURCES=utils/citmail.c \ locate_host.c auth.c msgbase.c parsedate.c \ room_ops.c euidindex.c server_main.c ldap.c \ support.c sysdep.c user_ops.c journaling.c threads.c \ - context.c netconfig.c nttlist.c md5.c + context.c netconfig.c md5.c include Make_sources @@ -136,7 +136,7 @@ SERV_OBJS = server_main.o utillib/citadel_dirs.o \ internet_addressing.o journaling.o \ parsedate.o genstamp.o ecrash.o threads.o context.o \ clientsocket.o modules_init.o modules_upgrade.o $(SERV_MODULES) \ - svn_revision.o ldap.o netconfig.o nttlist.o md5.o + svn_revision.o ldap.o netconfig.o md5.o citserver$(EXEEXT): $(SERV_OBJS) $(CC) $(SERV_OBJS) $(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) $(SERVER_LIBS) $(RESOLV) -o citserver$(EXEEXT) diff --git a/citadel/context.c b/citadel/context.c index 385f9a779..47da2679f 100644 --- a/citadel/context.c +++ b/citadel/context.c @@ -2,7 +2,7 @@ * Citadel context management stuff. * Here's where we (hopefully) have all the code that manipulates contexts. * - * Copyright (c) 1987-2015 by the citadel.org team + * Copyright (c) 1987-2018 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. @@ -16,7 +16,6 @@ #include "ctdl_module.h" #include "serv_extensions.h" #include "ecrash.h" - #include "citserver.h" #include "user_ops.h" #include "locate_host.h" @@ -52,6 +51,7 @@ int CtdlTrySingleUser(void) return can_do; } + void CtdlEndSingleUser(void) { begin_critical_section(S_SINGLE_USER); @@ -65,6 +65,7 @@ int CtdlWantSingleUser(void) return want_single_user; } + int CtdlIsSingleUser(void) { if (want_single_user) @@ -77,9 +78,6 @@ int CtdlIsSingleUser(void) } - - - /* * Locate a context by its session number and terminate it if the user is able. * User can NOT terminate their current session. @@ -494,7 +492,6 @@ void begin_session(CitContext *con) strcpy(con->lastcmdname, " "); strcpy(con->cs_clientname, "(unknown)"); strcpy(con->curr_user, NLI); - *con->net_node = '\0'; *con->fake_username = '\0'; *con->fake_hostname = '\0'; *con->fake_roomname = '\0'; @@ -548,7 +545,6 @@ void begin_session(CitContext *con) } con->cs_flags = 0; con->upload_type = UPL_FILE; - con->dl_is_net = 0; con->nologin = 0; if (((CtdlGetConfigInt("c_maxsessions") > 0)&&(num_sessions > CtdlGetConfigInt("c_maxsessions"))) || CtdlWantSingleUser()) { diff --git a/citadel/context.h b/citadel/context.h index 744fcb600..dacac07a2 100644 --- a/citadel/context.h +++ b/citadel/context.h @@ -82,7 +82,6 @@ struct CitContext { int curr_view; /* The view type for the current user/room */ int is_master; /* Is this session logged in using the master user? */ - char net_node[32] ;/* Is the client another Citadel server? */ time_t previous_login; /* Date/time of previous login */ char lastcmdname[5]; /* name of last command executed */ unsigned cs_flags; /* miscellaneous flags */ @@ -115,7 +114,6 @@ struct CitContext { char upl_comment[256]; char upl_filedir[PATH_MAX]; char upl_mimetype[64]; - char dl_is_net; char upload_type; struct ctdluser user; /* Database record buffers */ diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index c08333e4b..3783a0456 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -367,16 +367,7 @@ int CtdlIsValidNode(const StrBuf **nexthop, -int CtdlNetworkTalkingTo(const char *nodename, long len, int operation); -/* - * Operations that can be performed by network_talking_to() - */ -enum { - NTT_ADD, - NTT_REMOVE, - NTT_CHECK -}; /* * Expose API calls from user_ops.c diff --git a/citadel/modules/ctdlproto/serv_file.c b/citadel/modules/ctdlproto/serv_file.c index 44a5d3613..29b546056 100644 --- a/citadel/modules/ctdlproto/serv_file.c +++ b/citadel/modules/ctdlproto/serv_file.c @@ -365,13 +365,6 @@ void cmd_clos(char *cmdbuf) fclose(CC->download_fp); CC->download_fp = NULL; - - if (CC->dl_is_net == 1) { - CC->dl_is_net = 0; - snprintf(buf, sizeof buf, "%s/%s", ctdl_netout_dir, CC->net_node); - unlink(buf); - } - cprintf("%d Ok\n", CIT_OK); } @@ -524,105 +517,6 @@ void cmd_writ(char *cmdbuf) } -/* - * cmd_ndop() - open a network spool file for downloading - */ -void cmd_ndop(char *cmdbuf) -{ - struct CitContext *CCC = CC; - char pathname[256]; - struct stat statbuf; - - if (IsEmptyStr(CCC->net_node)) { - cprintf("%d Not authenticated as a network node.\n", - ERROR + NOT_LOGGED_IN); - return; - } - - if (CCC->download_fp != NULL) { - cprintf("%d You already have a download file open.\n", - ERROR + RESOURCE_BUSY); - return; - } - - snprintf(pathname, sizeof pathname, - "%s/%s", - ctdl_netout_dir, - CCC->net_node); - - /* first open the file in append mode in order to create a - * zero-length file if it doesn't already exist - */ - CCC->download_fp = fopen(pathname, "a"); - if (CCC->download_fp != NULL) - fclose(CCC->download_fp); - - /* now open it */ - CCC->download_fp = fopen(pathname, "r"); - if (CCC->download_fp == NULL) { - cprintf("%d cannot open %s: %s\n", - ERROR + INTERNAL_ERROR, pathname, strerror(errno)); - return; - } - - - /* set this flag so other routines know that the download file - * currently open is a network spool file - */ - CCC->dl_is_net = 1; - - stat(pathname, &statbuf); - CCC->download_fp_total = statbuf.st_size; - cprintf("%d %ld\n", CIT_OK, (long)statbuf.st_size); -} - - -/* - * cmd_nuop() - open a network spool file for uploading - */ -void cmd_nuop(char *cmdbuf) -{ - static int seq = 1; - - if (IsEmptyStr(CC->net_node)) { - cprintf("%d Not authenticated as a network node.\n", - ERROR + NOT_LOGGED_IN); - return; - } - - if (CC->upload_fp != NULL) { - cprintf("%d You already have an upload file open.\n", - ERROR + RESOURCE_BUSY); - return; - } - - snprintf(CC->upl_path, sizeof CC->upl_path, - "%s/%s.%04lx.%04x", - ctdl_nettmp_dir, - CC->net_node, - (long)getpid(), - ++seq - ); - - CC->upload_fp = fopen(CC->upl_path, "r"); - if (CC->upload_fp != NULL) { - fclose(CC->upload_fp); - CC->upload_fp = NULL; - cprintf("%d '%s' already exists\n", ERROR + ALREADY_EXISTS, CC->upl_path); - return; - } - - CC->upload_fp = fopen(CC->upl_path, "w"); - if (CC->upload_fp == NULL) { - cprintf("%d Cannot open %s: %s\n", ERROR + INTERNAL_ERROR, CC->upl_path, strerror(errno)); - return; - } - - CC->upload_type = UPL_NET; - cprintf("%d Ok\n", CIT_OK); -} - - void files_logout_hook(void) { CitContext *CCC = MyContext(); @@ -786,8 +680,6 @@ CTDL_MODULE_INIT(file_ops) CtdlRegisterProtoHook(cmd_ucls, "UCLS", "Close an upload file transfer"); CtdlRegisterProtoHook(cmd_read, "READ", "File transfer read operation"); CtdlRegisterProtoHook(cmd_writ, "WRIT", "File transfer write operation"); - CtdlRegisterProtoHook(cmd_ndop, "NDOP", "Open a network spool file for download"); - CtdlRegisterProtoHook(cmd_nuop, "NUOP", "Open a network spool file for upload"); CtdlRegisterProtoHook(cmd_oimg, "OIMG", "Open an image file for download"); CtdlRegisterProtoHook(cmd_uimg, "UIMG", "Upload an image file"); CtdlRegisterProtoHook(cmd_mesg, "MESG", "fetch system banners"); diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index 4434044de..36b23527a 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -318,31 +318,6 @@ void network_do_queue(void) } -void network_logout_hook(void) -{ - CitContext *CCC = MyContext(); - - /* - * If we were talking to a network node, we're not anymore... - */ - if (!IsEmptyStr(CCC->net_node)) { - CtdlNetworkTalkingTo(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE); - CCC->net_node[0] = '\0'; - } -} - - -void network_cleanup_function(void) -{ - struct CitContext *CCC = CC; - - if (!IsEmptyStr(CCC->net_node)) { - CtdlNetworkTalkingTo(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE); - CCC->net_node[0] = '\0'; - } -} - - /* * Module entry point */ @@ -353,8 +328,6 @@ CTDL_MODULE_INIT(network) if (!threading) { CtdlFillSystemContext(&networker_spool_CC, "CitNetSpool"); - CtdlRegisterSessionHook(network_cleanup_function, EVT_STOP, PRIO_STOP + 30); - CtdlRegisterSessionHook(network_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 10); CtdlRegisterRoomHook(network_room_handler); CtdlRegisterCleanupHook(destroy_network_queue_room_locked); CtdlRegisterSessionHook(network_do_queue, EVT_TIMER, PRIO_QUEUE + 10); diff --git a/citadel/netconfig.c b/citadel/netconfig.c index e59337f27..a21c39f50 100644 --- a/citadel/netconfig.c +++ b/citadel/netconfig.c @@ -1,7 +1,7 @@ /* * This module handles loading, saving, and parsing of room network configurations. * - * Copyright (c) 2000-2017 by the citadel.org team + * Copyright (c) 2000-2018 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. @@ -622,76 +622,6 @@ int CtdlNetconfigCheckRoomaccess(char *errmsgbuf, size_t n, const char* RemoteId } -/* - * cmd_netp() - authenticate to the server as another Citadel node polling - * for network traffic - */ -void cmd_netp(char *cmdbuf) -{ - struct CitContext *CCC = CC; - HashList *working_ignetcfg; - char *node; - StrBuf *NodeStr; - long nodelen; - int v; - - const StrBuf *secret = NULL; - const StrBuf *nexthop = NULL; - char err_buf[SIZ] = ""; - - /* Authenticate */ - node = CCC->curr_user; - nodelen = extract_token(CCC->curr_user, cmdbuf, 0, '|', sizeof CCC->curr_user); - NodeStr = NewStrBufPlain(node, nodelen); - /* load the IGnet Configuration to check node validity */ - working_ignetcfg = CtdlLoadIgNetCfg(); - v = CtdlIsValidNode(&nexthop, &secret, NodeStr, working_ignetcfg, NULL); - if (v != 0) { - snprintf(err_buf, sizeof err_buf, - "An unknown Citadel server called \"%s\" attempted to connect from %s [%s].\n", - node, CCC->cs_host, CCC->cs_addr - ); - syslog(LOG_WARNING, "netconfig: %s", err_buf); - cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED); - CtdlAideMessage(err_buf, "IGNet Networking"); - DeleteHash(&working_ignetcfg); - FreeStrBuf(&NodeStr); - return; - } - - extract_token(CCC->user.password, cmdbuf, 1, '|', sizeof CCC->user.password); - if (strcasecmp(CCC->user.password, ChrPtr(secret))) { - snprintf(err_buf, sizeof err_buf, - "A Citadel server at %s [%s] failed to authenticate as network node \"%s\".\n", - CCC->cs_host, CCC->cs_addr, node - ); - syslog(LOG_WARNING, "netconfig: %s", err_buf); - cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED); - - CtdlAideMessage(err_buf, "IGNet Networking"); - DeleteHash(&working_ignetcfg); - FreeStrBuf(&NodeStr); - return; - } - - if (CtdlNetworkTalkingTo(node, nodelen, NTT_CHECK)) { - syslog(LOG_WARNING, "netconfig: duplicate session for network node <%s>", node); - cprintf("%d Already talking to %s right now\n", ERROR + RESOURCE_BUSY, node); - DeleteHash(&working_ignetcfg); - FreeStrBuf(&NodeStr); - return; - } - nodelen = safestrncpy(CCC->net_node, node, sizeof CCC->net_node); - CtdlNetworkTalkingTo(CCC->net_node, nodelen, NTT_ADD); - syslog(LOG_INFO, "netconfig: network node <%s> logged in from %s [%s]", - CCC->net_node, CCC->cs_host, CCC->cs_addr - ); - cprintf("%d authenticated as network node '%s'\n", CIT_OK, CCC->net_node); - DeleteHash(&working_ignetcfg); - FreeStrBuf(&NodeStr); -} - - /*-----------------------------------------------------------------------------* * Network maps: evaluate other nodes * *-----------------------------------------------------------------------------*/ @@ -942,7 +872,6 @@ CTDL_MODULE_INIT(netconfig) convert_legacy_netcfg_files(); CtdlRegisterProtoHook(cmd_gnet, "GNET", "Get network config"); CtdlRegisterProtoHook(cmd_snet, "SNET", "Set network config"); - CtdlRegisterProtoHook(cmd_netp, "NETP", "Identify as network poller"); } return "netconfig"; } diff --git a/citadel/nttlist.c b/citadel/nttlist.c deleted file mode 100644 index 34d698442..000000000 --- a/citadel/nttlist.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This module handles shared rooms, inter-Citadel mail, and outbound - * mailing list processing. - * - * Copyright (c) 2000-2017 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. - * - * This program 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 "sysdep.h" -#include -#include -#include "ctdl_module.h" -#include "serv_extensions.h" - -/*-----------------------------------------------------------------------------* - * Network maps: evaluate other nodes * - *-----------------------------------------------------------------------------*/ - -/* - * network_talking_to() -- concurrency checker - */ -static HashList *nttlist = NULL; -int CtdlNetworkTalkingTo(const char *nodename, long len, int operation) -{ - - int retval = 0; - HashPos *Pos = NULL; - void *vdata; - - begin_critical_section(S_NTTLIST); - - switch(operation) { - - case NTT_ADD: - if (nttlist == NULL) - nttlist = NewHash(1, NULL); - Put(nttlist, nodename, len, NewStrBufPlain(nodename, len), HFreeStrBuf); - syslog(LOG_DEBUG, "nttlist: added <%s>\n", nodename); - break; - case NTT_REMOVE: - if ((nttlist == NULL) || - (GetCount(nttlist) == 0)) - break; - Pos = GetNewHashPos(nttlist, 1); - if (GetHashPosFromKey (nttlist, nodename, len, Pos)) - DeleteEntryFromHash(nttlist, Pos); - DeleteHashPos(&Pos); - syslog(LOG_DEBUG, "nttlist: removed <%s>\n", nodename); - - break; - - case NTT_CHECK: - if ((nttlist == NULL) || - (GetCount(nttlist) == 0)) - break; - if (GetHash(nttlist, nodename, len, &vdata)) - retval ++; - syslog(LOG_DEBUG, "nttlist: have [%d] <%s>\n", retval, nodename); - break; - } - - end_critical_section(S_NTTLIST); - return(retval); -} - -void cleanup_nttlist(void) -{ - begin_critical_section(S_NTTLIST); - DeleteHash(&nttlist); - end_critical_section(S_NTTLIST); -} - - - - -/* - * Module entry point - */ -CTDL_MODULE_INIT(nttlist) -{ - if (!threading) - { - CtdlRegisterCleanupHook(cleanup_nttlist); - } - return "nttlist"; -} diff --git a/citadel/scripts/mk_module_init.sh b/citadel/scripts/mk_module_init.sh index ade4e9698..3d684df2b 100755 --- a/citadel/scripts/mk_module_init.sh +++ b/citadel/scripts/mk_module_init.sh @@ -30,7 +30,7 @@ U_FILE="$CUR_DIR/modules_upgrade.c" /usr/bin/printf "Scanning extension modules for entry points.\n" -STATIC_FIRST_MODULES="control modules euidindex msgbase nttlist database" +STATIC_FIRST_MODULES="control modules euidindex msgbase database" DYNAMIC_MODULES=`grep CTDL_MODULE_INIT modules/*/*.c |$SED 's;.*(\(.*\));\1;'` if test -d user_modules; then USER_MODULES=`grep CTDL_MODULE_INIT user_modules/*/*.c |$SED 's;.*(\(.*\));\1;'` diff --git a/citadel/server.h b/citadel/server.h index 97be8d1b1..01d09c693 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -147,7 +147,6 @@ enum { S_SUPPMSGMAIN, S_CONFIG, S_HOUSEKEEPING, - S_NTTLIST, S_DIRECTORY, S_NETCONFIGS, S_PUBLIC_CLIENTS, -- 2.30.2