Back to index

citadel  8.12
Classes | Typedefs | Functions | Variables
serv_netfilter.c File Reference
#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>
#include <time.h>
#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"

Go to the source code of this file.

Classes

struct  FilterList

Typedefs

typedef struct FilterList

Functions

FilterListload_filter_list (void)
void free_filter_list (FilterList *fl)
void free_netfilter_list (void)
void load_network_filter_list (void)
int filter_the_idiots (struct CtdlMessage *msg, char *target_room)
 CTDL_MODULE_INIT (netfilter)

Variables

struct FilterListfilterlist = NULL

Class Documentation

struct FilterList

Definition at line 61 of file serv_netfilter.c.

Collaboration diagram for FilterList:
Class Members
char fl_node
char fl_room
char fl_user
FilterList * next

Typedef Documentation

typedef struct FilterList

Definition at line 59 of file serv_netfilter.c.


Function Documentation

CTDL_MODULE_INIT ( netfilter  )

Definition at line 188 of file serv_netfilter.c.

{
       if (!threading)
       {
              CtdlRegisterNetprocHook(filter_the_idiots);
       }
       
       /* return our module name for the log */
       return "netfilter";
}

Here is the call graph for this function:

int filter_the_idiots ( struct CtdlMessage msg,
char *  target_room 
)

Definition at line 136 of file serv_netfilter.c.

                                                                  {
       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);
}

Here is the caller graph for this function:

void free_filter_list ( FilterList fl)

Definition at line 113 of file serv_netfilter.c.

                                      {
       if (fl == NULL) return;
       free_filter_list(fl->next);
       free(fl);
}

Here is the caller graph for this function:

void free_netfilter_list ( void  )

Definition at line 119 of file serv_netfilter.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file serv_netfilter.c.

                                   {
       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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void load_network_filter_list ( void  )

Definition at line 125 of file serv_netfilter.c.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct FilterList* filterlist = NULL

Definition at line 68 of file serv_netfilter.c.