]> jfr.im git - irc/quakenet/newserv.git/blob - auth/auth.c
BUILD: add require-all build mode
[irc/quakenet/newserv.git] / auth / auth.c
1 #include <stdio.h>
2
3 #include "../control/control.h"
4 #include "../nick/nick.h"
5 #include "../irc/irc.h"
6 #include "../localuser/localuser.h"
7 #include "../lib/flags.h"
8 #include "../lib/version.h"
9
10 MODULE_VERSION("");
11
12 /* we allow reauthing for flag changing, as well as testing purposes */
13 int au_auth(void *source, int cargc, char **cargv) {
14 nick *sender=(nick *)source;
15 char *authname;
16 int authts;
17 int authid;
18 flag_t flags;
19
20 if(cargc < 2)
21 return CMD_USAGE;
22
23 if(sscanf(myserver->content, "%*s.quakenet.org") == 1) {
24 controlreply(sender, "Sorry, you can't use this command on QuakeNet.");
25 return CMD_ERROR;
26 }
27
28 if(cargc > 3) {
29 if(setflags(&flags, AFLAG_ALL, cargv[3], accountflags, REJECT_UNKNOWN) != REJECT_NONE) {
30 controlreply(sender, "Bad flag(s) supplied.");
31 return CMD_ERROR;
32 }
33 } else {
34 flags = 0;
35 }
36
37 authname = cargv[0];
38 authts = atoi(cargv[1]);
39 authid = atoi(cargv[2]);
40
41 controlwall(NO_OPER, NL_OPERATIONS, "AUTH'ed at %s:%d:%d:%s", authname, authts, authid, printflags(flags, accountflags));
42
43 localusersetaccount(sender, authname, authid, flags, authts);
44 controlreply(sender, "Done.");
45
46 return CMD_OK;
47 }
48
49 void _init() {
50 registercontrolhelpcmd("auth", NO_OPERED, 3, au_auth, "Usage: auth <authname> <authts> <authid> ?accountflags?");
51 }
52
53 void _fini() {
54 deregistercontrolcmd("auth", au_auth);
55 }
56