/** * drop.C: This file contains code for the nickserv DROP function. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * $Id: drop.C,v 1.10 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include static char const rcsid[] = "$Id: drop.C,v 1.10 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("nickserv/drop", false, "The Ermyth Team "); static void ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[]); command_t const ns_drop = { "DROP", N_("Drops an account registration."), AC_NONE, 2, ns_cmd_drop }; E cmdvec ns_cmdtree; E helpvec ns_helptree; bool _modinit (module *m) { ns_cmdtree << ns_drop; help_addentry (ns_helptree, "DROP", "help/nickserv/drop", NULL); return true; } void _moddeinit () { ns_cmdtree >> ns_drop; help_delentry (ns_helptree, "DROP"); } static void ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[]) { myuser_t *mu; mynick_t *mn; char *acc = parv[0]; char *pass = parv[1]; if (!acc) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP"); command_fail (si, fault::needmoreparams, _("Syntax: DROP ")); return; } if (!(mu = myuser_t::find (acc))) { if (!nicksvs.no_nick_ownership) { mn = mynick_t::find (acc); if (mn != NULL && si->service->cmdtree->find ("UNGROUP")) { command_fail (si, fault::nosuch_target, _("\2%s\2 is a grouped nick, use UNGROUP to remove it."), acc); return; } } command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), acc); return; } if (!has_priv (si, PRIV_USER_ADMIN) && mu->find_metadata ("private:freeze:freezer")) { command_fail (si, fault::authfail, nicksvs.no_nick_ownership ? "You cannot login as \2%s\2 because the account has been frozen." : "You cannot identify to \2%s\2 because the nickname has been frozen.", mu->name); return; } if ((pass || !has_priv (si, PRIV_USER_ADMIN)) && !mu->verify_password (pass)) { command_fail (si, fault::authfail, _("Authentication failed. Invalid password for \2%s\2."), mu->name); return; } if (!nicksvs.no_nick_ownership && pass && LIST_LENGTH (&mu->nicks) > 1 && si->service->cmdtree->find ("UNGROUP")) { command_fail (si, fault::noprivs, _("Account \2%s\2 has %d other nick(s) grouped to it, remove those first."), mu->name, LIST_LENGTH (&mu->nicks) - 1); return; } if (is_soper (mu)) { command_fail (si, fault::noprivs, _("The nickname \2%s\2 belongs to a services operator; it cannot be dropped."), acc); return; } if (mu->flags & MU_HOLD) { command_fail (si, fault::noprivs, _("The account \2%s\2 is held; it cannot be dropped."), acc); return; } if (!pass) wallops ("%s dropped the account \2%s\2", get_oper_name (si), mu->name); snoop ("DROP: \2%s\2 by \2%s\2", mu->name, get_oper_name (si)); logcommand (si, pass ? CMDLOG_REGISTER : CMDLOG_ADMIN | LG_REGISTER, "DROP %s%s", mu->name, pass ? "" : " (admin)"); mu->callback.drop (mu); command_success_nodata (si, _("The account \2%s\2 has been dropped."), mu->name); mu->refcnt_dec (); // XXX: what if this does not delete a myuser? mark as dead? }