2 * IRC - Internet Relay Chat, ircd/m_recover.c
3 * Copyright (C) 2012 Philipp Kreil <srvx@pk910.de>
5 * See file AUTHORS in IRC package for additional names of
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 1, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * m_functions execute protocol messages on this server:
27 * cptr is always NON-NULL, pointing to a *LOCAL* client
28 * structure (with an open socket connected!). This
29 * identifies the physical socket where the message
30 * originated (or which caused the m_function to be
31 * executed--some m_functions may call others...).
33 * sptr is the source of the message, defined by the
34 * prefix part of the message if present. If not
35 * or prefix not found, then sptr==cptr.
37 * (!IsServer(cptr)) => (cptr == sptr), because
38 * prefixes are taken *only* from servers...
41 * (sptr == cptr) => the message didn't
44 * (sptr != cptr && IsServer(sptr) means
45 * the prefix specified servername. (?)
47 * (sptr != cptr && !IsServer(sptr) means
48 * that message originated from a remote
53 * (!IsServer(sptr)) means that, sptr can safely
54 * taken as defining the target structure of the
55 * message in this server.
57 * *Always* true (if 'parse' and others are working correct):
59 * 1) sptr->from == cptr (note: cptr->from == cptr)
61 * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
62 * *cannot* be a local connection, unless it's
63 * actually cptr!). [MyConnect(x) should probably
64 * be defined as (x == x->from) --msa ]
66 * parc number of variable parameter strings (if zero,
67 * parv is allowed to be NULL)
69 * parv a NULL terminated list of parameter pointers,
71 * parv[0], sender (prefix string), if not present
72 * this points to an empty string.
73 * parv[1]...parv[parc-1]
74 * pointers to additional parameters
75 * parv[parc] == NULL, *always*
77 * note: it is guaranteed that parv[0]..parv[parc-1] are all
85 #include "ircd_reply.h"
86 #include "ircd_string.h"
97 /** m_recover - Try to recover a disconnected Client (Zombie)
99 * parv[0] = sender prefix
100 * parv[1] = nick of the zombie to be recovered
102 int m_recover(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
104 struct Client *victim;
107 return need_more_params(sptr, "RECOVER");
110 if(!IsAccount(sptr)) {
111 send_reply(sptr, ERR_NOTREGISTERED);
115 if (!(victim = findUser(parv[1]))) {
116 send_reply(sptr, ERR_NOSUCHNICK, parv[1]);
120 if (!IsNotConn(victim)) {
121 send_reply(sptr, ERR_RECOVERDENIED, cli_name(victim), "not zombie");
124 assert(IsAccount(victim));
126 const struct User* sptr_user = cli_user(sptr);
127 const struct User* victim_user = cli_user(victim);
128 if(ircd_strcmp(sptr_user->account, victim_user->account)) {
129 send_reply(sptr, ERR_RECOVERDENIED, cli_name(victim), "auth missmatch");
133 unzombie_client(&me, &me, sptr, victim);