Anope IRC Services  Version 1.8
cs_getpass.c
Go to the documentation of this file.
1 /* ChanServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 static int do_getpass(User * u);
18 static void myChanServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
34  c = createCommand("GETPASS", do_getpass, is_services_admin, -1, -1, -1,
35  CHAN_SERVADMIN_HELP_GETPASS,
36  CHAN_SERVADMIN_HELP_GETPASS);
38 
40 
41  return MOD_CONT;
42 }
43 
47 void AnopeFini(void)
48 {
49 
50 }
51 
52 
53 
58 static void myChanServHelp(User * u)
59 {
60  if (is_services_admin(u)) {
61  notice_lang(s_ChanServ, u, CHAN_HELP_CMD_GETPASS);
62  }
63 }
64 
71 static int do_getpass(User * u)
72 {
73  char *chan = strtok(NULL, " ");
74  char tmp_pass[PASSMAX];
75  ChannelInfo *ci;
76 
77  if (!chan) {
78  syntax_error(s_ChanServ, u, "GETPASS", CHAN_GETPASS_SYNTAX);
79  } else if (!(ci = cs_findchan(chan))) {
80  notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
81  } else if (ci->flags & CI_VERBOTEN) {
82  notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
83  } else if (CSRestrictGetPass && !is_services_root(u)) {
84  notice_lang(s_ChanServ, u, PERMISSION_DENIED);
85  } else {
86  if(enc_decrypt(ci->founderpass, tmp_pass, PASSMAX - 1)==1) {
87  alog("%s: %s!%s@%s used GETPASS on %s",
88  s_ChanServ, u->nick, u->username, u->host, ci->name);
89  if (WallGetpass) {
91  "\2%s\2 used GETPASS on channel \2%s\2",
92  u->nick, chan);
93  }
94  notice_lang(s_ChanServ, u, CHAN_GETPASS_PASSWORD_IS,
95  chan, tmp_pass);
96  } else {
97  notice_lang(s_ChanServ, u, CHAN_GETPASS_UNAVAILABLE);
98  }
99  }
100  return MOD_CONT;
101 }
char nick[NICKMAX]
Definition: services.h:875
char founderpass[PASSMAX]
Definition: services.h:658
E int CSRestrictGetPass
Definition: extern.h:412
static int do_getpass(User *u)
Definition: cs_getpass.c:71
#define CI_VERBOTEN
Definition: services.h:725
char * host
Definition: services.h:878
static void myChanServHelp(User *u)
Definition: cs_getpass.c:58
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
char name[CHANMAX]
Definition: services.h:654
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E int is_services_root(User *u)
Definition: operserv.c:577
uint32 flags
Definition: services.h:669
#define PASSMAX
Definition: config.h:65
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
MDE void moduleSetChanHelp(void(*func)(User *u))
Definition: modules.c:2090
Command * c
Definition: ns_recover.c:17
#define CHANSERV
Definition: modules.h:60
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
void AnopeFini(void)
Definition: cs_getpass.c:47
E int is_services_admin(User *u)
Definition: operserv.c:591
char * username
Definition: services.h:877
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
int AnopeInit(int argc, char **argv)
Definition: cs_getpass.c:26
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
E int enc_decrypt(const char *src, char *dest, int size)
Definition: encrypt.c:80
E char * s_ChanServ
Definition: extern.h:285
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
E int WallGetpass
Definition: extern.h:468
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506