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
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)
* 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.
#include "ctdl_module.h"
#include "serv_extensions.h"
#include "ecrash.h"
-
#include "citserver.h"
#include "user_ops.h"
#include "locate_host.h"
return can_do;
}
+
void CtdlEndSingleUser(void)
{
begin_critical_section(S_SINGLE_USER);
return want_single_user;
}
+
int CtdlIsSingleUser(void)
{
if (want_single_user)
}
-
-
-
/*
* Locate a context by its session number and terminate it if the user is able.
* User can NOT terminate their current session.
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';
}
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()) {
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 */
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 */
-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
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);
}
}
-/*
- * 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();
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");
}
-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
*/
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);
/*
* 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.
}
-/*
- * 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 *
*-----------------------------------------------------------------------------*/
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";
}
+++ /dev/null
-/*
- * 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 <stdio.h>
-#include <libcitadel.h>
-#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";
-}
/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;'`
S_SUPPMSGMAIN,
S_CONFIG,
S_HOUSEKEEPING,
- S_NTTLIST,
S_DIRECTORY,
S_NETCONFIGS,
S_PUBLIC_CLIENTS,