- move serv_network.h into modules/network where it belongs...
- move structs out of serv_network.h into their respective headers
- serv_expire doesn't need serv_network.h anymore, it seems to get the usetable struct from elsewhere
- the netfilter module was moved to the network directory, it seems to be closely dangled to networking
- move all code about the netfilter (config reading) into serv_netfilter.c
- move the code networker related from msgbase.c:CtdlDoIHavePermissionToPostInThisRoom() into serv_netconfig.c:netconfig_check_roomaccess()
- move the filterlist instance into serv_netfilter.c
lesson learned the hard way today: if you move a header, flush the dependencies, else the make process will abort with no usefull message at all.
-> Gentlemen please flush the dependencies and rebootstrap your workingcopy.
#include "msgbase.h"
#include "user_ops.h"
#include "control.h"
-#include "serv_network.h" /* Needed for definition of UseTable */
#include "threads.h"
#include "context.h"
+++ /dev/null
-/*
- * A server-side module for Citadel designed to filter idiots off the network.
- *
- * Copyright (c) 2002-2009 by the citadel.org team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <pwd.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#include <sys/wait.h>
-#include <string.h>
-#include <limits.h>
-#include <libcitadel.h>
-#include "citadel.h"
-#include "server.h"
-#include "citserver.h"
-#include "support.h"
-#include "config.h"
-#include "control.h"
-#include "user_ops.h"
-#include "database.h"
-#include "msgbase.h"
-#include "serv_network.h" /* Needed for defenition of FilterList */
-
-
-#include "ctdl_module.h"
-
-
-/*
- * This handler detects whether an incoming network message is from some
- * moron user who the site operator has elected to filter out. If a match
- * is found, the message is rejected.
- */
-int filter_the_idiots(struct CtdlMessage *msg, char *target_room) {
- FilterList *fptr;
- int zap_user = 0;
- int zap_room = 0;
- int zap_node = 0;
-
- if ( (msg == NULL) || (filterlist == NULL) ) {
- return(0);
- }
-
- for (fptr = filterlist; fptr != NULL; fptr = fptr->next) {
-
- zap_user = 0;
- zap_room = 0;
- zap_node = 0;
-
- if (msg->cm_fields['A'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['A'], fptr->fl_user))
- || (fptr->fl_user[0] == 0) ) {
- zap_user = 1;
- }
- }
-
- if (msg->cm_fields['C'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['C'], fptr->fl_room))
- || (fptr->fl_room[0] == 0) ) {
- zap_room = 1;
- }
- }
-
- if (msg->cm_fields['O'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['O'], fptr->fl_room))
- || (fptr->fl_room[0] == 0) ) {
- zap_room = 1;
- }
- }
-
- if (msg->cm_fields['N'] != NULL) {
- if ( (!strcasecmp(msg->cm_fields['N'], fptr->fl_node))
- || (fptr->fl_node[0] == 0) ) {
- zap_node = 1;
- }
- }
-
- if (zap_user + zap_room + zap_node == 3) return(1);
-
- }
-
- return(0);
-}
-
-
-CTDL_MODULE_INIT(netfilter)
-{
- if (!threading)
- {
- CtdlRegisterNetprocHook(filter_the_idiots);
- }
-
- /* return our module name for the log */
- return "netfilter";
-}
+typedef struct NetMap NetMap;
+
+struct NetMap {
+ NetMap *next;
+ char nodename[SIZ];
+ time_t lastcontact;
+ char nexthop[SIZ];
+};
+
NetMap *the_netmap;
int netmap_changed;
void load_working_ignetcfg(void);
void read_network_map(void);
-FilterList *load_filter_list(void);
void write_network_map(void);
-void free_filter_list(FilterList *fl);
int is_valid_node(char *nexthop, char *secret, char *node);
+typedef struct maplist maplist;
+
+struct maplist {
+ struct maplist *next;
+ char remote_nodename[SIZ];
+ char remote_roomname[SIZ];
+};
+
+
+typedef struct SpoolControl SpoolControl;
+
+struct SpoolControl {
+ long lastsent;
+ namelist *listrecps;
+ namelist *digestrecps;
+ namelist *participates;
+ maplist *ignet_push_shares;
+ char *misc;
+ FILE *digestfp;
+ int num_msgs_spooled;
+};
+
+
void network_spoolout_room(char *room_to_spool);
void network_do_spoolin(void);
void network_consolidate_spoolout(void);
+void free_spoolcontrol_struct(SpoolControl **scc);
+int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename);
+int read_spoolcontrol_file(SpoolControl **scc, char *filename);
+int is_recipient(SpoolControl *sc, const char *Name);
#include "context.h"
#include "netconfig.h"
+#include "netspool.h"
#include "ctdl_module.h"
}
-
-/*
- * Keep track of what messages to reject
- */
-FilterList *load_filter_list(void) {
- char *serialized_list = NULL;
- int i;
- char buf[SIZ];
- FilterList *newlist = NULL;
- FilterList *nptr;
-
- serialized_list = CtdlGetSysConfig(FILTERLIST);
- if (serialized_list == NULL) return(NULL); /* if null, no entries */
-
- /* Use the string tokenizer to grab one line at a time */
- for (i=0; i<num_tokens(serialized_list, '\n'); ++i) {
- extract_token(buf, serialized_list, i, '\n', sizeof buf);
- nptr = (FilterList *) malloc(sizeof(FilterList));
- extract_token(nptr->fl_user, buf, 0, '|', sizeof nptr->fl_user);
- striplt(nptr->fl_user);
- extract_token(nptr->fl_room, buf, 1, '|', sizeof nptr->fl_room);
- striplt(nptr->fl_room);
- extract_token(nptr->fl_node, buf, 2, '|', sizeof nptr->fl_node);
- striplt(nptr->fl_node);
-
- /* Cowardly refuse to add an any/any/any entry that would
- * end up filtering every single message.
- */
- if (IsEmptyStr(nptr->fl_user) &&
- IsEmptyStr(nptr->fl_room) &&
- IsEmptyStr(nptr->fl_node)) {
- free(nptr);
- }
- else {
- nptr->next = newlist;
- newlist = nptr;
- }
- }
-
- free(serialized_list);
- return newlist;
-}
-
-
-void free_filter_list(FilterList *fl) {
- if (fl == NULL) return;
- free_filter_list(fl->next);
- free(fl);
-}
-
/*
* Check the network map and determine whether the supplied node name is
* valid. If it is not a neighbor node, supply the name of a neighbor node
cprintf("%d authenticated as network node '%s'\n", CIT_OK, CC->net_node);
}
+int netconfig_check_roomaccess(
+ char *errmsgbuf,
+ size_t n,
+ const char* RemoteIdentifier)
+{
+ SpoolControl *sc;
+ char filename[SIZ];
+ int found;
+
+ if (RemoteIdentifier == NULL)
+ {
+ snprintf(errmsgbuf, n, "Need sender to permit access.");
+ return (ERROR + USERNAME_REQUIRED);
+ }
+
+ assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
+ begin_critical_section(S_NETCONFIGS);
+ if (!read_spoolcontrol_file(&sc, filename))
+ {
+ end_critical_section(S_NETCONFIGS);
+ snprintf(errmsgbuf, n,
+ "This mailing list only accepts posts from subscribers.");
+ return (ERROR + NO_SUCH_USER);
+ }
+ end_critical_section(S_NETCONFIGS);
+ found = is_recipient (sc, RemoteIdentifier);
+ free_spoolcontrol_struct(&sc);
+ if (found) {
+ return (0);
+ }
+ else {
+ snprintf(errmsgbuf, n,
+ "This mailing list only accepts posts from subscribers.");
+ return (ERROR + NO_SUCH_USER);
+ }
+}
/*
* Module entry point
*/
--- /dev/null
+/*
+ * A server-side module for Citadel designed to filter idiots off the network.
+ *
+ * Copyright (c) 2002-2009 by the citadel.org team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <pwd.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <sys/wait.h>
+#include <string.h>
+#include <limits.h>
+#include <libcitadel.h>
+#include "citadel.h"
+#include "server.h"
+#include "citserver.h"
+#include "support.h"
+#include "config.h"
+#include "control.h"
+#include "user_ops.h"
+#include "database.h"
+#include "msgbase.h"
+
+
+#include "ctdl_module.h"
+
+typedef struct FilterList FilterList;
+
+struct FilterList {
+ FilterList *next;
+ char fl_user[SIZ];
+ char fl_room[SIZ];
+ char fl_node[SIZ];
+};
+
+struct FilterList *filterlist = NULL;
+
+/*
+ * Keep track of what messages to reject
+ */
+FilterList *load_filter_list(void) {
+ char *serialized_list = NULL;
+ int i;
+ char buf[SIZ];
+ FilterList *newlist = NULL;
+ FilterList *nptr;
+
+ serialized_list = CtdlGetSysConfig(FILTERLIST);
+ if (serialized_list == NULL) return(NULL); /* if null, no entries */
+
+ /* Use the string tokenizer to grab one line at a time */
+ for (i=0; i<num_tokens(serialized_list, '\n'); ++i) {
+ extract_token(buf, serialized_list, i, '\n', sizeof buf);
+ nptr = (FilterList *) malloc(sizeof(FilterList));
+ extract_token(nptr->fl_user, buf, 0, '|', sizeof nptr->fl_user);
+ striplt(nptr->fl_user);
+ extract_token(nptr->fl_room, buf, 1, '|', sizeof nptr->fl_room);
+ striplt(nptr->fl_room);
+ extract_token(nptr->fl_node, buf, 2, '|', sizeof nptr->fl_node);
+ striplt(nptr->fl_node);
+
+ /* Cowardly refuse to add an any/any/any entry that would
+ * end up filtering every single message.
+ */
+ if (IsEmptyStr(nptr->fl_user) &&
+ IsEmptyStr(nptr->fl_room) &&
+ IsEmptyStr(nptr->fl_node)) {
+ free(nptr);
+ }
+ else {
+ nptr->next = newlist;
+ newlist = nptr;
+ }
+ }
+
+ free(serialized_list);
+ return newlist;
+}
+
+
+void free_filter_list(FilterList *fl) {
+ if (fl == NULL) return;
+ free_filter_list(fl->next);
+ free(fl);
+}
+
+void free_netfilter_list(void)
+{
+ free_filter_list(filterlist);
+ filterlist = NULL;
+}
+
+void load_network_filter_list(void)
+{
+ filterlist = load_filter_list();
+}
+
+
+/*
+ * This handler detects whether an incoming network message is from some
+ * moron user who the site operator has elected to filter out. If a match
+ * is found, the message is rejected.
+ */
+int filter_the_idiots(struct CtdlMessage *msg, char *target_room) {
+ FilterList *fptr;
+ int zap_user = 0;
+ int zap_room = 0;
+ int zap_node = 0;
+
+ if ( (msg == NULL) || (filterlist == NULL) ) {
+ return(0);
+ }
+
+ for (fptr = filterlist; fptr != NULL; fptr = fptr->next) {
+
+ zap_user = 0;
+ zap_room = 0;
+ zap_node = 0;
+
+ if (msg->cm_fields['A'] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields['A'], fptr->fl_user))
+ || (fptr->fl_user[0] == 0) ) {
+ zap_user = 1;
+ }
+ }
+
+ if (msg->cm_fields['C'] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields['C'], fptr->fl_room))
+ || (fptr->fl_room[0] == 0) ) {
+ zap_room = 1;
+ }
+ }
+
+ if (msg->cm_fields['O'] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields['O'], fptr->fl_room))
+ || (fptr->fl_room[0] == 0) ) {
+ zap_room = 1;
+ }
+ }
+
+ if (msg->cm_fields['N'] != NULL) {
+ if ( (!strcasecmp(msg->cm_fields['N'], fptr->fl_node))
+ || (fptr->fl_node[0] == 0) ) {
+ zap_node = 1;
+ }
+ }
+
+ if (zap_user + zap_room + zap_node == 3) return(1);
+
+ }
+
+ return(0);
+}
+
+
+CTDL_MODULE_INIT(netfilter)
+{
+ if (!threading)
+ {
+ CtdlRegisterNetprocHook(filter_the_idiots);
+ }
+
+ /* return our module name for the log */
+ return "netfilter";
+}
#include "context.h"
#include "netconfig.h"
+#include "netspool.h"
#include "ctdl_module.h"
#include "context.h"
#include "netconfig.h"
+#include "netspool.h"
#include "netmail.h"
#include "ctdl_module.h"
#include "context.h"
#include "netconfig.h"
+#include "netspool.h"
#include "netmail.h"
#include "ctdl_module.h"
-
/*
* Check the use table. This is a list of messages which have recently
* arrived on the system. It is maintained and queried to prevent the same
/* Load the IGnet Configuration into memory */
load_working_ignetcfg();
-
/*
* Load the network map and filter list into memory.
*/
read_network_map();
- filterlist = load_filter_list();
+ load_network_filter_list();
/*
* Go ahead and run the queue
write_network_map();
/* Free the filter list in memory */
- free_filter_list(filterlist);
- filterlist = NULL;
+ free_netfilter_list();
network_consolidate_spoolout();
--- /dev/null
+
+typedef struct namelist namelist;
+
+struct namelist {
+ namelist *next;
+ char name[SIZ];
+};
+
+
+void free_netfilter_list(void);
+void load_network_filter_list(void);
+
+
+
+void network_queue_room(struct ctdlroom *, void *);
+void destroy_network_queue_room(void);
+void network_bounce(struct CtdlMessage *msg, char *reason);
+int network_usetable(struct CtdlMessage *msg);
+
#include "journaling.h"
#include "citadel_dirs.h"
#include "clientsocket.h"
-#include "serv_network.h"
#include "threads.h"
#include "ctdl_module.h"
/* This temp file holds the queue of operations for AdjRefCount() */
static FILE *arcfp = NULL;
-/*
- * This really belongs in serv_network.c, but I don't know how to export
- * symbols between modules.
- */
-struct FilterList *filterlist = NULL;
-
-
/*
* These are the four-character field headers we use when outputting
* messages in Citadel format (as opposed to RFC822 format).
return(msg);
}
+extern int netconfig_check_roomaccess(
+ char *errmsgbuf,
+ size_t n,
+ const char* RemoteIdentifier); /* TODO: find a smarter way */
/*
* Check to see whether we have permission to post a message in the current
return (ERROR + NOT_LOGGED_IN);
}
if ((PostPublic!=POST_LMTP) &&(CC->room.QRflags2 & QR2_SMTP_PUBLIC) == 0) {
- SpoolControl *sc;
- char filename[SIZ];
- int found;
- if (RemoteIdentifier == NULL)
- {
- snprintf(errmsgbuf, n, "Need sender to permit access.");
- return (ERROR + USERNAME_REQUIRED);
- }
-
- assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
- begin_critical_section(S_NETCONFIGS);
- if (!read_spoolcontrol_file(&sc, filename))
- {
- end_critical_section(S_NETCONFIGS);
- snprintf(errmsgbuf, n,
- "This mailing list only accepts posts from subscribers.");
- return (ERROR + NO_SUCH_USER);
- }
- end_critical_section(S_NETCONFIGS);
- found = is_recipient (sc, RemoteIdentifier);
- free_spoolcontrol_struct(&sc);
- if (found) {
- return (0);
- }
- else {
- snprintf(errmsgbuf, n,
- "This mailing list only accepts posts from subscribers.");
- return (ERROR + NO_SUCH_USER);
- }
+ return netconfig_check_roomaccess(errmsgbuf, n, RemoteIdentifier);
}
return (0);
+++ /dev/null
-
-typedef struct namelist namelist;
-
-struct namelist {
- namelist *next;
- char name[SIZ];
-};
-
-typedef struct maplist maplist;
-
-struct maplist {
- struct maplist *next;
- char remote_nodename[SIZ];
- char remote_roomname[SIZ];
-};
-
-typedef struct SpoolControl SpoolControl;
-
-struct SpoolControl {
- long lastsent;
- namelist *listrecps;
- namelist *digestrecps;
- namelist *participates;
- maplist *ignet_push_shares;
- char *misc;
- FILE *digestfp;
- int num_msgs_spooled;
-};
-
-
-typedef struct NetMap NetMap;
-
-struct NetMap {
- NetMap *next;
- char nodename[SIZ];
- time_t lastcontact;
- char nexthop[SIZ];
-};
-
-typedef struct FilterList FilterList;
-
-struct FilterList {
- FilterList *next;
- char fl_user[SIZ];
- char fl_room[SIZ];
- char fl_node[SIZ];
-};
-extern FilterList *filterlist;
-
-void free_spoolcontrol_struct(SpoolControl **scc);
-int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename);
-int read_spoolcontrol_file(SpoolControl **scc, char *filename);
-
-int is_recipient(SpoolControl *sc, const char *Name);
-
-
-void network_queue_room(struct ctdlroom *, void *);
-void destroy_network_queue_room(void);
-void network_bounce(struct CtdlMessage *msg, char *reason);
-int network_usetable(struct CtdlMessage *msg);
-void network_do_spoolin(void);
-void network_consolidate_spoolout(void);
-void network_spoolout_room(char *room_to_spool);
-