ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/drop.C
Revision: 1.7
Committed: Thu Aug 30 19:56:23 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +11 -11 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.4 * 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.7 * $Id: drop.C,v 1.6 2007-08-29 08:04:33 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/mynick.h>
13     #include <account/myuser.h>
14    
15 pippijn 1.7 static char const rcsid[] = "$Id: drop.C,v 1.6 2007-08-29 08:04:33 pippijn Exp $";
16 pippijn 1.1
17 pippijn 1.4 REGISTER_MODULE ("nickserv/drop", false, "The Ermyth Team <http://ermyth.schmorp.de>");
18 pippijn 1.1
19     static void ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[]);
20    
21 pippijn 1.4 command_t const ns_drop = { "DROP", N_("Drops an account registration."), AC_NONE, 2, ns_cmd_drop };
22 pippijn 1.1
23 pippijn 1.4 E cmdvec ns_cmdtree;
24     E helpvec ns_helptree;
25 pippijn 1.1
26 pippijn 1.4 bool
27     _modinit (module *m)
28 pippijn 1.1 {
29     ns_cmdtree << ns_drop;
30     help_addentry (ns_helptree, "DROP", "help/nickserv/drop", NULL);
31 pippijn 1.4
32     return true;
33 pippijn 1.1 }
34    
35     void
36     _moddeinit ()
37     {
38     ns_cmdtree >> ns_drop;
39     help_delentry (ns_helptree, "DROP");
40     }
41    
42     static void
43     ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[])
44     {
45     myuser_t *mu;
46     mynick_t *mn;
47     char *acc = parv[0];
48     char *pass = parv[1];
49    
50     if (!acc)
51     {
52 pippijn 1.7 command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP");
53     command_fail (si, fault::needmoreparams, _("Syntax: DROP <account> <password>"));
54 pippijn 1.1 return;
55     }
56    
57 pippijn 1.5 if (!(mu = myuser_t::find (acc)))
58 pippijn 1.1 {
59     if (!nicksvs.no_nick_ownership)
60     {
61     mn = mynick_find (acc);
62     if (mn != NULL && si->service->cmdtree->find ("UNGROUP"))
63     {
64 pippijn 1.7 command_fail (si, fault::nosuch_target, _("\2%s\2 is a grouped nick, use UNGROUP to remove it."), acc);
65 pippijn 1.1 return;
66     }
67     }
68 pippijn 1.7 command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), acc);
69 pippijn 1.1 return;
70     }
71 pippijn 1.4
72     if (!has_priv (si, PRIV_USER_ADMIN) && mu->find_metadata ("private:freeze:freezer"))
73     {
74 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);
75 pippijn 1.4 return;
76     }
77 pippijn 1.1
78 pippijn 1.4 if ((pass || !has_priv (si, PRIV_USER_ADMIN)) && !mu->verify_password (pass))
79 pippijn 1.1 {
80 pippijn 1.7 command_fail (si, fault::authfail, _("Authentication failed. Invalid password for \2%s\2."), mu->name);
81 pippijn 1.1 return;
82     }
83    
84     if (!nicksvs.no_nick_ownership && pass && LIST_LENGTH (&mu->nicks) > 1 && si->service->cmdtree->find ("UNGROUP"))
85     {
86 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);
87 pippijn 1.1 return;
88     }
89    
90     if (is_soper (mu))
91     {
92 pippijn 1.7 command_fail (si, fault::noprivs, _("The nickname \2%s\2 belongs to a services operator; it cannot be dropped."), acc);
93 pippijn 1.1 return;
94     }
95    
96     if (mu->flags & MU_HOLD)
97     {
98 pippijn 1.7 command_fail (si, fault::noprivs, _("The account \2%s\2 is held; it cannot be dropped."), acc);
99 pippijn 1.1 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 pippijn 1.4 mu->callback.drop (mu);
108 pippijn 1.1 command_success_nodata (si, _("The account \2%s\2 has been dropped."), mu->name);
109 pippijn 1.6 mu->refcnt_dec (); // XXX: what if this does not delete a myuser? mark as dead?
110 pippijn 1.1 }