From: Matthew Wiggins Date: Fri, 14 Jan 2005 09:33:35 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: rubiks-ircd-1-0-6~32 X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=70d5bd4be33494a57407596af6ebbaaa1b211978;p=rubiks-ircd.git *** empty log message *** --- diff --git a/modules/auth/Makefile b/modules/auth/Makefile new file mode 100644 index 0000000..5ad1ff0 --- /dev/null +++ b/modules/auth/Makefile @@ -0,0 +1,10 @@ + +all: + [ -e ../../include/setup.h ] || (cd ../.. && ./configure) + make -C src auth.so + +install: + make -C src install + +clean: + make -C src clean diff --git a/modules/auth/include/auth_h.h b/modules/auth/include/auth_h.h new file mode 100644 index 0000000..fd20f53 --- /dev/null +++ b/modules/auth/include/auth_h.h @@ -0,0 +1,19 @@ +#ifndef __auth_h_include__ +#define __auth_h_include__ + +#include +#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 diff --git a/modules/auth/include/auth_struct.h b/modules/auth/include/auth_struct.h new file mode 100644 index 0000000..c00069c --- /dev/null +++ b/modules/auth/include/auth_struct.h @@ -0,0 +1,16 @@ +#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 diff --git a/modules/auth/include/dbengine.h b/modules/auth/include/dbengine.h new file mode 100644 index 0000000..23fb113 --- /dev/null +++ b/modules/auth/include/dbengine.h @@ -0,0 +1,11 @@ +#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 diff --git a/modules/auth/src/Makefile b/modules/auth/src/Makefile new file mode 100644 index 0000000..9137ed7 --- /dev/null +++ b/modules/auth/src/Makefile @@ -0,0 +1,32 @@ +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 $@ + + diff --git a/modules/auth/src/auth.c b/modules/auth/src/auth.c new file mode 100644 index 0000000..8a8c8d9 --- /dev/null +++ b/modules/auth/src/auth.c @@ -0,0 +1,43 @@ +#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; +} + + diff --git a/modules/auth/src/dbengine_mysql.c b/modules/auth/src/dbengine_mysql.c new file mode 100644 index 0000000..7fedaa7 --- /dev/null +++ b/modules/auth/src/dbengine_mysql.c @@ -0,0 +1,6 @@ +#include "auth_struct.h" +#include "dbengine.h" + +int dbengine_getnick(char *nick, aNickRow *anrow) +{ +} diff --git a/modules/auth/src/nick.c b/modules/auth/src/nick.c new file mode 100644 index 0000000..d57783d --- /dev/null +++ b/modules/auth/src/nick.c @@ -0,0 +1,63 @@ +#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; +}