ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/drop.C
Revision: 1.10
Committed: Sat Sep 22 14:27:27 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +3 -3 lines
Log Message:
split up ermyth into ermyth-modules, libermyth (currently just ermyth-util) and ermyth-core

File Contents

# User Rev Content
1 pippijn 1.9 /**
2     * drop.C: This file contains code for the nickserv DROP function.
3     *
4     * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5     * Rights to this code are as documented in COPYING.
6     *
7     *
8     * Portions of this file were derived from sources bearing the following license:
9 pippijn 1.4 * Copyright © 2005 William Pitcock, et al.
10 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
11 pippijn 1.1 *
12 pippijn 1.10 * $Id: drop.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $
13 pippijn 1.1 */
14    
15     #include "atheme.h"
16 pippijn 1.4 #include <ermyth/module.h>
17 pippijn 1.1 #include <account/mynick.h>
18     #include <account/myuser.h>
19    
20 pippijn 1.10 static char const rcsid[] = "$Id: drop.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $";
21 pippijn 1.1
22 pippijn 1.10 REGISTER_MODULE ("nickserv/drop", false, "The Ermyth Team <http://ermyth.xinutec.org>");
23 pippijn 1.1
24     static void ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[]);
25    
26 pippijn 1.4 command_t const ns_drop = { "DROP", N_("Drops an account registration."), AC_NONE, 2, ns_cmd_drop };
27 pippijn 1.1
28 pippijn 1.4 E cmdvec ns_cmdtree;
29     E helpvec ns_helptree;
30 pippijn 1.1
31 pippijn 1.4 bool
32     _modinit (module *m)
33 pippijn 1.1 {
34     ns_cmdtree << ns_drop;
35     help_addentry (ns_helptree, "DROP", "help/nickserv/drop", NULL);
36 pippijn 1.4
37     return true;
38 pippijn 1.1 }
39    
40     void
41     _moddeinit ()
42     {
43     ns_cmdtree >> ns_drop;
44     help_delentry (ns_helptree, "DROP");
45     }
46    
47     static void
48     ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[])
49     {
50     myuser_t *mu;
51     mynick_t *mn;
52     char *acc = parv[0];
53     char *pass = parv[1];
54    
55     if (!acc)
56     {
57 pippijn 1.7 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP");
58     command_fail (si, fault::needmoreparams, _("Syntax: DROP <account> <password>"));
59 pippijn 1.1 return;
60     }
61    
62 pippijn 1.5 if (!(mu = myuser_t::find (acc)))
63 pippijn 1.1 {
64     if (!nicksvs.no_nick_ownership)
65     {
66 pippijn 1.8 mn = mynick_t::find (acc);
67 pippijn 1.1 if (mn != NULL && si->service->cmdtree->find ("UNGROUP"))
68     {
69 pippijn 1.7 command_fail (si, fault::nosuch_target, _("\2%s\2 is a grouped nick, use UNGROUP to remove it."), acc);
70 pippijn 1.1 return;
71     }
72     }
73 pippijn 1.7 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), acc);
74 pippijn 1.1 return;
75     }
76 pippijn 1.4
77     if (!has_priv (si, PRIV_USER_ADMIN) && mu->find_metadata ("private:freeze:freezer"))
78     {
79 pippijn 1.7 command_fail (si, fault::authfail, nicksvs.no_nick_ownership ? "You cannot login as \2%s\2 because the account has been frozen." : "You cannot identify to \2%s\2 because the nickname has been frozen.", mu->name);
80 pippijn 1.4 return;
81     }
82 pippijn 1.1
83 pippijn 1.4 if ((pass || !has_priv (si, PRIV_USER_ADMIN)) && !mu->verify_password (pass))
84 pippijn 1.1 {
85 pippijn 1.7 command_fail (si, fault::authfail, _("Authentication failed. Invalid password for \2%s\2."), mu->name);
86 pippijn 1.1 return;
87     }
88    
89     if (!nicksvs.no_nick_ownership && pass && LIST_LENGTH (&mu->nicks) > 1 && si->service->cmdtree->find ("UNGROUP"))
90     {
91 pippijn 1.7 command_fail (si, fault::noprivs, _("Account \2%s\2 has %d other nick(s) grouped to it, remove those first."), mu->name, LIST_LENGTH (&mu->nicks) - 1);
92 pippijn 1.1 return;
93     }
94    
95     if (is_soper (mu))
96     {
97 pippijn 1.7 command_fail (si, fault::noprivs, _("The nickname \2%s\2 belongs to a services operator; it cannot be dropped."), acc);
98 pippijn 1.1 return;
99     }
100    
101     if (mu->flags & MU_HOLD)
102     {
103 pippijn 1.7 command_fail (si, fault::noprivs, _("The account \2%s\2 is held; it cannot be dropped."), acc);
104 pippijn 1.1 return;
105     }
106    
107     if (!pass)
108     wallops ("%s dropped the account \2%s\2", get_oper_name (si), mu->name);
109    
110     snoop ("DROP: \2%s\2 by \2%s\2", mu->name, get_oper_name (si));
111     logcommand (si, pass ? CMDLOG_REGISTER : CMDLOG_ADMIN | LG_REGISTER, "DROP %s%s", mu->name, pass ? "" : " (admin)");
112 pippijn 1.4 mu->callback.drop (mu);
113 pippijn 1.1 command_success_nodata (si, _("The account \2%s\2 has been dropped."), mu->name);
114 pippijn 1.6 mu->refcnt_dec (); // XXX: what if this does not delete a myuser? mark as dead?
115 pippijn 1.1 }