]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_netfilter.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_netfilter.c
index 5f84aa7330ee18299b5024c8232b750ca7c33f1c..31fced57ba0b4a543b82990ead58068a291e540d 100644 (file)
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
 #include "control.h"
-#include "dynloader.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
 #include "database.h"
 #include "msgbase.h"
+#include "serv_network.h"
 #include "tools.h"
 
+
+#include "ctdl_module.h"
+
+
 /*
- * This handler detects whether the user is attempting to save a new
- * vCard as part of his/her personal configuration, and handles the replace
- * function accordingly (delete the user's existing vCard in the config room
- * and in the global address book).
+ * 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) {
+int filter_the_idiots(struct CtdlMessage *msg, char *target_room) {
+       struct FilterList *fptr;
+       int zap_user = 0;
+       int zap_room = 0;
+       int zap_node = 0;
 
-       if (msg == NULL) {
+       if ( (msg == NULL) || (filterlist == NULL) ) {
                return(0);
        }
 
-       /* FIXME ... write it!  In the meantime, here's a temporary fix */
+       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['A'] != NULL) {
-               if (!strcasecmp(msg->cm_fields['A'],
-                               "Curly Surmudgeon")) {
-                       return(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);
 }
 
 
-char *Dynamic_Module_Init(void)
+CTDL_MODULE_INIT(netfilter)
 {
        CtdlRegisterNetprocHook(filter_the_idiots);
+
+       /* return our Subversion id for the Log */
        return "$Id$";
 }