ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/drop.C
Revision: 1.3
Committed: Sat Jul 21 13:23:20 2007 UTC (19 years, 2 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +2 -2 lines
Log Message:
- added rcsid to some files
- more documentation tweaks
- made most protocol commands local to phandler.C
- added ircd metadata (inspircd only for now)
- added inspircd swhois support

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2005 William Pitcock, 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 the nickserv DROP function.
6     *
7 pippijn 1.3 * $Id: drop.C,v 1.2 2007-07-21 01:29:09 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11     #include <account/mynick.h>
12     #include <account/myuser.h>
13    
14 pippijn 1.3 static char const rcsid[] = "$Id$";
15 pippijn 1.1
16     struct ns_drop_listeners : callback::has_listeners
17     {
18     };
19    
20     ns_drop_listeners listeners;
21    
22     DECLARE_MODULE_V1 ("nickserv/drop", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
23    
24     static void ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[]);
25    
26     command_t ns_drop = { "DROP", N_("Drops an account registration."), AC_NONE, 2, ns_cmd_drop };
27    
28     cmdvec *ns_cmdtree;
29     helpvec *ns_helptree;
30    
31     void
32     _modinit (module_t *m)
33     {
34     MODULE_USE_SYMBOL_T (ns_cmdtree, cmdvec, "nickserv/main", "ns_cmdtree");
35     MODULE_USE_SYMBOL_T (ns_helptree, helpvec, "nickserv/main", "ns_helptree");
36    
37     ns_cmdtree << ns_drop;
38     help_addentry (ns_helptree, "DROP", "help/nickserv/drop", NULL);
39     }
40    
41     void
42     _moddeinit ()
43     {
44     ns_cmdtree >> ns_drop;
45     help_delentry (ns_helptree, "DROP");
46     }
47    
48     static void
49     ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[])
50     {
51     myuser_t *mu;
52     mynick_t *mn;
53     char *acc = parv[0];
54     char *pass = parv[1];
55    
56     if (!acc)
57     {
58     command_fail (si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP");
59     command_fail (si, fault_needmoreparams, _("Syntax: DROP <account> <password>"));
60     return;
61     }
62    
63     if (!(mu = myuser_find (acc)))
64     {
65     if (!nicksvs.no_nick_ownership)
66     {
67     mn = mynick_find (acc);
68     if (mn != NULL && si->service->cmdtree->find ("UNGROUP"))
69     {
70     command_fail (si, fault_nosuch_target, _("\2%s\2 is a grouped nick, use UNGROUP to remove it."), acc);
71     return;
72     }
73     }
74     command_fail (si, fault_nosuch_target, _("\2%s\2 is not registered."), acc);
75     return;
76     }
77    
78     if ((pass || !has_priv (si, PRIV_USER_ADMIN)) && !verify_password (mu, pass))
79     {
80     command_fail (si, fault_authfail, _("Authentication failed. Invalid password for \2%s\2."), mu->name);
81     return;
82     }
83    
84     if (!nicksvs.no_nick_ownership && pass && LIST_LENGTH (&mu->nicks) > 1 && si->service->cmdtree->find ("UNGROUP"))
85     {
86     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);
87     return;
88     }
89    
90     if (is_soper (mu))
91     {
92     command_fail (si, fault_noprivs, _("The nickname \2%s\2 belongs to a services operator; it cannot be dropped."), acc);
93     return;
94     }
95    
96     if (mu->flags & MU_HOLD)
97     {
98     command_fail (si, fault_noprivs, _("The account \2%s\2 is held; it cannot be dropped."), acc);
99     return;
100     }
101    
102     if (!pass)
103     wallops ("%s dropped the account \2%s\2", get_oper_name (si), mu->name);
104    
105     snoop ("DROP: \2%s\2 by \2%s\2", mu->name, get_oper_name (si));
106     logcommand (si, pass ? CMDLOG_REGISTER : CMDLOG_ADMIN | LG_REGISTER, "DROP %s%s", mu->name, pass ? "" : " (admin)");
107     hook_call_event ("user_drop", mu);
108     command_success_nodata (si, _("The account \2%s\2 has been dropped."), mu->name);
109     object_unref (mu);
110     }
111    
112     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
113     * vim:ts=8
114     * vim:sw=8
115     * vim:noexpandtab
116     */