Anope IRC Services  Version 1.8
ns_getpass.c
Go to the documentation of this file.
1 /* NickServ 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 myNickServHelp(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  NICK_SERVADMIN_HELP_GETPASS,
36  NICK_SERVADMIN_HELP_GETPASS);
38 
40 
41  return MOD_CONT;
42 }
43 
47 void AnopeFini(void)
48 {
49 
50 }
51 
56 static void myNickServHelp(User * u)
57 {
58  if (is_services_admin(u)) {
59  notice_lang(s_NickServ, u, NICK_HELP_CMD_GETPASS);
60  }
61 }
62 
68 static int do_getpass(User * u)
69 {
70  char *nick = strtok(NULL, " ");
71  char tmp_pass[PASSMAX];
72  NickAlias *na;
73  NickRequest *nr = NULL;
74 
75  if (!nick) {
76  syntax_error(s_NickServ, u, "GETPASS", NICK_GETPASS_SYNTAX);
77  } else if (!(na = findnick(nick))) {
78  if ((nr = findrequestnick(nick))) {
79  alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick,
80  u->username, u->host, nick);
81  if (WallGetpass)
83  "\2%s\2 used GETPASS on \2%s\2", u->nick,
84  nick);
85  notice_lang(s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick,
86  nr->passcode);
87  } else {
88  notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick);
89  }
90  } else if (na->status & NS_VERBOTEN) {
91  notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);
92  } else if (NSSecureAdmins && nick_is_services_admin(na->nc)
93  && !is_services_root(u)) {
94  notice_lang(s_NickServ, u, PERMISSION_DENIED);
95  } else if (NSRestrictGetPass && !is_services_root(u)) {
96  notice_lang(s_NickServ, u, PERMISSION_DENIED);
97  } else {
98  if(enc_decrypt(na->nc->pass,tmp_pass,PASSMAX - 1)==1) {
99  alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick,
100  u->username, u->host, nick);
101  if (WallGetpass)
102  anope_cmd_global(s_NickServ, "\2%s\2 used GETPASS on \2%s\2",
103  u->nick, nick);
104  notice_lang(s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick,
105  tmp_pass);
106  } else {
107  notice_lang(s_NickServ, u, NICK_GETPASS_UNAVAILABLE);
108  }
109  }
110  return MOD_CONT;
111 }
E int NSRestrictGetPass
Definition: extern.h:398
E int nick_is_services_admin(NickCore *nc)
Definition: operserv.c:636
char nick[NICKMAX]
Definition: services.h:875
E NickAlias * findnick(const char *nick)
Definition: db-merger.c:1857
static void myNickServHelp(User *u)
Definition: ns_getpass.c:56
char * passcode
Definition: services.h:517
void AnopeFini(void)
Definition: ns_getpass.c:47
E int NSSecureAdmins
Definition: extern.h:394
#define NS_VERBOTEN
Definition: services.h:1273
char * host
Definition: services.h:878
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
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
NickCore * nc
Definition: services.h:533
static int do_getpass(User *u)
Definition: ns_getpass.c:68
E int is_services_root(User *u)
Definition: operserv.c:577
E NickRequest * findrequestnick(const char *nick)
Definition: nickserv.c:1218
#define PASSMAX
Definition: config.h:65
uint16 status
Definition: services.h:532
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
E int is_services_admin(User *u)
Definition: operserv.c:591
char * nick
Definition: services.h:526
char * username
Definition: services.h:877
MDE void moduleSetNickHelp(void(*func)(User *u))
Definition: modules.c:2078
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
char pass[PASSMAX]
Definition: services.h:543
E int enc_decrypt(const char *src, char *dest, int size)
Definition: encrypt.c:80
E char * s_NickServ
Definition: extern.h:284
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
E int WallGetpass
Definition: extern.h:468
int AnopeInit(int argc, char **argv)
Definition: ns_getpass.c:26
#define NICKSERV
Definition: modules.h:59
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506