ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/resetpass.C
Revision: 1.4
Committed: Tue Aug 28 17:08:10 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +16 -22 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

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