/** * sendpass.C: This file contains code for the ChanServ SENDPASS 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: sendpass.C,v 1.9 2007/09/22 14:27:28 pippijn Exp $ */ #include "atheme.h" #include #include #include static char const rcsid[] = "$Id: sendpass.C,v 1.9 2007/09/22 14:27:28 pippijn Exp $"; REGISTER_MODULE ("nickserv/sendpass", false, "The Ermyth Team "); static void ns_cmd_sendpass (sourceinfo_t *si, int parc, char *parv[]); command_t const ns_sendpass = { "SENDPASS", N_("Email registration passwords."), PRIV_USER_SENDPASS, 1, ns_cmd_sendpass }; E cmdvec ns_cmdtree; E helpvec ns_helptree; bool _modinit (module *m) { ns_cmdtree << ns_sendpass; help_addentry (ns_helptree, "SENDPASS", "help/nickserv/sendpass", NULL); return true; } void _moddeinit () { ns_cmdtree >> ns_sendpass; help_delentry (ns_helptree, "SENDPASS"); } static void ns_cmd_sendpass (sourceinfo_t *si, int parc, char *parv[]) { myuser_t *mu; char *name = parv[0]; char *newpass = NULL; char *key; metadata *md; if (!name) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "SENDPASS"); command_fail (si, fault::needmoreparams, _("Syntax: SENDPASS ")); 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 SENDPASS %s (is SOPER)", name); command_fail (si, fault::badparams, _("\2%s\2 belongs to a services operator; you need %s privilege to send the password."), name, PRIV_ADMIN); return; } if ((md = mu->find_metadata ("private:mark:setter"))) { if (has_priv (si, PRIV_MARK)) { command_success_nodata (si, _("Overriding MARK placed by %s on the nickname %s."), md->value, mu->name); wallops ("%s sent the password for the \2MARKED\2 nickname %s.", get_oper_name (si), mu->name); } else { logcommand (si, CMDLOG_ADMIN, "failed SENDPASS %s (marked by %s)", mu->name, md->value); command_fail (si, fault::badparams, _("This operation cannot be performed on %s, because the nickname has been marked by %s."), mu->name, md->value); return; } } /* alternative, safer method? */ if (si->service->cmdtree->find ("SETPASS")) { key = gen_pw (12); if (sendemail (si->su != NULL ? si->su : si->service->me, EMAIL_SETPASS, mu, key)) { mu->add_metadata ("private:setpass:key", crypter->crypt (key, crypto::gen_salt ())); logcommand (si, CMDLOG_ADMIN, "SENDPASS %s (change key)", name); snoop ("SENDPASS: \2%s\2 by \2%s\2", mu->name, get_oper_name (si)); command_success_nodata (si, _("The password change key for \2%s\2 has been sent to \2%s\2."), mu->name, mu->email); } else command_fail (si, fault::emailfail, _("Email send failed.")); sfree (key); return; } /* this is not without controversy... :) */ if (mu->flags & MU_CRYPTPASS) { command_success_nodata (si, _("The password for the nickname \2%s\2 is encrypted; a new password will be assigned and sent."), name); newpass = gen_pw (12); mu->set_password (newpass); } if (sendemail (si->su != NULL ? si->su : si->service->me, EMAIL_SENDPASS, mu, (newpass == NULL) ? mu->pass : newpass)) { logcommand (si, CMDLOG_ADMIN, "SENDPASS %s", name); snoop ("SENDPASS: \2%s\2 by \2%s\2", mu->name, get_oper_name (si)); command_success_nodata (si, _("The password for \2%s\2 has been sent to \2%s\2."), mu->name, mu->email); } else command_fail (si, fault::emailfail, _("Email send failed.")); if (newpass != NULL) sfree (newpass); return; }