--- /dev/null
+
+all:
+ [ -e ../../include/setup.h ] || (cd ../.. && ./configure)
+ make -C src auth.so
+
+install:
+ make -C src install
+
+clean:
+ make -C src clean
--- /dev/null
+#ifndef __auth_h_include__
+#define __auth_h_include__
+
+#include <fcntl.h>
+#include "struct.h"
+#include "common.h"
+#include "sys.h"
+#include "numeric.h"
+#include "msg.h"
+#include "channel.h"
+#include "throttle.h"
+#include "h.h"
+#include "hooks.h"
+#include "find.h"
+
+#include "auth_struct.h"
+#include "dbengine.h"
+
+#endif
--- /dev/null
+#ifndef __auth_struct_include__
+#define __auth_struct_include__
+
+typedef struct NickRow aNickRow;
+
+
+struct NickRow {
+ char *nick;
+ char *pass;
+ char *name;
+ char *email;
+ int autokill;
+};
+
+
+#endif
--- /dev/null
+#ifndef __dbengine_include__
+#define __dbengine_include__
+
+#include "auth_struct.h"
+
+
+extern int dbengine_startup(char *hostname, char *dbname, char *user, char *pass);
+extern int dbengine_nicktable(char *tablename);
+
+extern int dbengine_getnick(char *nick, aNickRow *anrow);
+#endif
--- /dev/null
+AUTH_FLAGS=-I../rubiks-ircd-include -I../include
+MYSQL_FLAGS=-lmysql
+
+MODULE_INSTALL_DIR=/usr/IRCd/modules
+
+
+INSTALL=install
+
+
+all: auth.so
+
+clean:
+ $(RM) *.o *.so
+
+install: auth.so
+ $(INSTALL) $^ $(MODULE_INSTALL_DIR)
+
+
+
+auth.so: nick.o auth.o
+ $(CC) $(CFLAGS) $(AUTH_FLAGS) -shared $^ -o $@
+
+auth.o: auth.c
+ $(CC) $(CFLAGS) $(AUTH_FLAGS) -c $< -o $@
+
+nick.o: nick.c
+ $(CC) $(CFLAGS) $(AUTH_FLAGS) -c $< -o $@
+
+dbengine.o: dbengine_mysql.c
+ $(CC) $(CFLAGS) $(AUTH_FLAGS) $(MYSQL_FLAGS) -c $< -o $@
+
+
--- /dev/null
+#include "auth_h.h"
+
+
+#define MODULEVERSION 1006
+#define MODULE_VERSION_STRING "0.1"
+#define MODULE_DESCRIPTION_STRING "auth [nick]"
+
+extern int
+hook_nick_usermsg(aClient *,aClient *,int,char*);
+
+
+
+
+int bircmodule_init(void *self)
+{
+ bircmodule_add_hook(CHOOK_USERMSG, self, hook_nick_usermsg);
+ return 0;
+
+}
+
+void bircmodule_check(int *acsz)
+{
+ *acsz = MODULEVERSION;
+}
+void bircmodule_getinfo(char **ver, char **desc)
+{
+ *ver = MODULE_VERSION_STRING;
+ *desc = MODULE_DESCRIPTION_STRING;
+}
+void bircmodule_shutdown(void)
+{
+ return;
+}
+int bircmodule_command(aClient *aptr, int parc, char **parv)
+{
+ return 0;
+}
+int bircmodule_globalcommand(aClient *sptr, aClient *dst, int parc, char **parv)
+{
+ return 0;
+}
+
+
--- /dev/null
+#include "auth_struct.h"
+#include "dbengine.h"
+
+int dbengine_getnick(char *nick, aNickRow *anrow)
+{
+}
--- /dev/null
+#include "auth_h.h"
+
+
+int hook_nick_usermsg(aClient *source, aClient *destination, int notice, char *text)
+{
+ char *p = text;
+
+ if (myncmp(p,"AUTH ",5) == 0)
+ {
+ char *realpass = "foo";
+ int rplen = strlen(realpass);
+ p+=5;
+ if ((myncmp(p,realpass,rplen) == 0))
+ {
+ char *parv[10];
+ int parc;
+ char tmp[10];
+ int toggle = 0;
+
+ if (source != destination)
+ {
+
+ parv[0] = me.name;
+ parv[1] = destination->name;
+ parv[2] = p + rplen;
+ parc = 3;
+ /* lol this little hack is to trick IsPrivileged */
+ me.status = STAT_SERVER;
+ m_kill(&me,&me, parc, parv);
+ me.status = STAT_ME;
+
+ sprintf(tmp,"%lu",NOW);
+ parv[0] = me.name;
+ parv[1] = source->name;
+ parv[2] = destination->name;
+ parv[3] = tmp;
+ parc = 4;
+ /* this is so we dont have to U:line every server */
+ if (!(me.flags & FLAGS_ULINE))
+ {
+ toggle = 1;
+ me.flags |= FLAGS_ULINE;
+ }
+ m_svsnick(&me,&me, parc,parv);
+ if (toggle)
+ me.flags &= ~FLAGS_ULINE;
+ }
+ else
+ {
+ sendto_one(source, ":%s NOTICE %s :Authorized for %s",
+ me.name, source->name, destination->name);
+ }
+
+ }
+ else
+ {
+ sendto_one(source, ":%s NOTICE %s :Failed AUTH for %s",
+ me.name, source->name, destination->name);
+ }
+ return FLUSH_BUFFER;
+ }
+ return 0;
+}