Anope IRC Services  Version 2.0
ns_getpass.cpp
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 #include "module.h"
13 
14 class CommandNSGetPass : public Command
15 {
16  public:
17  CommandNSGetPass(Module *creator) : Command(creator, "nickserv/getpass", 1, 1)
18  {
19  this->SetDesc(_("Retrieve the password for a nickname"));
20  this->SetSyntax(_("\037nickname\037"));
21  }
22 
23  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
24  {
25  const Anope::string &nick = params[0];
26  Anope::string tmp_pass;
27  const NickAlias *na;
28 
29  if (!(na = NickAlias::Find(nick)))
30  source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
31  else if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && na->nc->IsServicesOper())
32  source.Reply(_("You may not get the password of other Services Operators."));
33  else
34  {
35  if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1)
36  {
37  Log(LOG_ADMIN, source, this) << "for " << nick;
38  source.Reply(_("Password for %s is \002%s\002."), nick.c_str(), tmp_pass.c_str());
39  }
40  else
41  source.Reply(_("GETPASS command unavailable because encryption is in use."));
42  }
43  return;
44  }
45 
46  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
47  {
48  this->SendSyntax(source);
49  source.Reply(" ");
50  source.Reply(_("Returns the password for the given nickname. \002Note\002 that\n"
51  "whenever this command is used, a message including the\n"
52  "person who issued the command and the nickname it was used\n"
53  "on will be logged and sent out as a WALLOPS/GLOBOPS."));
54  return true;
55  }
56 };
57 
58 class NSGetPass : public Module
59 {
61 
62  public:
63  NSGetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
64  commandnsgetpass(this)
65  {
66 
67  Anope::string tmp_pass = "plain:tmp";
68  if (!Anope::Decrypt(tmp_pass, tmp_pass))
69  throw ModuleException("Incompatible with the encryption module being used");
70 
71  }
72 };
73 
Serialize::Reference< NickCore > nc
Definition: account.h:47
static NickAlias * Find(const Anope::string &nick)
Definition: nickalias.cpp:121
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: ns_getpass.cpp:23
NSGetPass(const Anope::string &modname, const Anope::string &creator)
Definition: ns_getpass.cpp:63
#define NICK_X_NOT_REGISTERED
Definition: language.h:79
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
CoreExport bool Decrypt(const Anope::string &src, Anope::string &dest)
Definition: misc.cpp:518
CommandNSGetPass(Module *creator)
Definition: ns_getpass.cpp:17
Definition: Config.cs:26
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: ns_getpass.cpp:46
#define anope_override
Definition: services.h:56
#define MODULE_INIT(x)
Definition: modules.h:45
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
void SendSyntax(CommandSource &)
Definition: command.cpp:145
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
#define _(x)
Definition: services.h:50
CommandNSGetPass commandnsgetpass
Definition: ns_getpass.cpp:60