| 1 |
pippijn |
1.1 |
/* |
| 2 |
|
|
* Copyright © 2005 Patrick Fish, et al. |
| 3 |
pippijn |
1.2 |
* Rights to this code are as documented in doc/pod/license.pod. |
| 4 |
pippijn |
1.1 |
* |
| 5 |
|
|
* This file contains code for nickserv RESETPASS |
| 6 |
|
|
* |
| 7 |
pippijn |
1.2 |
* $Id: resetpass.C,v 1.1 2007-07-19 08:24:54 pippijn Exp $ |
| 8 |
pippijn |
1.1 |
*/ |
| 9 |
|
|
|
| 10 |
|
|
#include "atheme.h" |
| 11 |
|
|
#include <account/myuser.h> |
| 12 |
|
|
|
| 13 |
|
|
static char const rcsid[] = "$Id"; |
| 14 |
|
|
|
| 15 |
|
|
struct ns_resetpass_listeners : callback::has_listeners |
| 16 |
|
|
{ |
| 17 |
|
|
}; |
| 18 |
|
|
|
| 19 |
|
|
ns_resetpass_listeners listeners; |
| 20 |
|
|
|
| 21 |
|
|
DECLARE_MODULE_V1 ("nickserv/resetpass", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>"); |
| 22 |
|
|
|
| 23 |
|
|
static void ns_cmd_resetpass (sourceinfo_t *si, int parc, char *parv[]); |
| 24 |
|
|
|
| 25 |
|
|
command_t ns_resetpass = { "RESETPASS", N_("Resets a nickname password."), PRIV_USER_ADMIN, 1, ns_cmd_resetpass }; |
| 26 |
|
|
|
| 27 |
|
|
cmdvec *ns_cmdtree; |
| 28 |
|
|
helpvec *ns_helptree; |
| 29 |
|
|
|
| 30 |
|
|
void |
| 31 |
|
|
_modinit (module_t *m) |
| 32 |
|
|
{ |
| 33 |
|
|
MODULE_USE_SYMBOL_T (ns_cmdtree, cmdvec, "nickserv/main", "ns_cmdtree"); |
| 34 |
|
|
MODULE_USE_SYMBOL_T (ns_helptree, helpvec, "nickserv/main", "ns_helptree"); |
| 35 |
|
|
|
| 36 |
|
|
ns_cmdtree << ns_resetpass; |
| 37 |
|
|
help_addentry (ns_helptree, "RESETPASS", "help/nickserv/resetpass", NULL); |
| 38 |
|
|
} |
| 39 |
|
|
|
| 40 |
|
|
void |
| 41 |
|
|
_moddeinit () |
| 42 |
|
|
{ |
| 43 |
|
|
ns_cmdtree >> ns_resetpass; |
| 44 |
|
|
help_delentry (ns_helptree, "RESETPASS"); |
| 45 |
|
|
} |
| 46 |
|
|
|
| 47 |
|
|
static void |
| 48 |
|
|
ns_cmd_resetpass (sourceinfo_t *si, int parc, char *parv[]) |
| 49 |
|
|
{ |
| 50 |
|
|
myuser_t *mu; |
| 51 |
|
|
metadata *md; |
| 52 |
|
|
char *name = parv[0]; |
| 53 |
|
|
char *newpass; |
| 54 |
|
|
|
| 55 |
|
|
if (!name) |
| 56 |
|
|
{ |
| 57 |
|
|
command_fail (si, fault_needmoreparams, STR_INVALID_PARAMS, "RESETPASS"); |
| 58 |
|
|
command_fail (si, fault_needmoreparams, _("Syntax: RESETPASS <nickname>")); |
| 59 |
|
|
return; |
| 60 |
|
|
} |
| 61 |
|
|
|
| 62 |
|
|
if (!(mu = myuser_find (name))) |
| 63 |
|
|
{ |
| 64 |
|
|
command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), name); |
| 65 |
|
|
return; |
| 66 |
|
|
} |
| 67 |
|
|
|
| 68 |
|
|
if (is_soper (mu) && !has_priv (si, PRIV_ADMIN)) |
| 69 |
|
|
{ |
| 70 |
|
|
logcommand (si, CMDLOG_ADMIN, "failed RESETPASS %s (is SOPER)", name); |
| 71 |
|
|
command_fail (si, fault_badparams, _("\2%s\2 belongs to a services operator; you need %s privilege to reset the password."), name, PRIV_ADMIN); |
| 72 |
|
|
return; |
| 73 |
|
|
} |
| 74 |
|
|
|
| 75 |
|
|
if ((md = mu->find_metadata ("private:mark:setter")) && has_priv (si, PRIV_MARK)) |
| 76 |
|
|
{ |
| 77 |
|
|
logcommand (si, CMDLOG_ADMIN, "RESETPASS %s (overriding mark by %s)", name, md->value); |
| 78 |
|
|
command_success_nodata (si, _("Overriding MARK placed by %s on the nickname %s."), md->value, name); |
| 79 |
|
|
newpass = gen_pw (12); |
| 80 |
|
|
command_success_nodata (si, _("The password for the nickname %s has been changed to %s."), name, newpass); |
| 81 |
|
|
set_password (mu, newpass); |
| 82 |
|
|
free (newpass); |
| 83 |
|
|
wallops ("%s reset the password for the \2MARKED\2 nickname %s.", get_oper_name (si), name); |
| 84 |
|
|
snoop ("RESETPASS: \2%s\2 by \2%s\2", name, get_oper_name (si)); |
| 85 |
|
|
return; |
| 86 |
|
|
} |
| 87 |
|
|
|
| 88 |
|
|
if ((md = mu->find_metadata ("private:mark:setter"))) |
| 89 |
|
|
{ |
| 90 |
|
|
logcommand (si, CMDLOG_ADMIN, "failed RESETPASS %s (marked by %s)", name, md->value); |
| 91 |
|
|
command_fail (si, fault_badparams, _("This operation cannot be performed on %s, because the nickname has been marked by %s."), name, md->value); |
| 92 |
|
|
return; |
| 93 |
|
|
} |
| 94 |
|
|
|
| 95 |
|
|
newpass = gen_pw (12); |
| 96 |
|
|
command_success_nodata (si, _("The password for the nickname %s has been changed to %s."), name, newpass); |
| 97 |
|
|
set_password (mu, newpass); |
| 98 |
|
|
free (newpass); |
| 99 |
|
|
mu->del_metadata ("private:setpass:key"); |
| 100 |
|
|
|
| 101 |
|
|
wallops ("%s reset the password for the nickname %s", get_oper_name (si), name); |
| 102 |
|
|
snoop ("RESETPASS: \2%s\2 by \2%s\2", name, get_oper_name (si)); |
| 103 |
|
|
logcommand (si, CMDLOG_ADMIN, "RESETPASS %s", name); |
| 104 |
|
|
} |