Exemplo n.º 1
0
static void ignorer__global_fini(void)
{
  /* restore initial iptables state */
  iptables_restore();

  GDBG("ignorer threads finished.");
}
Exemplo n.º 2
0
static int 
_gmodule_write_proc(struct file *file, const char *buffer,
		    unsigned long count, void *data)
{
    /* Workaround to toggle debugging */
    if(count > 2) {
	if(buffer[0] == 'd') {
	    _dbg_enable = buffer[1] - '0';
	    GDBG("Debugging Enabled");
	}
    }
    return count;
}
Exemplo n.º 3
0
static ssize_t
_gmodule_proc_write(struct file *file, const char *buffer,
                   size_t count, loff_t *loff)
{
    /* Workaround to toggle debugging */
    if(count > 2) {
	if(buffer[0] == 'd') {
	    _dbg_enable = buffer[1] - '0';
	    GDBG("Debugging Enabled");
	}
    }
    return count;
}
Exemplo n.º 4
0
static void ignorer__global_init(void)
{
  char **a,
       *iscript[] = {
          "/sbin/iptables", "-t", "filter", "-F", NULL,
          "/sbin/iptables", "-t", "nat",    "-F", NULL,
          "/sbin/iptables", "-t", "mangle", "-F", NULL,
          "/sbin/iptables", "-t", "raw",    "-F", NULL,
          "/sbin/iptables", "-F", NULL,
          NULL },
       *igscript[] = {
          "/sbin/iptables", "-A", "FORWARD", "-j", "DROP", NULL,
          "/sbin/iptables", "-A", "INPUT",   "-j", "DROP", NULL,
          NULL },
       *isscript[] = {
          "/sbin/iptables", "-A", "FORWARD", "-i", NULL, "-j", "DROP", NULL,
          "/sbin/iptables", "-A", "INPUT",   "-i", NULL, "-j", "DROP", NULL,
          NULL },
       *ifscript[] = {
          "/sbin/iptables", "-L", "-v", NULL,
          NULL };

  GDBG2("save iptables config.");
  iptables_save();

  GDBG2("Init iptables config.");
  if(cfg.interfaces[0] == NULL)
  {
    iptables_apply_script(iscript);
    iptables_apply_script(igscript);
  } else {
    for(a = cfg.interfaces; *a; a++)
      if(*a)
      {
        isscript[4] = *a;
        isscript[12] = *a;
        iptables_apply_script(isscript);
      }
  }
  iptables_apply_script(ifscript);

  /* set the finalization routine */
  dosis_atexit(MODNAME, ignorer__global_fini);

  GDBG("Initialized.");
}