anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

ns_getpass.cpp (2152B)

      1 /* NickServ core functions
      2  *
      3  * (C) 2003-2022 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 {
     60 	CommandNSGetPass commandnsgetpass;
     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 
     74 MODULE_INIT(NSGetPass)