/** * ghost.C: This file contains code for the NickServ GHOST function. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Copyright © 2005-2007 William Pitcock, et al. * Rights to this code are as documented in doc/pod/license.pod. * * $Id: ghost.C,v 1.9 2007/09/22 14:27:27 pippijn Exp $ */ #include "atheme.h" #include #include #include #include static char const rcsid[] = "$Id: ghost.C,v 1.9 2007/09/22 14:27:27 pippijn Exp $"; REGISTER_MODULE ("nickserv/ghost", false, "The Ermyth Team "); static void ns_cmd_ghost (sourceinfo_t *si, int parc, char *parv[]); command_t const ns_ghost = { "GHOST", N_("Reclaims use of a nickname."), AC_NONE, 2, ns_cmd_ghost }; E cmdvec ns_cmdtree; E helpvec ns_helptree; bool _modinit (module *m) { ns_cmdtree << ns_ghost; help_addentry (ns_helptree, "GHOST", "help/nickserv/ghost", NULL); return true; } void _moddeinit () { ns_cmdtree >> ns_ghost; help_delentry (ns_helptree, "GHOST"); } void ns_cmd_ghost (sourceinfo_t *si, int parc, char *parv[]) { myuser_t *mu; char *target = parv[0]; char *password = parv[1]; user_t *target_u; mynick_t *mn; if (!target) { command_fail (si, fault::needmoreparams, STR_INSUFFICIENT_PARAMS, "GHOST"); command_fail (si, fault::needmoreparams, _("Syntax: GHOST [password]")); return; } if (nicksvs.no_nick_ownership) mn = NULL, mu = myuser_t::find (target); else { mn = mynick_t::find (target); mu = mn != NULL ? mn->owner : NULL; } target_u = user_find_named (target); if (!mu && (!target_u || !target_u->myuser)) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not a registered nickname."), target); return; } if (!target_u) { command_fail (si, fault::nosuch_target, _("\2%s\2 is not online."), target); return; } else if (target_u == si->su) { command_fail (si, fault::badparams, _("You may not ghost yourself.")); return; } if ((target_u->myuser && target_u->myuser == si->smu) || /* they're identified under our account */ (!nicksvs.no_nick_ownership && mn && mu == si->smu) || /* we're identified under their nick's account */ (!nicksvs.no_nick_ownership && password && mn && mu->verify_password (password))) /* we have their nick's password */ { /* If we're ghosting an unregistered nick, mu will be unset, * however if it _is_ registered, we still need to set it or * the wrong user will have their last seen time updated... */ if (target_u->myuser && target_u->myuser == si->smu) mu = target_u->myuser; logcommand (si, CMDLOG_DO, "GHOST %s!%s@%s", target_u->nick, target_u->user, target_u->vhost); phandler->skill (nicksvs.nick, target, "GHOST command used by %s", si->su != NULL && !strcmp (si->su->user, target_u->user) && !strcmp (si->su->vhost, target_u->vhost) ? si->su->nick : get_source_mask (si)); user_delete (target_u); command_success_nodata (si, _("\2%s\2 has been ghosted."), target); /* don't update the nick's last seen time */ mu->lastlogin = NOW; return; } if (password && mu) { logcommand (si, CMDLOG_DO, "failed GHOST %s (bad password)", target); command_fail (si, fault::authfail, _("Invalid password for \2%s\2."), mu->name); } else { logcommand (si, CMDLOG_DO, "failed GHOST %s (invalid login)", target); command_fail (si, fault::noprivs, _("You may not ghost \2%s\2."), target); } } /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs * vim:ts=8 * vim:sw=8 * vim:noexpandtab */