ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/resetpass.C
Revision: 1.7
Committed: Wed Sep 5 11:23:13 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +3 -3 lines
Log Message:
removed GPLed code and put license back to BSD

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.7 * $Id: resetpass.C,v 1.6 2007-08-30 19:56:23 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.7 static char const rcsid[] = "$Id: resetpass.C,v 1.6 2007-08-30 19:56:23 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 pippijn 1.7 metadata *md;
46 pippijn 1.1 char *name = parv[0];
47     char *newpass;
48    
49     if (!name)
50     {
51 pippijn 1.6 command_fail (si, fault::needmoreparams, STR_INVALID_PARAMS, "RESETPASS");
52     command_fail (si, fault::needmoreparams, _("Syntax: RESETPASS <nickname>"));
53 pippijn 1.1 return;
54     }
55    
56 pippijn 1.5 if (!(mu = myuser_t::find (name)))
57 pippijn 1.1 {
58 pippijn 1.6 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), name);
59 pippijn 1.1 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 pippijn 1.6 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 pippijn 1.1 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 pippijn 1.6 command_fail (si, fault::badparams, _("This operation cannot be performed on %s, because the nickname has been marked by %s."), name, md->value);
86 pippijn 1.1 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     }