/** * resetpass.C: This file contains code for nickserv RESETPASS * * 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 Patrick Fish, et al. * Rights to this code are as documented in doc/pod/license.pod. * * $Id: resetpass.C,v 1.9 2007/09/22 14:27:28 pippijn Exp $ */ #include "atheme.h" #include #include static char const rcsid[] = "$Id: resetpass.C,v 1.9 2007/09/22 14:27:28 pippijn Exp $"; REGISTER_MODULE ("nickserv/resetpass", false, "The Ermyth Team "); static void ns_cmd_resetpass (sourceinfo_t *si, int parc, char *parv[]); command_t const ns_resetpass = { "RESETPASS", N_("Resets a nickname password."), PRIV_USER_ADMIN, 1, ns_cmd_resetpass }; E cmdvec ns_cmdtree; E helpvec ns_helptree; bool _modinit (module *m) { ns_cmdtree << ns_resetpass; help_addentry (ns_helptree, "RESETPASS", "help/nickserv/resetpass", NULL); return true; } void _moddeinit () { ns_cmdtree >> ns_resetpass; help_delentry (ns_helptree, "RESETPASS"); } static void ns_cmd_resetpass (sourceinfo_t *si, int parc, char *parv[]) { myuser_t *mu; metadata *md; char *name = parv[0]; char *newpass; if (!name) { command_fail (si, fault::needmoreparams, STR_INVALID_PARAMS, "RESETPASS"); command_fail (si, fault::needmoreparams, _("Syntax: RESETPASS ")); return; } if (!(mu = myuser_t::find (name))) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), name); return; } if (is_soper (mu) && !has_priv (si, PRIV_ADMIN)) { logcommand (si, CMDLOG_ADMIN, "failed RESETPASS %s (is SOPER)", name); command_fail (si, fault::badparams, _("\2%s\2 belongs to a services operator; you need %s privilege to reset the password."), name, PRIV_ADMIN); return; } if ((md = mu->find_metadata ("private:mark:setter")) && has_priv (si, PRIV_MARK)) { logcommand (si, CMDLOG_ADMIN, "RESETPASS %s (overriding mark by %s)", name, md->value); command_success_nodata (si, _("Overriding MARK placed by %s on the nickname %s."), md->value, name); newpass = gen_pw (12); command_success_nodata (si, _("The password for the nickname %s has been changed to %s."), name, newpass); mu->set_password (newpass); sfree (newpass); wallops ("%s reset the password for the \2MARKED\2 nickname %s.", get_oper_name (si), name); snoop ("RESETPASS: \2%s\2 by \2%s\2", name, get_oper_name (si)); return; } if ((md = mu->find_metadata ("private:mark:setter"))) { logcommand (si, CMDLOG_ADMIN, "failed RESETPASS %s (marked by %s)", name, md->value); command_fail (si, fault::badparams, _("This operation cannot be performed on %s, because the nickname has been marked by %s."), name, md->value); return; } newpass = gen_pw (12); command_success_nodata (si, _("The password for the nickname %s has been changed to %s."), name, newpass); mu->set_password (newpass); sfree (newpass); mu->del_metadata ("private:setpass:key"); wallops ("%s reset the password for the nickname %s", get_oper_name (si), name); snoop ("RESETPASS: \2%s\2 by \2%s\2", name, get_oper_name (si)); logcommand (si, CMDLOG_ADMIN, "RESETPASS %s", name); }