ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/resetpass.C
Revision: 1.1
Committed: Thu Jul 19 08:24:54 2007 UTC (19 years, 2 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2005 Patrick Fish, et al.
3     * Rights to this code are as documented in doc/LICENSE.
4     *
5     * This file contains code for nickserv RESETPASS
6     *
7     * $Id: resetpass.c 7895 2007-03-06 02:40:03Z pippijn $
8     */
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     }