/*
* 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.
if ((enc_len > 1) && (enc[enc_len-2] == 13)) enc[enc_len-2] = 0;
if ((enc_len > 0) && (enc[enc_len-1] == 10)) enc[enc_len-1] = 0;
enc[enc_len] = 0;
- syslog(LOG_DEBUG, "Writing key '%s' (length=%d)", keyname, enc_len);
+ syslog(LOG_DEBUG, "netconfig: writing key '%s' (length=%d)", keyname, enc_len);
CtdlSetConfigStr(keyname, enc);
free(enc);
}
}
-/*
- * 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, "%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, "%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, "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_NOTICE, "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 *
*-----------------------------------------------------------------------------*/
* First try the neighbor nodes
*/
if (GetCount(IgnetCfg) == 0) {
- syslog(LOG_INFO, "IgnetCfg is empty!");
+ syslog(LOG_INFO, "netconfig: IgnetCfg is empty!");
if (nexthop != NULL) {
*nexthop = NULL;
}
/*
* If we get to this point, the supplied node name is bogus.
*/
- syslog(LOG_ERR, "Invalid node name <%s>", ChrPtr(node));
+ syslog(LOG_ERR, "netconfig: invalid node name <%s>", ChrPtr(node));
return(-1);
}
dh = opendir(ctdl_netcfg_dir);
if (!dh) return;
- syslog(LOG_INFO, "Legacy netconfig files exist - converting them!");
+ syslog(LOG_INFO, "netconfig: legacy netconfig files exist - converting them!");
while (dit = readdir(dh), dit != NULL) { // yes, we use the non-reentrant version; we're not in threaded mode yet
roomnum = atol(dit->d_name);
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";
}