svshost/nick commands added in m_svscmds.c sethost fixed up to relay to other servers correctly. other updates that escape me now

This commit is contained in:
fishwaldo 2002-09-05 10:48:36 +00:00
parent fade11fb8f
commit e5ea01201f
12 changed files with 260 additions and 58 deletions

1
.gitattributes vendored
View file

@ -376,6 +376,7 @@ modules/m_set.c -text
modules/m_sethost.c -text
modules/m_stats.c -text
modules/m_svinfo.c -text
modules/m_svscmds.c -text
modules/m_testline.c -text
modules/m_time.c -text
modules/m_topic.c -text

View file

@ -27,4 +27,5 @@ Symbols are:
(HP) - Big arse rc2 patch for Hybrid. Sigh. Found a cute bug in hybrid that would allow it to accept any password for /oper though!
(F) - Removed all ifdef HALFOP ANONOP VCHAN defines, as these will be standard in NeoIRCd
(F) - Removed all OANDVcode as its not going to be used at all
(F) - Removed all Vchan Code and finished rc2 patch from hybrid merge
(F) - Removed all Vchan Code and finished rc2 patch from hybrid merge
(F) - Added svshost and svsnick commands in module m_svscmds.c for begining of service support

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: numeric.h,v 1.4 2002/09/02 04:10:59 fishwaldo Exp $
* $Id: numeric.h,v 1.5 2002/09/05 10:48:36 fishwaldo Exp $
*/
#ifndef INCLUDED_numeric_h
@ -201,8 +201,8 @@ extern const char* form_str(int);
#define RPL_TEXT 304
#define RPL_UNAWAY 305
#define RPL_NOWAWAY 306
#define RPL_USERIP 307 /* Undernet extension */
/* RPL_WHOISREGNICK 307 Numeric List: Dalnet */
/* RPL_USERIP 307 Undernet extension */
#define RPL_WHOISREGNICK 307 /* Numeric List: Dalnet */
/* RPL_SUSERHOST 307 austnet */
/* RPL_NOTIFYACTION 308 aircd */
/* RPL_WHOISADMIN 308 Numeric List: Dalnet */

View file

@ -1,7 +1,7 @@
#
# Makefile.in for ircd/modules
#
# $Id: Makefile.in,v 1.3 2002/09/02 04:10:59 fishwaldo Exp $
# $Id: Makefile.in,v 1.4 2002/09/05 10:48:36 fishwaldo Exp $
#
CC = @CC@
AR = @AR@
@ -103,7 +103,8 @@ SRCS = \
m_who.c \
m_whois.c \
m_whowas.c \
m_sethost.c
m_sethost.c \
m_svscmds.c
ALL_SRCS = $(CORE_SRCS) \
$(SRCS)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: m_sethost.c,v 1.1 2002/08/13 14:52:06 fishwaldo Exp $
* $Id: m_sethost.c,v 1.2 2002/09/05 10:48:36 fishwaldo Exp $
*/
/* List of ircd includes from ../include/ */
@ -49,8 +49,6 @@
*/
static void ms_sethost(struct Client *client_p, struct Client *source_p,
int parc, char *parv[]);
static void set_sethost_capab();
static void unset_sethost_capab();
/* Show the commands this module can handle in a msgtab
* and give the msgtab a name, here its test_msgtab
@ -69,7 +67,6 @@ _modinit(void)
{
/* This will add the commands in test_msgtab (which is above) */
mod_add_cmd(&sethost_msgtab);
set_sethost_capab();
}
/* here we tell it what to do when the module is unloaded */
@ -78,12 +75,11 @@ _moddeinit(void)
{
/* This will remove the commands in test_msgtab (which is above) */
mod_del_cmd(&sethost_msgtab);
unset_sethost_capab();
}
/* When we last modified the file (shown in /modlist), this is usually:
*/
const char *_version = "$Revision: 1.1 $";
const char *_version = "$Revision: 1.2 $";
#endif
/*
@ -103,12 +99,14 @@ static void ms_sethost(struct Client *client_p, struct Client *source_p,
/* first find the target that we want to change */
if (target_p != NULL) {
ilog(L_WARN, "Found Target %s", target_p->name);
if (target_p == source_p) {
if (IsServer(source_p)) {
/* client is changing his own hostname */
ilog(L_WARN, "Target is source");
/* check its not a client on my server, because this is a error then */
/* use svshost instead. */
if (MyClient(target_p)) {
ilog(L_WARN, "Target is my client?");
return;
@ -119,15 +117,15 @@ static void ms_sethost(struct Client *client_p, struct Client *source_p,
strncpy(target_p->vhost, parv[2], HOSTLEN);
/* send it to the rest of the net */
sendto_server(NULL, source_p, NULL, CAP_MODEX, 0, LL_ICLIENT, ":%s SETHOST %s :%s", source_p->name, source_p->name, source_p->vhost);
sendto_server(source_p, source_p, NULL, 0, 0, LL_ICLIENT, ":%s SETHOST %s :%s", me.name, source_p->name, source_p->vhost);
return;
} else {
} else if (IsClient(source_p)) {
/* can't change someone else's host. (services use svshost) */
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
return;
}
} else
ilog(L_WARN, "shouldn't be here");
} else {
ilog(L_WARN, "Couldn't find target %s", parv[1]);
@ -137,32 +135,5 @@ static void ms_sethost(struct Client *client_p, struct Client *source_p,
}
static void set_sethost_capab()
{
default_server_capabs |= CAP_MODEX;
}
static void unset_sethost_capab()
{
default_server_capabs &= ~CAP_MODEX;
}
#if 0
/* its someone else changing the targets host
* check the source_p is either a Ulined Box, or Services
*/
ilog(L_WARN, "Changing someone else %s %s", source_p->name, target_p->name);
if (IsServer(source_p) && (!IsUlined(source_p))) {
ilog(L_WARN, "non ulined server tried to sethost");
return;
}
if (IsPerson(source_p) && (!IsServices(source_p))) {
ilog(L_WARN, "non Services trying to sethost");
return;
}
ilog(L_WARN, "Setting host of %s from %s", target_p->name, source_p->name);
strncpy(target_p->vhost, parv[2], HOSTLEN);
return;
}
#endif

221
modules/m_svscmds.c Normal file
View file

@ -0,0 +1,221 @@
/************************************************************************
* IRC - Internet Relay Chat, doc/example_module.c
* Copyright (C) 2001 Hybrid Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: m_svscmds.c,v 1.1 2002/09/05 10:48:36 fishwaldo Exp $
*/
/* List of ircd includes from ../include/ */
#include "stdinc.h"
#include "handlers.h"
#include "client.h"
#include "common.h" /* FALSE bleah */
#include "ircd.h"
#include "irc_string.h"
#include "numeric.h"
#include "fdlist.h"
#include "s_bsd.h"
#include "s_conf.h"
#include "s_log.h"
#include "s_serv.h"
#include "send.h"
#include "msg.h"
#include "parse.h"
#include "modules.h"
#include "hash.h"
#include "whowas.h"
/* Declare the void's initially up here, as modules dont have an
* include file, we will normally have client_p, source_p, parc
* and parv[] where:
*
* client_p == client issuing command
* source_p == where the command came from
* parc == the number of parameters
* parv == an array of the parameters
*/
static void ms_svshost(struct Client *client_p, struct Client *source_p,
int parc, char *parv[]);
static void ms_svsnick(struct Client *client_p, struct Client *source_p,
int parc, char *parv[]);
static int clean_nick_name(char *);
/* Show the commands this module can handle in a msgtab
* and give the msgtab a name, here its test_msgtab
*/
struct Message svshost_msgtab = {
"SVSHOST", 0, 0, 3, 3, MFLG_SLOW, 0,
{m_ignore, m_ignore, ms_svshost, m_ignore}
};
struct Message svsnick_msgtab = {
"SVSNICK", 0, 0, 3, 3, MFLG_SLOW, 0,
{m_ignore, m_ignore, ms_svsnick, m_ignore}
};
/* Thats the msgtab finished */
#ifndef STATIC_MODULES
/* Here we tell it what to do when the module is loaded */
void
_modinit(void)
{
/* This will add the commands in test_msgtab (which is above) */
mod_add_cmd(&svshost_msgtab);
mod_add_cmd(&svsnick_msgtab);
}
/* here we tell it what to do when the module is unloaded */
void
_moddeinit(void)
{
/* This will remove the commands in test_msgtab (which is above) */
mod_del_cmd(&svshost_msgtab);
mod_del_cmd(&svsnick_msgtab);
}
/* When we last modified the file (shown in /modlist), this is usually:
*/
const char *_version = "$Revision: 1.1 $";
#endif
/*
* ms_svshost
* Changes the Targets Virtual Hostname, and also sets +x if its not set already on the target
* parv[0] = sender prefix
* parv[1] = target
* parv[2] = new hostname
*/
static void ms_svshost(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
struct Client *target_p;
target_p = find_person(parv[1]);
/* first find the target that we want to change */
if (target_p != NULL) {
ilog(L_WARN, "svshost: Found Target %s", target_p->name);
if (IsServer(source_p) && IsUlined(source_p)) {
ilog(L_WARN, "svshost: Setting his own hostname %s (from %s)", target_p->name, client_p->name);
SetHidden(target_p);
strncpy(target_p->vhost, parv[2], HOSTLEN);
/* send it to the rest of the net */
sendto_server(client_p, target_p, NULL, 0, 0, LL_ICLIENT, ":%s SVSHOST %s :%s", source_p->name, target_p->name, target_p->vhost);
return;
} else {
sendto_realops_flags(FLAGS_ALL, L_ALL, "Non U-Lined Server %s is attempting to use svshost on %s", source_p->name, target_p->name);
return;
}
} else {
ilog(L_WARN, "svshost: Couldn't find target %s", parv[1]);
/* we couldn't find the target. Just exit */
return;
}
}
/*
* ms_svsnick
* Changes the targets nickname
* parv[0] = sender prefix
* parv[1] = target
* parv[2] = new nickname
* parv[3] = ts
*
*/
static void ms_svsnick(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
struct Client *target_p;
target_p = find_person(parv[1]);
if (target_p == NULL) {
ilog(L_WARN, "SVSNICK from %s was invalid. Can't find the client", parv[1]);
return;
}
if (!IsClient(target_p))
return;
if (!IsUlined(source_p)) {
sendto_realops_flags(FLAGS_ALL, L_ALL, "Non U-Lined Server %s is attempting to use svsnick on %s", source_p->name, target_p->name);
return;
}
/* first find the target that we want to change */
if (MyClient(target_p)) {
if (!clean_nick_name(parv[2]) || !strcmp(target_p->name, parv[2])) {
ilog(L_WARN, "svsnick: invalid nickname");
return;
}
target_p->tsinfo = parv[4] ? atol(parv[3]) : CurrentTime;
sendto_common_channels_local(target_p, ":%s!%s@%s NICK :%s", target_p->name, target_p->username, target_p->vhost, parv[2]);
/* send it to the other servers */
if (target_p->user) {
add_history(target_p, 1);
sendto_server(NULL, target_p, NULL, 0, 0, LL_ICLIENT, ":%s NICK %s :%lu", target_p->name, parv[2], target_p->tsinfo);
}
if (target_p->name[0])
del_from_client_hash_table(target_p->name, target_p);
strcpy(target_p->name, parv[2]);
add_to_client_hash_table(target_p->name, target_p);
/* del all the accept entries for this nick */
del_all_accepts(target_p);
} else {
/* just relay the svsnick to a server that has this client */
sendto_one(target_p, ":%s SVSNICK %s %s :%lu", source_p->name, target_p->name, parv[2], atol(parv[3]));
}
return;
}
/* clean_nick_name()
*
* input - nickname
* output - none
* side effects - walks through the nickname, returning 0 if erroneous
*/
static int clean_nick_name(char *nick)
{
assert(nick);
if(nick == NULL)
return 0;
/* nicks cant start with a digit or - */
if (*nick == '-' || IsDigit(*nick))
return 0;
for(; *nick; nick++)
{
if(!IsNickChar(*nick))
return 0;
}
return 1;
}

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: m_whois.c,v 1.4 2002/09/02 07:41:15 fishwaldo Exp $
* $Id: m_whois.c,v 1.5 2002/09/05 10:48:36 fishwaldo Exp $
*/
#include "stdinc.h"
@ -76,7 +76,7 @@ _moddeinit(void)
mod_del_cmd(&whois_msgtab);
}
const char *_version = "$Revision: 1.4 $";
const char *_version = "$Revision: 1.5 $";
#endif
/*
** m_whois
@ -457,7 +457,7 @@ static void whois_person(struct Client *source_p,struct Client *target_p, int gl
if (IsServices(target_p))
sendto_one(source_p, form_str(RPL_WHOISSERVICES),
me.name, source_p->name, target_p->name);
if (IsOper(source_p))
if (IsOper(source_p) || (source_p == target_p))
{
send_umode(NULL, target_p, 0, ALL_UMODES, ubuf);
if (!*ubuf)
@ -471,7 +471,10 @@ static void whois_person(struct Client *source_p,struct Client *target_p, int gl
sendto_one(source_p, form_str(RPL_WHOISREALHOST),
me.name, source_p->name, target_p->name, target_p->host);
}
if (target_p->umodes & FLAGS_REGNICK) {
sendto_one(source_p, form_str(RPL_WHOISREGNICK),
me.name, source_p->name, target_p->name);
}
if ( (glob == 1) || (MyConnect(target_p) && (IsOper(source_p) ||
!ConfigServerHide.hide_servers)) || (target_p == source_p) )
{

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: channel_mode.c,v 1.8 2002/09/02 09:17:08 fishwaldo Exp $
* $Id: channel_mode.c,v 1.9 2002/09/05 10:48:36 fishwaldo Exp $
*/
#include "stdinc.h"
@ -697,9 +697,10 @@ chm_simple(struct Client *client_p, struct Client *source_p,
}
/* don't allow users to set +r */
if ((!IsServices(source_p) || !IsUlined(source_p->from)) && (mode_type == MODE_REGCHAN))
if ((!IsServices(source_p) || !IsUlined(source_p->from)) && (mode_type == MODE_REGCHAN)) {
sendto_one(source_p, ":%s NOTICE %s :Only Services can (un)set +r", me.name, source_p->name);
return;
}
/* setting + */
if ((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: ircd.c,v 1.4 2002/08/16 14:22:06 fishwaldo Exp $
* $Id: ircd.c,v 1.5 2002/09/05 10:48:36 fishwaldo Exp $
*/
#include "stdinc.h"
@ -475,7 +475,7 @@ static void check_pidfile(const char *filename)
{
/* log(L_ERROR, "Server is already running"); */
printf("ircd: daemon is already running\n");
// exit(-1);
exit(-1);
}
}
fbclose(fb);
@ -601,6 +601,9 @@ int main(int argc, char *argv[])
#ifdef __CYGWIN__
server_state.foreground = 1;
#endif
#ifdef DEBUG
server_state.foreground = 1;
#endif
if (!server_state.foreground)
{

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: messages.tab,v 1.3 2002/09/02 04:11:00 fishwaldo Exp $
* $Id: messages.tab,v 1.4 2002/09/05 10:48:36 fishwaldo Exp $
*/
static char * replies[] = {
@ -331,7 +331,7 @@ static char * replies[] = {
/* 304 RPL_TEXT, */ NULL,
/* 305 RPL_UNAWAY, */ ":%s 305 %s :You are no longer marked as being away",
/* 306 RPL_NOWAWAY, */ ":%s 306 %s :You have been marked as being away",
/* 307 */ NULL,
/* 307 RPL_WHOISREGNICK */ ":%s 307 %s %s :has identified for this nick",
/* 308 RPL_WHOISADMIN, */ ":%s 308 %s %s :is a Server Administrator",
/* 309 */ NULL,
/* 310 */ NULL,

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: s_serv.c,v 1.6 2002/09/02 04:11:00 fishwaldo Exp $
* $Id: s_serv.c,v 1.7 2002/09/05 10:48:36 fishwaldo Exp $
*/
#include "stdinc.h"
@ -852,7 +852,7 @@ void sendnick_TS(struct Client *client_p, struct Client *target_p)
target_p->username, target_p->host,
target_p->user->server, target_p->info);
if (IsHidden(target_p) && IsCapable(client_p, CAP_MODEX)) sendto_one(client_p, ":%s SETHOST %s :%s", target_p->name, target_p->name, target_p->vhost);
if (IsHidden(target_p)) sendto_one(client_p, ":%s SETHOST %s :%s", me.name, target_p->name, target_p->vhost);
}

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: s_user.c,v 1.7 2002/09/03 04:57:46 fishwaldo Exp $
* $Id: s_user.c,v 1.8 2002/09/05 10:48:36 fishwaldo Exp $
*/
#include "stdinc.h"
@ -505,7 +505,7 @@ register_local_user(struct Client *client_p, struct Client *source_p,
}
user_welcome(source_p);
introduce_client(client_p, source_p, user, nick);
if (IsHidden(source_p)) sendto_server(NULL, source_p, NULL, CAP_MODEX, 0, LL_ICLIENT, ":%s SETHOST %s :%s", source_p->name, source_p->name, source_p->vhost);
if (IsHidden(source_p)) sendto_server(NULL, source_p, NULL, 0, 0, LL_ICLIENT, ":%s SETHOST %s :%s", me.name, source_p->name, source_p->vhost);
return (0);
}