Exemplo n.º 1
0
	void OnCheckAuthentication(User *, NickServ::IdentifyRequest *req) override
	{
		NickServ::Nick *na = NickServ::FindNick(req->GetAccount());
		if (na == NULL)
			return;
		NickServ::Account *nc = na->GetAccount();

		size_t pos = nc->GetPassword().find(':');
		if (pos == Anope::string::npos)
			return;
		Anope::string hash_method(nc->GetPassword().begin(), nc->GetPassword().begin() + pos);
		if (!hash_method.equals_cs("oldmd5"))
			return;

		Anope::string buf;
		this->OnEncrypt(req->GetPassword(), buf);
		if (nc->GetPassword().equals_cs(buf))
		{
			/* if we are NOT the first module in the list,
			 * we want to re-encrypt the pass with the new encryption
			 */
			if (ModuleManager::FindFirstOf(ENCRYPTION) != this)
			{
				Anope::string p;
				Anope::Encrypt(req->GetPassword(), p);
				nc->SetPassword(p);
			}
			req->Success(this);
		}
	}
Exemplo n.º 2
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		const Anope::string &nick = params[0];

		if (Anope::ReadOnly)
			source.Reply(_("Services are in read-only mode. Any changes made may not persist."));

		NickServ::Nick *na = NickServ::FindNick(nick);
		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), nick);
			return;
		}

		NSSuspendInfo *si = na->GetAccount()->GetRef<NSSuspendInfo *>();
		if (!si)
		{
			source.Reply(_("\002{0}\002 is not suspended."), na->GetNick());
			return;
		}

		Log(LOG_ADMIN, source, this) << "for " << na->GetNick() << " which was suspended by " << (!si->GetBy().empty() ? si->GetBy() : "(none)") << " for: " << (!si->GetReason().empty() ? si->GetReason() : "No reason");

		si->Delete();

		source.Reply(_("\002{0}\002 is now released."), na->GetNick());

		EventManager::Get()->Dispatch(&Event::NickUnsuspend::OnNickUnsuspend, na);
	}
Exemplo n.º 3
0
static void rsend_notify(CommandSource &source, MemoServ::MemoInfo *mi, MemoServ::Memo *m, const Anope::string &targ)
{
	/* Only send receipt if memos are allowed */
	if (MemoServ::service && !Anope::ReadOnly)
	{
		/* Get nick alias for sender */
		NickServ::Nick *na = NickServ::FindNick(m->GetSender());

		if (!na)
			return;

		/* Get nick core for sender */
		NickServ::Account *nc = na->GetAccount();

		if (!nc)
			return;

		/* Text of the memo varies if the recipient was a
		   nick or channel */
		Anope::string text = Anope::printf(Language::Translate(na->GetAccount(), _("\002[auto-memo]\002 The memo you sent to \002%s\002 has been viewed.")), targ.c_str());

		/* Send notification */
		MemoServ::service->Send(source.GetNick(), m->GetSender(), text, true);

		/* Notify recipient of the memo that a notification has
		   been sent to the sender */
		source.Reply(_("A notification memo has been sent to \002{0}\002 informing him/her you have read his/her memo."), nc->GetDisplay());
	}

	/* Remove receipt flag from the original memo */
	m->SetReceipt(false);
}
Exemplo n.º 4
0
bool User::IsIdentified(bool check_nick) const
{
	if (check_nick && this->nc)
	{
		NickServ::Nick *na = NickServ::FindNick(nick);
		return na && na->GetAccount() == *this->nc;
	}

	return this->nc ? true : false;
}
Exemplo n.º 5
0
bool User::IsRecognized(bool check_secure) const
{
	if (check_secure && on_access)
	{
		NickServ::Nick *na = NickServ::FindNick(nick);

		if (!na || na->GetAccount()->HasFieldS("NS_SECURE"))
			return false;
	}

	return on_access;
}
Exemplo n.º 6
0
void User::ChangeNick(const Anope::string &newnick, time_t ts)
{
	/* Sanity check to make sure we don't segfault */
	if (newnick.empty())
		throw CoreException("User::ChangeNick() got a bad argument");

	this->super_admin = false;
	Log(this, "nick") << "(" << this->realname << ") changed nick to " << newnick;

	Anope::string old = this->nick;
	this->timestamp = ts;

	if (this->nick.equals_ci(newnick))
		this->nick = newnick;
	else
	{
		NickServ::Nick *old_na = NickServ::FindNick(this->nick);
		if (old_na && (this->IsIdentified(true) || this->IsRecognized()))
			old_na->SetLastSeen(Anope::CurTime);

		UserListByNick.erase(this->nick);

		this->nick = newnick;

		User* &other = UserListByNick[this->nick];
		if (other)
		{
			CollideKill(this, "Nick collision");
			CollideKill(other, "Nick collision");
			return;
		}
		other = this;

		on_access = false;
		if (NickServ::service)
		{
			NickServ::Nick *na = NickServ::service->FindNick(this->nick);
			if (na)
			{
				on_access = na->GetAccount()->IsOnAccess(this);

				if (na->GetAccount() == this->Account())
				{
					na->SetLastSeen(Anope::CurTime);
					this->UpdateHost();
				}
			}
		}
	}

	EventManager::Get()->Dispatch(&Event::UserNickChange::OnUserNickChange, this, old);
}
Exemplo n.º 7
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		const Anope::string &nick = !params.empty() ? params[0] : "";
		NickServ::Account *nc;

		if (!nick.empty() && source.IsServicesOper())
		{
			NickServ::Nick *na = NickServ::FindNick(nick);
			if (!na)
			{
				source.Reply(_("\002{0}\002 isn't registered."), nick);
				return;
			}

			nc = na->GetAccount();
		}
		else
			nc = source.GetAccount();

		ListFormatter list(source.GetAccount());
		list.AddColumn(_("Nick")).AddColumn(_("Expires"));
		time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire", "21d"),
		       unconfirmed_expire = Config->GetModule("nickserv")->Get<time_t>("unconfirmedexpire", "1d");
		for (NickServ::Nick *na2 : nc->GetRefs<NickServ::Nick *>())
		{
			Anope::string expires;
			if (na2->HasFieldS("NS_NO_EXPIRE"))
				expires = _("Does not expire");
			else if (!nickserv_expire || Anope::NoExpire)
				;
			else if (na2->GetAccount()->HasFieldS("UNCONFIRMED") && unconfirmed_expire)
				expires = Anope::strftime(na2->GetTimeRegistered() + unconfirmed_expire, source.GetAccount());
			else
				expires = Anope::strftime(na2->GetLastSeen() + nickserv_expire, source.GetAccount());

			ListFormatter::ListEntry entry;
			entry["Nick"] = na2->GetNick();
			entry["Expires"] = expires;
			list.AddEntry(entry);
		}

		source.Reply(nc != source.GetAccount() ? _("List of nicknames in the group of \002%s\002:") : _("List of nicknames in your group:"), nc->GetDisplay().c_str());
		std::vector<Anope::string> replies;
		list.Process(replies);

		for (unsigned i = 0; i < replies.size(); ++i)
			source.Reply(replies[i]);

		source.Reply(_("%d nickname(s) in the group."), replies.size());
	}
Exemplo n.º 8
0
	void OnSuccess(NickServ::IdentifyRequest *) override
	{
		if (!source.GetUser() || source.GetUser()->nick != nick || !target)
			return;

		User *u = source.GetUser();
		NickServ::Nick *na = NickServ::FindNick(nick);
		/* If the nick is already registered, drop it. */
		if (na)
		{
			EventManager::Get()->Dispatch(&Event::ChangeCoreDisplay::OnChangeCoreDisplay, na->GetAccount(), u->nick);
			delete na;
		}

		na = Serialize::New<NickServ::Nick *>();
		na->SetNick(nick);
		na->SetAccount(target->GetAccount());
		na->SetLastUsermask(u->GetIdent() + "@" + u->GetDisplayedHost());
		na->SetLastRealname(u->realname);
		na->SetLastSeen(Anope::CurTime);
		na->SetTimeRegistered(Anope::CurTime);

		u->Login(target->GetAccount());
		EventManager::Get()->Dispatch(&Event::NickGroup::OnNickGroup, u, target);

		Log(LOG_COMMAND, source, cmd) << "to make " << nick << " join group of " << target->GetNick() << " (" << target->GetAccount()->GetDisplay() << ") (email: " << (!target->GetAccount()->GetEmail().empty() ? target->GetAccount()->GetEmail() : "none") << ")";
		source.Reply(_("You are now in the group of \002{0}\002."), target->GetNick());

		u->lastnickreg = Anope::CurTime;

	}
Exemplo n.º 9
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		const Anope::string &cmd = params[0];
		Anope::string nick, mask;

		if (cmd.equals_ci("LIST"))
			nick = params.size() > 1 ? params[1] : "";
		else
		{
			nick = params.size() == 3 ? params[1] : "";
			mask = params.size() > 1 ? params[params.size() - 1] : "";
		}

		NickServ::Account *nc;
		if (!nick.empty() && source.HasPriv("nickserv/access"))
		{
			NickServ::Nick *na = NickServ::FindNick(nick);
			if (na == NULL)
			{
				source.Reply(_("\002{0}\002 isn't registered."), nick);
				return;
			}

			if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && source.GetAccount() != na->GetAccount() && na->GetAccount()->IsServicesOper() && !cmd.equals_ci("LIST"))
			{
				source.Reply(_("You may view but not modify the access list of other Services Operators."));
				return;
			}

			nc = na->GetAccount();
		}
		else
			nc = source.nc;

		if (!mask.empty() && (mask.find('@') == Anope::string::npos || mask.find('!') != Anope::string::npos))
		{
			source.Reply(_("Mask must be in the form \037user\037@\037host\037."));
			source.Reply(_("\002%s%s HELP %s\002 for more information."), Config->StrictPrivmsg, source.service->nick, source.command); // XXX
		}
		else if (cmd.equals_ci("LIST"))
			return this->DoList(source, nc, mask);
		else if (nc->HasFieldS("NS_SUSPENDED"))
			source.Reply(_("\002{0}\002 is suspended."), nc->GetDisplay());
		else if (cmd.equals_ci("ADD"))
			return this->DoAdd(source, nc, mask);
		else if (cmd.equals_ci("DEL"))
			return this->DoDel(source, nc, mask);
		else
			this->OnSyntaxError(source, "");
	}
Exemplo n.º 10
0
void User::SetRealname(const Anope::string &srealname)
{
	if (srealname.empty())
		throw CoreException("realname empty in SetRealname");

	this->realname = srealname;

	//XXX event
	NickServ::Nick *na = NickServ::FindNick(this->nick);

	if (na && (this->IsIdentified(true) || this->IsRecognized()))
		na->SetLastRealname(srealname);

	Log(this, "realname") << "changed realname to " << srealname;
}
Exemplo n.º 11
0
// :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB 0 192.168.0.5 :Adam
void plexus::UID::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
	/* An IP of 0 means the user is spoofed */
	Anope::string ip = params[6];
	if (ip == "0")
		ip.clear();

	time_t ts;
	try
	{
		ts = convertTo<time_t>(params[2]);
	}
	catch (const ConvertException &)
	{
		ts = Anope::CurTime;
	}

	NickServ::Nick *na = NULL;
	try
	{
		if (params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == ts)
			na = NickServ::FindNick(params[0]);
	}
	catch (const ConvertException &) { }
	if (params[8] != "0" && !na)
		na = NickServ::FindNick(params[8]);

	User::OnIntroduce(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], ts, params[3], params[7], na ? na->GetAccount() : NULL);
}
Exemplo n.º 12
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		User *u = source.GetUser();
		NickServ::Nick *na = NickServ::FindNick(u->nick);

		if (!na || !na->HasVhost() || na->GetAccount() != source.GetAccount())
		{
			source.Reply(_("There is no vhost assigned to this nickname."));
			return;
		}

		u->vhost.clear();
		IRCD->SendVhostDel(u);
		Log(LOG_COMMAND, source, this) << "to disable their vhost";
		source.Reply(_("Your vhost was removed and the normal cloaking restored."));
	}
Exemplo n.º 13
0
    void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
    {
        const Anope::string &cmd = params[0];
        Anope::string nick, certfp;

        if (cmd.equals_ci("LIST"))
            nick = params.size() > 1 ? params[1] : "";
        else
        {
            nick = params.size() == 3 ? params[1] : "";
            certfp = params.size() > 1 ? params[params.size() - 1] : "";
        }

        NickServ::Account *nc;
        if (!nick.empty() && source.HasPriv("nickserv/access"))
        {
            NickServ::Nick *na = NickServ::FindNick(nick);
            if (na == NULL)
            {
                source.Reply(_("\002{0}\002 isn't registered."), nick);
                return;
            }

            if (Config->GetModule("nickserv")->Get<bool>("secureadmins", "yes") && source.GetAccount() != na->GetAccount() && na->GetAccount()->IsServicesOper() && !cmd.equals_ci("LIST"))
            {
                source.Reply(_("You may view, but not modify, the certificate list of other Services Operators."));
                return;
            }

            nc = na->GetAccount();
        }
        else
            nc = source.nc;

        if (cmd.equals_ci("LIST"))
            return this->DoList(source, nc);
        else if (nc->HasFieldS("NS_SUSPENDED"))
            source.Reply(_("\002{0}\002 is suspended."), nc->GetDisplay());
        else if (Anope::ReadOnly)
            source.Reply(_("Services are in read-only mode."));
        else if (cmd.equals_ci("ADD"))
            return this->DoAdd(source, nc, certfp);
        else if (cmd.equals_ci("DEL"))
            return this->DoDel(source, nc, certfp);
        else
            this->OnSyntaxError(source, "");
    }
Exemplo n.º 14
0
/* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB Steve      :Mining all the time */
void hybrid::UID::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
	Anope::string ip = params[6];

	if (ip == "0") /* Can be 0 for spoofed clients */
		ip.clear();

	NickServ::Nick *na = NULL;
	if (params[8] != "0" && params[8] != "*")
		na = NickServ::FindNick(params[8]);

	/* Source is always the server */
	User::OnIntroduce(params[0], params[4], params[5], "",
			ip, source.GetServer(),
			params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
			params[3], params[7], na ? na->GetAccount() : NULL);
}
Exemplo n.º 15
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		const Anope::string &cmd = params[0];
		Anope::string nick, param, param2;

		if (cmd.equals_ci("LIST"))
			nick = params.size() > 1 ? params[1] : "";
		else
			nick = (params.size() > 2 && IRCD->IsChannelValid(params[2])) ? params[1] : "";

		NickServ::Account *nc;
		if (!nick.empty() && !source.HasCommand("nickserv/ajoin"))
		{
			NickServ::Nick *na = NickServ::FindNick(nick);
			if (na == NULL)
			{
				source.Reply(_("\002{0}\002 isn't registered."), nick);
				return;
			}

			nc = na->GetAccount();
			param = params.size() > 2 ? params[2] : "";
			param2 = params.size() > 3 ? params[3] : "";
		}
		else
		{
			nc = source.nc;
			param = params.size() > 1 ? params[1] : "";
			param2 = params.size() > 2 ? params[2] : "";
		}

		if (cmd.equals_ci("LIST"))
			return this->DoList(source, nc);
		else if (nc->HasFieldS("NS_SUSPENDED"))
			source.Reply(_("\002{0}\002 isn't registered."), nc->GetDisplay());
		else if (param.empty())
			this->OnSyntaxError(source, "");
		else if (Anope::ReadOnly)
			source.Reply(_("Services are in read-only mode."));
		else if (cmd.equals_ci("ADD"))
			return this->DoAdd(source, nc, param, param2);
		else if (cmd.equals_ci("DEL"))
			return this->DoDel(source, nc, param);
		else
			this->OnSyntaxError(source, "");
	}
Exemplo n.º 16
0
	/*
	 * :42X EUID DukePyrolator 1 1353240577 +Zi ~jens erft-5d80b00b.pool.mediaWays.net 93.128.176.11 42XAAAAAD * * :jens
	 * :<SID> EUID <NICK> <HOPS> <TS> +<UMODE> <USERNAME> <VHOST> <IP> <UID> <REALHOST> <ACCOUNT> :<GECOS>
	 *               0      1     2      3         4         5     6     7       8         9         10
	 *
	 * Introduces a user. The hostname field is now always the visible host.
	 * The realhost field is * if the real host is equal to the visible host.
	 * The account field is * if the login is not set.
	 * Note that even if both new fields are *, an EUID command still carries more
	 * information than a UID command (namely that real host is visible host and the
	 * user is not logged in with services). Hence a NICK or UID command received
	 * from a remote server should not be sent in EUID form to other servers.
	 */
	void Run(MessageSource &source, const std::vector<Anope::string> &params) override
	{
		NickServ::Nick *na = NULL;
		if (params[9] != "*")
			na = NickServ::FindNick(params[9]);

		User::OnIntroduce(params[0], params[4], params[8], params[5], params[6], source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime, params[3], params[7], na ? na->GetAccount() : NULL);
	}
Exemplo n.º 17
0
    EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
    {
        if (command->name == "nickserv/confirm" && params.size() > 1)
        {
            if (Anope::ReadOnly)
            {
                source.Reply(_("Services are in read-only mode."));
                return EVENT_STOP;
            }

            NickServ::Nick *na = NickServ::FindNick(params[0]);

            ResetInfo *ri = na ? reset.Get(na->GetAccount()) : NULL;
            if (na && ri)
            {
                NickServ::Account *nc = na->GetAccount();
                const Anope::string &passcode = params[1];
                if (ri->time < Anope::CurTime - 3600)
                {
                    reset.Unset(nc);
                    source.Reply(_("Your password reset request has expired."));
                }
                else if (passcode.equals_cs(ri->code))
                {
                    reset.Unset(nc);
                    nc->UnsetS<bool>("UNCONFIRMED");

                    Log(LOG_COMMAND, source, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify as " << na->GetNick();

                    if (source.GetUser())
                    {
                        source.GetUser()->Identify(na);
                        source.Reply(_("You are now identified for \002{0}\002. Change your password now."), na->GetAccount()->GetDisplay());
                    }
                }
                else
                    return EVENT_CONTINUE;

                return EVENT_STOP;
            }
        }

        return EVENT_CONTINUE;
    }
Exemplo n.º 18
0
void User::UpdateHost()
{
	if (this->host.empty())
		return;

	//XXX event
	NickServ::Nick *na = NickServ::FindNick(this->nick);
	on_access = false;
	if (na)
		on_access = na->GetAccount()->IsOnAccess(this);

	if (na && (this->IsIdentified(true) || this->IsRecognized()))
	{
		Anope::string last_usermask = this->GetIdent() + "@" + this->GetDisplayedHost();
		Anope::string last_realhost = this->GetIdent() + "@" + this->host;
		na->SetLastUsermask(last_usermask);
		na->SetLastRealhost(last_realhost);
	}
}
Exemplo n.º 19
0
    void OnFingerprint(User *u) override
    {
        ServiceBot *NickServ = Config->GetClient("NickServ");
        if (!NickServ || u->IsIdentified())
            return;

        NickServ::Account *nc = cs.FindAccountFromCert(u->fingerprint);
        if (!nc || nc->HasFieldS("NS_SUSPENDED"))
            return;

        NickServ::Nick *na = NickServ::FindNick(u->nick);
        if (na && na->GetAccount() == nc)
            u->Identify(na);
        else
            u->Login(nc);

        u->SendMessage(NickServ, _("SSL certificate fingerprint accepted, you are now identified to \002%s\002."), nc->GetDisplay().c_str());
        Log(NickServ) << u->GetMask() << " automatically identified for account " << nc->GetDisplay() << " via SSL certificate fingerprint";
    }
Exemplo n.º 20
0
    void DoCommand(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request)
    {
        Anope::string service = request.data.size() > 0 ? request.data[0] : "";
        Anope::string user = request.data.size() > 1 ? request.data[1] : "";
        Anope::string command = request.data.size() > 2 ? request.data[2] : "";

        if (service.empty() || user.empty() || command.empty())
            request.reply("error", "Invalid parameters");
        else
        {
            ServiceBot *bi = ServiceBot::Find(service, true);
            if (!bi)
                request.reply("error", "Invalid service");
            else
            {
                request.reply("result", "Success");

                NickServ::Nick *na = NickServ::FindNick(user);

                Anope::string out;

                struct XMLRPCommandReply : CommandReply
                {
                    Anope::string &str;

                    XMLRPCommandReply(Anope::string &s) : str(s) { }

                    void SendMessage(const MessageSource &, const Anope::string &msg) override
                    {
                        str += msg + "\n";
                    };
                }
                reply(out);

                CommandSource source(user, NULL, na ? na->GetAccount() : NULL, &reply, bi);
                Command::Run(source, command);

                if (!out.empty())
                    request.reply("return", iface->Sanitize(out));
            }
        }
    }
Exemplo n.º 21
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		const Anope::string &nick = params[0];
		const Anope::string &pass = params.size() > 1 ? params[1] : "";

		User *user = User::Find(nick, true);

		if (user && source.GetUser() == user)
		{
			source.Reply(_("You can't %s yourself!"), source.command.lower().c_str());
			return;
		}

		NickServ::Nick *na = NickServ::FindNick(nick);

		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), nick);
			return;
		}

		if (na->GetAccount()->HasFieldS("NS_SUSPENDED"))
		{
			source.Reply(_("\002{0}\002 is suspended."), na->GetNick());
			return;
		}

		bool ok = false;
		if (source.GetAccount() == na->GetAccount())
			ok = true;
		else if (!na->GetAccount()->HasFieldS("NS_SECURE") && source.GetUser() && na->GetAccount()->IsOnAccess(source.GetUser()))
			ok = true;

		if (certservice && source.GetUser() && certservice->Matches(source.GetUser(), na->GetAccount()))
			ok = true;

		if (ok == false && !pass.empty())
		{
			NickServ::IdentifyRequest *req = NickServ::service->CreateIdentifyRequest(new NSRecoverRequestListener(source, this, na->GetNick(), pass), owner, na->GetNick(), pass);
			Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req);
			req->Dispatch();
		}
		else
		{
			NSRecoverRequestListener req(source, this, na->GetNick(), pass);

			if (ok)
				req.OnSuccess(nullptr);
			else
				req.OnFail(nullptr);
		}
	}
Exemplo n.º 22
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		User *u = source.GetUser();
		Anope::string nick = !params.empty() ? params[0] : "";
		NickServ::Nick *na = NickServ::FindNick(!nick.empty() ? nick : u->nick);

		if (u->Account()->GetRefs<NickServ::Nick *>().size() == 1)
		{
			source.Reply(_("Your nickname is not grouped to anything, so you can't ungroup it."));
			return;
		}

		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), !nick.empty() ? nick : u->nick);
			return;
		}

		if (na->GetAccount() != u->Account())
		{
			source.Reply(_("\002{0}\002 is not in your group."), na->GetNick());
			return;
		}


		NickServ::Account *oldcore = na->GetAccount();

		if (na->GetNick().equals_ci(oldcore->GetDisplay()))
			oldcore->SetDisplay(oldcore->GetRef<NickServ::Nick *>());

		NickServ::Account *nc = Serialize::New<NickServ::Account *>();
		nc->SetDisplay(na->GetNick());
		na->SetAccount(nc);

		nc->SetPassword(oldcore->GetPassword());
		if (!oldcore->GetEmail().empty())
			nc->SetEmail(oldcore->GetEmail());
		nc->SetLanguage(oldcore->GetLanguage());

		source.Reply(_("\002{0}\002 has been ungrouped from \002{1}\002."), na->GetNick(), oldcore->GetDisplay());

		User *user = User::Find(na->GetNick());
		if (user)
			/* The user on the nick who was ungrouped may be identified to the old group, set -r */
			user->RemoveMode(source.service, "REGISTERED");
	}
Exemplo n.º 23
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		if (Anope::ReadOnly)
		{
			source.Reply(_("Services are in read-only mode."));
			return;
		}

		const Anope::string &nick = params[0];
		const Anope::string &reason = params.size() > 1 ? params[1] : "";

		NickServ::Nick *na = NickServ::FindNick(nick);
		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), nick);
			return;
		}

		HostRequest *req = na->GetExt<HostRequest>("hostrequest");
		if (!req)
		{
			source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->GetNick());
			return;
		}

		req->Delete();

		if (Config->GetModule(this->GetOwner())->Get<bool>("memouser") && memoserv)
		{
			Anope::string message;
			if (!reason.empty())
				message = Anope::printf(_("[auto memo] Your requested vHost has been rejected. Reason: %s"), reason.c_str());
			else
				message = _("[auto memo] Your requested vHost has been rejected.");

			memoserv->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true);
		}

		source.Reply(_("Vhost for \002{0}\002 has been rejected."), na->GetNick());
		Log(LOG_COMMAND, source, this) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "no reason") << ")";
	}
Exemplo n.º 24
0
	void SendMemos(CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost)
	{
		Anope::string host;

		if (!vIdent.empty())
			host = vIdent + "@" + vHost;
		else
			host = vHost;

		if (Config->GetModule(GetOwner())->Get<bool>("memooper") && memoserv)
			for (Oper *o : Serialize::GetObjects<Oper *>()) 
			{
				NickServ::Nick *na = NickServ::FindNick(o->GetName());
				if (!na)
					continue;

				Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str());

				memoserv->Send(source.service->nick, na->GetNick(), message, true);
			}
	}
Exemplo n.º 25
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
	{
		if (Anope::ReadOnly)
		{
			source.Reply(_("Services are in read-only mode."));
			return;
		}

		const Anope::string &nick = params[0];
		NickServ::Nick *na = NickServ::FindNick(nick);

		if (!na)
		{
			source.Reply(_("\002{0}\002 isn't registered."), nick);
			return;
		}

		HostRequest *req = na->GetExt<HostRequest>("hostrequest");
		if (!req)
		{
			source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->GetNick());
			return;
		}

		na->SetVhost(req->GetIdent(), req->GetHost(), source.GetNick(), req->GetTime());
		EventManager::Get()->Dispatch(&Event::SetVhost::OnSetVhost, na);

		if (Config->GetModule(this->GetOwner())->Get<bool>("memouser") && memoserv)
			memoserv->Send(source.service->nick, na->GetNick(), _("[auto memo] Your requested vHost has been approved."), true);

		source.Reply(_("Vhost for \002{0}\002 has been activated."), na->GetNick());
		Log(LOG_COMMAND, source, this) << "for " << na->GetNick() << " for vhost " << (!req->GetIdent().empty() ? req->GetIdent() + "@" : "") << req->GetHost();
		req->Delete();
	}
Exemplo n.º 26
0
static void req_send_memos(Module *me, CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost)
{
	Anope::string host;
	std::list<std::pair<Anope::string, Anope::string> >::iterator it, it_end;

	if (!vIdent.empty())
		host = vIdent + "@" + vHost;
	else
		host = vHost;

	if (Config->GetModule(me)->Get<bool>("memooper") && MemoServ::service)
		for (Oper *o : Serialize::GetObjects<Oper *>(operblock))
		{
			NickServ::Nick *na = NickServ::FindNick(o->GetName());
			if (!na)
				continue;

			Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str());

			MemoServ::service->Send(source.service->nick, na->GetNick(), message, true);
		}
}
Exemplo n.º 27
0
    void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
    {
        NickServ::Nick *na = NickServ::FindNick(params[0]);

        if (!na)
        {
            source.Reply(_("\002{0}\002 isn't registered."), params[0]);
            return;
        }

        if (!na->GetAccount()->GetEmail().equals_ci(params[1]))
        {
            source.Reply(_("Incorrect email address."));
            return;
        }

        if (SendResetEmail(source.GetUser(), na, source.service))
        {
            Log(LOG_COMMAND, source, this) << "for " << na->GetNick() << " (group: " << na->GetAccount()->GetDisplay() << ")";
            source.Reply(_("Password reset email for \002{0}\002 has been sent."), na->GetNick());
        }
    }
Exemplo n.º 28
0
	MemoServ::MemoInfo *GetMemoInfo(const Anope::string &target, bool &is_registered, bool &ischan, bool create) override
	{
		if (!target.empty() && target[0] == '#')
		{
			ischan = true;
			ChanServ::Channel *ci = ChanServ::Find(target);
			if (ci != NULL)
			{
				is_registered = true;
				if (create && !ci->GetMemos())
				{
					MemoServ::MemoInfo *mi = Serialize::New<MemoServ::MemoInfo *>();
					mi->SetOwner(ci);
				}
				return ci->GetMemos();
			}
			else
				is_registered = false;
		}
		else
		{
			ischan = false;
			NickServ::Nick *na = NickServ::FindNick(target);
			if (na != NULL)
			{
				is_registered = true;
				if (create && !na->GetAccount()->GetMemos())
				{
					MemoServ::MemoInfo *mi = Serialize::New<MemoServ::MemoInfo *>();
					mi->SetOwner(na->GetAccount());
				}
				return na->GetAccount()->GetMemos();
			}
			else
				is_registered = false;
		}

		return NULL;
	}
Exemplo n.º 29
0
ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u, bool updateLastUsed)
{
	ChanServ::AccessGroup group;

	if (u == NULL)
		return group;

	NickServ::Account *nc = u->Account();
	if (nc == NULL && !nc->IsSecure() && u->IsRecognized())
	{
		NickServ::Nick *na = NickServ::FindNick(u->nick);
		if (na != NULL)
			nc = na->GetAccount();
	}

	group.super_admin = u->super_admin;
	group.founder = IsFounder(u);
	group.ci = this;
	group.nc = nc;

	for (unsigned i = 0, end = this->GetAccessCount(); i < end; ++i)
	{
		ChanServ::ChanAccess *a = this->GetAccess(i);
		if (a->Matches(u, u->Account()))
			group.push_back(a);
	}

	if (group.founder || !group.empty())
	{
		if (updateLastUsed)
			this->SetLastUsed(Anope::CurTime);

		for (unsigned i = 0; i < group.size(); ++i)
			group[i]->SetLastSeen(Anope::CurTime);
	}

	return group;
}
Exemplo n.º 30
0
/*
 ** NICK - new
 **	  source  = NULL
 **	  parv[0] = nickname
 **	  parv[1] = hopcount
 **	  parv[2] = timestamp
 **	  parv[3] = modes
 **	  parv[4] = username
 **	  parv[5] = hostname
 **	  parv[6] = server
 **	  parv[7] = servicestamp
 **	  parv[8] = IP
 **	  parv[9] = info
 ** NICK - change
 **	  source  = oldnick
 **	  parv[0] = new nickname
 **	  parv[1] = hopcount
 */
void bahamut::Nick::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
	if (params.size() == 10)
	{
		Server *s = Server::Find(params[6]);
		if (s == nullptr)
		{
			Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[6] << "?";
			return;
		}

		NickServ::Nick *na = nullptr;
		time_t signon = 0, stamp = 0;

		try
		{
			signon = convertTo<time_t>(params[2]);
			stamp = convertTo<time_t>(params[7]);
		}
		catch (const ConvertException &)
		{
		}

		if (signon && signon == stamp && NickServ::service)
			na = NickServ::service->FindNick(params[0]);

		User::OnIntroduce(params[0], params[4], params[5], "", params[8], s, params[9], signon, params[3], "", na ? na->GetAccount() : nullptr);
	}
	else
	{
		User *u = source.GetUser();

		if (u)
			u->ChangeNick(params[0]);
	}
}