| 1 |
/** |
| 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 |
* Copyright © 2005 William Pitcock, et al. |
| 10 |
* Rights to this code are as documented in doc/pod/license.pod. |
| 11 |
* |
| 12 |
* $Id: drop.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $ |
| 13 |
*/ |
| 14 |
|
| 15 |
#include "atheme.h" |
| 16 |
#include <ermyth/module.h> |
| 17 |
#include <account/mynick.h> |
| 18 |
#include <account/myuser.h> |
| 19 |
|
| 20 |
static char const rcsid[] = "$Id: drop.C,v 1.9 2007-09-16 18:54:43 pippijn Exp $"; |
| 21 |
|
| 22 |
REGISTER_MODULE ("nickserv/drop", false, "The Ermyth Team <http://ermyth.xinutec.org>"); |
| 23 |
|
| 24 |
static void ns_cmd_drop (sourceinfo_t *si, int parc, char *parv[]); |
| 25 |
|
| 26 |
command_t const ns_drop = { "DROP", N_("Drops an account registration."), AC_NONE, 2, ns_cmd_drop }; |
| 27 |
|
| 28 |
E cmdvec ns_cmdtree; |
| 29 |
E helpvec ns_helptree; |
| 30 |
|
| 31 |
bool |
| 32 |
_modinit (module *m) |
| 33 |
{ |
| 34 |
ns_cmdtree << ns_drop; |
| 35 |
help_addentry (ns_helptree, "DROP", "help/nickserv/drop", NULL); |
| 36 |
|
| 37 |
return true; |
| 38 |
} |
| 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 |
command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "DROP"); |
| 58 |
command_fail (si, fault::needmoreparams, _("Syntax: DROP <account> <password>")); |
| 59 |
return; |
| 60 |
} |
| 61 |
|
| 62 |
if (!(mu = myuser_t::find (acc))) |
| 63 |
{ |
| 64 |
if (!nicksvs.no_nick_ownership) |
| 65 |
{ |
| 66 |
mn = mynick_t::find (acc); |
| 67 |
if (mn != NULL && si->service->cmdtree->find ("UNGROUP")) |
| 68 |
{ |
| 69 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is a grouped nick, use UNGROUP to remove it."), acc); |
| 70 |
return; |
| 71 |
} |
| 72 |
} |
| 73 |
command_fail (si, fault::nosuch_target, _("\2%s\2 is not registered."), acc); |
| 74 |
return; |
| 75 |
} |
| 76 |
|
| 77 |
if (!has_priv (si, PRIV_USER_ADMIN) && mu->find_metadata ("private:freeze:freezer")) |
| 78 |
{ |
| 79 |
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 |
return; |
| 81 |
} |
| 82 |
|
| 83 |
if ((pass || !has_priv (si, PRIV_USER_ADMIN)) && !mu->verify_password (pass)) |
| 84 |
{ |
| 85 |
command_fail (si, fault::authfail, _("Authentication failed. Invalid password for \2%s\2."), mu->name); |
| 86 |
return; |
| 87 |
} |
| 88 |
|
| 89 |
if (!nicksvs.no_nick_ownership && pass && LIST_LENGTH (&mu->nicks) > 1 && si->service->cmdtree->find ("UNGROUP")) |
| 90 |
{ |
| 91 |
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 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
if (is_soper (mu)) |
| 96 |
{ |
| 97 |
command_fail (si, fault::noprivs, _("The nickname \2%s\2 belongs to a services operator; it cannot be dropped."), acc); |
| 98 |
return; |
| 99 |
} |
| 100 |
|
| 101 |
if (mu->flags & MU_HOLD) |
| 102 |
{ |
| 103 |
command_fail (si, fault::noprivs, _("The account \2%s\2 is held; it cannot be dropped."), acc); |
| 104 |
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 |
mu->callback.drop (mu); |
| 113 |
command_success_nodata (si, _("The account \2%s\2 has been dropped."), mu->name); |
| 114 |
mu->refcnt_dec (); // XXX: what if this does not delete a myuser? mark as dead? |
| 115 |
} |