Add strip domain plugin
authorDavid Parrish <david@dparrish.com>
Thu, 2 Sep 2004 04:29:30 +0000 (04:29 +0000)
committerDavid Parrish <david@dparrish.com>
Thu, 2 Sep 2004 04:29:30 +0000 (04:29 +0000)
Changes
Makefile
stripdomain.c [new file with mode: 0644]

diff --git a/Changes b/Changes
index bd8f94c..38586c1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -16,6 +16,7 @@
 - Make autothrottle.so understand cisco lcp:interface-config - Yuri
 - Show filter stats in show session - Yuri
 - Cleanup from Michael to change sid to unique_id
+- Add plugin to remove domain name from auth requests
 
 * Tue Jul 13 2004 Brendan O'Dea <bod@optusnet.com.au> 2.0.1
 - Update INSTALL, Docs/manual.html documentation.
index 9cad50b..015aa63 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -27,12 +27,13 @@ OBJS=       md5.o \
        tbf.o \
        bgp.o \
 
-PLUGINS=garden.so autothrottle.so autosnoop.so
+PLUGINS=garden.so autothrottle.so autosnoop.so stripdomain.so
+TARGETS=l2tpns nsctl generateload bounce $(PLUGINS)
 
-all:   l2tpns nsctl generateload bounce $(PLUGINS)
+all:   $(TARGETS)
 
 clean:
-       /bin/rm -f *.o *.so l2tpns nsctl
+       /bin/rm -f *.o *.so $(TARGETS)
 
 depend:
        (sed -n 'p; /^## Dependencies: (autogenerated) ##/q' Makefile && \
diff --git a/stripdomain.c b/stripdomain.c
new file mode 100644 (file)
index 0000000..2711912
--- /dev/null
@@ -0,0 +1,29 @@
+#include <string.h>
+#include "l2tpns.h"
+#include "plugin.h"
+
+char const *cvs_id = "$Id: stripdomain.c,v 1.1 2004-09-02 04:29:30 fred_nerk Exp $";
+
+int __plugin_api_version = 1;
+static struct pluginfuncs *p = 0;
+
+int plugin_pre_auth(struct param_pre_auth *data)
+{
+       char *x;
+
+       if (!data->continue_auth) return PLUGIN_RET_STOP;
+
+       // Strip off @domain
+       if ((x = strchr(data->username, '@')))
+       {
+               p->log(3, 0, 0, 0, "Stripping off trailing domain name \"%s\"\n", x);
+               *x = 0;
+       }
+
+       return PLUGIN_RET_OK;
+}
+
+int plugin_init(struct pluginfuncs *funcs)
+{
+       return ((p = funcs)) ? 1 : 0;
+}