0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-02 21:59:02 +02:00

Automated merge with ssh://hg.atheme.org//hg/charybdis

This commit is contained in:
William Pitcock 2008-08-01 17:00:41 -05:00
commit 041d07b3d0
103 changed files with 4829 additions and 4882 deletions

View file

@ -1,9 +1,12 @@
syntax: glob
Makefile
*~
*.o
*.so
*.lo
*.la
*.orig
*.log
.deps
.libs
autom4te.cache
@ -14,13 +17,17 @@ include/serno.h
libratbox/include/libratbox_config.h
libratbox/include/librb-config.h
libratbox/include/stamp-h1
libratbox/libratbox.pc
libratbox/libtool
scripts/*.tbz2
scripts/*.tgz
servlink/servlink
src/ircd
src/lex.yy.c
src/version.c.last
src/y.tab.h
src/y.tab.c
ssld/ssld
tools/convertilines
tools/convertklines
tools/mkpasswd

View file

@ -7,7 +7,7 @@ network configurations.
The charybdis core team is listed in nick-alphabetical order:
dwr, Valery Yatsko <darkwire -at- darkwire.ru>
dwr, Valery Yatsko <darkwire -at- sellcenter.ru>
gxti, Michael Tharp <gxti -at- partiallystapled.com>
jilles, Jilles Tjoelker <jilles -at- stack.nl>
nenolod, William Pitcock <nenolod -at- nenolod.net>

22
TODO
View file

@ -4,6 +4,7 @@
[x] remove 2.8 report_error() in ratbox imported stuff
[F] client.c, channel.c is very 2.8 style still. it'd be nice to pack them into their own
namespace and such. moreover, the other 2.8 code needs similar rewriting/reworking too...
[x] merge m_join.c and m_sjoin.c in one module (same functions, done in ratbox3)
[ ] rewrite s_auth.c
[ ] authentication state/lock manager
[ ] move resolver/auth checker code into separated modules
@ -12,7 +13,7 @@
[x] clean up maxconnections kludges &c
[x] in-process SSL
[x] port and use ratbox ssld for server links
[ ] merge with libratbox SVN
[x] merge with libratbox SVN
[/] ssl stuff
[x] client-to-client ssl
[x] server-to-server ssl
@ -21,29 +22,32 @@
[ ] acknowledgement message for SSL users like '* *** You are connected using SSL cipher "DHE RSA-AES 128 CBC-SHA"'
[x] tool for generating ssl certificates and other stuff
[x] gnutls backend for at least SSL connections (replacing libcrypto use in m_challenge would be nice too)
[x] merge some stuff from ircd-seven directly (to be determined what)
[/] merge some stuff from ircd-seven directly (to be determined what)
[x] remote d:lines support
[x] PASS selector:password for auth{} (useful for dynamic IPs)
[ ] +C (noctcp) channel/usermode
[F] kline/xline/resv sync
[F] make an ability of using bandb instead of .conf files as bans storage
[x] drop non-TS6 (legacy protocol) support
[F] Doxygen code documentation
[/] module engine rework
[x] more beautiful way of adding new channel modes by module
[/] more beautiful way of adding new channel modes by module
[x] basic functionality
[x] some example modules
[ ] think on how could we append privilege checking for simple chmode - like chm_staff, but additionaly limited (e. g. IsOperResv etc);
possibly move the same code for all functions into separated one and make it extern?
[ ] make nick/user/host validation functions/match tables able to work in separated modules,
this will help us making support for native characters sets/slashes in host etc
[ ] auth checker module
[ ] resolver module
[x] Remove glines entirely
[ ] Bug fixes
[ ] Compilation without zlib headers fails
[/] Bug fixes
[x] Compilation without zlib headers fails - fixed
[ ] Compilation date and time in server welcome message is in OS locale - looks ugly 'cause often it's not match user's codepage
--- other stuff
[?] allow to set up configfiles path (etc/) instead of separated configfiles names (kline.conf, ircd.conf etc) like it is in ratbox3?
[?] PASS selector:password for auth{} from ircd-seven? (useful for dynamic IPs)
[?] +C (noctcp) channel/usermode from ircd-seven?
[ ] allow to set up configfiles path (etc/) instead of separated configfiles names (kline.conf, ircd.conf etc) like it is in ratbox3?
[?] internally split out +o/+v "ranks" into a series of permissions. this could allow for configure-defined
special access levels, halfops, etc. (would need to match globally, somehow. extra SVINFO param?)
[?] somehow hide channel operators like ircnet can do?
[x] merge m_join.c and m_sjoin.c in one module (same functions, done in ratbox3)
[x] create chmode.h and put there all declarations of chm_* - this will make some modules clean
[?] Move oper override server WALLOPS to global server notices?

View file

@ -460,7 +460,8 @@ general {
reject_ban_time = 1 minute;
reject_after_count = 3;
reject_duration = 5 minutes;
max_unknown_ip = 2;
throttle_duration = 60;
throttle_count = 4;
};
modules {

View file

@ -1153,10 +1153,14 @@ general {
/* reject duration: the amount of time to cache the rejection */
reject_duration = 5 minutes;
/* max_unknown_ip: maximum number of pending connections to the server
* that are allowed per IP address
/* throttle_duration: Amount of time that throttling will be applied to an IP
* address.
*/
max_unknown_ip = 2;
throttle_duration = 60;
/* throttle_count: Number of connections within throttle_duration that it takes
* for throttling to take effect */
throttle_count = 4;
};
modules {

View file

@ -549,8 +549,6 @@ connect "<replaceable>name</replaceable>" {
<listitem>
<para>The hostname or IP to connect to.</para>
<note><para>
Charybdis uses solely DNS for all hostname/address lookups
(no <filename>/etc/hosts</filename> or anything else).
Furthermore, if a hostname is used, it must have an A or AAAA
record (no CNAME) and it must be the primary
hostname for inbound connections to work.
@ -1094,6 +1092,28 @@ service {
</variablelist>
</sect2>
</sect1>
<sect1>
<title>Hostname resolution (DNS)</title>
<para>
Charybdis uses solely DNS for all hostname/address lookups
(no <filename>/etc/hosts</filename> or anything else).
The DNS servers are taken from <filename>/etc/resolv.conf</filename>.
If this file does not exist or no valid IP addresses are listed in it,
the local host (127.0.0.1) is used. (Note that the latter part
did not work in older versions of Charybdis.)
</para>
<para>
IPv4 as well as IPv6 DNS servers are supported, but it is not
possible to use both IPv4 and IPv6 in
<filename>/etc/resolv.conf</filename>.
</para>
<para>
For both security and performance reasons, it is recommended
that a caching nameserver such as BIND be run on the same machine
as Charybdis and that <filename>/etc/resolv.conf</filename> only
list 127.0.0.1.
</para>
</sect1>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:

View file

@ -1,151 +0,0 @@
Overview of the TS5 system
Lee H <lee@leeh.co.uk>
$Id: ts5.txt 6 2005-09-10 01:02:21Z nenolod $
For the purposes of this document, ircd versions:
hybrid6.0
ircd-comstud-1.12
CSr31pl4
and prior, are TS3.
ircd-hybrid-6.2 and later support TS5.
Whats TS5?
----------
The difference between TS5 and TS3 is what happened on opless channels. TS
works by establishing which server has the oldest version of the channel,
the version that is oldest, keeps its modes and ops, the version that is
youngest, removes their modes and ops, and accepts the older version.
There was an exception to this rule with opless channels, if a channel was
opless, TS3 would allow anybody to keep their ops and modes on the channel.
TS5 aims to stop this, by removing this exception.
Example1:
An irc network, with server A (every server is ts3)
UserA is on ServerA, in channel #broken. This channel is opless, and has a
TS of 800000000. ServerA splits, and whilst it is split, UserA cycles
channel #broken, recreates the channel and is given ops. On ServerA #broken
now has a TS of 900000000 and has ops. ServerA rejoins with the network,
via HubB. HubB realises #broken is opless, so allows UserA to retain ops.
The TS is moved forward to 900000000.
The network now sees #broken as having a TS of 900000000, with UserA being
opped.
Example2:
An irc network, with server C (every server is ts5)
Same scenario as above. ServerC splits and UserC cycles channel #broken,
recreating it with a TS of 900000000. ServerC rejoins with the network via
HubD. HubD realises #broken has a TS of 800000000 locally, and ServerC is
showing a TS of 900000000, it ignores ServerC's modes and ops. The channel
remains opless. ServerC receives HubD's modes, and it notices HubD has a
lower TS of channel #broken. It removes UserC's ops, removes the channel
modes on #broken, and accepts HubD's status.
The network version of #broken hasnt changed. It is still opless, with a TS
of 800000000.
As you can see, TS5 makes splitting a server to regain ops useless, as it
cannot be abused to give ops after a netsplit.
The problem with TS5 however, is what happens on a mixed TS5/TS3 network.
Channels where the older TS has ops will behave the same way on TS5 and TS3,
however an opless channel will behave differently, as you can see above.
The result of TS5/TS3 mixed can be a desync:
Example1:
As per Example1 above, except the rest of the network is TS5, ServerA is
TS3. ServerA would keep its modes and ops, whilst the rest of the network
would remove them. This means only ServerA would see UserA as opped. The
desync can be abused, as UserA can send modes. Hybrid6.0 servers will
accept these modes from the unopped client, so if UserA ops UserB, who then
ops UserA, the channel will be the same across all Hybrid6.0 and Hybrid6.1
servers.
Example2:
As per Example2 above, except the rest of the network is TS3. ServerC is
TS5. ServerC would remove its modes and ops, therefore UserC would not be
opped on ServerC, therefore it could not send any mode changes to the
channel. Although it is opped elsewhere, it isnt opped locally, so the
desync cannot be abused.
As you can see, the desync's that can occur can either be resynced, or are
useless to the user, so a mixed TS5/TS3 network is not a huge problem,
although a desync is NOT a good thing to have.
Why TS5?
--------
We have jumped to TS5 from TS3, because there was a version of ircd that was
TS4, so it was thought better to avoid a clash with an existing version.
Advantages
----------
Its a realistic event that a server will be attacked so it splits off a
network, then used to regain ops in a channel. TS5 makes this pointless,
the server will never give ops on a netsplit. TS5 is network wide, so it
leaves individual servers free to choose options like NO_JOIN_ON_SPLIT,
whilst keeping splits useless to users.
Disadvantages
-------------
Its virtually impossible for a user to actively regain ops themselves (some
regard this as an advantage..) because on a large sized channel, its
impossible to get people to leave so it can be recreated, therefore if a
network did not have some form of services, it could possibly end up
requiring oper intervention, as you cant get everybody to leave, and you
cant use splits to regain ops, therefore if the channel is open (an
invite-only channel would gradually destroy itself as noone new can join) it
could be impossible for a user to regain ops.
On a network that has some form of services, The effect of TS5 would be
minimal, however the services must be of sufficient quality to fix opless
channels, as TS5 renders netsplits for ops worthless.
Recommendations
---------------
If your network has good stable services, we recommend TS5 is enabled, as
people have no reason to abuse netsplits anyway.
If your network has no services at all, then TS5 may cause problems with
users being left with a permanently opless channel.
If your network occupies the middle ground, then its a choice between users
needing to be able to use splits to regain ops, or making netsplits that are
caused to regain ops worthless.
If TS5 is chosen, the FULL network must upgrade and this should be done in a
relatively short space of time to minimise the possible desync effects.
Alternatives
------------
There is also NO_JOIN_ON_SPLIT and NO_OP_ON_SPLIT, however these use the
configuration of minimum servers and users, and sometimes a split that is
above these limits is enough to be abused to regain ops, whereas if the
limits are too high, clients will never be able to join anything or be opped
when they create a channel.
EOF

View file

@ -1,113 +0,0 @@
$Id: whats-new-2.0.txt 6 2005-09-10 01:02:21Z nenolod $
The following is a list of major changes between ircd-ratbox-1.x and
ircd-ratbox-2.0
Config File
-----------
- name="foo"; is no longer supported in connect {}; operator {}; and
class {};. You must now use connect "irc.foo.com" { ... }; etc.
- operator {}; no longer contains a class
- kline_with_connection_closed is gone, replaced with
kline_reason = "Connection closed";
- logging {}; is gone, replaced with more advanced log system - see
example.conf log {}; for more info. Note, by default only very basic
information will be logged.
- support for a specific opers initial umodes on /oper, by umodes = ...;
in operator {};
- added stats_e_disabled = yes|no; to general {};, controlling whether stats
e (which can contain server ips) is never shown to anyone
- support for compressed|encrypted|topicburst|autoconn = yes|no; is gone,
replaced with flags = compressed, encrypted, topicburst, autoconn;
- support for individual auth flags "kline_exempt = yes"; etc removed, now
must use flags = ...; method
- support for individual oper flags "kline = yes;" etc removed, now must use
flags = ...; method.
- extended flags = ...; method to allow negation, so you may prefix a flag
with '~' to negate it. Default oper flags are operwall, remoteban and
encrypted (indicates password is encrypted with mkpasswd)
- new flags in shared {};, tkline, txline and tresv, allowing temp only of
kline, xline and resv respectively.
- new flags in cluster {}; tkline, txline and tresv which will cluster
only the temp of each type. kline, xline and resv will now only
cluster the permanent ones of each type.
- cluster {}; no longer allows a server to place klines etc locally, it
simply dictates who we send to.
- shared {}; is now ordered top-down and the first one that matches the
user@host and server will be used, and the flags taken from this. This
means if a remote oper matches a shared block without kline privs, even
though there is a shared {}; block they match under it with kline privs
they will not be able to place klines.
- added invite_ops_only to channel {}; which will restrict the use of INVITE
to chanops on that channel always, rather than just to +i chans.
Client
------
- /help is now available for all users, as its now cached in memory.
removes config option use_help from general {};
- default CHANNELLEN for local clients is now 50
- AWAYLEN added to 005, default is 90
- kick/part/quit now use REASONLEN (120) rather than TOPICLEN
- umode +g now exempts users messaging themselves
Oper
----
- kline/dline <nick> is no longer supported
- oper reasons are now more fully supported
- opers can now be hidden from stats p, by flag "invisible"
- XLINEs no longer contain a type field, theyll now all just silently reject
- xlines are now 'tracked' - stats X shows how many times each xline has
rejected a client
- temp xlines and resvs
- klines set against spoofed users will now take effect when the user
connects as well, if the user is not kline_exempt
- trace spy now contains target param if its against a single user
- the old "you need xline=yes;" notices have been replaced by ERR_NOPRIVS
(numeric 723)
- umode +C, machine parsable client connect/exit notices which includes the
two unused fields sent in the USER command
Channels
--------
- persistent channels have been removed
- quiet_on_ban now uses a cache, which should speed it up
Server <-> Server Protocol
--------------------------
- support for bursting away messages on connect, controlled by
burst_away = yes|no; in general {};
- TS6, the new server <-> server protocol. As part of this you *must*
specify a "sid" in serverinfo {}; that is three alphanumeric characters,
and must start with a digit. use_ts6 = yes|no; in general controls
whether it is actually used or not. For more information, see:
http://www.ircd-ratbox.org/TS6.txt
- fakename in connect {}; is gone, you can no longer mask servers.
- support for encrypted links are gone
- global capabilities. The server will now inform the rest of the network
over ENCAP about the capabilities of other servers.
Misc
----
- support for message translation has been removed. If you want these,
modify messages.tab and distribute that.
- most of server hiding is gone, only thing that is left is flattened links
- flattened links cache is now stored in memory instead of a file
- nick delay. any client which splits will have their nick 'locked', until
a remote client uses this nick, or until it expires after the time nick_delay
in general {}. This prevents the masses of kills from clients 'regaining'
nicknames on a short split.
- support for disabling bold chars etc in channel names for local users, to
prevent faking channels. disable_fake_channels = <yes|no>; in general {};
Code cleanups
-------------
- remove mapped ipv4 in ipv6 sockets, the correct native socket will now be
used for each.
- module API has been rewritten, 1.x modules will no longer work.
- hook API has been rewritten
- proper handlers for ENCAP commands
- support for vms ast i/o
- connect {}; and operator {}; are now in their own structs, saving memory
in ConfItem
- shared/cluster now use the same struct and flags
- various other code cleanups thatd take all year to list ;)

View file

@ -1,69 +0,0 @@
# $Id: whats-new-2.1.txt 6 2005-09-10 01:02:21Z nenolod $
The following is a list of the major changes between ircd-ratbox-2.0 and
ircd-ratbox-2.1.
Config file
-----------
- IP entries within exempt {}; can now be stacked, eg:
exempt { ip = "127.0.0.1"; ip = "192.168.0.0/24"; };
- shared {}; has been completely reworked so that it allows stacking.
shared {}; blocks for 2.0 and earlier will no longer work.
See example.conf for the new format.
- cluster {}; has been reworked to allow stacking.
cluster {}; blocks for 2.0 and earlier will no longer work.
See example.conf for the new format.
- New auth flag, jupe_exempt. When set on a client, that client will not
generate jupe warning notices when they try to join juped channels.
- You may no longer specify klines, dlines, xlines and resvs in ircd.conf.
Instead, there is no support for banconfigs with a ".perm" extension,
eg kline.conf.perm. Anything within a .perm file will be read, but
cannot be removed via the ircd. The format of these files is the same
format as their normal non-permanent counterpart. So kline.conf.perm
takes the same format as kline.conf, and so on.
- rehash and kill -HUP no longer reread the ban configs kline.conf etc.
You must now use /rehash bans, or kill -USR2
- New config option to general {};, dline_with_reason = yes|no;. Default no.
Traditionally, when a client connects and is dlined, the reason is never
shown. Enabling this will output the reason to clients.
Client
------
- Support for "deaf", umode +D. When a client is 'deaf', they will not
receive any messages sent towards channels. They will still receive joins
etc, but normal channel chat will not be sent. Any private messages
will still be sent.
- Target change anti-spam system. Restrictions are now placed upon how many
different clients (not channels) can be messaged within a specific time
period.
- Server-side notify lists. These allow a client to request a server
notifies them when a nickname comes online or goesoffline. See
doc/monitor.txt for more information.
- Client capabilities. These allow clients to negotiate capabilities with
the server. Currently supports:
- multi-prefix: A +ov client will have "@+" shown in names/who replies.
Oper
----
- RESVs are now tracked. Stats q/Q have been modified so that the first
field of the output is now a number indicating how many times the RESV
has been hit.
ratbox-services support (non-efnet)
-----------------------------------
- For those of you using ratbox-services, there is now compatibility code
within ircd, enabled by passing '--enable-services' to configure.
See doc/services.txt for more information.
Code cleanups
-------------
- Removed the custom file implementation, use the system one instead.
- The hook system has been redesigned, theres now a more thorough set of
hooks that may be used. See docs/hooks.txt
- Removed support for VMS. It hasnt worked for a long time.
- Cleanups to the expiry of temp klines/dlines.
- Various other things ;-).
- Better splitcode, it now works on how many servers have notified
us of burst finishing, rather than how many servers are linked to the
network.

View file

@ -27,8 +27,10 @@ INCLUDES = -I. -I../include -I../libratbox/include $(SSL_INCLUDES)
CPPFLAGS = ${INCLUDES} @CPPFLAGS@
SRCS = \
chm_operonly.c \
chm_operonly_compat.c \
chm_quietunreg_compat.c \
chm_sslonly.c \
chm_sslonly_compat.c \
createauthonly.c \
createoperonly.c \
@ -58,6 +60,7 @@ SRCS = \
m_okick.c \
m_omode.c \
m_opme.c \
m_sendbans.c \
m_webirc.c \
no_locops.c \
no_oper_invis.c \

65
extensions/chm_operonly.c Normal file
View file

@ -0,0 +1,65 @@
#include "stdinc.h"
#include "modules.h"
#include "hook.h"
#include "client.h"
#include "ircd.h"
#include "send.h"
#include "s_conf.h"
#include "s_user.h"
#include "s_serv.h"
#include "numeric.h"
#include "chmode.h"
static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 operonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
};
/* This is a simple example of how to use dynamic channel modes.
* Not tested enough yet, use at own risk.
* -- dwr
*/
static int
_modinit(void)
{
/* add the channel mode to the available slot */
chmode_table['O'].mode_type = find_cflag_slot();
chmode_table['O'].set_func = chm_simple;
construct_noparam_modes();
return 0;
}
/* Well, the first ugly thing is that we changle chmode_table in _modinit
* and chmode_flags in _moddeinit (different arrays) - must be fixed.
* -- dwr
*/
static void
_moddeinit(void)
{
/* disable the channel mode and remove it from the available list */
chmode_table['O'].mode_type = 0;
construct_noparam_modes();
}
DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
static void
h_can_join(hook_data_channel *data)
{
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
if((chptr->mode.mode & chmode_flags['O']) && !IsOper(source_p)) {
sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
data->approved = ERR_CUSTOM;
}
}

53
extensions/chm_sslonly.c Normal file
View file

@ -0,0 +1,53 @@
#include "stdinc.h"
#include "modules.h"
#include "hook.h"
#include "client.h"
#include "ircd.h"
#include "send.h"
#include "s_conf.h"
#include "s_user.h"
#include "s_serv.h"
#include "numeric.h"
#include "chmode.h"
static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 sslonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
};
static int
_modinit(void)
{
chmode_table['S'].mode_type = find_cflag_slot();
chmode_table['S'].set_func = chm_simple;
construct_noparam_modes();
return 0;
}
static void
_moddeinit(void)
{
chmode_table['S'].mode_type = 0;
construct_noparam_modes();
}
DECLARE_MODULE_AV1(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, "$Revision$");
static void
h_can_join(hook_data_channel *data)
{
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
if((chptr->mode.mode & chmode_flags['S']) && !IsSSLClient(source_p)) {
sendto_one_notice(source_p, ":Only users using SSL could join this channel!");
data->approved = ERR_CUSTOM;
}
}

View file

@ -100,10 +100,17 @@ do_host_cloak_ip(const char *inbuf, char *outbuf)
char *tptr;
unsigned int accum = get_string_weighted_entropy(inbuf);
char buf[HOSTLEN];
int ipv6 = 0;
strncpy(buf, inbuf, HOSTLEN);
tptr = strrchr(buf, '.');
if (tptr == NULL)
{
tptr = strrchr(buf, ':');
ipv6 = 1;
}
if (tptr == NULL)
{
strncpy(outbuf, inbuf, HOSTLEN);
@ -112,7 +119,14 @@ do_host_cloak_ip(const char *inbuf, char *outbuf)
*tptr++ = '\0';
snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum);
if(ipv6)
{
snprintf(outbuf, HOSTLEN, "%s:%x", buf, accum);
}
else
{
snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum);
}
}
static void

View file

@ -27,8 +27,6 @@
#include <string.h>
extern char *crypt();
static int m_mkpasswd(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]);
static int mo_mkpasswd(struct Client *client_p, struct Client *source_p,
@ -90,7 +88,7 @@ m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const cha
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "MKPASSWD");
else
sendto_one_notice(source_p, ":Encryption for [%s]: %s",
parv[1], crypt(parv[1],
parv[1], rb_crypt(parv[1],
is_md5 ? make_md5_salt() :
make_salt()));
@ -132,7 +130,7 @@ mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const ch
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "MKPASSWD");
else
sendto_one_notice(source_p, ":Encryption for [%s]: %s",
parv[1], crypt(parv[1], is_md5 ? make_md5_salt() : make_salt()));
parv[1], rb_crypt(parv[1], is_md5 ? make_md5_salt() : make_salt()));
return 0;
}

174
extensions/m_sendbans.c Normal file
View file

@ -0,0 +1,174 @@
/*
* m_sendbans.c: sends all permanent resvs and xlines to given server
*
* Copyright (C) 2008 Jilles Tjoelker
* Copyright (C) 2008 charybdis development team
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1.Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2.Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3.The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdinc.h"
#include "client.h"
#include "common.h"
#include "ircd.h"
#include "match.h"
#include "numeric.h"
#include "s_conf.h"
#include "s_serv.h"
#include "s_newconf.h"
#include "send.h"
#include "msg.h"
#include "hash.h"
#include "modules.h"
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message sendbans_msgtab = {
"SENDBANS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}}
};
mapi_clist_av1 sendbans_clist[] = {
&sendbans_msgtab,
NULL
};
DECLARE_MODULE_AV1(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, "$Revision$");
static const char *expand_xline(const char *mask)
{
static char buf[512];
const char *p;
char *q;
if (!strchr(mask, ' '))
return mask;
if (strlen(mask) > 250)
return NULL;
p = mask;
q = buf;
while (*p != '\0')
{
if (*p == ' ')
*q++ = '\\', *q++ = 's';
else
*q++ = *p;
p++;
}
*q = '\0';
return buf;
}
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct ConfItem *aconf;
rb_dlink_node *ptr;
int i, count;
const char *target, *mask2;
struct Client *server_p;
if (!IsOperRemoteBan(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "remoteban");
return 0;
}
if (!IsOperXline(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "xline");
return 0;
}
if (!IsOperResv(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "resv");
return 0;
}
target = parv[1];
count = 0;
RB_DLINK_FOREACH(ptr, global_serv_list.head)
{
server_p = ptr->data;
if (IsMe(server_p))
continue;
if (match(target, server_p->name))
count++;
}
if (count == 0)
{
sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
form_str(ERR_NOSUCHSERVER), target);
return 0;
}
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"%s is sending resvs and xlines to %s",
get_oper_name(source_p), target);
RB_DLINK_FOREACH(ptr, resv_conf_list.head)
{
aconf = ptr->data;
if (aconf->hold)
continue;
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s RESV 0 %s 0 :%s",
target, aconf->name, aconf->passwd);
}
HASH_WALK(i, R_MAX, ptr, resvTable)
{
aconf = ptr->data;
if (aconf->hold)
continue;
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s RESV 0 %s 0 :%s",
target, aconf->name, aconf->passwd);
}
HASH_WALK_END
RB_DLINK_FOREACH(ptr, xline_conf_list.head)
{
aconf = ptr->data;
if (aconf->hold)
continue;
mask2 = expand_xline(aconf->name);
if (mask2 == NULL)
{
sendto_one_notice(source_p, ":Skipping xline [%s]",
aconf->name);
continue;
}
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s XLINE 0 %s 2 :%s",
target, mask2, aconf->passwd);
}
return 0;
}

View file

@ -89,7 +89,7 @@ mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char
IsGotId(client_p) ? client_p->username : "webirc",
IsGotId(client_p) ? client_p->username : "webirc",
(struct sockaddr *) &client_p->localClient->ip,
client_p->localClient->ip.ss_family);
client_p->localClient->ip.ss_family, NULL);
if (aconf == NULL || !(aconf->status & CONF_CLIENT))
return 0;
if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->name, "webirc."))
@ -125,7 +125,6 @@ mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char
else
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
del_unknown_ip(source_p);
rb_inet_pton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip);
/* Check dlines now, klines will be checked on registration */

View file

@ -26,8 +26,6 @@
#ifndef INCLUDED_channel_h
#define INCLUDED_channel_h
#include "config.h" /* config settings */
#include "ircd_defs.h" /* buffer sizes */
#define MODEBUFLEN 200
@ -56,7 +54,6 @@ struct Channel
char *topic;
char *topic_info;
time_t topic_time;
time_t users_last; /* when last user was in channel */
time_t last_knock; /* don't allow knock to flood */
rb_dlink_list members; /* channel members */

View file

@ -1,30 +0,0 @@
/*
* charybdis: a useful ircd.
* charybdis.h: primary include file
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2005 Hybrid Development Team
* Copyright (C) 2005 William Pitcock and Jilles Tjoelker
*
* 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: charybdis.h 238 2005-09-21 05:26:03Z nenolod $
*/
#ifndef CHARYBDIS_H
#define CHARYBDIS_H
#endif

View file

@ -28,6 +28,12 @@
#ifndef INCLUDED_chmode_h
#define INCLUDED_chmode_h
/* something not included in messages.tab
* to change some hooks behaviour when needed
* -- dwr
*/
#define ERR_CUSTOM 1000
extern void chm_nosuch(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
@ -68,5 +74,7 @@ extern void chm_voice(struct Client *source_p, struct Channel *chptr,
extern void construct_noparam_modes(void);
extern void find_orphaned_cflags(void);
extern unsigned int find_cflag_slot(void);
extern char cflagsbuf[256];
extern char cflagsmyinfo[256];
#endif

View file

@ -168,6 +168,10 @@ struct Client
*/
rb_dlink_list on_allow_list;
time_t first_received_message_time;
int received_number_of_privmsgs;
int flood_noticed;
local_user_t *localClient;
pre_client_t *preClient;
};
@ -189,9 +193,6 @@ struct LocalUser
int oper_warn_count_down; /* warn opers of this possible
spambot every time this gets to 0 */
time_t last_caller_id_time;
time_t first_received_message_time;
int received_number_of_privmsgs;
int flood_noticed;
time_t lasttime; /* last time we parsed something */
time_t firsttime; /* time client was created */
@ -230,6 +231,7 @@ struct LocalUser
* agreed. lets get rid of it someday! --nenolod
*/
char *passwd;
char *auth_user;
char *opername; /* name of operator{} block being used or tried (challenge) */
char *challenge;
char *fullcaps;
@ -275,9 +277,9 @@ struct LocalUser
applicable to this client */
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
rb_uint32_t localflags;
uint32_t localflags;
struct ZipStats *zipstats; /* zipstats */
rb_uint16_t cork_count; /* used for corking/uncorking connections */
uint16_t cork_count; /* used for corking/uncorking connections */
struct ev_entry *event; /* used for associated events */
};
@ -568,7 +570,6 @@ extern void check_dlines(void);
extern void check_xlines(void);
extern const char *get_client_name(struct Client *client, int show_ip);
extern const char *get_server_name(struct Client *client, int show_ip);
extern const char *log_client_name(struct Client *, int);
extern int is_remote_connect(struct Client *);
extern void init_client(void);

View file

@ -81,13 +81,6 @@
*/
#undef IGNORE_BOGUS_TS
/* HIDE_SERVERS_IPS
*
* If this is undefined, anyone can see a servers ip. If it is defined,
* noone can.
*/
#define HIDE_SERVERS_IPS
/* HANGONGOODLINK and HANGONRETRYDELAY
* Often net breaks for a short time and it's useful to try to
* establishing the same connection again faster than CONNECTFREQUENCY

View file

@ -81,13 +81,6 @@
*/
#undef IGNORE_BOGUS_TS
/* HIDE_SERVERS_IPS
*
* If this is undefined, anyone can see a servers ip. If it is defined,
* noone can.
*/
#define HIDE_SERVERS_IPS
/* HANGONGOODLINK and HANGONRETRYDELAY
* Often net breaks for a short time and it's useful to try to
* establishing the same connection again faster than CONNECTFREQUENCY

View file

@ -39,24 +39,24 @@ enum
int parse_netmask(const char *, struct sockaddr *, int *);
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
const char *orighost, struct sockaddr *,
int, int, const char *);
int, int, const char *, const char *);
struct ConfItem *find_exact_conf_by_address(const char *address, int type,
const char *username);
void add_conf_by_address(const char *, int, const char *, struct ConfItem *);
void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
void delete_one_address_conf(const char *, struct ConfItem *);
void clear_out_address_conf(void);
void clear_out_address_conf_bans(void);
void init_host_hash(void);
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
const char *, const char *, struct sockaddr *,
int);
int, char *);
struct ConfItem *find_dline(struct sockaddr *, int);
#define find_kline(x) (find_conf_by_address((x)->host, (x)->sockhost, \
(x)->orighost, \
(struct sockaddr *)&(x)->localClient->ip, CONF_KILL,\
(x)->localClient->ip.ss_family, (x)->username))
(x)->localClient->ip.ss_family, (x)->username, NULL))
void report_Klines(struct Client *);
void report_auth(struct Client *);
@ -99,6 +99,8 @@ struct AddressRec
/* Only checked if !(type & 1)... */
const char *username;
/* Only checked if type == CONF_CLIENT */
const char *auth_user;
struct ConfItem *aconf;
/* The next record in this hash bucket. */

View file

@ -80,7 +80,6 @@ extern struct Client me;
extern rb_dlink_list global_client_list;
extern struct Client *local[];
extern struct Counter Count;
extern struct timeval SystemTime;
extern int default_server_capabs;
extern time_t startup_time;
@ -99,11 +98,6 @@ extern rb_dlink_list local_oper_list;
extern rb_dlink_list oper_list;
extern rb_dlink_list dead_list;
extern rb_bh *channel_heap;
extern rb_bh *ban_heap;
extern rb_bh *topic_heap;
extern rb_bh *member_heap;
extern int testing_conf;
extern struct ev_entry *check_splitmode_ev;

View file

@ -6,12 +6,6 @@
#ifndef _NEWCONF_H_INCLUDED
#define _NEWCONF_H_INCLUDED
#include <sys/types.h>
#include <stdio.h>
#include "client.h"
struct ConfEntry
{
const char *cf_name;

View file

@ -3,7 +3,7 @@
* reject.h: header to a file which rejects users with prejudice
*
* Copyright (C) 2003 Aaron Sethman <androsyn@ratbox.org>
* Copyright (C) 2003-2004 ircd-ratbox development team
* Copyright (C) 2003-2005 ircd-ratbox 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
@ -17,11 +17,11 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
*
* $Id: reject.h 3446 2007-05-14 22:21:16Z jilles $
* $Id: reject.h 25056 2008-02-06 20:47:40Z androsyn $
*/
#ifndef INCLUDED_reject_h
#define INCLUDED_reject_h
@ -29,17 +29,16 @@
/* amount of time to delay a rejected clients exit */
#define DELAYED_EXIT_TIME 10
extern rb_dlink_list delay_exit;
void init_reject(void);
int check_reject(struct Client *);
int check_reject(rb_fde_t *F, struct sockaddr *addr);
void add_reject(struct Client *, const char *mask1, const char *mask2);
void flush_reject(void);
int remove_reject_ip(const char *ip);
int remove_reject_mask(const char *mask1, const char *mask2);
unsigned long delay_exit_length(void);
int throttle_add(struct sockaddr *addr);
int add_unknown_ip(struct Client *client_p);
void del_unknown_ip(struct Client *client_p);
#endif

View file

@ -88,7 +88,8 @@ struct ConfItem
/* aConfItem->flags */
/* Generic flags... */
/* access flags... */
#define CONF_FLAGS_TEMPORARY 0x00800000
/* auth{} flags... */
#define CONF_FLAGS_NO_TILDE 0x00000004
#define CONF_FLAGS_NEED_IDENTD 0x00000008
#define CONF_FLAGS_EXEMPTKLINE 0x00000040
@ -102,14 +103,7 @@ struct ConfItem
#define CONF_FLAGS_EXEMPTSHIDE 0x00010000
#define CONF_FLAGS_EXEMPTJUPE 0x00020000 /* exempt from resv generating warnings */
#define CONF_FLAGS_NEED_SASL 0x00040000
/* server flags */
#define CONF_FLAGS_ALLOW_AUTO_CONN 0x00080000
#define CONF_FLAGS_LAZY_LINK 0x00100000
#define CONF_FLAGS_ENCRYPTED 0x00200000
#define CONF_FLAGS_COMPRESSED 0x00400000
#define CONF_FLAGS_TEMPORARY 0x00800000
#define CONF_FLAGS_TB 0x01000000
#define CONF_FLAGS_VHOSTED 0x02000000
#define CONF_FLAGS_EXEMPTDNSBL 0x04000000
@ -126,9 +120,6 @@ struct ConfItem
#define IsConfDoSpoofIp(x) ((x)->flags & CONF_FLAGS_SPOOF_IP)
#define IsConfSpoofNotice(x) ((x)->flags & CONF_FLAGS_SPOOF_NOTICE)
#define IsConfEncrypted(x) ((x)->flags & CONF_FLAGS_ENCRYPTED)
#define IsConfCompressed(x) ((x)->flags & CONF_FLAGS_COMPRESSED)
#define IsConfVhosted(x) ((x)->flags & CONF_FLAGS_VHOSTED)
#define IsConfTburst(x) ((x)->flags & CONF_FLAGS_TB)
#define IsNeedSasl(x) ((x)->flags & CONF_FLAGS_NEED_SASL)
#define IsConfExemptDNSBL(x) ((x)->flags & CONF_FLAGS_EXEMPTDNSBL)
@ -219,12 +210,13 @@ struct config_file_entry
int reject_ban_time;
int reject_after_count;
int reject_duration;
int throttle_count;
int throttle_duration;
int target_change;
int collision_fnc;
int default_umodes;
int global_snotices;
int operspy_dont_care_user_info;
int max_unknown_ip;
};
struct config_channel_entry

View file

@ -1,3 +1,498 @@
androsyn 2008/07/29 15:26:55 UTC (25795)
Log:
some sanity checks in the rb_open path
Modified:
libratbox/trunk/src/commio.c (File Modified)
androsyn 2008/07/29 14:47:48 UTC (25793)
Log:
pass new_F along to rb_ssl_accept_setup instead of the fd itself
Modified:
libratbox/trunk/include/commio-ssl.h (File Modified)
libratbox/trunk/src/commio.c (File Modified)
libratbox/trunk/src/gnutls.c (File Modified)
libratbox/trunk/src/nossl.c (File Modified)
libratbox/trunk/src/openssl.c (File Modified)
androsyn 2008/07/28 23:14:29 UTC (25791)
Log:
log if rb_open returns NULL on accept and close the fd..this shouldn't happen and the real cause needs to be found
Modified:
libratbox/trunk/src/commio.c (File Modified)
androsyn 2008/07/11 18:21:57 UTC (25705)
Log:
add a newline at the end of arc4random.c
Modified:
libratbox/trunk/src/arc4random.c (File Modified)
androsyn 2008/07/10 18:34:03 UTC (25699)
Log:
i'm doing good today..move the ifdefs down
Modified:
libratbox/trunk/src/arc4random.c (File Modified)
androsyn 2008/07/10 18:32:34 UTC (25697)
Log:
remove some debugging code
Modified:
libratbox/trunk/src/arc4random.c (File Modified)
libratbox/trunk/src/nossl.c (File Modified)
androsyn 2008/07/10 18:30:19 UTC (25695)
Log:
add a missing ; and add arc4random.h too
Modified:
libratbox/trunk/include/arc4random.h (File Added)
libratbox/trunk/src/openssl.c (File Modified)
androsyn 2008/07/10 18:27:23 UTC (25693)
Log:
forgot a prototype for rb_get_pseudo_random
Modified:
libratbox/trunk/include/rb_commio.h (File Modified)
androsyn 2008/07/10 18:05:43 UTC (25691)
Log:
fix a typo
Modified:
libratbox/trunk/src/nossl.c (File Modified)
androsyn 2008/07/10 17:13:27 UTC (25689)
Log:
- Add arc4random as a source for random bytes in the nossl.c case.
- Add in a pseudo random source function as well. This is really only different on OpenSSL.
Modified:
libratbox/trunk/configure (File Modified)
libratbox/trunk/configure.ac (File Modified)
libratbox/trunk/include/libratbox_config.h.in (File Modified)
libratbox/trunk/src/Makefile.am (File Modified)
libratbox/trunk/src/Makefile.in (File Modified)
libratbox/trunk/src/arc4random.c (File Added)
libratbox/trunk/src/export-syms.txt (File Modified)
libratbox/trunk/src/gnutls.c (File Modified)
libratbox/trunk/src/nossl.c (File Modified)
libratbox/trunk/src/openssl.c (File Modified)
androsyn 2008/07/06 18:57:15 UTC (25683)
Log:
change a rb_uint8_t to uint8_t
Modified:
libratbox/trunk/configure (File Modified)
libratbox/trunk/configure.ac (File Modified)
androsyn 2008/07/06 05:15:22 UTC (25681)
Log:
fix the socklen_t stuff
Modified:
libratbox/trunk/configure (File Modified)
libratbox/trunk/configure.ac (File Modified)
libratbox/trunk/include/libratbox_config.h.in (File Modified)
androsyn 2008/07/06 04:33:03 UTC (25679)
Log:
get rid of some testing code that snuck into the last commit
Modified:
libratbox/trunk/configure (File Modified)
libratbox/trunk/configure.ac (File Modified)
androsyn 2008/07/06 04:13:05 UTC (25675)
Log:
remove the rb_uint/rb_int stuff as we require a C99 compiler and this is standard now. Also add a better check for socklen_t
Modified:
libratbox/trunk/acinclude.m4 (File Modified)
libratbox/trunk/configure (File Modified)
libratbox/trunk/configure.ac (File Modified)
libratbox/trunk/include/commio-int.h (File Modified)
libratbox/trunk/include/libratbox_config.h.in (File Modified)
libratbox/trunk/include/rb_commio.h (File Modified)
libratbox/trunk/include/rb_linebuf.h (File Modified)
libratbox/trunk/src/Makefile.in (File Modified)
libratbox/trunk/src/balloc.c (File Modified)
libratbox/trunk/src/commio.c (File Modified)
libratbox/trunk/src/crypt.c (File Modified)
libratbox/trunk/src/epoll.c (File Modified)
libratbox/trunk/src/rawbuf.c (File Modified)
androsyn 2008/07/06 03:10:23 UTC (25673)
Log:
a few minor cleanups
Modified:
libratbox/trunk/src/commio.c (File Modified)
androsyn 2008/06/24 14:04:50 UTC (25588)
Log:
move some of the common accept code into a function
Modified:
libratbox/trunk/src/openssl.c (File Modified)
androsyn 2008/06/20 21:49:53 UTC (25576)
Log:
rerun autoconf again
Modified:
libratbox/trunk/configure (File Modified)
androsyn 2008/06/20 21:49:06 UTC (25574)
Log:
enable Id tags on configure.ac
Modified:
libratbox/trunk/configure.ac (File Modified) (Property Modified)
jilles 2008/06/20 21:42:48 UTC (25572)
Log:
Rerun autoconf.
Modified:
libratbox/trunk/configure (File Modified)
jilles 2008/06/20 21:42:29 UTC (25570)
Log:
Change == in test to =.
Modified:
libratbox/trunk/configure.ac (File Modified)
androsyn 2008/06/20 18:46:08 UTC (25568)
Log:
add a missing commio-ssl.h include in gnutls.c
Modified:
libratbox/trunk/src/gnutls.c (File Modified)
androsyn 2008/06/19 19:05:46 UTC (25556)
Log:
don't load the certificate twice and remember to close the file after opening it
Modified:
libratbox/trunk/src/gnutls.c (File Modified)
androsyn 2008/06/11 14:40:44 UTC (25532)
Log:
All sorts of autotools goo for GNUTLS. Partially based on nenolod's patch.
Modified:
libratbox/trunk/Makefile.in (File Modified)
libratbox/trunk/aclocal.m4 (File Modified)
libratbox/trunk/configure (File Modified)
libratbox/trunk/configure.ac (File Modified)
libratbox/trunk/include/libratbox_config.h.in (File Modified)
libratbox/trunk/src/Makefile.am (File Modified)
libratbox/trunk/src/Makefile.in (File Modified)
libratbox/trunk/src/nossl.c (File Modified)
androsyn 2008/06/11 06:12:55 UTC (25530)
Log:
first pass at gnutls code..
Modified:
libratbox/trunk/src/gnutls.c (File Added)
jilles 2008/05/17 13:36:55 UTC (25387)
Log:
Remove static inline symbols from export-syms.txt.
These do not exist in the library and some platforms
such as MacOS X don't like that.
Modified:
libratbox/trunk/src/export-syms.txt (File Modified)
androsyn 2008/05/16 16:06:02 UTC (25377)
Log:
fix a compile warning
Modified:
libratbox/trunk/src/openssl.c (File Modified)
androsyn 2008/05/16 15:19:51 UTC (25375)
Log:
fix up the soft assert stuff for libratbox and rename likely/unlikely to rb_likely/rb_unlikely
Modified:
libratbox/trunk/include/commio-int.h (File Modified)
libratbox/trunk/include/ratbox_lib.h (File Modified)
libratbox/trunk/include/rb_memory.h (File Modified)
libratbox/trunk/src/balloc.c (File Modified)
libratbox/trunk/src/commio.c (File Modified)
libratbox/trunk/src/linebuf.c (File Modified)
libratbox/trunk/src/poll.c (File Modified)
libratbox/trunk/src/ratbox_lib.c (File Modified)
libratbox/trunk/src/sigio.c (File Modified)
libratbox/trunk/src/snprintf.c (File Modified)
jilles 2008/05/14 17:55:22 UTC (25364)
Log:
Fix a mistake in kqueue 'overflow' handling.
If there is no space in the output buffer to report an
error adding to the kqueue, kevent(2) will abort and
return the error in errno (I was correct that it does
not tell you where it failed). So do not abort the loop
if kevent(2) fails and do not log (expected) EBADF.
Modified:
libratbox/trunk/src/kqueue.c (File Modified)
androsyn 2008/05/13 14:48:46 UTC (25358)
Log:
save connect errno so that we get a correct connect failure reason
Modified:
libratbox/trunk/src/commio.c (File Modified)
jilles 2008/05/12 17:52:22 UTC (25356)
Log:
Fix a possible crash with SSL connections closing early.
Modified:
libratbox/trunk/src/openssl.c (File Modified)
jilles 2008/05/12 16:51:54 UTC (25354)
Log:
Fix kqueue sometimes dropping updates.
(ircd wouldn't read or write anymore to certain clients)
This happens because kqueue.c will often try to add
already closed file descriptors to the kqueue. The kernel
tries to report bad file descriptors in the eventlist; if
the eventlist has no space, processing of the changelist
is silently halted.
The fix:
1. allocate two kqlst things, one for what kqlst currently does
and one as output buffer
this ensures the kevent(2) call in rb_select_kqueue() never
drops updates
2. replace the kevent(2) call in kq_update_events() by a loop
that processes the updates one at a time
that doesn't happen much, and it's the only way to be sure
without also getting events out of the queue we cannot process
at that time
Modified:
libratbox/trunk/src/kqueue.c (File Modified)
androsyn 2008/05/08 19:32:13 UTC (25327)
Log:
forgot prototypes and nossl versions of rb_ssl handshake stuff
Modified:
libratbox/trunk/include/rb_commio.h (File Modified)
libratbox/trunk/src/nossl.c (File Modified)
androsyn 2008/05/08 19:09:42 UTC (25325)
Log:
keep track of the number of openssl handshakes and export rb_ssl_handshake_count and rb_ssl_clear_handshake_count
Modified:
libratbox/trunk/include/commio-int.h (File Modified)
libratbox/trunk/src/export-syms.txt (File Modified)
libratbox/trunk/src/openssl.c (File Modified)
androsyn 2008/05/02 12:41:05 UTC (25291)
Log:
fix build for bsd platforms with lack EVFILT_TIMER
Modified:
libratbox/trunk/src/kqueue.c (File Modified)
androsyn 2008/04/21 18:38:23 UTC (25245)
Log:
kill a process with SIGKILL when calling helper_close to be certain the process goes away
Modified:
libratbox/trunk/src/helper.c (File Modified)
river 2008/04/16 20:33:35 UTC (25235)
Log:
support for compiling on OpenVMS (untested)
Modified:
libratbox/trunk/include/libratbox_config.h_vms (File Added)
libratbox/trunk/src/descrip.mms (File Added)
libratbox/trunk/src/rawbuf.c (File Modified)
androsyn 2008/04/16 20:11:37 UTC (25233)
Log:
less than zero doesn't make sense for size_t
Modified:
libratbox/trunk/src/balloc.c (File Modified)
jilles 2008/04/13 16:19:04 UTC (25229)
Log:
patricia: remove ugly abuse of K&R style function declaration
It left the argument types unspecified in a function
pointer, then called it using different numbers of
arguments.
Modified:
libratbox/trunk/include/rb_patricia.h (File Modified)
libratbox/trunk/src/patricia.c (File Modified)
jilles 2008/04/12 22:20:43 UTC (25227)
Log:
Remove linebuf's per-line flushing flag, as it's per-head state.
In rare cases, this sharing caused the ircd to skip
part of outgoing traffic, e.g. appearing as "not enough
parameters" errors on the other side.
The purpose of this flag can be fulfilled by the writeofs
in the bufhead.
Modified:
libratbox/trunk/include/rb_linebuf.h (File Modified)
libratbox/trunk/src/linebuf.c (File Modified)
jilles 2008/04/12 14:30:19 UTC (25225)
Log:
read/write return type should be ssize_t, not int or size_t.
The writev emulation used size_t, which is unsigned,
preventing negative values to be seen.
Modified:
libratbox/trunk/src/commio.c (File Modified)
jilles 2008/04/11 08:48:21 UTC (25223)
Log:
kqueue: also use EV_ONESHOT for read events
This makes the kernel's state agree with our handler pointer.
SSL may need to suspend selecting for reading to write
something, e.g. with renegotiation.
Modified:
libratbox/trunk/src/kqueue.c (File Modified)
jilles 2008/04/09 19:43:08 UTC (25219)
Log:
Call the accept callback when timing out an SSL accept.
The callback will close the F.
Modified:
libratbox/trunk/src/openssl.c (File Modified)
jilles 2008/04/09 19:26:04 UTC (25217)
Log:
Fix up ssl_accept WANT_READ/WANT_WRITE a bit.
Only select for the exact thing asked, and if
SSL_ERROR_SYSCALL happens abort it even if the
errno is "ignorable".
Modified:
libratbox/trunk/src/openssl.c (File Modified)
jilles 2008/04/05 19:09:32 UTC (25205)
Log:
Fix SET_SS_LEN so that it also works correctly outside libratbox.
Use RB_SOCKADDR_HAS_SA_LEN instead of SOCKADDR_IN_HAS_LEN
which is only defined inside libratbox.
This fixes creating own sockaddr structs in other programs
using SET_SS_LEN, then passing them to libratbox, on
4.4BSD based systems.
Modified:
libratbox/trunk/include/ratbox_lib.h (File Modified)
androsyn 2008/04/04 18:43:29 UTC (25203)
Log:
don't spin on accept when you don't get any data
Modified:
libratbox/trunk/src/openssl.c (File Modified)
androsyn 2008/04/01 22:05:38 UTC (25197)
Log:
return useful errno values here
Modified:
libratbox/trunk/src/nossl.c (File Modified)
jilles 2008/04/01 20:38:54 UTC (25195)
Log:
Make this link without OpenSSL.
Patch from nenolod.
Modified:
libratbox/trunk/src/nossl.c (File Modified)
androsyn 2008/03/30 16:34:18 UTC (25177)
Log:
Remove DISABLE_SSL_COMP stuff completely. Force our outbound connections to use TLSv1

View file

@ -13,6 +13,7 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@ -33,7 +34,8 @@ build_triplet = @build@
host_triplet = @host@
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/configure \
$(srcdir)/Makefile.in $(srcdir)/libratbox.pc.in \
$(top_srcdir)/configure \
$(top_srcdir)/include/libratbox_config.h.in COPYING ChangeLog \
INSTALL TODO config.guess config.sub depcomp install-sh \
ltmain.sh missing
@ -46,7 +48,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/libratbox_config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_FILES = libratbox.pc
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@ -56,6 +58,15 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
pkgconfigDATA_INSTALL = $(INSTALL_DATA)
DATA = $(pkgconfig_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
@ -142,7 +153,7 @@ SED = @SED@
SEDOBJ = @SEDOBJ@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SSL_INCLUDES = @SSL_INCLUDES@
SSL_CFLAGS = @SSL_CFLAGS@
SSL_LIBS = @SSL_LIBS@
STRIP = @STRIP@
TOUCH = @TOUCH@
@ -201,6 +212,8 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libratbox.pc
all: all-recursive
.SUFFIXES:
@ -254,6 +267,8 @@ $(top_srcdir)/include/libratbox_config.h.in: @MAINTAINER_MODE_TRUE@ $(am__config
distclean-hdr:
-rm -f include/libratbox_config.h include/stamp-h1
libratbox.pc: $(top_builddir)/config.status $(srcdir)/libratbox.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
@ -263,6 +278,23 @@ clean-libtool:
distclean-libtool:
-rm -f libtool
install-pkgconfigDATA: $(pkgconfig_DATA)
@$(NORMAL_INSTALL)
test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
@list='$(pkgconfig_DATA)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(pkgconfigDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
$(pkgconfigDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgconfigdir)/$$f"; \
done
uninstall-pkgconfigDATA:
@$(NORMAL_UNINSTALL)
@list='$(pkgconfig_DATA)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
rm -f "$(DESTDIR)$(pkgconfigdir)/$$f"; \
done
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
@ -544,9 +576,12 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile
all-am: Makefile $(DATA)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(pkgconfigdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
@ -591,7 +626,7 @@ info: info-recursive
info-am:
install-data-am:
install-data-am: install-pkgconfigDATA
install-dvi: install-dvi-recursive
@ -627,7 +662,7 @@ ps: ps-recursive
ps-am:
uninstall-am:
uninstall-am: uninstall-pkgconfigDATA
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
install-strip
@ -642,11 +677,12 @@ uninstall-am:
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-recursive uninstall uninstall-am
install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-pkgconfigDATA
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View file

@ -22,84 +22,6 @@ AC_DEFUN([AC_SUBST_DIR], [
])
# RB_TYPE_INTMAX_T
# -----------------
AC_DEFUN([RB_TYPE_INTMAX_T],
[
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
AC_CHECK_TYPE([intmax_t],
[AC_DEFINE([HAVE_INTMAX_T], 1,
[Define to 1 if the system has the type `intmax_t'.]) ac_cv_c_intmax_t=yes],
[test $ac_cv_type_long_long_int = yes \
&& ac_type='long long int' \
|| ac_type='long int'
AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
[Define to the widest signed integer type
if <stdint.h> and <inttypes.h> do not define.]) ac_cv_c_intmax_t="$ac_type"])
])
# RB_TYPE_UINTMAX_T
# -----------------
AC_DEFUN([RB_TYPE_UINTMAX_T],
[
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
AC_CHECK_TYPE([uintmax_t],
[AC_DEFINE([HAVE_UINTMAX_T], 1,
[Define to 1 if the system has the type `uintmax_t'.]) ac_cv_c_uintmax_t=yes],
[test $ac_cv_type_unsigned_long_long_int = yes \
&& ac_type='unsigned long long int' \
|| ac_type='unsigned long int'
AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
[Define to the widest unsigned integer type
if <stdint.h> and <inttypes.h> do not define.]) ac_cv_c_uintmax_t="$ac_type"])
])
# RB_TYPE_INTPTR_T
# -----------------
AC_DEFUN([RB_TYPE_INTPTR_T],
[
AC_CHECK_TYPE([intptr_t],
[AC_DEFINE([HAVE_INTPTR_T], 1,
[Define to 1 if the system has the type `intptr_t'.]) ac_cv_c_intptr_t=yes],
[for ac_type in 'int' 'long int' 'long long int'; do
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY(
[AC_INCLUDES_DEFAULT],
[[sizeof (void *) <= sizeof ($ac_type)]])],
[AC_DEFINE_UNQUOTED([intptr_t], [$ac_type],
[Define to the type of a signed integer type wide enough to
hold a pointer, if such a type exists, and if the system
does not define it.]) ac_cv_c_intptr_t="$ac_type"
ac_type=])
test -z "$ac_type" && break
done])
])
# RB_TYPE_UINTPTR_T
# -----------------
AC_DEFUN([RB_TYPE_UINTPTR_T],
[
AC_CHECK_TYPE([uintptr_t],
[AC_DEFINE([HAVE_UINTPTR_T], 1,
[Define to 1 if the system has the type `uintptr_t'.]) ac_cv_c_uintptr_t=yes],
[for ac_type in 'unsigned int' 'unsigned long int' \
'unsigned long long int'; do
AC_COMPILE_IFELSE(
[AC_LANG_BOOL_COMPILE_TRY(
[AC_INCLUDES_DEFAULT],
[[sizeof (void *) <= sizeof ($ac_type)]])],
[AC_DEFINE_UNQUOTED([uintptr_t], [$ac_type],
[Define to the type of an unsigned integer type wide enough to
hold a pointer, if such a type exists, and if the system
does not define it.]) ac_cv_c_uintptr_t="$ac_type"
ac_type=])
test -z "$ac_type" && break
done])
])
dnl IPv6 support macros..pretty much swiped from wget
dnl RB_PROTO_INET6

112
libratbox/aclocal.m4 vendored
View file

@ -21,7 +21,7 @@ To do so, use the procedure documented by the package, typically `autoreconf'.])
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
# serial 52 Debian 1.5.26-4 AC_PROG_LIBTOOL
# serial 52 Debian 1.5.26-1ubuntu1 AC_PROG_LIBTOOL
# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
@ -6671,116 +6671,6 @@ AC_SUBST([SED])
AC_MSG_RESULT([$SED])
])
# longlong.m4 serial 13
dnl Copyright (C) 1999-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
# Define HAVE_LONG_LONG_INT if 'long long int' works.
# This fixes a bug in Autoconf 2.61, but can be removed once we
# assume 2.62 everywhere.
# Note: If the type 'long long int' exists but is only 32 bits large
# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
# defined. In this case you can treat 'long long int' like 'long int'.
AC_DEFUN([AC_TYPE_LONG_LONG_INT],
[
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
[AC_LINK_IFELSE(
[_AC_TYPE_LONG_LONG_SNIPPET],
[dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
dnl If cross compiling, assume the bug isn't important, since
dnl nobody cross compiles for this platform as far as we know.
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[@%:@include <limits.h>
@%:@ifndef LLONG_MAX
@%:@ define HALF \
(1LL << (sizeof (long long int) * CHAR_BIT - 2))
@%:@ define LLONG_MAX (HALF - 1 + HALF)
@%:@endif]],
[[long long int n = 1;
int i;
for (i = 0; ; i++)
{
long long int m = n << i;
if (m >> i != n)
return 1;
if (LLONG_MAX / 2 < m)
break;
}
return 0;]])],
[ac_cv_type_long_long_int=yes],
[ac_cv_type_long_long_int=no],
[ac_cv_type_long_long_int=yes])],
[ac_cv_type_long_long_int=no])])
if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], 1,
[Define to 1 if the system has the type `long long int'.])
fi
])
# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
# This fixes a bug in Autoconf 2.61, but can be removed once we
# assume 2.62 everywhere.
# Note: If the type 'unsigned long long int' exists but is only 32 bits
# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
# will not be defined. In this case you can treat 'unsigned long long int'
# like 'unsigned long int'.
AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
[
AC_CACHE_CHECK([for unsigned long long int],
[ac_cv_type_unsigned_long_long_int],
[AC_LINK_IFELSE(
[_AC_TYPE_LONG_LONG_SNIPPET],
[ac_cv_type_unsigned_long_long_int=yes],
[ac_cv_type_unsigned_long_long_int=no])])
if test $ac_cv_type_unsigned_long_long_int = yes; then
AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1,
[Define to 1 if the system has the type `unsigned long long int'.])
fi
])
# Expands to a C program that can be used to test for simultaneous support
# of 'long long' and 'unsigned long long'. We don't want to say that
# 'long long' is available if 'unsigned long long' is not, or vice versa,
# because too many programs rely on the symmetry between signed and unsigned
# integer types (excluding 'bool').
AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
[
AC_LANG_PROGRAM(
[[/* Test preprocessor. */
#if ! (-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
error in preprocessor;
#endif
#if ! (18446744073709551615ULL <= -1ull)
error in preprocessor;
#endif
/* Test literals. */
long long int ll = 9223372036854775807ll;
long long int nll = -9223372036854775807LL;
unsigned long long int ull = 18446744073709551615ULL;
/* Test constant expressions. */
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
? 1 : -1)];
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
? 1 : -1)];
int i = 63;]],
[[/* Test availability of runtime routines for shift and division. */
long long int llmax = 9223372036854775807ll;
unsigned long long int ullmax = 18446744073709551615ull;
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
| (llmax / ll) | (llmax % ll)
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
| (ullmax / ull) | (ullmax % ull));]])
])
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
#
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.

1982
libratbox/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
dnl $Id: configure.ac 23020 2006-09-01 18:20:19Z androsyn $
dnl $Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $
dnl Process this file with autoconf to produce a configure script.
dnl TODO: clean up all the OpenSSL and shared module checking stuff;
@ -8,7 +8,7 @@ dnl said functions need to be just about as complex as they already are.
AC_PREREQ(2.60)
AUTOMAKE_OPTIONS = 1.10
dnl Sneaky way to get an Id tag into the configure script
AC_COPYRIGHT([$Id: configure.ac 23020 2006-09-01 18:20:19Z androsyn $])
AC_COPYRIGHT([$Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $])
AC_INIT([libratbox],[devel])
AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION, -)
@ -99,20 +99,6 @@ if test "$libexecdir" = '${exec_prefix}/libexec' &&
localstatedir='${prefix}'
fi
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
RB_TYPE_INTPTR_T
RB_TYPE_INTMAX_T
RB_TYPE_UINTMAX_T
RB_TYPE_UINTPTR_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
@ -144,21 +130,41 @@ member.])],,[[
#endif
]])
AC_CHECK_TYPE(socklen_t, ,
[AC_DEFINE([socklen_t], [unsigned int],
[If we don't have a real socklen_t, unsigned int is good enough.])],
[
#ifdef HAVE_SYS_TYPES_H
AC_CHECK_TYPE([socklen_t], rb_socklen_t=socklen_t,[
AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([rb_socklen_t],
[
# Systems have either "struct sockaddr *" or
# "void *" as the second argument to getpeername
rb_socklen_t=
for arg2 in "struct sockaddr" void; do
for t in int size_t unsigned long "unsigned long"; do
AC_TRY_COMPILE([
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
int getpeername (int, $arg2 *, $t *);
],[
$t len;
getpeername(0,0,&len);
],[
rb_socklen_t="$t"
break
])
done
done
if test "x$rb_socklen_t" = x; then
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
fi
])
AC_MSG_RESULT($rb_socklen_t)],
[#include <sys/types.h>
#include <sys/socket.h>])
AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes])
@ -218,7 +224,7 @@ AC_CHECK_TYPE([sa_family_t], [],
dnl check for various functions...
AC_CHECK_FUNCS([socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl])
AC_CHECK_FUNCS([socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage])
AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
@ -241,25 +247,6 @@ if test "$is_mingw" = "yes"; then
AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
fi
dnl GnuTLS support
AC_MSG_CHECKING(for GnuTLS)
AC_ARG_ENABLE(gnutls,
[AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
[cf_enable_gnutls=$enableval],
[cf_enable_gnutls="auto"])
if test "$cf_enable_gnutls" != no; then
PKG_CHECK_MODULES(GNUTLS, [gnutls], [
CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
LIBS="$LIBS $GNUTLS_LIBS"
cf_enable_gnutls="yes"
], [cf_enable_gnutls="no"])
fi
if test "$cf_enable_gnutls" != no; then
AC_DEFINE(HAVE_GNUTLS, 1, [Has GNUTLS])
fi
dnl OpenSSL support
AC_MSG_CHECKING(for OpenSSL)
@ -269,11 +256,6 @@ AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
[cf_enable_openssl=$enableval],
[cf_enable_openssl="auto"])
dnl Prefer GnuTLS over OpenSSL due to licensing issues, this could use improvement
if test "$cf_enable_gnutls" = "yes" -a "$cf_enable_openssl" = "auto"; then
cf_enable_openssl="no"
fi
if test "$cf_enable_openssl" != "no" ; then
cf_openssl_basedir=""
if test "$cf_enable_openssl" != "auto" &&
@ -294,7 +276,7 @@ if test "$cf_enable_openssl" != "no" ; then
dnl Now check cf_openssl_found to see if we found anything.
if test ! -z "$cf_openssl_basedir"; then
if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
SSL_INCLUDES="-I${cf_openssl_basedir}/include"
SSL_CFLAGS="-I${cf_openssl_basedir}/include"
SSL_LIBS="-L${cf_openssl_basedir}/lib"
else
dnl OpenSSL wasn't found in the directory specified. Naughty
@ -329,7 +311,7 @@ else
fi
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
CPPFLAGS="$CPPFLAGS $SSL_CFLAGS"
save_LIBS="$LIBS"
LIBS="$LIBS $SSL_LIBS"
if test "$cf_enable_openssl" != no; then
@ -369,10 +351,40 @@ if test "$cf_enable_openssl" != no; then
[cf_enable_openssl=no], [-lcrypto])
fi
if test "$cf_enable_openssl" != no; then
AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
dnl GnuTLS support
AC_MSG_CHECKING(for GnuTLS)
AC_ARG_ENABLE(gnutls,
[AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
[cf_enable_gnutls=$enableval],
[cf_enable_gnutls="auto"])
if test "$cf_enable_gnutls" != no; then
PKG_CHECK_MODULES(GNUTLS, [gnutls], [
cf_enable_gnutls="yes"
], [cf_enable_gnutls="no"])
fi
if test "$cf_enable_gnutls" = "auto" -a "$cf_enable_openssl" = "yes"; then
cf_enable_gnutls="no"
fi
if test x"$cf_enable_openssl" != xno; then
AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
GNUTLS_CFLAGS=""
GNUTLS_LIBS=""
SSL_TYPE="openssl"
elif test x"$cf_enable_gnutls" != xno; then
AC_DEFINE(HAVE_GNUTLS, 1, [Has GnuTLS])
SSL_LIBS=""
SSL_CFLAGS=""
SSL_TYPE="gnutls"
fi
CPPFLAGS="$save_CPPFLAGS"
LIBS="$save_LIBS"
@ -431,9 +443,10 @@ AC_SUBST(LDFLAGS)
AC_SUBST(PICFLAGS)
AC_SUBST(CFLAGS)
AC_SUBST(SEDOBJ)
AC_SUBST(SSL_INCLUDES)
AC_SUBST(SSL_CFLAGS)
AC_SUBST(SSL_LIBS)
AC_SUBST(GNUTLS_CFLAGS)
AC_SUBST(GNUTLS_LIBS)
if test "$prefix" = "NONE"; then
AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where libratbox is installed.])
@ -450,17 +463,6 @@ fi
AC_SUBST(RB_PREFIX)
for dtype in uint64_t uint32_t uint16_t uint8_t int64_t int32_t int16_t int8_t intmax_t intptr_t uintmax_t uintptr_t
do
var="\$ac_cv_c_${dtype}"
t_type=$(eval echo $var);
if test "x$t_type" = "xyes"; then
eval rb_$dtype="\"$dtype\""
else
eval rb_$dtype="\"$t_type\""
fi
done
AC_CONFIG_COMMANDS([include/librb-config.h],
[
outfile=include/librb-config.h.tmp
@ -545,28 +547,17 @@ if test "x$rb_errno_h" = "xyes"; then
echo '#include <errno.h>' >> $outfile
fi
echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
if test "x$rb_sockaddr_sa_len" = "xyes"; then
echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
fi
echo "typedef $rb_uint64_t rb_uint64_t;" >> $outfile
echo "typedef $rb_uint32_t rb_uint32_t;" >> $outfile
echo "typedef $rb_uint16_t rb_uint16_t;" >> $outfile
echo "typedef $rb_uint8_t rb_uint8_t;" >> $outfile
echo "typedef $rb_int64_t rb_int64_t;" >> $outfile
echo "typedef $rb_int32_t rb_int32_t;" >> $outfile
echo "typedef $rb_int16_t rb_int16_t;" >> $outfile
echo "typedef $rb_int8_t rb_int8_t;" >> $outfile
echo "typedef $rb_intmax_t rb_intmax_t;" >> $outfile
echo "typedef $rb_intptr_t rb_intptr_t;" >> $outfile
echo "typedef $rb_uintmax_t rb_uintmax_t;" >> $outfile
echo "typedef $rb_uintptr_t rb_uintptr_t;" >> $outfile
echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
if test "x$rb_sockaddr_storage" = "xyes"; then
echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
else
echo 'struct rb_sockaddr_storage { rb_uint8_t _padding[128]; };' >> $outfile
echo 'struct rb_sockaddr_storage { uint8_t _padding[128]; };' >> $outfile
fi
cat >> $outfile <<\_______EOF
@ -581,18 +572,6 @@ else
fi
],[
rb_uint64_t="$rb_uint64_t"
rb_uint32_t="$rb_uint32_t"
rb_uint16_t="$rb_uint16_t"
rb_uint8_t="$rb_uint8_t"
rb_int64_t="$rb_int64_t"
rb_int32_t="$rb_int32_t"
rb_int16_t="$rb_int16_t"
rb_int8_t="$rb_int8_t"
rb_intmax_t="$rb_intmax_t"
rb_intptr_t="$rb_intptr_t"
rb_uintmax_t="$rb_uintmax_t"
rb_uintptr_t="$rb_uintptr_t"
if test x$ac_cv_header_stdc = xyes; then
rb_header_stdc=yes
fi
@ -654,11 +633,9 @@ fi
if test x$ac_cv_header_winsock2_h = xyes; then
rb_winsock2_h=yes
fi
if test x$ac_cv_type_socklen_t = xyes; then
rb_socklen_t="socklen_t"
else
rb_socklen_t="unsigned int"
fi
rb_socklen_t=$rb_socklen_t
if test "x$rb_have_sockaddr_storage" = "xyes"; then
rb_sockaddr_storage="yes"
else
@ -675,11 +652,12 @@ fi
)
AC_CONFIG_FILES([
src/Makefile
Makefile
libratbox.pc
])
AC_CONFIG_FILES( \
src/Makefile \
Makefile \
libratbox.pc \
)
AC_OUTPUT
@ -694,7 +672,6 @@ echo "Installing into: $prefix"
echo "IPv6 support ................... $have_v6"
echo "Assert debugging ............... $assert"
echo "Block allocator ................ $balloc"
echo "OpenSSL ........................ $cf_enable_openssl"
echo "GnuTLS ......................... $cf_enable_gnutls"
echo "SSL Type........................ $SSL_TYPE"
echo

View file

@ -0,0 +1,7 @@
#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_ARC4RANDOM)
void arc4random_stir(void);
uint32_t arc4random(void);
void arc4random_addrandom(uint8_t *dat, int datlen);
#endif

View file

@ -103,8 +103,8 @@ struct _fde
*/
rb_dlink_node node;
int fd; /* So we can use the rb_fde_t as a callback ptr */
rb_uint8_t flags;
rb_uint8_t type;
uint8_t flags;
uint8_t type;
int pflags;
char *desc;
PF *read_handler;
@ -115,6 +115,7 @@ struct _fde
struct conndata *connect;
struct acceptdata *accept;
void *ssl;
unsigned int handshake_count;
unsigned long ssl_errno;
};
@ -137,7 +138,7 @@ rb_find_fd(int fd)
rb_dlink_list *hlist;
rb_dlink_node *ptr;
if(unlikely(fd < 0))
if(rb_unlikely(fd < 0))
return NULL;
hlist = &rb_fd_table[rb_hash_fd(fd)];

View file

@ -9,7 +9,7 @@ const char *rb_get_ssl_strerror(rb_fde_t *F);
void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout);
void rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout);
void rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, struct sockaddr *clocal, int socklen, CNCB *callback, void *data, int timeout);
void rb_ssl_accept_setup(rb_fde_t *F, int new_fd, struct sockaddr *st, int addrlen);
void rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen);
void rb_ssl_shutdown(rb_fde_t *F);
ssize_t rb_ssl_read(rb_fde_t *F, void *buf, size_t count);
ssize_t rb_ssl_write(rb_fde_t *F, const void *buf, size_t count);

View file

@ -18,6 +18,9 @@
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the `arc4random' function. */
#undef HAVE_ARC4RANDOM
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
@ -45,30 +48,24 @@
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define to 1 if you have the `getrusage' function. */
#undef HAVE_GETRUSAGE
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `gmtime_r' function. */
#undef HAVE_GMTIME_R
/* Has GNUTLS */
/* Has GnuTLS */
#undef HAVE_GNUTLS
/* Define to 1 if the system has the type `intmax_t'. */
#undef HAVE_INTMAX_T
/* Define to 1 if the system has the type `intptr_t'. */
#undef HAVE_INTPTR_T
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `kevent' function. */
#undef HAVE_KEVENT
/* Define to 1 if the system has the type `long long int'. */
#undef HAVE_LONG_LONG_INT
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
@ -183,18 +180,9 @@
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define to 1 if the system has the type `uintmax_t'. */
#undef HAVE_UINTMAX_T
/* Define to 1 if the system has the type `uintptr_t'. */
#undef HAVE_UINTPTR_T
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if the system has the type `unsigned long long int'. */
#undef HAVE_UNSIGNED_LONG_LONG_INT
/* Define to 1 if you have the `usleep' function. */
#undef HAVE_USLEEP
@ -280,21 +268,6 @@
# undef _GNU_SOURCE
#endif
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
#undef _UINT64_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
@ -307,30 +280,6 @@
#undef inline
#endif
/* Define to the type of a signed integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef int16_t
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef int32_t
/* Define to the type of a signed integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef int64_t
/* Define to the type of a signed integer type of width exactly 8 bits if such
a type exists and the standard includes do not define it. */
#undef int8_t
/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
not define. */
#undef intmax_t
/* Define to the type of a signed integer type wide enough to hold a pointer,
if such a type exists, and if the system does not define it. */
#undef intptr_t
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
@ -340,38 +289,11 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* If we don't have a real socklen_t, unsigned int is good enough. */
#undef socklen_t
/* Define to `int' if <sys/types.h> does not define. */
#undef ssize_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define to the type of an unsigned integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef uint16_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef uint64_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
#undef uint8_t
/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
do not define. */
#undef uintmax_t
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
#undef uintptr_t
/* Define as `fork' if `vfork' does not work. */
#undef vfork

View file

@ -0,0 +1,374 @@
/* include/libratbox_config.h.in. Generated from configure.ac by autoheader. */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* This is a Cygwin system */
#undef CYGWIN
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if you have `alloca', as a function or macro. */
#define HAVE_ALLOCA 1
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define to 1 if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H
/* Define to 1 if you have devpoll */
#undef HAVE_DEVPOLL
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `epoll_ctl' function. */
#undef HAVE_EPOLL_CTL
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
/* Define to 1 if you have the `fstat' function. */
#define HAVE_FSTAT 1
/* Define to 1 if you have the `getpagesize' function. */
#define HAVE_GETPAGESIZE 1
/* Define to 1 if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the `gmtime_r' function. */
#define HAVE_GMTIME_R 1
/* Define to 1 if the system has the type `intmax_t'. */
#define HAVE_INTMAX_T 1
/* Define to 1 if the system has the type `intptr_t'. */
#define HAVE_INTPTR_T 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `kevent' function. */
#undef HAVE_KEVENT
/* Define to 1 if the system has the type `long long int'. */
#define HAVE_LONG_LONG_INT 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have a working `mmap' system call. */
#define HAVE_MMAP 1
/* Define if you have nanosleep */
#define HAVE_NANOSLEEP 1
/* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Has OpenSSL */
#undef HAVE_OPENSSL
/* Define to 1 if you have the `poll' function. */
#define HAVE_POLL 1
/* Define to 1 if you have the `port_create' function. */
#undef HAVE_PORT_CREATE
/* Define to 1 if you have the <port.h> header file. */
#undef HAVE_PORT_H
/* Define to 1 if you have the `posix_spawn' function. */
#define HAVE_POSIX_SPAWN 1
/* Define to 1 if you have the `select' function. */
#define HAVE_SELECT 1
/* Define to 1 if you have the `sendmsg' function. */
#define HAVE_SENDMSG 1
/* Define to 1 if you have the `signalfd' function. */
#undef HAVE_SIGNALFD
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the `socketpair' function. */
#define HAVE_SOCKETPAIR 1
/* Define to 1 if you have the <spawn.h> header file. */
#undef HAVE_SPAWN_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strlcat' function. */
#undef HAVE_STRLCAT
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
/* Define to 1 if you have the `strnlen' function. */
#define HAVE_STRNLEN 1
/* Define to 1 if you have the `strtok_r' function. */
#define HAVE_STRTOK_R 1
/* Define to 1 if the system has the type `struct sockaddr_in6'. */
#define HAVE_STRUCT_SOCKADDR_IN6 1
/* Define to 1 if the system has the type `struct sockaddr_storage'. */
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
/* Define to 1 if you have the <sys/devpoll.h> header file. */
#undef HAVE_SYS_DEVPOLL_H
/* Define to 1 if you have the <sys/epoll.h> header file. */
#undef HAVE_SYS_EPOLL_H
/* Define to 1 if you have the <sys/event.h> header file. */
#undef HAVE_SYS_EVENT_H
/* Define to 1 if you have the <sys/poll.h> header file. */
#undef HAVE_SYS_POLL_H
/* Define to 1 if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/signalfd.h> header file. */
#undef HAVE_SYS_SIGNALFD_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/uio.h> header file. */
#define HAVE_SYS_UIO_H 1
/* Define if you have timer_create */
#undef HAVE_TIMER_CREATE
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define to 1 if the system has the type `uintmax_t'. */
#define HAVE_UINTMAX_T 1
/* Define to 1 if the system has the type `uintptr_t'. */
#define HAVE_UINTPTR_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type `unsigned long long int'. */
#define HAVE_UNSIGNED_LONG_LONG_INT 1
/* Define to 1 if you have the `usleep' function. */
#define HAVE_USLEEP 1
/* Define to 1 if you have the `vfork' function. */
#define HAVE_VFORK 1
/* Define to 1 if you have the <vfork.h> header file. */
#undef HAVE_VFORK_H
/* Define to 1 if you are on windows */
#undef HAVE_WIN32
/* Define to 1 if `fork' works. */
#undef HAVE_WORKING_FORK
/* Define to 1 if `vfork' works. */
#define HAVE_WORKING_VFORK 1
/* Define to 1 if you have the `writev' function. */
#define HAVE_WRITEV 1
/* This is a MinGW system */
#undef MINGW
/* Define this to disable debugging support. */
#undef NDEBUG
/* Define if your system needs crypt. */
#undef NEED_CRYPT
/* Define to 1 if you wish to disable the block allocator. */
#undef NOBALLOC
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Defined to mark profiling is enabled */
#undef RATBOX_PROFILE
/* Prefix where libratbox is installed. */
#define RB_PREFIX "/ratbox"
/* Define to 1 if sockaddr has a 'sa_len' member. */
#undef SOCKADDR_IN_HAS_LEN
/* Define this to enable soft asserts. */
#undef SOFT_ASSERT
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define to 1 if we can use timer_create(CLOCK_REALTIME,...) */
#undef USE_TIMER_CREATE
/* This is a Windows system */
#undef WINDOWS
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
#undef _UINT64_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef was allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#define inline inline
#endif
/* Define to the type of a signed integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef int16_t
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef int32_t
/* Define to the type of a signed integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef int64_t
/* Define to the type of a signed integer type of width exactly 8 bits if such
a type exists and the standard includes do not define it. */
#undef int8_t
/* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
not define. */
#undef intmax_t
/* Define to the type of a signed integer type wide enough to hold a pointer,
if such a type exists, and if the system does not define it. */
#undef intptr_t
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* If system does not define sa_family_t, define it here. */
#undef sa_family_t
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* If we don't have a real socklen_t, unsigned int is good enough. */
#undef socklen_t
/* Define to `int' if <sys/types.h> does not define. */
#undef ssize_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define to the type of an unsigned integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
#undef uint16_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef uint64_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
#undef uint8_t
/* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
do not define. */
#undef uintmax_t
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
#undef uintptr_t
/* Define as `fork' if `vfork' does not work. */
#define vfork fork

View file

@ -1,5 +1,5 @@
/*
* $Id: ratbox_lib.h 24866 2008-01-10 16:33:54Z androsyn $
* $Id: ratbox_lib.h 25375 2008-05-16 15:19:51Z androsyn $
*/
#ifndef RB_LIB_H
@ -38,32 +38,32 @@ char *alloca();
#ifdef __GNUC__
#ifdef likely
#undef likely
#ifdef rb_likely
#undef rb_likely
#endif
#ifdef unlikely
#undef unlikely
#ifdef rb_unlikely
#undef rb_unlikely
#endif
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
# define __builtin_expect(x, expected_value) (x)
#endif
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define rb_likely(x) __builtin_expect(!!(x), 1)
#define rb_unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ */
#define UNUSED(x) x
#ifdef likely
#undef likely
#ifdef rb_likely
#undef rb_likely
#endif
#ifdef unlikely
#undef unlikely
#ifdef rb_unlikely
#undef rb_unlikely
#endif
#define likely(x) (x)
#define unlikely(x) (x)
#define rb_likely(x) (x)
#define rb_unlikely(x) (x)
#endif
@ -118,24 +118,18 @@ unsigned int geteuid(void);
#ifdef SOFT_ASSERT
#ifdef __GNUC__
#define lrb_assert(expr) do \
if(unlikely(!(expr))) { \
lib_ilog(L_MAIN, \
if(rb_unlikely(!(expr))) { \
rb_lib_log( \
"file: %s line: %d (%s): Assertion failed: (%s)", \
__FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
sendto_realops_flags(UMODE_ALL, L_ALL, \
"file: %s line: %d (%s): Assertion failed: (%s)", \
__FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
} \
while(0)
#else
#define lrb_assert(expr) do \
if(unlikely(!(expr))) { \
lib_ilog(L_MAIN, \
if(rb_unlikely(!(expr))) { \
rb_lib_log(L_MAIN, \
"file: %s line: %d: Assertion failed: (%s)", \
__FILE__, __LINE__, #expr); \
sendto_realops_flags(UMODE_ALL, L_ALL, \
"file: %s line: %d: Assertion failed: (%s)" \
__FILE__, __LINE__, #expr); \
} \
while(0)
#endif

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: rb_commio.h 25038 2008-01-23 16:03:08Z androsyn $
* $Id: rb_commio.h 25693 2008-07-10 18:27:23Z androsyn $
*/
#ifndef RB_LIB_H
@ -88,7 +88,7 @@ struct rb_iovec
void rb_fdlist_init(int closeall, int maxfds, size_t heapsize);
rb_fde_t * rb_open(int, rb_uint8_t, const char *);
rb_fde_t * rb_open(int, uint8_t, const char *);
void rb_close(rb_fde_t *);
void rb_dump_fd(DUMPCB *, void *xdata);
void rb_note(rb_fde_t *, const char *);
@ -148,8 +148,8 @@ rb_fde_t *rb_get_fde(int fd);
int rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize);
int rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int count);
void rb_set_type(rb_fde_t *F, rb_uint8_t type);
rb_uint8_t rb_get_type(rb_fde_t *F);
void rb_set_type(rb_fde_t *F, uint8_t type);
uint8_t rb_get_type(rb_fde_t *F);
const char *rb_get_iotype(void);
@ -164,9 +164,12 @@ typedef enum {
int rb_init_prng(const char *path, prng_seed_t seed_type);
int rb_get_random(void *buf, size_t len);
int rb_get_pseudo_random(void *buf, size_t len);
void rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout);
void rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout);
int rb_supports_ssl(void);
unsigned int rb_ssl_handshake_count(rb_fde_t *F);
void rb_ssl_clear_handshake_count(rb_fde_t *F);
#endif /* INCLUDED_commio_h */

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: rb_linebuf.h 24324 2007-08-31 22:05:45Z androsyn $
* $Id: rb_linebuf.h 25675 2008-07-06 04:13:05Z androsyn $
*/
#ifndef RB_LIB_H
@ -45,8 +45,8 @@ struct _buf_head;
typedef struct _buf_line
{
char buf[BUF_DATA_SIZE + 2];
rb_uint8_t terminated; /* Whether we've terminated the buffer */
rb_uint8_t raw; /* Whether this linebuf may hold 8-bit data */
uint8_t terminated; /* Whether we've terminated the buffer */
uint8_t raw; /* Whether this linebuf may hold 8-bit data */
int len; /* How much data we've got */
int refcount; /* how many linked lists are we in? */
} buf_line_t;

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: rb_memory.h 25022 2008-01-23 03:54:00Z androsyn $
* $Id: rb_memory.h 25375 2008-05-16 15:19:51Z androsyn $
*/
#ifndef RB_LIB_H
@ -40,7 +40,7 @@ static inline void *
rb_malloc(size_t size)
{
void *ret = calloc(1, size);
if(unlikely(ret == NULL))
if(rb_unlikely(ret == NULL))
rb_outofmemory();
return (ret);
}
@ -50,7 +50,7 @@ rb_realloc(void *x, size_t y)
{
void *ret = realloc(x, y);
if(unlikely(ret == NULL))
if(rb_unlikely(ret == NULL))
rb_outofmemory();
return (ret);
}
@ -59,7 +59,7 @@ static inline char *
rb_strndup(const char *x, size_t y)
{
char *ret = malloc(y);
if(unlikely(ret == NULL))
if(rb_unlikely(ret == NULL))
rb_outofmemory();
rb_strlcpy(ret, x, y);
return(ret);
@ -69,7 +69,7 @@ static inline char *
rb_strdup(const char *x)
{
char *ret = malloc(strlen(x) + 1);
if(unlikely(ret == NULL))
if(rb_unlikely(ret == NULL))
rb_outofmemory();
strcpy(ret, x);
return(ret);
@ -79,8 +79,9 @@ rb_strdup(const char *x)
static inline void
rb_free(void *ptr)
{
if(likely(ptr != NULL))
if(rb_likely(ptr != NULL))
free(ptr);
}
#endif /* _I_MEMORY_H */

View file

@ -1,8 +1,8 @@
# $Id: Makefile.am 24820 2008-01-02 19:47:32Z androsyn $
# $Id: Makefile.am 25689 2008-07-10 17:13:27Z androsyn $
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I. -I../include @SSL_INCLUDES@
INCLUDES = -I. -I../include @SSL_CFLAGS@ @GNUTLS_CFLAGS@
libratbox_la_SOURCES = \
unix.c \
@ -28,10 +28,11 @@ libratbox_la_SOURCES = \
select.c \
kqueue.c \
rawbuf.c \
patricia.c
patricia.c \
arc4random.c
libratbox_la_LDFLAGS = -version-info 3:0:0 -no-undefined -export-symbols export-syms.txt
libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@
libratbox_la_LDFLAGS = -avoid-version -no-undefined -export-symbols export-syms.txt
libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@
lib_LTLIBRARIES = libratbox.la

View file

@ -14,7 +14,7 @@
@SET_MAKE@
# $Id: Makefile.am 24820 2008-01-02 19:47:32Z androsyn $
# $Id: Makefile.am 25689 2008-07-10 17:13:27Z androsyn $
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
@ -58,7 +58,7 @@ am_libratbox_la_OBJECTS = unix.lo win32.lo crypt.lo balloc.lo \
commio.lo openssl.lo gnutls.lo nossl.lo event.lo ratbox_lib.lo \
rb_memory.lo linebuf.lo snprintf.lo tools.lo helper.lo \
devpoll.lo epoll.lo poll.lo ports.lo sigio.lo select.lo \
kqueue.lo rawbuf.lo patricia.lo
kqueue.lo rawbuf.lo patricia.lo arc4random.lo
libratbox_la_OBJECTS = $(am_libratbox_la_OBJECTS)
libratbox_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@ -150,7 +150,7 @@ SED = @SED@
SEDOBJ = @SEDOBJ@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SSL_INCLUDES = @SSL_INCLUDES@
SSL_CFLAGS = @SSL_CFLAGS@
SSL_LIBS = @SSL_LIBS@
STRIP = @STRIP@
TOUCH = @TOUCH@
@ -208,7 +208,7 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
INCLUDES = -I. -I../include @SSL_INCLUDES@
INCLUDES = -I. -I../include @SSL_CFLAGS@ @GNUTLS_CFLAGS@
libratbox_la_SOURCES = \
unix.c \
win32.c \
@ -233,10 +233,11 @@ libratbox_la_SOURCES = \
select.c \
kqueue.c \
rawbuf.c \
patricia.c
patricia.c \
arc4random.c
libratbox_la_LDFLAGS = -avoid-version -no-undefined -export-symbols export-syms.txt
libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@
libratbox_la_LIBADD = @CRYPT_LIB@ @SSL_LIBS@ @GNUTLS_LIBS@
lib_LTLIBRARIES = libratbox.la
all: all-am
@ -307,6 +308,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc4random.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/balloc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commio.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt.Plo@am__quote@

200
libratbox/src/arc4random.c Normal file
View file

@ -0,0 +1,200 @@
/* $Id: arc4random.c 25705 2008-07-11 18:21:57Z androsyn $ */
/* $$$: arc4random.c 2005/02/08 robert */
/* $NetBSD: arc4random.c,v 1.5.2.1 2004/03/26 22:52:50 jmc Exp $ */
/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
/*
* Arc4 random number generator for OpenBSD.
* Copyright 1996 David Mazieres <dm@lcs.mit.edu>.
*
* Modification and redistribution in source and binary forms is
* permitted provided that due credit is given to the author and the
* OpenBSD project by leaving this copyright notice intact.
*/
/*
* This code is derived from section 17.1 of Applied Cryptography,
* second edition, which describes a stream cipher allegedly
* compatible with RSA Labs "RC4" cipher (the actual description of
* which is a trade secret). The same algorithm is used as a stream
* cipher called "arcfour" in Tatu Ylonen's ssh package.
*
* Here the stream cipher has been modified always to include the time
* when initializing the state. That makes it impossible to
* regenerate the same random sequence twice, so this can't be used
* for encryption, but will generate good random numbers.
*
* RC4 is a registered trademark of RSA Laboratories.
*/
#include <libratbox_config.h>
#include <ratbox_lib.h>
#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_ARC4RANDOM)
#include "arc4random.h"
#ifdef HAVE_GETRUSAGE
#include <sys/resource.h>
#endif
struct arc4_stream {
uint8_t i;
uint8_t j;
uint8_t s[256];
};
static int rs_initialized;
static struct arc4_stream rs;
static inline void arc4_init(struct arc4_stream *);
static inline void arc4_addrandom(struct arc4_stream *, uint8_t *, int);
static void arc4_stir(struct arc4_stream *);
static inline uint8_t arc4_getbyte(struct arc4_stream *);
static inline uint32_t arc4_getword(struct arc4_stream *);
static inline void
arc4_init(struct arc4_stream *as)
{
int n;
for (n = 0; n < 256; n++)
as->s[n] = n;
as->i = 0;
as->j = 0;
}
static inline void
arc4_addrandom(struct arc4_stream *as, uint8_t *dat, int datlen)
{
int n;
uint8_t si;
as->i--;
for (n = 0; n < 256; n++) {
as->i = (as->i + 1);
si = as->s[as->i];
as->j = (as->j + si + dat[n % datlen]);
as->s[as->i] = as->s[as->j];
as->s[as->j] = si;
}
as->j = as->i;
}
static void
arc4_stir(struct arc4_stream *as)
{
struct timeval tv;
pid_t pid;
int n;
/* XXX this doesn't support egd sources or similiar */
pid = getpid();
arc4_addrandom(as, (void *)&pid, sizeof(pid));
rb_gettimeofday(&tv, NULL);
arc4_addrandom(as, (void *)&tv.tv_sec, sizeof(&tv.tv_sec));
arc4_addrandom(as, (void *)&tv.tv_usec, sizeof(&tv.tv_usec));
rb_gettimeofday(&tv, NULL);
arc4_addrandom(as, (void *)&tv.tv_usec, sizeof(&tv.tv_usec));
#if defined(HAVE_GETRUSAGE) && RUSAGE_SELF
{
struct rusage buf;
getrusage(RUSAGE_SELF, &buf);
arc4_addrandom(as, (void *)&buf, sizeof(buf));
memset(&buf, 0, sizeof(buf))
}
#endif
#if !defined(WIN32)
{
uint8_t rnd[128];
int fd;
fd = open("/dev/urandom", O_RDONLY);
if (fd != -1)
{
read(fd, rnd, sizeof(rnd));
close(fd);
arc4_addrandom(as, (void *)rnd, sizeof(rnd));
}
}
#else
{
LARGE_INTEGER performanceCount;
if (QueryPerformanceCounter (&performanceCount))
{
arc4_addrandom(as, (void *)&performanceCount, sizeof(performanceCount));
}
}
#endif
/*
* Throw away the first N words of output, as suggested in the
* paper "Weaknesses in the Key Scheduling Algorithm of RC4"
* by Fluher, Mantin, and Shamir.
* http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps
* N = 256 in our case.
*/
for (n = 0; n < 256 * 4; n++)
arc4_getbyte(as);
}
static inline uint8_t
arc4_getbyte(struct arc4_stream *as)
{
uint8_t si, sj;
as->i = (as->i + 1);
si = as->s[as->i];
as->j = (as->j + si);
sj = as->s[as->j];
as->s[as->i] = sj;
as->s[as->j] = si;
return (as->s[(si + sj) & 0xff]);
}
static inline uint32_t
arc4_getword(struct arc4_stream *as)
{
uint32_t val;
val = arc4_getbyte(as) << 24;
val |= arc4_getbyte(as) << 16;
val |= arc4_getbyte(as) << 8;
val |= arc4_getbyte(as);
return val;
}
void
arc4random_stir(void)
{
if (!rs_initialized) {
arc4_init(&rs);
rs_initialized = 1;
}
arc4_stir(&rs);
}
void
arc4random_addrandom(uint8_t *dat, int datlen)
{
if (!rs_initialized)
arc4random_stir();
arc4_addrandom(&rs, dat, datlen);
}
uint32_t
arc4random(void)
{
if (!rs_initialized)
arc4random_stir();
return arc4_getword(&rs);
}
#endif

View file

@ -28,7 +28,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: balloc.c 25048 2008-01-23 18:34:02Z androsyn $
* $Id: balloc.c 25675 2008-07-06 04:13:05Z androsyn $
*/
/*
@ -225,7 +225,7 @@ newblock(rb_bh * bh)
{
rb_heap_block *b;
unsigned long i;
rb_uintptr_t offset;
uintptr_t offset;
/* Setup the initial data structure. */
b = rb_malloc(sizeof(rb_heap_block));
@ -233,11 +233,11 @@ newblock(rb_bh * bh)
b->alloc_size = bh->elemsPerBlock * (bh->elemSize + sizeof(rb_heap_block *));
b->elems = get_block(b->alloc_size);
if(unlikely(b->elems == NULL))
if(rb_unlikely(b->elems == NULL))
{
return (1);
}
offset = (rb_uintptr_t)b->elems;
offset = (uintptr_t)b->elems;
/* Setup our blocks now */
for (i = 0; i < bh->elemsPerBlock; i++, offset += (bh->elemSize + sizeof(rb_heap_block *)))
{
@ -273,7 +273,7 @@ rb_bh_create(size_t elemsize, int elemsperblock, const char *desc)
lrb_assert(elemsize > 0 && elemsperblock > 0);
lrb_assert(elemsize >= sizeof(rb_dlink_node));
/* Catch idiotic requests up front */
if((elemsize <= 0) || (elemsperblock <= 0))
if((elemsize == 0) || (elemsperblock <= 0))
{
rb_bh_fail("Attempting to rb_bh_create idiotic sizes");
}
@ -337,7 +337,7 @@ rb_bh_alloc(rb_bh * bh)
rb_heap_memblock *memblock;
#endif
lrb_assert(bh != NULL);
if(unlikely(bh == NULL))
if(rb_unlikely(bh == NULL))
{
rb_bh_fail("Cannot allocate if bh == NULL");
}
@ -350,7 +350,7 @@ rb_bh_alloc(rb_bh * bh)
/* Allocate new block and assign */
/* newblock returns 1 if unsuccessful, 0 if not */
if(unlikely(newblock(bh)))
if(rb_unlikely(newblock(bh)))
{
rb_lib_log("newblock() failed");
rb_outofmemory(); /* Well that didn't work either...bail */
@ -392,15 +392,15 @@ rb_bh_free(rb_bh * bh, void *ptr)
lrb_assert(bh != NULL);
lrb_assert(ptr != NULL);
if(unlikely(bh == NULL))
if(rb_unlikely(bh == NULL))
{
rb_lib_log("balloc.c:rb_bh_free() bh == NULL");
rb_lib_log("balloc.c:rb_bhFree() bh == NULL");
return (1);
}
if(unlikely(ptr == NULL))
if(rb_unlikely(ptr == NULL))
{
rb_lib_log("balloc.rb_bh_free() ptr == NULL");
rb_lib_log("balloc.rb_bhFree() ptr == NULL");
return (1);
}
@ -409,7 +409,7 @@ rb_bh_free(rb_bh * bh, void *ptr)
#else
memblock = (rb_heap_memblock *) ((uintptr_t)ptr - sizeof(rb_heap_block *));
/* XXX */
if(unlikely(!((uintptr_t)ptr >= (uintptr_t)memblock->block->elems && (uintptr_t)ptr < (uintptr_t)memblock->block->elems + (uintptr_t)memblock->block->alloc_size)))
if(rb_unlikely(!((uintptr_t)ptr >= (uintptr_t)memblock->block->elems && (uintptr_t)ptr < (uintptr_t)memblock->block->elems + (uintptr_t)memblock->block->alloc_size)))
{
rb_bh_fail("rb_bh_free() bogus pointer");
}

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: commio.c 25358 2008-05-13 14:48:46Z androsyn $
* $Id: commio.c 25795 2008-07-29 15:26:55Z androsyn $
*/
#include <libratbox_config.h>
#include <ratbox_lib.h>
@ -80,7 +80,6 @@ static inline rb_fde_t *
add_fd(int fd)
{
rb_fde_t *F = rb_find_fd(fd);
rb_dlink_list *list;
/* look up to see if we have it already */
if(F != NULL)
@ -88,21 +87,17 @@ add_fd(int fd)
F = rb_bh_alloc(fd_heap);
F->fd = fd;
list = &rb_fd_table[rb_hash_fd(fd)];
rb_dlinkAdd(F, &F->node, list);
rb_dlinkAdd(F, &F->node, &rb_fd_table[rb_hash_fd(fd)]);
return(F);
}
static inline void
remove_fd(rb_fde_t *F)
{
rb_dlink_list *list;
if(F == NULL || !IsFDOpen(F))
return;
list = &rb_fd_table[rb_hash_fd(F->fd)];
rb_dlinkMoveNode(&F->node, list, &closed_list);
rb_dlinkMoveNode(&F->node, &rb_fd_table[rb_hash_fd(F->fd)], &closed_list);
}
static void
@ -368,7 +363,14 @@ rb_accept_tryaccept(rb_fde_t *F, void *data)
new_F = rb_open(new_fd, RB_FD_SOCKET, "Incoming Connection");
if(unlikely(!rb_set_nb(new_F)))
if(new_F == NULL)
{
rb_lib_log("rb_accept: new_F == NULL on incoming connection. Closing new_fd == %d\n", new_fd);
close(new_fd);
continue;
}
if(rb_unlikely(!rb_set_nb(new_F)))
{
rb_get_errno();
rb_lib_log("rb_accept: Couldn't set FD %d non blocking!", new_F->fd);
@ -387,7 +389,7 @@ rb_accept_tryaccept(rb_fde_t *F, void *data)
#ifdef HAVE_SSL
if(F->type & RB_FD_SSL)
{
rb_ssl_accept_setup(F, new_fd, (struct sockaddr *)&st, addrlen);
rb_ssl_accept_setup(F, new_F, (struct sockaddr *)&st, addrlen);
}
else
#endif /* HAVE_SSL */
@ -603,7 +605,7 @@ rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2
}
/* Set the socket non-blocking, and other wonderful bits */
if(unlikely(!rb_set_nb(*F1)))
if(rb_unlikely(!rb_set_nb(*F1)))
{
rb_lib_log("rb_open: Couldn't set FD %d non blocking: %s", nfd[0], strerror(errno));
rb_close(*F1);
@ -611,7 +613,7 @@ rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2
return -1;
}
if(unlikely(!rb_set_nb(*F2)))
if(rb_unlikely(!rb_set_nb(*F2)))
{
rb_lib_log("rb_open: Couldn't set FD %d non blocking: %s", nfd[1], strerror(errno));
rb_close(*F1);
@ -640,7 +642,7 @@ rb_pipe(rb_fde_t **F1, rb_fde_t **F2, const char *desc)
*F1 = rb_open(fd[0], RB_FD_PIPE, desc);
*F2 = rb_open(fd[1], RB_FD_PIPE, desc);
if(unlikely(!rb_set_nb(*F1)))
if(rb_unlikely(!rb_set_nb(*F1)))
{
rb_lib_log("rb_open: Couldn't set FD %d non blocking: %s", fd[0], strerror(errno));
rb_close(*F1);
@ -648,7 +650,7 @@ rb_pipe(rb_fde_t **F1, rb_fde_t **F2, const char *desc)
return -1;
}
if(unlikely(!rb_set_nb(*F2)))
if(rb_unlikely(!rb_set_nb(*F2)))
{
rb_lib_log("rb_open: Couldn't set FD %d non blocking: %s", fd[1], strerror(errno));
rb_close(*F1);
@ -679,7 +681,7 @@ rb_socket(int family, int sock_type, int proto, const char *note)
rb_fde_t *F;
int fd;
/* First, make sure we aren't going to run out of file descriptors */
if(unlikely(number_fd >= rb_maxconnections))
if(rb_unlikely(number_fd >= rb_maxconnections))
{
errno = ENFILE;
return NULL;
@ -692,7 +694,7 @@ rb_socket(int family, int sock_type, int proto, const char *note)
*/
fd = socket(family, sock_type, proto);
rb_fd_hack(&fd);
if(unlikely(fd < 0))
if(rb_unlikely(fd < 0))
return NULL; /* errno will be passed through, yay.. */
#if defined(RB_IPV6) && defined(IPV6_V6ONLY)
@ -715,10 +717,13 @@ rb_socket(int family, int sock_type, int proto, const char *note)
F = rb_open(fd, RB_FD_SOCKET, note);
if(F == NULL)
{
rb_lib_log("rb_socket: rb_open returns NULL on FD %d: %s, closing fd", fd, strerror(errno));
close(fd);
return NULL;
}
/* Set the socket non-blocking, and other wonderful bits */
if(unlikely(!rb_set_nb(F)))
if(rb_unlikely(!rb_set_nb(F)))
{
rb_lib_log("rb_open: Couldn't set FD %d non blocking: %s", fd, strerror(errno));
rb_close(F);
@ -747,7 +752,7 @@ mangle_mapped_sockaddr(struct sockaddr *in)
memset(&in4, 0, sizeof(struct sockaddr_in));
in4.sin_family = AF_INET;
in4.sin_port = in6->sin6_port;
in4.sin_addr.s_addr = ((rb_uint32_t *) & in6->sin6_addr)[3];
in4.sin_addr.s_addr = ((uint32_t *) & in6->sin6_addr)[3];
memcpy(in, &in4, sizeof(struct sockaddr_in));
}
return;
@ -796,16 +801,24 @@ rb_fdlist_init(int closeall, int maxfds, size_t heapsize)
/* Called to open a given filedescriptor */
rb_fde_t *
rb_open(int fd, rb_uint8_t type, const char *desc)
rb_open(int fd, uint8_t type, const char *desc)
{
rb_fde_t *F = add_fd(fd);
rb_fde_t *F;
lrb_assert(fd >= 0);
if(unlikely(IsFDOpen(F)))
F = add_fd(fd);
lrb_assert(!IsFDOpen(F));
if(rb_unlikely(IsFDOpen(F)))
{
const char *fdesc;
if(F != NULL && F->desc != NULL)
fdesc = F->desc;
else
fdesc = "NULL";
rb_lib_log("Trying to rb_open an already open FD: %d desc: %d", fd, fdesc);
return NULL;
}
lrb_assert(!IsFDOpen(F));
F->fd = fd;
F->type = type;
SetFDOpen(F);
@ -831,7 +844,7 @@ rb_close(rb_fde_t *F)
lrb_assert(IsFDOpen(F));
lrb_assert(!(type & RB_FD_FILE));
if(unlikely(type & RB_FD_FILE))
if(rb_unlikely(type & RB_FD_FILE))
{
lrb_assert(F->read_handler == NULL);
lrb_assert(F->write_handler == NULL);
@ -913,14 +926,14 @@ rb_note(rb_fde_t *F, const char *string)
}
void
rb_set_type(rb_fde_t *F, rb_uint8_t type)
rb_set_type(rb_fde_t *F, uint8_t type)
{
/* if the caller is calling this, lets assume they have a clue */
F->type = type;
return;
}
rb_uint8_t
uint8_t
rb_get_type(rb_fde_t *F)
{
return F->type;
@ -2002,7 +2015,7 @@ rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds
struct cmsghdr *cmsg;
struct iovec iov[1];
struct stat st;
rb_uint8_t stype = RB_FD_UNKNOWN;
uint8_t stype = RB_FD_UNKNOWN;
const char *desc;
int fd, len, x, rfds;

View file

@ -110,7 +110,7 @@ rb_crypt(const char *key, const char *salt)
*
* ARCHITECTURE ASSUMPTIONS:
* It is assumed that the 8-byte arrays passed by reference can be
* addressed as arrays of rb_uint32_t's (ie. the CPU is not picky about
* addressed as arrays of uint32_t's (ie. the CPU is not picky about
* alignment).
*/
@ -121,15 +121,15 @@ static u_char inv_key_perm[64];
static u_char inv_comp_perm[56];
static u_char u_sbox[8][64];
static u_char un_pbox[32];
static rb_uint32_t en_keysl[16], en_keysr[16];
static rb_uint32_t de_keysl[16], de_keysr[16];
static rb_uint32_t ip_maskl[8][256], ip_maskr[8][256];
static rb_uint32_t fp_maskl[8][256], fp_maskr[8][256];
static rb_uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
static rb_uint32_t comp_maskl[8][128], comp_maskr[8][128];
static rb_uint32_t saltbits;
static rb_uint32_t old_salt;
static rb_uint32_t old_rawkey0, old_rawkey1;
static uint32_t en_keysl[16], en_keysr[16];
static uint32_t de_keysl[16], de_keysr[16];
static uint32_t ip_maskl[8][256], ip_maskr[8][256];
static uint32_t fp_maskl[8][256], fp_maskr[8][256];
static uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
static uint32_t comp_maskl[8][128], comp_maskr[8][128];
static uint32_t saltbits;
static uint32_t old_salt;
static uint32_t old_rawkey0, old_rawkey1;
/* Static stuff that stays resident and doesn't change after
@ -137,7 +137,7 @@ static rb_uint32_t old_rawkey0, old_rawkey1;
* reentrant. */
static u_char init_perm[64], final_perm[64];
static u_char m_sbox[4][4096];
static rb_uint32_t psbox[4][256];
static uint32_t psbox[4][256];
@ -230,7 +230,7 @@ static const u_char pbox[32] = {
2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
};
static const rb_uint32_t bits32[32] =
static const uint32_t bits32[32] =
{
0x80000000, 0x40000000, 0x20000000, 0x10000000,
0x08000000, 0x04000000, 0x02000000, 0x01000000,
@ -243,7 +243,7 @@ static const rb_uint32_t bits32[32] =
};
static const u_char bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
static const rb_uint32_t *bits28, *bits24;
static const uint32_t *bits28, *bits24;
static int
@ -268,7 +268,7 @@ static void
des_init(void)
{
int i, j, b, k, inbit, obit;
rb_uint32_t *p, *il, *ir, *fl, *fr;
uint32_t *p, *il, *ir, *fl, *fr;
static int des_initialised = 0;
if (des_initialised==1)
@ -401,7 +401,7 @@ des_init(void)
static void
setup_salt(long salt)
{
rb_uint32_t obit, saltbit;
uint32_t obit, saltbit;
int i;
if (salt == (long)old_salt)
@ -423,13 +423,13 @@ setup_salt(long salt)
static int
des_setkey(const char *key)
{
rb_uint32_t k0, k1, rawkey0, rawkey1;
uint32_t k0, k1, rawkey0, rawkey1;
int shifts, round;
des_init();
rawkey0 = ntohl(*(const rb_uint32_t *) key);
rawkey1 = ntohl(*(const rb_uint32_t *) (key + 4));
rawkey0 = ntohl(*(const uint32_t *) key);
rawkey1 = ntohl(*(const uint32_t *) (key + 4));
if ((rawkey0 | rawkey1)
&& rawkey0 == old_rawkey0
@ -469,7 +469,7 @@ des_setkey(const char *key)
*/
shifts = 0;
for (round = 0; round < 16; round++) {
rb_uint32_t t0, t1;
uint32_t t0, t1;
shifts += key_shifts[round];
@ -501,13 +501,13 @@ des_setkey(const char *key)
static int
do_des( rb_uint32_t l_in, rb_uint32_t r_in, rb_uint32_t *l_out, rb_uint32_t *r_out, int count)
do_des( uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint32_t *r_out, int count)
{
/*
* l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
*/
rb_uint32_t l, r, *kl, *kr, *kl1, *kr1;
rb_uint32_t f, r48l, r48r;
uint32_t l, r, *kl, *kr, *kl1, *kr1;
uint32_t f, r48l, r48r;
int round;
if (count == 0) {
@ -619,12 +619,12 @@ do_des( rb_uint32_t l_in, rb_uint32_t r_in, rb_uint32_t *l_out, rb_uint32_t *r_o
#if 0
static int
des_cipher(const char *in, char *out, rb_uint32_t salt, int count)
des_cipher(const char *in, char *out, uint32_t salt, int count)
{
rb_uint32_t l_out, r_out, rawl, rawr;
uint32_t l_out, r_out, rawl, rawr;
int retval;
union {
rb_uint32_t *ui32;
uint32_t *ui32;
const char *c;
} trans;
@ -650,7 +650,7 @@ void
setkey(const char *key)
{
int i, j;
rb_uint32_t packed_keys[2];
uint32_t packed_keys[2];
u_char *p;
p = (u_char *) packed_keys;
@ -668,7 +668,7 @@ setkey(const char *key)
void
encrypt(char *block, int flag)
{
rb_uint32_t io[2];
uint32_t io[2];
u_char *p;
int i, j;
@ -692,7 +692,7 @@ encrypt(char *block, int flag)
static char *
__des_crypt(const char *key, const char *setting)
{
rb_uint32_t count, salt, l, r0, r1, keybuf[2];
uint32_t count, salt, l, r0, r1, keybuf[2];
u_char *p, *q;
static char output[21];
@ -885,8 +885,8 @@ __des_crypt(const char *key, const char *setting)
/* MD5 context. */
struct MD5Context {
rb_uint32_t state[4]; /* state (ABCD) */
rb_uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
uint32_t state[4]; /* state (ABCD) */
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
};
@ -894,7 +894,7 @@ static void __md5_Init (struct MD5Context *);
static void __md5_Update (struct MD5Context *, const char *, unsigned int);
static void __md5_Pad (struct MD5Context *);
static void __md5_Final (char [16], struct MD5Context *);
static void __md5_Transform (rb_uint32_t [4], const unsigned char [64]);
static void __md5_Transform (uint32_t [4], const unsigned char [64]);
static const char __md5__magic[] = "$1$"; /* This string is magic for this algorithm. Having
@ -910,12 +910,12 @@ static const unsigned char __md5_itoa64[] = /* 0 ... 63 => ascii - 64 */
#else /* i386 */
/*
* __md5_Encodes input (rb_uint32_t) into output (unsigned char). Assumes len is
* __md5_Encodes input (uint32_t) into output (unsigned char). Assumes len is
* a multiple of 4.
*/
static void
__md5_Encode (unsigned char *output, rb_uint32_t *input, unsigned int len)
__md5_Encode (unsigned char *output, uint32_t *input, unsigned int len)
{
unsigned int i, j;
@ -928,18 +928,18 @@ __md5_Encode (unsigned char *output, rb_uint32_t *input, unsigned int len)
}
/*
* __md5_Decodes input (unsigned char) into output (rb_uint32_t). Assumes len is
* __md5_Decodes input (unsigned char) into output (uint32_t). Assumes len is
* a multiple of 4.
*/
static void
__md5_Decode (rb_uint32_t *output, const unsigned char *input, unsigned int len)
__md5_Decode (uint32_t *output, const unsigned char *input, unsigned int len)
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((rb_uint32_t)input[j]) | (((rb_uint32_t)input[j+1]) << 8) |
(((rb_uint32_t)input[j+2]) << 16) | (((rb_uint32_t)input[j+3]) << 24);
output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) |
(((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24);
}
#endif /* i386 */
@ -957,22 +957,22 @@ __md5_Decode (rb_uint32_t *output, const unsigned char *input, unsigned int len)
* Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \
(a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \
(a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \
(a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (rb_uint32_t)(ac); \
(a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
@ -1004,10 +1004,10 @@ static void __md5_Update ( struct MD5Context *context, const char *xinput, unsig
lindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((rb_uint32_t)inputLen << 3))
< ((rb_uint32_t)inputLen << 3))
if ((context->count[0] += ((uint32_t)inputLen << 3))
< ((uint32_t)inputLen << 3))
context->count[1]++;
context->count[1] += ((rb_uint32_t)inputLen >> 29);
context->count[1] += ((uint32_t)inputLen >> 29);
partLen = 64 - lindex;
@ -1077,13 +1077,13 @@ static void __md5_Final ( char xdigest[16], struct MD5Context *context)
static void
__md5_Transform (state, block)
rb_uint32_t state[4];
uint32_t state[4];
const unsigned char block[64];
{
rb_uint32_t a, b, c, d, x[16];
uint32_t a, b, c, d, x[16];
#if MD5_SIZE_OVER_SPEED > 1
rb_uint32_t temp;
uint32_t temp;
const char *ps;
static const char S[] = {
@ -1095,11 +1095,11 @@ __md5_Transform (state, block)
#endif /* MD5_SIZE_OVER_SPEED > 1 */
#if MD5_SIZE_OVER_SPEED > 0
const rb_uint32_t *pc;
const uint32_t *pc;
const char *pp;
int i;
static const rb_uint32_t C[] = {
static const uint32_t C[] = {
/* round 1 */
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,

10
libratbox/src/descrip.mms Normal file
View file

@ -0,0 +1,10 @@
CFLAGS= /INCLUDE=([-.INCLUDE])/ERROR_LIMIT=5/DEFINE=(_XOPEN_SOURCE_EXTENDED)/NOANSI_ALIAS
OBJECTS= balloc.obj, commio.obj, crypt.obj, event.obj, -
helper.obj, linebuf.obj, nossl.obj, patricia.obj, -
poll.obj, ratbox_lib.obj, rawbuf.obj, rb_memory.obj, -
snprintf.obj, tools.obj, unix.obj
DEFAULT : RATBOX.OLB($(OBJECTS))
CLEAN :
- DELETE *.OBJ;*, *.OLB;*

View file

@ -23,7 +23,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: epoll.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: epoll.c 25675 2008-07-06 04:13:05Z androsyn $
*/
#define _GNU_SOURCE 1
@ -282,23 +282,23 @@ rb_epoll_supports_event(void)
/* bleh..work around a glibc header bug on 32bit systems */
struct our_signalfd_siginfo {
rb_uint32_t signo;
rb_int32_t err;
rb_int32_t code;
rb_uint32_t pid;
rb_uint32_t uid;
rb_int32_t fd;
rb_uint32_t tid;
rb_uint32_t band;
rb_uint32_t overrun;
rb_uint32_t trapno;
rb_int32_t status;
rb_int32_t svint;
rb_uint64_t svptr;
rb_uint64_t utime;
rb_uint64_t stime;
rb_uint64_t addr;
rb_uint8_t pad[48];
uint32_t signo;
int32_t err;
int32_t code;
uint32_t pid;
uint32_t uid;
int32_t fd;
uint32_t tid;
uint32_t band;
uint32_t overrun;
uint32_t trapno;
int32_t status;
int32_t svint;
uint64_t svptr;
uint64_t utime;
uint64_t stime;
uint64_t addr;
uint8_t pad[48];
};

View file

@ -143,3 +143,6 @@ rb_gettimeofday
rb_sleep
rb_spawn_process
rb_supports_ssl
rb_ssl_handshake_count
rb_ssl_clear_handshake_count
rb_get_pseudo_random

View file

@ -4,7 +4,6 @@
*
* Copyright (C) 2007-2008 ircd-ratbox development team
* Copyright (C) 2007-2008 Aaron Sethman <androsyn@ratbox.org>
* Copyright (C) 2008 William Pitcock <nenolod@nenolod.net>
*
* 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
@ -21,29 +20,50 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: commio.c 24808 2008-01-02 08:17:05Z androsyn $
* $Id: gnutls.c 25793 2008-07-29 14:47:48Z androsyn $
*/
#include <libratbox_config.h>
#include <ratbox_lib.h>
#ifdef HAVE_GNUTLS
#include <commio-int.h>
#include <commio-ssl.h>
#include <gnutls/gnutls.h>
#ifdef HAVE_GNUTLS
static gnutls_certificate_credentials_t x509_cred;
static gnutls_dh_params_t dh_params;
#include <gnutls/gnutls.h>
#include <gcrypt.h>
static gnutls_certificate_credentials x509;
static gnutls_dh_params dh_params;
#define SSL_P(x) *((gnutls_session_t *)F->ssl)
void
rb_ssl_shutdown(rb_fde_t * F)
{
int i;
if(F == NULL || F->ssl == NULL)
return;
for (i = 0; i < 4; i++)
{
if(gnutls_bye(SSL_P(F), GNUTLS_SHUT_RDWR) == GNUTLS_E_SUCCESS)
break;
}
gnutls_deinit(SSL_P(F));
rb_free(F->ssl);
}
gnutls_bye((gnutls_session_t) F->ssl, GNUTLS_SHUT_RDWR);
gnutls_deinit((gnutls_session_t) F->ssl);
unsigned int
rb_ssl_handshake_count(rb_fde_t *F)
{
return F->handshake_count;
}
void
rb_ssl_clear_handshake_count(rb_fde_t *F)
{
F->handshake_count = 0;
}
static void
@ -53,38 +73,52 @@ rb_ssl_timeout(rb_fde_t * F, void *notused)
F->accept->callback(F, RB_ERR_TIMEOUT, NULL, 0, F->accept->data);
}
static int do_ssl_handshake(rb_fde_t *F, PF *callback)
{
int ret;
int flags;
ret = gnutls_handshake(SSL_P(F));
if(ret < 0)
{
if((ret == GNUTLS_E_INTERRUPTED && rb_ignore_errno(errno)) || ret == GNUTLS_E_AGAIN)
{
if(gnutls_record_get_direction(SSL_P(F)) == 0)
flags = RB_SELECT_READ;
else
flags = RB_SELECT_WRITE;
rb_setselect(F, flags, callback, NULL);
return 0;
}
F->ssl_errno = ret;
return -1;
}
return 1; /* handshake is finished..go about life */
}
static void
rb_ssl_tryaccept(rb_fde_t * F, void *data)
{
int ssl_err;
lrb_assert(F->accept != NULL);
int flags;
int ret;
struct acceptdata *ad;
if((ssl_err = gnutls_handshake((gnutls_session_t) F->ssl)) != 0)
{
switch (ssl_err)
{
case GNUTLS_E_INTERRUPTED:
if(rb_ignore_errno(errno))
case GNUTLS_E_AGAIN:
{
if(gnutls_record_get_direction((gnutls_session_t) F->ssl))
flags = RB_SELECT_WRITE;
else
flags = RB_SELECT_READ;
lrb_assert(F->accept != NULL);
F->ssl_errno = ssl_err;
rb_setselect(F, flags, rb_ssl_tryaccept, NULL);
return;
}
break;
default:
F->ssl_errno = ssl_err;
ret = do_ssl_handshake(F, rb_ssl_tryaccept);
switch(ret)
{
case -1:
F->accept->callback(F, RB_ERROR_SSL, NULL, 0, F->accept->data);
break;
}
return;
case 0:
/* do_ssl_handshake does the rb_setselect stuff */
return;
default:
break;
}
rb_settimeout(F, 0, NULL, NULL);
rb_setselect(F, RB_SELECT_READ | RB_SELECT_WRITE, NULL, NULL);
@ -94,91 +128,46 @@ rb_ssl_tryaccept(rb_fde_t * F, void *data)
ad->callback(F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen,
ad->data);
rb_free(ad);
}
void
rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
{
gnutls_session_t sess;
int ssl_err;
gnutls_session_t *ssl;
new_F->type |= RB_FD_SSL;
gnutls_init(&sess, GNUTLS_SERVER);
gnutls_set_default_priority(sess);
gnutls_credentials_set(sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_dh_set_prime_bits(sess, 1024);
gnutls_certificate_server_set_request(sess, GNUTLS_CERT_REQUEST);
new_F->ssl = sess;
ssl = new_F->ssl = rb_malloc(sizeof(gnutls_session_t));
new_F->accept = rb_malloc(sizeof(struct acceptdata));
new_F->accept->callback = cb;
new_F->accept->data = data;
rb_settimeout(new_F, timeout, rb_ssl_timeout, NULL);
new_F->accept->addrlen = 0;
gnutls_transport_set_ptr((gnutls_session_t) new_F->ssl, (gnutls_transport_ptr_t) rb_get_fd(new_F));
if((ssl_err = gnutls_handshake((gnutls_session_t) new_F->ssl)) != 0)
gnutls_init(ssl, GNUTLS_SERVER);
gnutls_set_default_priority(*ssl);
gnutls_credentials_set(*ssl, GNUTLS_CRD_CERTIFICATE, x509);
gnutls_dh_set_prime_bits(*ssl, 1024);
gnutls_transport_set_ptr(*ssl, (gnutls_transport_ptr_t) (long int)new_F->fd);
if(do_ssl_handshake(new_F, rb_ssl_tryaccept))
{
switch(ssl_err)
{
case GNUTLS_E_INTERRUPTED:
if(rb_ignore_errno(errno))
case GNUTLS_E_AGAIN:
{
int flags;
if(gnutls_record_get_direction((gnutls_session_t) new_F->ssl))
flags = RB_SELECT_WRITE;
else
flags = RB_SELECT_READ;
new_F->ssl_errno = ssl_err;
rb_setselect(new_F, flags, rb_ssl_tryaccept, NULL);
return;
}
break;
default:
new_F->ssl_errno = ssl_err;
new_F->accept->callback(new_F, RB_ERROR_SSL, NULL, 0, new_F->accept->data);
return;
}
}
else
{
struct acceptdata *ad;
rb_settimeout(new_F, 0, NULL, NULL);
rb_setselect(new_F, RB_SELECT_READ | RB_SELECT_WRITE, NULL, NULL);
ad = new_F->accept;
struct acceptdata *ad = new_F->accept;
new_F->accept = NULL;
ad->callback(new_F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen,
ad->data);
rb_free(ad);
ad->callback(new_F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen, ad->data);
rb_free(ad);
}
}
void
rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen)
rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
{
gnutls_session_t sess;
rb_fde_t *new_F;
int ssl_err;
new_F = rb_find_fd(new_fd);
gnutls_init(&sess, GNUTLS_SERVER);
gnutls_set_default_priority(sess);
gnutls_credentials_set(sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_dh_set_prime_bits(sess, 1024);
gnutls_certificate_server_set_request(sess, GNUTLS_CERT_REQUEST);
new_F->type |= RB_FD_SSL;
new_F->ssl = rb_malloc(sizeof(gnutls_session_t));
new_F->accept = rb_malloc(sizeof(struct acceptdata));
new_F->accept->callback = F->accept->callback;
@ -187,89 +176,53 @@ rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen)
memcpy(&new_F->accept->S, st, addrlen);
new_F->accept->addrlen = addrlen;
gnutls_transport_set_ptr((gnutls_session_t) new_F->ssl, (gnutls_transport_ptr_t) rb_get_fd(new_F));
if((ssl_err = gnutls_handshake((gnutls_session_t) new_F->ssl)) != 0)
gnutls_init((gnutls_session_t *)new_F->ssl, GNUTLS_SERVER);
gnutls_set_default_priority(SSL_P(new_F));
gnutls_credentials_set(SSL_P(new_F), GNUTLS_CRD_CERTIFICATE, x509);
gnutls_dh_set_prime_bits(SSL_P(new_F), 1024);
gnutls_transport_set_ptr(SSL_P(new_F), (gnutls_transport_ptr_t) (long int)rb_get_fd(new_F));
if(do_ssl_handshake(F, rb_ssl_tryaccept))
{
switch(ssl_err)
{
case GNUTLS_E_INTERRUPTED:
if(rb_ignore_errno(errno))
case GNUTLS_E_AGAIN:
{
int flags;
if(gnutls_record_get_direction((gnutls_session_t) new_F->ssl))
flags = RB_SELECT_WRITE;
else
flags = RB_SELECT_READ;
new_F->ssl_errno = ssl_err;
rb_setselect(new_F, flags, rb_ssl_tryaccept, NULL);
return;
}
break;
default:
new_F->ssl_errno = ssl_err;
new_F->accept->callback(new_F, RB_ERROR_SSL, NULL, 0, new_F->accept->data);
return;
}
}
else
{
struct acceptdata *ad;
rb_settimeout(new_F, 0, NULL, NULL);
rb_setselect(new_F, RB_SELECT_READ | RB_SELECT_WRITE, NULL, NULL);
ad = new_F->accept;
new_F->accept = NULL;
ad->callback(new_F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen,
ad->data);
rb_free(ad);
struct acceptdata *ad = F->accept;
F->accept = NULL;
ad->callback(F, RB_OK, (struct sockaddr *) &ad->S, ad->addrlen, ad->data);
rb_free(ad);
}
}
static ssize_t
rb_ssl_read_or_write(int r_or_w, rb_fde_t * F, void *rbuf, const void *wbuf, size_t count)
{
ssize_t ret;
unsigned long err;
gnutls_session_t ssl = F->ssl;
gnutls_session_t *ssl = F->ssl;
if(r_or_w == 0)
ret = gnutls_record_recv(ssl, rbuf, count);
ret = gnutls_record_recv(*ssl, rbuf, count);
else
ret = gnutls_record_send(ssl, wbuf, count);
ret = gnutls_record_send(*ssl, wbuf, count);
if(ret < 0)
{
switch (ret)
switch(ret)
{
case GNUTLS_E_AGAIN:
errno = EAGAIN;
if (gnutls_record_get_direction(ssl))
return RB_RW_SSL_NEED_WRITE;
else
return RB_RW_SSL_NEED_READ;
case GNUTLS_E_INTERRUPTED:
err = ret;
if(err == 0)
if(rb_ignore_errno(errno))
{
F->ssl_errno = 0;
return RB_RW_IO_ERROR;
if(gnutls_record_get_direction(*ssl) == 0)
return RB_RW_SSL_NEED_READ;
else
return RB_RW_SSL_NEED_WRITE;
break;
}
break;
default:
err = ret;
break;
F->ssl_errno = ret;
errno = EIO;
return RB_RW_IO_ERROR;
}
F->ssl_errno = err;
if(err > 0)
{
errno = EIO; /* not great but... */
return RB_RW_SSL_ERROR;
}
return RB_RW_IO_ERROR;
}
return ret;
}
@ -286,38 +239,107 @@ rb_ssl_write(rb_fde_t * F, const void *buf, size_t count)
return rb_ssl_read_or_write(1, F, NULL, buf, count);
}
static void
rb_gcry_random_seed(void *unused)
{
gcry_fast_random_poll();
}
int
rb_init_ssl(void)
{
int ret = 1, g_ret;
gnutls_global_init();
gnutls_certificate_allocate_credentials(&x509_cred);
gnutls_dh_params_init(&dh_params);
if((g_ret = gnutls_dh_params_generate2(dh_params, 1024)) < 0)
if(gnutls_certificate_allocate_credentials(&x509) != GNUTLS_E_SUCCESS)
{
rb_lib_log("rb_init_gnutls: Failed to generate GNUTLS DH params: %s", gnutls_strerror(g_ret));
ret = 0;
rb_lib_log("rb_init_ssl: Unable to allocate SSL/TLS certificate credentials");
return 0;
}
rb_event_addish("rb_gcry_random_seed", rb_gcry_random_seed, NULL, 300);
return 1;
}
gnutls_certificate_set_dh_params(x509_cred, dh_params);
static void
rb_free_datum_t(gnutls_datum_t *d)
{
rb_free(d->data);
rb_free(d);
}
return ret;
static gnutls_datum_t *
rb_load_file_into_datum_t(const char *file)
{
FILE *f;
gnutls_datum_t *datum;
struct stat fileinfo;
if((f = fopen(file, "r")) == NULL)
return NULL;
if(fstat(fileno(f), &fileinfo))
return NULL;
datum = rb_malloc(sizeof(gnutls_datum_t));
if(fileinfo.st_size > 131072) /* deal with retards */
datum->size = 131072;
else
datum->size = fileinfo.st_size;
datum->data = rb_malloc(datum->size + 1);
fread(datum->data, datum->size, 1, f);
fclose(f);
return datum;
}
int
rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
{
int ret = 0;
if((ret = gnutls_certificate_set_x509_key_file(x509_cred, cert, keyfile, GNUTLS_X509_FMT_PEM)) < 0)
int ret;
gnutls_datum_t *d_cert, *d_key;
if(cert == NULL)
{
rb_lib_log("rb_setup_ssl_server: Setting x509 keys up failed: %s", gnutls_strerror(ret));
rb_lib_log("rb_setup_ssl_server: No certificate file");
return 0;
}
if((d_cert = rb_load_file_into_datum_t(cert)) == NULL)
{
rb_lib_log("rb_setup_ssl_server: Error loading certificate: %s", strerror(errno));
return 0;
}
if((d_key = rb_load_file_into_datum_t(keyfile)) == NULL)
{
rb_lib_log("rb_setup_ssl_server: Error loading key: %s", strerror(errno));
return 0;
}
if((ret = gnutls_certificate_set_x509_key_mem(x509, d_cert, d_key, GNUTLS_X509_FMT_PEM)) != GNUTLS_E_SUCCESS)
{
rb_lib_log("rb_setup_ssl_server: Error loading certificate or key file: %s", gnutls_strerror(ret));
return 0;
}
rb_free_datum_t(d_cert);
rb_free_datum_t(d_key);
if(dhfile != NULL)
{
if(gnutls_dh_params_init(&dh_params) == GNUTLS_E_SUCCESS)
{
gnutls_datum_t *data;
int xret;
data = rb_load_file_into_datum_t(dhfile);
if(data != NULL)
{
xret = gnutls_dh_params_import_pkcs3(dh_params, data, GNUTLS_X509_FMT_PEM);
if(xret < 0)
rb_lib_log("rb_setup_ssl_server: Error parsing DH file: %s\n", gnutls_strerror(xret));
rb_free_datum_t(data);
}
gnutls_certificate_set_dh_params(x509, dh_params);
} else
rb_lib_log("rb_setup_ssl_server: Unable to setup DH parameters");
}
return 1;
}
@ -354,40 +376,30 @@ static void
rb_ssl_tryconn_cb(rb_fde_t * F, void *data)
{
struct ssl_connect *sconn = data;
int ssl_err;
int ret;
if((ssl_err = gnutls_handshake((gnutls_session_t) F->ssl)) != 0)
{
switch (ssl_err)
{
case GNUTLS_E_INTERRUPTED:
if(rb_ignore_errno(errno))
case GNUTLS_E_AGAIN:
{
F->ssl_errno = ssl_err;
rb_setselect(F, RB_SELECT_READ | RB_SELECT_WRITE,
rb_ssl_tryconn_cb, sconn);
return;
}
default:
F->ssl_errno = ssl_err;
rb_ssl_connect_realcb(F, RB_ERROR_SSL, sconn);
return;
}
}
else
{
rb_ssl_connect_realcb(F, RB_OK, sconn);
}
ret = do_ssl_handshake(F, rb_ssl_tryconn_cb);
switch(ret)
{
case -1:
rb_ssl_connect_realcb(F, RB_ERROR_SSL, sconn);
break;
case 0:
/* do_ssl_handshake does the rb_setselect stuff */
return;
default:
break;
}
rb_ssl_connect_realcb(F, RB_OK, sconn);
}
static void
rb_ssl_tryconn(rb_fde_t * F, int status, void *data)
{
gnutls_session_t sess;
struct ssl_connect *sconn = data;
int ssl_err;
if(status != RB_OK)
{
rb_ssl_connect_realcb(F, status, sconn);
@ -396,35 +408,15 @@ rb_ssl_tryconn(rb_fde_t * F, int status, void *data)
F->type |= RB_FD_SSL;
gnutls_init(&sess, GNUTLS_CLIENT);
gnutls_set_default_priority(sess);
gnutls_credentials_set(sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_dh_set_prime_bits(sess, 1024);
gnutls_transport_set_ptr(sess, (gnutls_transport_ptr_t) F->fd);
F->ssl = sess;
rb_settimeout(F, sconn->timeout, rb_ssl_tryconn_timeout_cb, sconn);
if((ssl_err = gnutls_handshake((gnutls_session_t) F->ssl)) != 0)
{
switch (ssl_err)
{
case GNUTLS_E_INTERRUPTED:
if(rb_ignore_errno(errno))
case GNUTLS_E_AGAIN:
{
F->ssl_errno = ssl_err;
rb_setselect(F, RB_SELECT_READ | RB_SELECT_WRITE,
rb_ssl_tryconn_cb, sconn);
return;
}
default:
F->ssl_errno = ssl_err;
rb_ssl_connect_realcb(F, RB_ERROR_SSL, sconn);
return;
}
}
else
F->ssl = rb_malloc(sizeof(gnutls_session_t));
gnutls_init(F->ssl, GNUTLS_CLIENT);
gnutls_set_default_priority(SSL_P(F));
gnutls_dh_set_prime_bits(SSL_P(F), 1024);
gnutls_transport_set_ptr(SSL_P(F), (gnutls_transport_ptr_t) (long int)F->fd);
if(do_ssl_handshake(F, rb_ssl_tryconn_cb))
{
rb_ssl_connect_realcb(F, RB_OK, sconn);
}
@ -443,14 +435,13 @@ rb_connect_tcp_ssl(rb_fde_t * F, struct sockaddr *dest,
sconn->callback = callback;
sconn->timeout = timeout;
rb_connect_tcp(F, dest, clocal, socklen, rb_ssl_tryconn, sconn, timeout);
}
void
rb_ssl_start_connected(rb_fde_t * F, CNCB * callback, void *data, int timeout)
{
gnutls_session_t sess;
struct ssl_connect *sconn;
int ssl_err;
if(F == NULL)
return;
@ -462,54 +453,41 @@ rb_ssl_start_connected(rb_fde_t * F, CNCB * callback, void *data, int timeout)
F->connect->callback = callback;
F->connect->data = data;
F->type |= RB_FD_SSL;
gnutls_init(&sess, GNUTLS_CLIENT);
gnutls_set_default_priority(sess);
gnutls_credentials_set(sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_dh_set_prime_bits(sess, 1024);
gnutls_transport_set_ptr(sess, (gnutls_transport_ptr_t) F->fd);
F->ssl = sess;
F->ssl = rb_malloc(sizeof(gnutls_session_t));
gnutls_init(F->ssl, GNUTLS_CLIENT);
gnutls_set_default_priority(SSL_P(F));
gnutls_dh_set_prime_bits(SSL_P(F), 1024);
gnutls_transport_set_ptr(SSL_P(F), (gnutls_transport_ptr_t) (long int)F->fd);
rb_settimeout(F, sconn->timeout, rb_ssl_tryconn_timeout_cb, sconn);
if((ssl_err = gnutls_handshake((gnutls_session_t) F->ssl)) != 0)
{
switch (ssl_err)
{
case GNUTLS_E_INTERRUPTED:
if(rb_ignore_errno(errno))
case GNUTLS_E_AGAIN:
{
F->ssl_errno = ssl_err;
rb_setselect(F, RB_SELECT_READ | RB_SELECT_WRITE,
rb_ssl_tryconn_cb, sconn);
return;
}
default:
F->ssl_errno = ssl_err;
rb_ssl_connect_realcb(F, RB_ERROR_SSL, sconn);
return;
}
}
else
if(do_ssl_handshake(F, rb_ssl_tryconn_cb))
{
rb_ssl_connect_realcb(F, RB_OK, sconn);
}
}
/* XXX: implement me */
int
rb_init_prng(const char *path, prng_seed_t seed_type)
{
return -1;
gcry_fast_random_poll();
return 1;
}
int
rb_get_random(void *buf, size_t length)
{
return -1;
gcry_randomize(buf, length, GCRY_STRONG_RANDOM);
return 1;
}
int
rb_get_pseudo_random(void *buf, size_t length)
{
gcry_randomize(buf, length, GCRY_WEAK_RANDOM);
return 1;
}
const char *
rb_get_ssl_strerror(rb_fde_t * F)

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: helper.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: helper.c 25245 2008-04-21 18:38:23Z androsyn $
*/
#include <libratbox_config.h>
#include <ratbox_lib.h>
@ -271,7 +271,7 @@ rb_helper_close(rb_helper *helper)
{
if(helper == NULL)
return;
kill(helper->pid, SIGKILL);
rb_close(helper->ifd);
rb_close(helper->ofd);
rb_free(helper);

View file

@ -22,7 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: kqueue.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: kqueue.c 25364 2008-05-14 17:55:22Z jilles $
*/
#include <libratbox_config.h>
@ -285,6 +285,8 @@ rb_select_kqueue(long delay)
}
return RB_OK;
}
#if defined(KQUEUE_SCHED_EVENT)
static int can_do_event = 0;
int
rb_kqueue_supports_event(void)
@ -343,6 +345,7 @@ rb_kqueue_init_event(void)
{
return;
}
#endif /* KQUEUE_SCHED_EVENT */
#else /* kqueue not supported */
int

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: linebuf.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: linebuf.c 25375 2008-05-16 15:19:51Z androsyn $
*/
#include <libratbox_config.h>
@ -547,13 +547,13 @@ rb_linebuf_putmsg(buf_head_t * bufhead, const char *format, va_list * va_args, c
bufline->terminated = 1;
/* Truncate the data if required */
if(unlikely(len > 510))
if(rb_unlikely(len > 510))
{
len = 510;
bufline->buf[len++] = '\r';
bufline->buf[len++] = '\n';
}
else if(unlikely(len == 0))
else if(rb_unlikely(len == 0))
{
bufline->buf[len++] = '\r';
bufline->buf[len++] = '\n';
@ -593,19 +593,19 @@ rb_linebuf_putbuf(buf_head_t *bufhead, const char *buffer)
/* Create a new line */
bufline = rb_linebuf_new_line(bufhead);
if(unlikely(buffer != NULL))
if(rb_unlikely(buffer != NULL))
len = rb_strlcpy(bufline->buf, buffer, BUF_DATA_SIZE);
bufline->terminated = 1;
/* Truncate the data if required */
if(unlikely(len > 510))
if(rb_unlikely(len > 510))
{
len = 510;
bufline->buf[len++] = '\r';
bufline->buf[len++] = '\n';
}
else if(unlikely(len == 0))
else if(rb_unlikely(len == 0))
{
bufline->buf[len++] = '\r';
bufline->buf[len++] = '\n';
@ -648,7 +648,7 @@ rb_linebuf_put(buf_head_t * bufhead, const char *format, ...)
/* Create a new line */
bufline = rb_linebuf_new_line(bufhead);
if(unlikely(format != NULL))
if(rb_unlikely(format != NULL))
{
va_start(args, format);
len = rb_vsnprintf(bufline->buf, BUF_DATA_SIZE, format, args);
@ -658,13 +658,13 @@ rb_linebuf_put(buf_head_t * bufhead, const char *format, ...)
bufline->terminated = 1;
/* Truncate the data if required */
if(unlikely(len > 510))
if(rb_unlikely(len > 510))
{
len = 510;
bufline->buf[len++] = '\r';
bufline->buf[len++] = '\n';
}
else if(unlikely(len == 0))
else if(rb_unlikely(len == 0))
{
bufline->buf[len++] = '\r';
bufline->buf[len++] = '\n';

View file

@ -26,9 +26,10 @@
#include <libratbox_config.h>
#include <ratbox_lib.h>
#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS)
#include "arc4random.h"
#include <commio-int.h>
#include <commio-ssl.h>
@ -54,17 +55,43 @@ rb_ssl_listen(rb_fde_t *F, int backlog)
return -1;
}
static void
rb_stir_arc4random(void *unused)
{
arc4random_stir();
}
int rb_init_prng(const char *path, prng_seed_t seed_type)
{
return -1;
/* xxx this ignores the parameters above */
arc4random_stir();
rb_event_addish("rb_stir_arc4random", rb_stir_arc4random, NULL, 300);
return 1;
}
int
rb_get_random(void *buf, size_t length)
{
return -1;
uint32_t rnd = 0, i;
uint8_t *xbuf = buf;
for (i = 0; i < sizeof(length); i++)
{
if(i % 4 == 0)
rnd = arc4random();
xbuf[i] = rnd;
rnd >>= 8;
}
return 1;
}
int
rb_get_pseudo_random(void *buf, size_t length)
{
return rb_get_random(buf, length);
}
const char *
rb_get_ssl_strerror(rb_fde_t *F)
{
@ -104,7 +131,7 @@ rb_ssl_shutdown(rb_fde_t * F)
}
void
rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen)
rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
{
return;
}
@ -112,14 +139,28 @@ rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen)
ssize_t
rb_ssl_read(rb_fde_t * F, void *buf, size_t count)
{
return 0;
errno = ENOSYS;
return -1;
}
ssize_t
rb_ssl_write(rb_fde_t * F, const void *buf, size_t count)
{
return 0;
errno = ENOSYS;
return -1;
}
unsigned int
rb_ssl_handshake_count(rb_fde_t *F)
{
return 0;
}
void
rb_ssl_clear_handshake_count(rb_fde_t *F)
{
return;
}
#endif /* !HAVE_OPENSSL */

View file

@ -37,6 +37,7 @@
static SSL_CTX *ssl_server_ctx;
static SSL_CTX *ssl_client_ctx;
static int libratbox_index = -1;
static unsigned long get_last_err(void)
{
@ -68,6 +69,18 @@ rb_ssl_shutdown(rb_fde_t * F)
SSL_free((SSL *) F->ssl);
}
unsigned int
rb_ssl_handshake_count(rb_fde_t *F)
{
return F->handshake_count;
}
void
rb_ssl_clear_handshake_count(rb_fde_t *F)
{
F->handshake_count = 0;
}
static void
rb_ssl_timeout(rb_fde_t * F, void *notused)
{
@ -76,6 +89,24 @@ rb_ssl_timeout(rb_fde_t * F, void *notused)
}
static void rb_ssl_info_callback(SSL *ssl, int where, int ret)
{
if(where & SSL_CB_HANDSHAKE_START)
{
rb_fde_t *F = SSL_get_ex_data(ssl, libratbox_index);
if(F == NULL)
return;
F->handshake_count++;
}
}
static void
rb_setup_ssl_cb(rb_fde_t *F)
{
SSL_set_ex_data(F->ssl, libratbox_index, (char *)F);
SSL_set_info_callback((SSL *)F->ssl, (void *)rb_ssl_info_callback);
}
static void
rb_ssl_tryaccept(rb_fde_t * F, void *data)
{
@ -121,21 +152,11 @@ rb_ssl_tryaccept(rb_fde_t * F, void *data)
}
void
rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
static void
rb_ssl_accept_common(rb_fde_t *new_F)
{
int ssl_err;
new_F->type |= RB_FD_SSL;
new_F->ssl = SSL_new(ssl_server_ctx);
new_F->accept = rb_malloc(sizeof(struct acceptdata));
new_F->accept->callback = cb;
new_F->accept->data = data;
rb_settimeout(new_F, timeout, rb_ssl_timeout, NULL);
new_F->accept->addrlen = 0;
SSL_set_fd((SSL *) new_F->ssl, rb_get_fd(new_F));
if((ssl_err = SSL_accept((SSL *) new_F->ssl)) <= 0)
{
switch (ssl_err = SSL_get_error((SSL *) new_F->ssl, ssl_err))
@ -162,16 +183,29 @@ rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
}
}
void
rb_ssl_start_accepted(rb_fde_t * new_F, ACCB * cb, void *data, int timeout)
{
new_F->type |= RB_FD_SSL;
new_F->ssl = SSL_new(ssl_server_ctx);
new_F->accept = rb_malloc(sizeof(struct acceptdata));
new_F->accept->callback = cb;
new_F->accept->data = data;
rb_settimeout(new_F, timeout, rb_ssl_timeout, NULL);
new_F->accept->addrlen = 0;
SSL_set_fd((SSL *) new_F->ssl, rb_get_fd(new_F));
rb_setup_ssl_cb(new_F);
rb_ssl_accept_common(new_F);
}
void
rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen)
rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
{
rb_fde_t *new_F;
int ssl_err;
new_F = rb_find_fd(new_fd);
new_F->type |= RB_FD_SSL;
new_F->ssl = SSL_new(ssl_server_ctx);
new_F->accept = rb_malloc(sizeof(struct acceptdata));
@ -182,31 +216,9 @@ rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen)
memcpy(&new_F->accept->S, st, addrlen);
new_F->accept->addrlen = addrlen;
SSL_set_fd((SSL *) new_F->ssl, new_fd);
if((ssl_err = SSL_accept((SSL *) new_F->ssl)) <= 0)
{
switch (ssl_err = SSL_get_error((SSL *) new_F->ssl, ssl_err))
{
case SSL_ERROR_SYSCALL:
if(rb_ignore_errno(errno))
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
{
F->ssl_errno = get_last_err();
rb_setselect(new_F, RB_SELECT_READ | RB_SELECT_WRITE,
rb_ssl_tryaccept, NULL);
return;
}
default:
F->ssl_errno = get_last_err();
F->accept->callback(F, RB_ERROR_SSL, NULL, 0, F->accept->data);
return;
}
}
else
{
rb_ssl_tryaccept(new_F, NULL);
}
SSL_set_fd((SSL *) new_F->ssl, rb_get_fd(new_F));
rb_setup_ssl_cb(new_F);
rb_ssl_accept_common(new_F);
}
static ssize_t
@ -272,8 +284,10 @@ int
rb_init_ssl(void)
{
int ret = 1;
char libratbox_data[] = "libratbox data";
SSL_load_error_strings();
SSL_library_init();
libratbox_index = SSL_get_ex_new_index(0, libratbox_data, NULL, NULL, NULL);
ssl_server_ctx = SSL_CTX_new(SSLv23_server_method());
if(ssl_server_ctx == NULL)
{
@ -430,7 +444,7 @@ rb_ssl_tryconn(rb_fde_t * F, int status, void *data)
F->type |= RB_FD_SSL;
F->ssl = SSL_new(ssl_client_ctx);
SSL_set_fd((SSL *) F->ssl, F->fd);
rb_setup_ssl_cb(F);
rb_settimeout(F, sconn->timeout, rb_ssl_tryconn_timeout_cb, sconn);
if((ssl_err = SSL_connect((SSL *) F->ssl)) <= 0)
{
@ -493,6 +507,7 @@ rb_ssl_start_connected(rb_fde_t * F, CNCB * callback, void *data, int timeout)
F->ssl = SSL_new(ssl_client_ctx);
SSL_set_fd((SSL *) F->ssl, F->fd);
rb_setup_ssl_cb(F);
rb_settimeout(F, sconn->timeout, rb_ssl_tryconn_timeout_cb, sconn);
if((ssl_err = SSL_connect((SSL *) F->ssl)) <= 0)
{
@ -558,19 +573,25 @@ rb_init_prng(const char *path, prng_seed_t seed_type)
int
rb_get_random(void *buf, size_t length)
{
if(RAND_status())
int ret;
if((ret = RAND_bytes(buf, length)) == 0)
{
if(RAND_bytes(buf, length) > 0)
return 1;
/* remove the error from the queue */
ERR_get_error();
}
else
{
if(RAND_pseudo_bytes(buf, length) >= 0)
return 1;
}
return 0;
return ret;
}
int
rb_get_pseudo_random(void *buf, size_t length)
{
int ret;
ret = RAND_pseudo_bytes(buf, length);
if(ret < 0)
return 0;
return 1;
}
const char *
rb_get_ssl_strerror(rb_fde_t * F)

View file

@ -22,7 +22,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: poll.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: poll.c 25375 2008-05-16 15:19:51Z androsyn $
*/
#include <libratbox_config.h>
#include <ratbox_lib.h>
@ -81,7 +81,7 @@ rb_init_netio_poll(void)
static void
resize_pollarray(int fd)
{
if(unlikely(fd >= pollfd_list.allocated))
if(rb_unlikely(fd >= pollfd_list.allocated))
{
int x, old_value = pollfd_list.allocated;
pollfd_list.allocated += 1024;

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: ratbox_lib.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: ratbox_lib.c 25375 2008-05-16 15:19:51Z androsyn $
*/
#include <libratbox_config.h>
@ -69,7 +69,7 @@ rb_ctime(const time_t t, char *buf, size_t len)
#else
tp = gmtime(&t);
#endif
if(unlikely(tp == NULL))
if(rb_unlikely(tp == NULL))
{
strcpy(buf, "");
return(buf);
@ -104,7 +104,7 @@ rb_date(const time_t t, char *buf, size_t len)
gm = gmtime(&t);
#endif
if(unlikely(gm == NULL))
if(rb_unlikely(gm == NULL))
{
rb_strlcpy(buf, "", len);
return(buf);
@ -169,7 +169,7 @@ rb_set_time(void)
{
struct timeval newtime;
if(unlikely(rb_gettimeofday(&newtime, NULL) == -1))
if(rb_unlikely(rb_gettimeofday(&newtime, NULL) == -1))
{
rb_lib_log("Clock Failure (%s)", strerror(errno));
rb_lib_restart("Clock Failure");
@ -184,7 +184,7 @@ rb_set_time(void)
const char *
rb_lib_version(void)
{
static const char *id = "$Rev: 25038 $";
static const char *id = "$Rev: 25375 $";
return id;
}

View file

@ -30,9 +30,9 @@
struct _rawbuf
{
rb_dlink_node node;
rb_uint8_t data[RAWBUF_SIZE];
uint8_t data[RAWBUF_SIZE];
int len;
rb_uint8_t flushing;
uint8_t flushing;
};
struct _rawbuf_head
@ -207,7 +207,7 @@ rb_rawbuf_append(rawbuf_head_t * rb, void *data, int len)
len -= clen;
if(len == 0)
return;
data += clen;
data = (char *)data + clen;
}
@ -223,7 +223,7 @@ rb_rawbuf_append(rawbuf_head_t * rb, void *data, int len)
memcpy(buf->data, data, clen);
buf->len += clen;
len -= clen;
data += clen;
data = (char *)data + clen;
rb->len += clen;
}
}

View file

@ -23,7 +23,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: sigio.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: sigio.c 25375 2008-05-16 15:19:51Z androsyn $
*/
#ifndef _GNU_SOURCE
@ -103,7 +103,7 @@ rb_init_netio_sigio(void)
static inline void
resize_pollarray(int fd)
{
if(unlikely(fd >= pollfd_list.allocated))
if(rb_unlikely(fd >= pollfd_list.allocated))
{
int x, old_value = pollfd_list.allocated;
pollfd_list.allocated += 1024;

View file

@ -4,7 +4,7 @@
* The original headers are below..
* Note that this implementation does not process floating point numbers so
* you will likely need to fall back to using sprintf yourself to do those...
* $Id: snprintf.c 25038 2008-01-23 16:03:08Z androsyn $
* $Id: snprintf.c 25375 2008-05-16 15:19:51Z androsyn $
*/
/*
@ -295,7 +295,7 @@ int rb_vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
/* Reject out-of-range values early. Large positive sizes are
used for unknown buffer sizes. */
if (unlikely((int) size < 0)) {
if (rb_unlikely((int) size < 0)) {
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -203,7 +203,7 @@ depend:
@$(RM) -f .depend
${MKDEP} ${CPPFLAGS} ${ALL_SRCS} > .depend
@$(SED) -e '${SEDOBJ}' < .depend > .depend.tmp-1
@$(SED) -e 's/^m_\(die\|kick\|kill\|message\|mode\|nick\|part\|quit\|server\|sjoin\|squit\)/core\/m_\1/' .depend.tmp-1 > .depend.tmp
@$(SED) -e 's#^m_die\.#core/&#' -e 's#^m_error\.#core/&#' -e 's#^m_join\.#core/&#' -e 's#^m_kick\.#core/&#' -e 's#^m_kill\.#core/&#' -e 's#^m_message\.#core/&#' -e 's#^m_mode\.#core/&#' -e 's#^m_nick\.#core/&#' -e 's#^m_part\.#core/&#' -e 's#^m_quit\.#core/&#' -e 's#^m_server\.#core/&#' -e 's#^m_squit\.#core/&#' .depend.tmp-1 > .depend.tmp
@$(MV) -f .depend.tmp .depend
@$(RM) -f .depend.tmp-1

View file

@ -106,11 +106,11 @@ m_error(struct Client *client_p, struct Client *source_p, int parc, const char *
if (hideit < 2)
sendto_realops_snomask(SNO_GENERAL, hideit ? L_ADMIN : (is_remote_connect(client_p) ? L_NETWIDE : L_ALL),
"ERROR :from %s -- %s",
get_server_name(client_p, HIDE_IP), para);
client_p->name, para);
if (hideit > 0)
sendto_realops_snomask(SNO_GENERAL, (hideit == 1 ? L_OPER : L_ALL) | (is_remote_connect(client_p) ? L_NETWIDE : L_ALL),
"ERROR :from %s -- <hidden>",
get_server_name(client_p, HIDE_IP));
client_p->name);
}
exit_client(client_p, source_p, source_p, "ERROR");
@ -137,12 +137,12 @@ ms_error(struct Client *client_p, struct Client *source_p, int parc, const char
if(client_p == source_p)
{
sendto_realops_snomask(SNO_GENERAL, hideit ? L_ADMIN : L_ALL, "ERROR :from %s -- %s",
get_server_name(client_p, HIDE_IP), para);
client_p->name, para);
}
else
{
sendto_realops_snomask(SNO_GENERAL, hideit ? L_ADMIN : L_ALL, "ERROR :from %s via %s -- %s",
source_p->name, get_server_name(client_p, HIDE_IP), para);
source_p->name, client_p->name, para);
}
return 0;

View file

@ -40,6 +40,7 @@
#include "parse.h"
#include "modules.h"
#include "packet.h"
#include "chmode.h"
static int m_join(struct Client *, struct Client *, int, const char **);
static int ms_join(struct Client *, struct Client *, int, const char **);
@ -136,6 +137,7 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
struct ConfItem *aconf;
char *name;
char *key = NULL;
const char *modes;
int i, flags = 0;
char *p = NULL, *p2 = NULL;
char *chanlist;
@ -302,11 +304,18 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
if ((i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_INVITEONLYCHAN && i != ERR_CHANNELISFULL) ||
(!ConfigChannel.use_forward || (chptr = check_forward(source_p, chptr, key)) == NULL))
{
sendto_one(source_p, form_str(i), me.name, source_p->name, name);
/* might be wrong, but is there any other better location for such?
* see extensions/chm_operonly.c for other comments on this
* -- dwr
*/
if(i != ERR_CUSTOM)
sendto_one(source_p, form_str(i), me.name, source_p->name, name);
if(successful_join_count > 0)
successful_join_count--;
continue;
}
sendto_one_numeric(source_p, ERR_LINKCHANNEL, form_str(ERR_LINKCHANNEL), name, chptr->chname);
}
@ -333,17 +342,15 @@ m_join(struct Client *client_p, struct Client *source_p, int parc, const char *p
chptr->channelts = rb_current_time();
chptr->mode.mode |= MODE_TOPICLIMIT;
chptr->mode.mode |= MODE_NOPRIVMSGS;
modes = channel_modes(chptr, &me);
sendto_channel_local(ONLY_CHANOPS, chptr, ":%s MODE %s +nt",
me.name, chptr->chname);
sendto_channel_local(ONLY_CHANOPS, chptr, ":%s MODE %s %s",
me.name, chptr->chname, modes);
if(*chptr->chname == '#')
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s +nt :@%s",
me.id, (long) chptr->channelts,
chptr->chname, source_p->id);
}
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s %s :@%s",
me.id, (long) chptr->channelts,
chptr->chname, modes, source_p->id);
}
else
{

View file

@ -90,10 +90,10 @@ static int build_target_list(int p_or_n, const char *command,
struct Client *client_p,
struct Client *source_p, const char *nicks_channels, const char *text);
static struct Channel *find_allowing_channel(struct Client *source_p, struct Client *target_p);
static int flood_attack_client(int p_or_n, struct Client *source_p, struct Client *target_p);
static int flood_attack_channel(int p_or_n, struct Client *source_p,
struct Channel *chptr, char *chname);
static struct Client *find_userhost(const char *, const char *, int *);
#define ENTITY_NONE 0
#define ENTITY_CHANNEL 1
@ -649,6 +649,8 @@ static void
msg_client(int p_or_n, const char *command,
struct Client *source_p, struct Client *target_p, const char *text)
{
int do_floodcount = 0;
if(MyClient(source_p))
{
/* reset idle time for message only if its not to self
@ -656,12 +658,16 @@ msg_client(int p_or_n, const char *command,
if(p_or_n != NOTICE)
source_p->localClient->last = rb_current_time();
/* auto cprivmsg/cnotice */
do_floodcount = !IsOper(source_p) &&
!find_allowing_channel(source_p, target_p);
/* target change stuff, dont limit ctcp replies as that
* would allow people to start filling up random users
* targets just by ctcping them
*/
if((p_or_n != NOTICE || *text != '\001') &&
ConfigFileEntry.target_change && !IsOper(source_p))
ConfigFileEntry.target_change && do_floodcount)
{
if(!add_target(source_p, target_p))
{
@ -704,7 +710,8 @@ msg_client(int p_or_n, const char *command,
form_str(ERR_NONONREG),
target_p->name);
/* Only so opers can watch for floods */
(void) flood_attack_client(p_or_n, source_p, target_p);
if (do_floodcount)
(void) flood_attack_client(p_or_n, source_p, target_p);
}
else
{
@ -731,7 +738,8 @@ msg_client(int p_or_n, const char *command,
target_p->localClient->last_caller_id_time = rb_current_time();
}
/* Only so opers can watch for floods */
(void) flood_attack_client(p_or_n, source_p, target_p);
if (do_floodcount)
(void) flood_attack_client(p_or_n, source_p, target_p);
}
}
else
@ -741,18 +749,33 @@ msg_client(int p_or_n, const char *command,
* we dont give warnings.. we then check if theyre opered
* (to avoid flood warnings), lastly if theyre our client
* and flooding -- fl */
if(!MyClient(source_p) || IsOper(source_p) ||
if(!do_floodcount ||
!flood_attack_client(p_or_n, source_p, target_p))
sendto_anywhere(target_p, source_p, command, ":%s", text);
}
}
else if(!MyClient(source_p) || IsOper(source_p) ||
else if(!do_floodcount ||
!flood_attack_client(p_or_n, source_p, target_p))
sendto_anywhere(target_p, source_p, command, ":%s", text);
return;
}
static struct Channel *
find_allowing_channel(struct Client *source_p, struct Client *target_p)
{
rb_dlink_node *ptr;
struct membership *msptr;
RB_DLINK_FOREACH(ptr, source_p->user->channel.head)
{
msptr = ptr->data;
if (is_chanop_voiced(msptr) && IsMember(target_p, msptr->chptr))
return msptr->chptr;
}
return NULL;
}
/*
* flood_attack_client
* inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
@ -767,33 +790,38 @@ flood_attack_client(int p_or_n, struct Client *source_p, struct Client *target_p
{
int delta;
if(GlobalSetOptions.floodcount && MyConnect(target_p) && IsClient(source_p))
/* Services could get many messages legitimately and
* can be messaged without rate limiting via aliases
* and msg user@server.
* -- jilles
*/
if(GlobalSetOptions.floodcount && IsClient(source_p) && source_p != target_p && !IsService(target_p))
{
if((target_p->localClient->first_received_message_time + 1) < rb_current_time())
if((target_p->first_received_message_time + 1) < rb_current_time())
{
delta = rb_current_time() - target_p->localClient->first_received_message_time;
target_p->localClient->received_number_of_privmsgs -= delta;
target_p->localClient->first_received_message_time = rb_current_time();
if(target_p->localClient->received_number_of_privmsgs <= 0)
delta = rb_current_time() - target_p->first_received_message_time;
target_p->received_number_of_privmsgs -= delta;
target_p->first_received_message_time = rb_current_time();
if(target_p->received_number_of_privmsgs <= 0)
{
target_p->localClient->received_number_of_privmsgs = 0;
target_p->localClient->flood_noticed = 0;
target_p->received_number_of_privmsgs = 0;
target_p->flood_noticed = 0;
}
}
if((target_p->localClient->received_number_of_privmsgs >=
GlobalSetOptions.floodcount) || target_p->localClient->flood_noticed)
if((target_p->received_number_of_privmsgs >=
GlobalSetOptions.floodcount) || target_p->flood_noticed)
{
if(target_p->localClient->flood_noticed == 0)
if(target_p->flood_noticed == 0)
{
sendto_realops_snomask(SNO_BOTS, L_NETWIDE,
"Possible Flooder %s[%s@%s] on %s target: %s",
source_p->name, source_p->username,
source_p->orighost,
source_p->servptr->name, target_p->name);
target_p->localClient->flood_noticed = 1;
target_p->flood_noticed = 1;
/* add a bit of penalty */
target_p->localClient->received_number_of_privmsgs += 2;
target_p->received_number_of_privmsgs += 2;
}
if(MyClient(source_p) && (p_or_n != NOTICE))
sendto_one(source_p,
@ -802,7 +830,7 @@ flood_attack_client(int p_or_n, struct Client *source_p, struct Client *target_p
return 1;
}
else
target_p->localClient->received_number_of_privmsgs++;
target_p->received_number_of_privmsgs++;
}
return 0;
@ -886,7 +914,6 @@ handle_special(int p_or_n, const char *command, struct Client *client_p,
struct Client *source_p, const char *nick, const char *text)
{
struct Client *target_p;
char *host;
char *server;
char *s;
int count;
@ -924,39 +951,23 @@ handle_special(int p_or_n, const char *command, struct Client *client_p,
return;
}
*server = '\0';
if((host = strchr(nick, '%')) != NULL)
*host++ = '\0';
/* Check if someones msg'ing opers@our.server */
if(strcmp(nick, "opers") == 0)
if(strncmp(nick, "opers@", 6) == 0)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL, "To opers: From: %s: %s",
source_p->name, text);
return;
}
/*
* Look for users which match the destination host
* (no host == wildcard) and if one and one only is
* found connected to me, deliver message!
/* This was not very useful except for bypassing certain
* restrictions. Note that we still allow sending to
* remote servers this way, for messaging pseudoservers
* securely whether they have a service{} block or not.
* -- jilles
*/
target_p = find_userhost(nick, host, &count);
if(target_p != NULL)
{
if(server != NULL)
*server = '@';
if(host != NULL)
*--host = '%';
if(count == 1)
sendto_anywhere(target_p, source_p, command, ":%s", text);
else
sendto_one(source_p, form_str(ERR_TOOMANYTARGETS),
get_id(&me, source_p), get_id(source_p, source_p), nick);
}
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), nick);
return;
}
/*
@ -1007,38 +1018,3 @@ handle_special(int p_or_n, const char *command, struct Client *client_p,
return;
}
}
/*
* find_userhost - find a user@host (server or user).
* inputs - user name to look for
* - host name to look for
* - pointer to count of number of matches found
* outputs - pointer to client if found
* - count is updated
* side effects - none
*
*/
static struct Client *
find_userhost(const char *user, const char *host, int *count)
{
struct Client *c2ptr;
struct Client *res = NULL;
char *u = LOCAL_COPY(user);
rb_dlink_node *ptr;
*count = 0;
if(collapse(u) != NULL)
{
RB_DLINK_FOREACH(ptr, global_client_list.head)
{
c2ptr = ptr->data;
if(!MyClient(c2ptr)) /* implies mine and an user */
continue;
if((!host || match(host, c2ptr->host)) && irccmp(u, c2ptr->username) == 0)
{
(*count)++;
res = c2ptr;
}
}
}
return (res);
}

View file

@ -897,7 +897,7 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
/* if we dont have a ts, or their TS's are the same, kill both */
if(!newts || !target_p->tsinfo || (newts == target_p->tsinfo))
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick collision on %s(%s <- %s)(both %s)",
target_p->name, target_p->from->name, client_p->name, action);
@ -960,12 +960,12 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
else
{
if(sameuser)
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick collision on %s(%s <- %s)(older %s)",
target_p->name, target_p->from->name,
client_p->name, action);
else
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick collision on %s(%s <- %s)(newer %s)",
target_p->name, target_p->from->name,
client_p->name, action);
@ -1014,7 +1014,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
/* its a client changing nick and causing a collide */
if(!newts || !target_p->tsinfo || (newts == target_p->tsinfo) || !source_p->user)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick change collision from %s to %s(%s <- %s)(both %s)",
source_p->name, target_p->name, target_p->from->name,
client_p->name, action);
@ -1057,12 +1057,12 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
(!sameuser && newts > target_p->tsinfo))
{
if(sameuser)
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick change collision from %s to %s(%s <- %s)(older %s)",
source_p->name, target_p->name,
target_p->from->name, client_p->name, action);
else
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick change collision from %s to %s(%s <- %s)(newer %s)",
source_p->name, target_p->name,
target_p->from->name, client_p->name, action);
@ -1102,12 +1102,12 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
else
{
if(sameuser)
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick collision on %s(%s <- %s)(older %s)",
target_p->name, target_p->from->name,
client_p->name, action);
else
sendto_realops_snomask(SNO_GENERAL, L_ALL,
sendto_realops_snomask(SNO_SKILL, L_ALL,
"Nick collision on %s(%s <- %s)(newer %s)",
target_p->name, target_p->from->name,
client_p->name, action);

View file

@ -85,7 +85,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
{
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
"Server %s has unexpected name %s",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Server %s has unexpected name %s",
log_client_name(client_p, SHOW_IP), name);
exit_client(client_p, client_p, client_p, "Server name mismatch");
@ -98,7 +98,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
if(!DoesTS(client_p))
{
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Link %s dropped, non-TS server",
get_server_name(client_p, HIDE_IP));
client_p->name);
exit_client(client_p, client_p, client_p, "Non-TS server");
return 0;
}
@ -119,7 +119,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Unauthorised server connection attempt from %s: "
"No entry for servername %s",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Access denied, no connect block for server %s%s",
EmptyString(client_p->name) ? name : "",
@ -135,7 +135,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
"Unauthorised server connection attempt from %s: "
"Bad password for server %s",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Access denied, invalid password for server %s%s",
EmptyString(client_p->name) ? name : "",
@ -150,7 +150,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Unauthorised server connection attempt from %s: "
"Invalid host for server %s",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Access denied, invalid host for server %s%s",
EmptyString(client_p->name) ? name : "",
@ -165,7 +165,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
case -4:
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Invalid servername %s from %s",
name, get_server_name(client_p, HIDE_IP));
name, client_p->name);
ilog(L_SERVER, "Access denied, invalid servername from %s",
log_client_name(client_p, SHOW_IP));
@ -208,7 +208,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
*/
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Attempt to re-introduce server %s from %s",
name, get_server_name(client_p, HIDE_IP));
name, client_p->name);
ilog(L_SERVER, "Attempt to re-introduce server %s from %s",
name, log_client_name(client_p, SHOW_IP));
@ -223,7 +223,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char
"Attempt to re-introduce SID %s from %s%s",
client_p->id,
EmptyString(client_p->name) ? name : "",
get_server_name(client_p, HIDE_IP));
client_p->name);
ilog(L_SERVER, "Attempt to re-introduce SID %s from %s%s",
client_p->id,
EmptyString(client_p->name) ? name : "",
@ -302,7 +302,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s cancelled, server %s already exists",
get_server_name(client_p, SHOW_IP), name);
client_p->name, name);
ilog(L_SERVER, "Link %s cancelled, server %s already exists",
client_p->name, name);
@ -324,7 +324,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_one(client_p, "ERROR :Nickname %s already exists!", name);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s cancelled: Server/nick collision on %s",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Link %s cancelled: Server/nick collision on %s",
client_p->name, name);
@ -390,7 +390,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
{
/* OOOPs nope can't HUB */
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Non-Hub link %s introduced %s.",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Non-Hub link %s introduced %s.",
client_p->name, name);
@ -404,7 +404,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
/* OOOPs nope can't HUB this leaf */
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s introduced leafed server %s.",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Link %s introduced leafed server %s.",
client_p->name, name);
@ -418,7 +418,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s introduced server with invalid servername %s",
get_server_name(client_p, HIDE_IP), name);
client_p->name, name);
ilog(L_SERVER, "Link %s introduced server with invalid servername %s",
client_p->name, name);
@ -482,7 +482,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_one(client_p, "ERROR :Server %s already exists", parv[1]);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s cancelled, server %s already exists",
get_server_name(client_p, SHOW_IP), parv[1]);
client_p->name, parv[1]);
ilog(L_SERVER, "Link %s cancelled, server %s already exists",
client_p->name, parv[1]);
@ -496,7 +496,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_one(client_p, "ERROR :SID %s already exists", parv[3]);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s cancelled, SID %s already exists",
get_server_name(client_p, SHOW_IP), parv[3]);
client_p->name, parv[3]);
ilog(L_SERVER, "Link %s cancelled, SID %s already exists",
client_p->name, parv[3]);
@ -509,7 +509,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_one(client_p, "ERROR :Invalid servername");
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s cancelled, servername %s invalid",
get_server_name(client_p, SHOW_IP), parv[1]);
client_p->name, parv[1]);
ilog(L_SERVER, "Link %s cancelled, servername %s invalid",
client_p->name, parv[1]);
@ -523,7 +523,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_one(client_p, "ERROR :Invalid SID");
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s cancelled, SID %s invalid",
get_server_name(client_p, SHOW_IP), parv[3]);
client_p->name, parv[3]);
ilog(L_SERVER, "Link %s cancelled, SID %s invalid",
client_p->name, parv[3]);
@ -554,7 +554,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_one(client_p, "ERROR :No matching hub_mask");
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Non-Hub link %s introduced %s.",
get_server_name(client_p, SHOW_IP), parv[1]);
client_p->name, parv[1]);
ilog(L_SERVER, "Non-Hub link %s introduced %s.",
client_p->name, parv[1]);
exit_client(NULL, client_p, &me, "No matching hub_mask.");
@ -567,7 +567,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_one(client_p, "ERROR :Matching leaf_mask");
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s introduced leafed server %s.",
get_server_name(client_p, SHOW_IP), parv[1]);
client_p->name, parv[1]);
ilog(L_SERVER, "Link %s introduced leafed server %s.",
client_p->name, parv[1]);
exit_client(NULL, client_p, &me, "Leafed Server.");

View file

@ -138,14 +138,8 @@ mo_connect(struct Client *client_p, struct Client *source_p, int parc, const cha
*/
if(serv_connect(server_p, source_p))
{
#ifndef HIDE_SERVERS_IPS
sendto_one_notice(source_p, ":*** Connecting to %s[%s].%d",
server_p->host, server_p->name, server_p->port);
#else
sendto_one_notice(source_p, ":*** Connecting to %s.%d",
server_p->name, server_p->port);
#endif
}
else
{

View file

@ -263,16 +263,6 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char *
return 0;
}
/* Look for an oper reason */
if((oper_reason = strchr(reason, '|')) != NULL)
{
*oper_reason = '\0';
oper_reason++;
if(!EmptyString(oper_reason))
aconf->spasswd = rb_strdup(oper_reason);
}
if(ConfigFileEntry.non_redundant_klines)
{
if((aconf = find_dline((struct sockaddr *)&daddr, t)) != NULL)
@ -302,6 +292,16 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char *
aconf->status = CONF_DLINE;
aconf->host = rb_strdup(dlhost);
/* Look for an oper reason */
if((oper_reason = strchr(reason, '|')) != NULL)
{
*oper_reason = '\0';
oper_reason++;
if(!EmptyString(oper_reason))
aconf->spasswd = rb_strdup(oper_reason);
}
if(tdline_time > 0)
{
rb_snprintf(dlbuffer, sizeof(dlbuffer),
@ -339,7 +339,7 @@ apply_dline(struct Client *source_p, const char *dlhost, int tdline_time, char *
{
rb_snprintf(dlbuffer, sizeof(dlbuffer), "%s (%s)", reason, current_date);
aconf->passwd = rb_strdup(dlbuffer);
add_conf_by_address(aconf->host, CONF_DLINE, NULL, aconf);
add_conf_by_address(aconf->host, CONF_DLINE, NULL, NULL, aconf);
write_confitem(DLINE_TYPE, source_p, NULL, aconf->host, reason,
oper_reason, current_date, 0);
}

View file

@ -446,6 +446,18 @@ static struct InfoStruct info_table[] = {
&ConfigFileEntry.stats_y_oper_only,
"STATS Y is only shown to operators",
},
{
"throttle_count",
OUTPUT_DECIMAL,
&ConfigFileEntry.throttle_count,
"Connection throttle threshold",
},
{
"throttle_duration",
OUTPUT_DECIMAL,
&ConfigFileEntry.throttle_duration,
"Connection throttle duration",
},
{
"tkline_expire_notices",
OUTPUT_BOOLEAN,

View file

@ -492,7 +492,7 @@ static void
apply_kline(struct Client *source_p, struct ConfItem *aconf,
const char *reason, const char *oper_reason, const char *current_date)
{
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, NULL, aconf);
write_confitem(KLINE_TYPE, source_p, aconf->user, aconf->host,
reason, oper_reason, current_date, 0);
}
@ -716,7 +716,7 @@ already_placed_kline(struct Client *source_p, const char *luser, const char *lho
else
piphost = NULL;
aconf = find_conf_by_address(lhost, NULL, NULL, (struct sockaddr *)piphost, CONF_KILL, t, luser);
aconf = find_conf_by_address(lhost, NULL, NULL, (struct sockaddr *)piphost, CONF_KILL, t, luser, NULL);
if (aconf != NULL)
{
/* The above was really a lookup of a single IP,

View file

@ -52,7 +52,6 @@ mapi_clist_av1 oper_clist[] = { &oper_msgtab, NULL };
DECLARE_MODULE_AV1(oper, NULL, NULL, oper_clist, NULL, NULL, "$Revision: 1483 $");
static int match_oper_password(const char *password, struct oper_conf *oper_p);
extern char *crypt();
/*
* m_oper
@ -156,7 +155,7 @@ match_oper_password(const char *password, struct oper_conf *oper_p)
* the proper encrypted hash for comparison.
*/
if(!EmptyString(password))
encr = crypt(password, oper_p->passwd);
encr = rb_crypt(password, oper_p->passwd);
else
encr = "";
}

View file

@ -60,6 +60,9 @@ DECLARE_MODULE_AV1(pass, NULL, NULL, pass_clist, NULL, NULL, "$Revision: 3550 $"
static int
mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char *auth_user, *pass, *buf;
buf = LOCAL_COPY(parv[1]);
if(client_p->localClient->passwd)
{
memset(client_p->localClient->passwd, 0,
@ -68,6 +71,22 @@ mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char *
}
client_p->localClient->passwd = rb_strndup(parv[1], PASSWDLEN);
if ((pass = strchr(buf, ':')) != NULL)
{
*pass++ = '\0';
auth_user = buf;
}
else
{
pass = buf;
auth_user = NULL;
}
client_p->localClient->passwd = rb_strndup(pass, PASSWDLEN);
if(auth_user)
client_p->localClient->auth_user = rb_strndup(auth_user, PASSWDLEN);
/* These are for servers only */
if(parc > 2 && client_p->user == NULL)

View file

@ -318,11 +318,7 @@ stats_connect(struct Client *source_p)
sendto_one_numeric(source_p, RPL_STATSCLINE,
form_str(RPL_STATSCLINE),
#ifndef HIDE_SERVERS_IPS
server_p->host,
#else
"*@127.0.0.1",
#endif
buf, server_p->name,
server_p->port, server_p->class_name);
}
@ -497,7 +493,7 @@ stats_auth (struct Client *source_p)
else if((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper (source_p))
{
struct ConfItem *aconf;
char *name, *host, *pass, *user, *classname;
char *name, *host, *pass = "*", *user, *classname;
int port;
if(MyConnect (source_p))
@ -505,18 +501,20 @@ stats_auth (struct Client *source_p)
(struct sockaddr *)&source_p->localClient->ip,
CONF_CLIENT,
source_p->localClient->ip.ss_family,
source_p->username);
source_p->username, NULL);
else
aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_CLIENT,
0, source_p->username);
0, source_p->username, NULL);
if(aconf == NULL)
return;
get_printable_conf (aconf, &name, &host, &pass, &user, &port, &classname);
if(!EmptyString(aconf->spasswd))
pass = aconf->spasswd;
sendto_one_numeric(source_p, RPL_STATSILINE, form_str(RPL_STATSILINE),
name, show_iline_prefix(source_p, aconf, user),
name, pass, show_iline_prefix(source_p, aconf, user),
host, port, classname);
}
@ -545,10 +543,10 @@ stats_tklines(struct Client *source_p)
(struct sockaddr *)&source_p->localClient->ip,
CONF_KILL,
source_p->localClient->ip.ss_family,
source_p->username);
source_p->username, NULL);
else
aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL,
0, source_p->username);
0, source_p->username, NULL);
if(aconf == NULL)
return;
@ -611,10 +609,10 @@ stats_klines(struct Client *source_p)
(struct sockaddr *)&source_p->localClient->ip,
CONF_KILL,
source_p->localClient->ip.ss_family,
source_p->username);
source_p->username, NULL);
else
aconf = find_conf_by_address (source_p->host, NULL, NULL, NULL, CONF_KILL,
0, source_p->username);
0, source_p->username, NULL);
if(aconf == NULL)
return;
@ -877,7 +875,7 @@ stats_tstats (struct Client *source_p)
"T :accepts %u refused %u", sp.is_ac, sp.is_ref);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :rejected %u delaying %lu",
sp.is_rej, rb_dlink_list_length(&delay_exit));
sp.is_rej, delay_exit_length());
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :nicks being delayed %lu",
get_nd_count());
@ -1394,7 +1392,7 @@ stats_servlinks (struct Client *source_p)
sendto_one(source_p, Sformat,
get_id(&me, source_p), RPL_STATSLINKINFO, get_id(source_p, source_p),
get_server_name(target_p, SHOW_IP),
target_p->name,
(int) rb_linebuf_len (&target_p->localClient->buf_sendq),
(int) target_p->localClient->sendM,
(int) target_p->localClient->sendK,
@ -1548,7 +1546,7 @@ stats_l_client(struct Client *source_p, struct Client *target_p,
if(IsAnyServer(target_p))
{
sendto_one_numeric(source_p, RPL_STATSLINKINFO, Lformat,
get_server_name(target_p, SHOW_IP),
target_p->name,
(int) rb_linebuf_len(&target_p->localClient->buf_sendq),
(int) target_p->localClient->sendM,
(int) target_p->localClient->sendK,

View file

@ -70,7 +70,7 @@ ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char
/* TS version is too low on one of the sides, drop the link */
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s dropped, wrong TS protocol version (%s,%s)",
get_server_name(source_p, SHOW_IP), parv[1], parv[2]);
source_p->name, parv[1], parv[2]);
snprintf(squitreason, sizeof squitreason, "Incompatible TS version (%s,%s)",
parv[1], parv[2]);
exit_client(source_p, source_p, source_p, squitreason);
@ -89,7 +89,7 @@ ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link %s dropped, excessive TS delta"
" (my TS=%ld, their TS=%ld, delta=%d)",
get_server_name(source_p, SHOW_IP),
source_p->name,
(long) rb_current_time(), (long) theirtime, deltat);
ilog(L_SERVER,
"Link %s dropped, excessive TS delta"

View file

@ -155,7 +155,7 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch
#ifdef RB_IPV6
(type == HM_IPV6) ? AF_INET6 :
#endif
AF_INET) : 0)))
AF_INET) : 0, NULL)))
{
static char buf[HOSTLEN+USERLEN+2];
@ -193,7 +193,8 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch
if(aconf && aconf->status & CONF_CLIENT)
{
sendto_one_numeric(source_p, RPL_STATSILINE, form_str(RPL_STATSILINE),
aconf->name, show_iline_prefix(source_p, aconf, aconf->user),
aconf->name, EmptyString(aconf->spasswd) ? "<NULL>" : aconf->spasswd,
show_iline_prefix(source_p, aconf, aconf->user),
aconf->host, aconf->port, aconf->className);
return 0;
}

View file

@ -63,6 +63,8 @@ DECLARE_MODULE_AV1(trace, NULL, NULL, trace_clist, trace_hlist, NULL, "$Revision
static void count_downlinks(struct Client *server_p, int *pservcount, int *pusercount);
static int report_this_status(struct Client *source_p, struct Client *target_p);
static const char *empty_sockhost = "255.255.255.255";
/*
* m_trace
* parv[0] = sender prefix
@ -345,7 +347,7 @@ report_this_status(struct Client *source_p, struct Client *target_p)
class_name = get_client_class(target_p);
if(IsAnyServer(target_p))
name = get_server_name(target_p, HIDE_IP);
name = target_p->name;
else
name = get_client_name(target_p, HIDE_IP);
@ -378,22 +380,18 @@ report_this_status(struct Client *source_p, struct Client *target_p)
break;
case STAT_CLIENT:
if(IsOper(target_p))
sendto_one_numeric(source_p, RPL_TRACEOPERATOR,
form_str(RPL_TRACEOPERATOR),
class_name, name,
show_ip(source_p, target_p) ? ip : "255.255.255.255",
rb_current_time() - target_p->localClient->lasttime,
rb_current_time() - target_p->localClient->last);
{
int tnumeric;
else
sendto_one_numeric(source_p, RPL_TRACEUSER,
form_str(RPL_TRACEUSER),
class_name, name,
show_ip(source_p, target_p) ? ip : "255.255.255.255",
rb_current_time() - target_p->localClient->lasttime,
rb_current_time() - target_p->localClient->last);
cnt++;
tnumeric = IsOper(target_p) ? RPL_TRACEOPERATOR : RPL_TRACEUSER;
sendto_one_numeric(source_p, tnumeric, form_str(tnumeric),
class_name, name,
show_ip(source_p, target_p) ? ip : empty_sockhost,
rb_current_time() - target_p->localClient->lasttime,
rb_current_time() - target_p->localClient->last);
cnt++;
}
break;
case STAT_SERVER:

View file

@ -0,0 +1,629 @@
blacklist.o: blacklist.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/res.h ../include/numeric.h ../include/reject.h \
../include/s_conf.h ../include/class.h ../include/s_user.h \
../include/blacklist.h
cache.o: cache.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/ircd_defs.h \
../include/common.h ../include/s_conf.h ../include/class.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/hash.h ../include/cache.h ../include/irc_dictionary.h \
../include/numeric.h
channel.o: channel.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/channel.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/client.h ../include/common.h ../include/hash.h \
../include/hook.h ../include/match.h ../include/ircd.h \
../include/numeric.h ../include/s_serv.h ../include/s_user.h \
../include/send.h ../include/whowas.h ../include/s_conf.h \
../include/class.h ../include/s_newconf.h ../include/logger.h
chmode.o: chmode.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/channel.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/common.h ../include/hash.h ../include/hook.h \
../include/match.h ../include/ircd.h ../include/numeric.h \
../include/s_serv.h ../include/s_user.h ../include/send.h \
../include/whowas.h ../include/s_conf.h ../include/class.h \
../include/s_newconf.h ../include/logger.h ../include/chmode.h
class.o: class.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/config.h \
../include/class.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/client.h ../include/common.h ../include/ircd.h \
../include/numeric.h ../include/s_conf.h ../include/class.h \
../include/s_newconf.h ../include/send.h ../include/match.h
client.o: client.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/config.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/class.h ../include/common.h ../include/hash.h \
../include/match.h ../include/ircd.h ../include/numeric.h \
../include/packet.h ../include/s_auth.h ../include/s_conf.h \
../include/class.h ../include/s_newconf.h ../include/logger.h \
../include/s_serv.h ../include/s_stats.h ../include/send.h \
../include/whowas.h ../include/s_user.h ../include/hostmask.h \
../include/listener.h ../include/hook.h ../include/msg.h \
../include/monitor.h ../include/blacklist.h ../include/reject.h \
../include/scache.h ../include/irc_dictionary.h ../include/sslproc.h
extban.o: extban.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/channel.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/common.h
getopt.o: getopt.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/ircd_getopt.h
hash.o: hash.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/ircd_defs.h \
../include/s_conf.h ../include/class.h ../include/client.h \
../include/channel.h ../include/res.h ../include/common.h \
../include/reslib.h ../include/match.h ../include/ircd.h \
../include/snomask.h ../include/channel.h ../include/client.h \
../include/common.h ../include/hash.h ../include/match.h \
../include/ircd.h ../include/numeric.h ../include/send.h \
../include/msg.h ../include/cache.h ../include/s_newconf.h
hook.o: hook.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/hook.h \
../include/match.h
hostmask.o: hostmask.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/ircd_defs.h ../include/s_conf.h ../include/class.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/hostmask.h \
../include/numeric.h ../include/send.h ../include/match.h
irc_dictionary.o: irc_dictionary.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/match.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/client.h ../include/setup.h ../include/irc_dictionary.h
ircd.o: ircd.c ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/setup.h \
../include/config.h ../include/ircd.h ../include/channel.h \
../include/class.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/client.h ../include/common.h ../include/hash.h \
../include/match.h ../include/ircd_signal.h ../include/msg.h \
../include/hostmask.h ../include/numeric.h ../include/parse.h \
../include/irc_dictionary.h ../include/res.h ../include/restart.h \
../include/s_auth.h ../include/s_conf.h ../include/class.h \
../include/logger.h ../include/s_serv.h ../include/s_user.h \
../include/s_stats.h ../include/scache.h ../include/send.h \
../include/supported.h ../include/whowas.h ../include/modules.h \
../include/parse.h ../include/msg.h ../include/hook.h ../include/hook.h \
../include/ircd_getopt.h ../include/newconf.h ../include/reject.h \
../include/s_newconf.h ../include/cache.h ../include/monitor.h \
../include/patchlevel.h ../include/serno.h ../include/sslproc.h \
../include/chmode.h
ircd_signal.o: ircd_signal.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/ircd_signal.h ../include/ircd.h ../include/restart.h \
../include/logger.h ../include/s_conf.h ../include/class.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/send.h
kdparse.o: kdparse.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/logger.h ../include/s_conf.h ../include/class.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/s_newconf.h \
../include/hostmask.h ../include/client.h ../include/match.h \
../include/hash.h
listener.o: listener.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/setup.h ../include/listener.h ../include/client.h \
../include/channel.h ../include/res.h ../include/common.h \
../include/reslib.h ../include/match.h ../include/ircd.h \
../include/snomask.h ../include/client.h ../include/match.h \
../include/ircd.h ../include/ircd_defs.h ../include/numeric.h \
../include/s_conf.h ../include/class.h ../include/s_newconf.h \
../include/s_stats.h ../include/send.h ../include/s_auth.h \
../include/reject.h ../include/hostmask.h ../include/sslproc.h \
../include/hash.h
logger.o: logger.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/ircd_defs.h \
../include/logger.h ../include/s_conf.h ../include/class.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/send.h \
../include/client.h ../include/s_serv.h
match.o: match.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/config.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/ircd.h ../include/match.h
modules.o: modules.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/modules.h ../include/parse.h ../include/irc_dictionary.h \
../include/msg.h ../include/hook.h ../include/logger.h \
../include/ircd.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/client.h ../include/send.h ../include/s_conf.h \
../include/class.h ../include/s_newconf.h ../include/numeric.h \
../include/parse.h ../include/ircd_defs.h ../include/match.h
monitor.o: monitor.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/monitor.h ../include/hash.h ../include/numeric.h
newconf.o: newconf.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/newconf.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/ircd_defs.h ../include/common.h ../include/logger.h \
../include/s_conf.h ../include/class.h ../include/s_user.h \
../include/s_newconf.h ../include/send.h ../include/setup.h \
../include/modules.h ../include/parse.h ../include/irc_dictionary.h \
../include/msg.h ../include/hook.h ../include/listener.h \
../include/hostmask.h ../include/s_serv.h ../include/hash.h \
../include/cache.h ../include/ircd.h ../include/snomask.h \
../include/blacklist.h ../include/sslproc.h
numeric.o: numeric.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/setup.h ../include/config.h ../include/s_conf.h \
../include/class.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/numeric.h ../include/match.h ../include/common.h \
messages.tab
packet.o: packet.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/s_conf.h \
../include/class.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/s_serv.h ../include/client.h ../include/common.h \
../include/ircd.h ../include/parse.h ../include/irc_dictionary.h \
../include/packet.h ../include/match.h ../include/hook.h \
../include/send.h
parse.o: parse.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/parse.h \
../include/irc_dictionary.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/client.h ../include/channel.h ../include/common.h \
../include/hash.h ../include/match.h ../include/ircd.h \
../include/numeric.h ../include/logger.h ../include/s_stats.h \
../include/send.h ../include/msg.h ../include/s_conf.h \
../include/class.h ../include/s_serv.h ../include/packet.h
res.o: res.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/ircd_defs.h \
../include/common.h ../include/ircd.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/reslib.h ../include/match.h \
../include/numeric.h ../include/client.h ../include/channel.h \
../include/res.h ../include/snomask.h ../include/client.h
reslib.o: reslib.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/ircd_defs.h \
../include/common.h ../include/ircd.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/reslib.h ../include/match.h
reject.o: reject.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/config.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/s_conf.h ../include/class.h ../include/reject.h \
../include/s_stats.h ../include/msg.h ../include/hash.h
restart.o: restart.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/restart.h ../include/ircd.h ../include/send.h \
../include/logger.h ../include/s_conf.h ../include/class.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/ircd_signal.h
s_auth.o: s_auth.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/config.h \
../include/s_auth.h ../include/s_conf.h ../include/class.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/common.h ../include/match.h ../include/ircd.h \
../include/numeric.h ../include/packet.h ../include/res.h \
../include/logger.h ../include/s_stats.h ../include/send.h \
../include/hook.h ../include/blacklist.h
s_conf.o: s_conf.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/ircd_defs.h \
../include/s_conf.h ../include/class.h ../include/client.h \
../include/channel.h ../include/res.h ../include/common.h \
../include/reslib.h ../include/match.h ../include/ircd.h \
../include/snomask.h ../include/s_newconf.h ../include/s_serv.h \
../include/s_stats.h ../include/channel.h ../include/class.h \
../include/client.h ../include/common.h ../include/hash.h \
../include/match.h ../include/ircd.h ../include/listener.h \
../include/hostmask.h ../include/modules.h ../include/parse.h \
../include/irc_dictionary.h ../include/msg.h ../include/hook.h \
../include/numeric.h ../include/logger.h ../include/send.h \
../include/reject.h ../include/cache.h ../include/blacklist.h \
../include/sslproc.h
s_newconf.o: s_newconf.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/ircd_defs.h ../include/common.h ../include/s_conf.h \
../include/class.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/s_newconf.h ../include/client.h ../include/s_serv.h \
../include/send.h ../include/hostmask.h ../include/newconf.h \
../include/hash.h ../include/irc_dictionary.h
s_serv.o: s_serv.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/s_serv.h \
../include/class.h ../include/client.h ../include/channel.h \
../include/res.h ../include/common.h ../include/reslib.h \
../include/match.h ../include/ircd.h ../include/snomask.h \
../include/client.h ../include/common.h ../include/hash.h \
../include/match.h ../include/ircd.h ../include/ircd_defs.h \
../include/numeric.h ../include/packet.h ../include/res.h \
../include/s_conf.h ../include/class.h ../include/s_newconf.h \
../include/logger.h ../include/s_stats.h ../include/s_user.h \
../include/scache.h ../include/send.h ../include/channel.h \
../include/hook.h ../include/msg.h ../include/reject.h \
../include/sslproc.h
s_user.o: s_user.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/s_user.h \
../include/channel.h ../include/class.h ../include/client.h \
../include/channel.h ../include/res.h ../include/common.h \
../include/reslib.h ../include/match.h ../include/ircd.h \
../include/snomask.h ../include/client.h ../include/common.h \
../include/hash.h ../include/match.h ../include/ircd.h \
../include/listener.h ../include/msg.h ../include/numeric.h \
../include/s_conf.h ../include/class.h ../include/s_newconf.h \
../include/logger.h ../include/s_serv.h ../include/s_stats.h \
../include/scache.h ../include/send.h ../include/supported.h \
../include/whowas.h ../include/packet.h ../include/reject.h \
../include/cache.h ../include/hook.h ../include/monitor.h \
../include/snomask.h ../include/blacklist.h ../include/substitution.h \
../include/stdinc.h ../include/chmode.h
scache.o: scache.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/client.h \
../include/channel.h ../include/res.h ../include/common.h \
../include/reslib.h ../include/match.h ../include/ircd.h \
../include/snomask.h ../include/client.h ../include/common.h \
../include/match.h ../include/ircd.h ../include/numeric.h \
../include/send.h ../include/scache.h ../include/s_conf.h \
../include/class.h
send.o: send.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/send.h \
../include/channel.h ../include/class.h ../include/client.h \
../include/channel.h ../include/res.h ../include/common.h \
../include/reslib.h ../include/match.h ../include/ircd.h \
../include/snomask.h ../include/client.h ../include/common.h \
../include/match.h ../include/ircd.h ../include/numeric.h \
../include/s_serv.h ../include/s_conf.h ../include/class.h \
../include/s_newconf.h ../include/logger.h ../include/hook.h \
../include/monitor.h
snomask.o: snomask.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/snomask.h
sslproc.o: sslproc.c ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/stdinc.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/s_conf.h ../include/class.h ../include/client.h \
../include/channel.h ../include/res.h ../include/common.h \
../include/reslib.h ../include/match.h ../include/ircd.h \
../include/snomask.h ../include/logger.h ../include/listener.h \
../include/sslproc.h ../include/s_serv.h ../include/ircd.h \
../include/hash.h ../include/client.h ../include/send.h \
../include/packet.h
substitution.o: substitution.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/s_user.h ../include/match.h ../include/substitution.h \
../include/stdinc.h
supported.o: supported.c ../include/stdinc.h \
../libratbox/include/ratbox_lib.h ../libratbox/include/librb-config.h \
../libratbox/include/rb_tools.h ../libratbox/include/rb_memory.h \
../libratbox/include/rb_commio.h ../libratbox/include/rb_balloc.h \
../libratbox/include/rb_linebuf.h ../libratbox/include/rb_snprintf.h \
../libratbox/include/rb_event.h ../libratbox/include/rb_helper.h \
../libratbox/include/rb_rawbuf.h ../libratbox/include/rb_patricia.h \
../include/config.h ../include/setup.h ../include/defaults.h \
../include/ircd_defs.h ../include/logger.h ../include/send.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/common.h ../include/numeric.h ../include/ircd.h \
../include/s_conf.h ../include/class.h ../include/supported.h \
../include/chmode.h
whowas.o: whowas.c ../include/stdinc.h ../libratbox/include/ratbox_lib.h \
../libratbox/include/librb-config.h ../libratbox/include/rb_tools.h \
../libratbox/include/rb_memory.h ../libratbox/include/rb_commio.h \
../libratbox/include/rb_balloc.h ../libratbox/include/rb_linebuf.h \
../libratbox/include/rb_snprintf.h ../libratbox/include/rb_event.h \
../libratbox/include/rb_helper.h ../libratbox/include/rb_rawbuf.h \
../libratbox/include/rb_patricia.h ../include/config.h \
../include/setup.h ../include/defaults.h ../include/ircd_defs.h \
../include/logger.h ../include/send.h ../include/whowas.h \
../include/client.h ../include/channel.h ../include/res.h \
../include/common.h ../include/reslib.h ../include/match.h \
../include/ircd.h ../include/snomask.h ../include/client.h \
../include/common.h ../include/hash.h ../include/match.h \
../include/ircd.h ../include/ircd_defs.h ../include/numeric.h \
../include/s_serv.h ../include/s_user.h ../include/send.h \
../include/s_conf.h ../include/class.h ../include/scache.h

View file

@ -144,7 +144,7 @@ version.c: version.c.SH
.PHONY: depend clean distclean
depend:
${MKDEP} ${CPPFLAGS} ${BASE_SRCS} > .depend
${MKDEP} ${CPPFLAGS} ${SRCS} > .depend
clean:
${RM} -f *.o *.exe *~ y.tab.* lex.yy.c ircd.core core ircd

View file

@ -74,6 +74,35 @@ init_cache(void)
help_dict_user = irc_dictionary_create(strcasecmp);
}
/*
* removes tabs from src, replaces with 8 spaces, and returns the length
* of the new string. if the new string would be greater than destlen,
* it is truncated to destlen - 1
*/
static size_t
untabify(char *dest, const char *src, size_t destlen)
{
size_t x = 0, i;
const char *s = src;
char *d = dest;
while(*s != '\0' && x < destlen - 1)
{
if(*s == '\t')
{
for(i = 0; i < 8 && x < destlen - 1; i++, x++, d++)
*d = ' ';
s++;
} else
{
*d++ = *s++;
x++;
}
}
*d = '\0';
return x;
}
/* cache_file()
*
* inputs - file to cache, files "shortname", flags to set
@ -107,7 +136,7 @@ cache_file(const char *filename, const char *shortname, int flags)
if(!EmptyString(line))
{
lineptr = rb_malloc(sizeof(struct cacheline));
rb_strlcpy(lineptr->data, line, sizeof(lineptr->data));
untabify(lineptr->data, line, sizeof(lineptr->data));
rb_dlinkAddTail(lineptr, &lineptr->linenode, &cacheptr->contents);
}
else
@ -195,6 +224,10 @@ load_help(void)
struct cachefile *cacheptr;
struct DictionaryIter iter;
#if defined(S_ISLNK) && defined(HAVE_LSTAT)
struct stat sb;
#endif
DICTIONARY_FOREACH(cacheptr, &iter, help_dict_oper)
{
irc_dictionary_delete(help_dict_oper, cacheptr->name);
@ -228,6 +261,25 @@ load_help(void)
{
rb_snprintf(filename, sizeof(filename), "%s/%s", UHPATH, ldirent->d_name);
#if defined(S_ISLNK) && defined(HAVE_LSTAT)
if(lstat(filename, &sb) < 0)
continue;
/* ok, if its a symlink, we work on the presumption if an
* oper help exists of that name, its a symlink to that --fl
*/
if(S_ISLNK(sb.st_mode))
{
cacheptr = irc_dictionary_retrieve(help_dict_oper, ldirent->d_name);
if(cacheptr != NULL)
{
cacheptr->flags |= HELP_USER;
continue;
}
}
#endif
cacheptr = cache_file(filename, ldirent->d_name, HELP_USER);
irc_dictionary_add(help_dict_user, cacheptr->name, cacheptr);
}

View file

@ -41,6 +41,13 @@
#include "s_newconf.h"
#include "logger.h"
struct config_channel_entry ConfigChannel;
rb_dlink_list global_channel_list;
static rb_bh *channel_heap;
static rb_bh *ban_heap;
static rb_bh *topic_heap;
static rb_bh *member_heap;
static int channel_capabs[] = { CAP_EX, CAP_IE,
CAP_SERVICE,
CAP_TS6
@ -233,8 +240,6 @@ remove_user_from_channel(struct membership *msptr)
if(client_p->servptr == &me)
rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers);
chptr->users_last = rb_current_time();
if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
destroy_channel(chptr);
@ -270,8 +275,6 @@ remove_user_from_channels(struct Client *client_p)
if(client_p->servptr == &me)
rb_dlinkDelete(&msptr->locchannode, &chptr->locmembers);
chptr->users_last = rb_current_time();
if(!(chptr->mode.mode & MODE_PERMANENT) && rb_dlink_list_length(&chptr->members) <= 0)
destroy_channel(chptr);
@ -992,6 +995,7 @@ check_splitmode(void *unused)
"Network rejoined, deactivating splitmode");
rb_event_delete(check_splitmode_ev);
check_splitmode_ev = NULL;
}
}
}

View file

@ -65,37 +65,22 @@ static int mode_limit;
static int mode_limit_simple;
static int mask_pos;
char cflagsbuf[256];
char cflagsmyinfo[256];
int chmode_flags[256];
void
find_orphaned_cflags(void)
{
int i;
static int prev_chmode_flags[256];
for (i = 0; i < 256; i++)
{
if (prev_chmode_flags[i] != 0 && prev_chmode_flags[i] != chmode_flags[i])
{
if (chmode_flags[i] == 0)
{
chmode_table[i].set_func = chm_orphaned;
sendto_realops_snomask(SNO_DEBUG, L_ALL, "Cmode +%c is now orphaned", i);
}
else
{
sendto_realops_snomask(SNO_DEBUG, L_ALL, "Orphaned cmode +%c is picked up by module", i);
}
chmode_flags[i] = prev_chmode_flags[i];
}
else
prev_chmode_flags[i] = chmode_flags[i];
}
}
/* OPTIMIZE ME! -- dwr */
void
construct_noparam_modes(void)
{
int i;
char *ptr = cflagsbuf;
char *ptr2 = cflagsmyinfo;
static int prev_chmode_flags[256];
*ptr = '\0';
*ptr2 = '\0';
for(i = 0; i < 256; i++)
{
@ -113,9 +98,56 @@ construct_noparam_modes(void)
{
chmode_flags[i] = 0;
}
if (prev_chmode_flags[i] != 0 && prev_chmode_flags[i] != chmode_flags[i])
{
if (chmode_flags[i] == 0)
{
chmode_table[i].set_func = chm_orphaned;
sendto_realops_snomask(SNO_DEBUG, L_ALL, "Cmode +%c is now orphaned", i);
}
else
{
sendto_realops_snomask(SNO_DEBUG, L_ALL, "Orphaned cmode +%c is picked up by module", i);
}
chmode_flags[i] = prev_chmode_flags[i];
}
else
prev_chmode_flags[i] = chmode_flags[i];
switch (chmode_flags[i])
{
case MODE_EXLIMIT:
case MODE_DISFORWARD:
if(ConfigChannel.use_forward)
{
*ptr++ = (char) i;
}
break;
case MODE_REGONLY:
if(rb_dlink_list_length(&service_list))
{
*ptr++ = (char) i;
}
break;
default:
if(chmode_flags[i] != 0)
{
*ptr++ = (char) i;
}
}
/* Should we leave orphaned check here? -- dwr */
if(!(chmode_table[i].set_func == chm_nosuch) && !(chmode_table[i].set_func == chm_orphaned))
{
*ptr2++ = (char) i;
}
}
find_orphaned_cflags();
*ptr++ = '\0';
*ptr2++ = '\0';
}
/*

View file

@ -72,12 +72,12 @@ static int qs_server(struct Client *, struct Client *, struct Client *, const ch
static EVH check_pings;
extern rb_bh *client_heap;
extern rb_bh *lclient_heap;
extern rb_bh *pclient_heap;
static rb_bh *client_heap = NULL;
static rb_bh *lclient_heap = NULL;
static rb_bh *pclient_heap = NULL;
static rb_bh *user_heap = NULL;
static rb_bh *away_heap = NULL;
extern char current_uid[IDLEN];
static char current_uid[IDLEN];
struct Dictionary *nd_dict = NULL;
@ -119,6 +119,7 @@ init_client(void)
client_heap = rb_bh_create(sizeof(struct Client), CLIENT_HEAP_SIZE, "client_heap");
lclient_heap = rb_bh_create(sizeof(struct LocalUser), LCLIENT_HEAP_SIZE, "lclient_heap");
pclient_heap = rb_bh_create(sizeof(struct PreClient), PCLIENT_HEAP_SIZE, "pclient_heap");
user_heap = rb_bh_create(sizeof(struct User), USER_HEAP_SIZE, "user_heap");
away_heap = rb_bh_create(AWAYLEN, AWAY_HEAP_SIZE, "away_heap");
rb_event_addish("check_pings", check_pings, NULL, 30);
@ -152,7 +153,7 @@ make_client(struct Client *from)
{
client_p->from = client_p; /* 'from' of local client is self! */
localClient = (struct LocalUser *) rb_bh_alloc(lclient_heap);
localClient = rb_bh_alloc(lclient_heap);
SetMyConnect(client_p);
client_p->localClient = localClient;
@ -160,7 +161,7 @@ make_client(struct Client *from)
client_p->localClient->F = NULL;
client_p->preClient = (struct PreClient *) rb_bh_alloc(pclient_heap);
client_p->preClient = rb_bh_alloc(pclient_heap);;
/* as good a place as any... */
rb_dlinkAdd(client_p, &client_p->localClient->tnode, &unknown_list);
@ -322,7 +323,7 @@ check_pings_list(rb_dlink_list * list)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"No response from %s, closing link",
get_server_name(client_p, HIDE_IP));
client_p->name);
ilog(L_SERVER,
"No response from %s, closing link",
log_client_name(client_p, HIDE_IP));
@ -390,7 +391,7 @@ check_unknowns_list(rb_dlink_list * list)
{
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
"No response from %s, closing link",
get_server_name(client_p, HIDE_IP));
client_p->name);
ilog(L_SERVER,
"No response from %s, closing link",
log_client_name(client_p, HIDE_IP));
@ -416,15 +417,7 @@ notify_banned_client(struct Client *client_p, struct ConfItem *aconf, int ban)
}
else
{
switch (aconf->status)
{
case D_LINED:
reason = d_lined;
break;
default:
reason = k_lined;
break;
}
reason = aconf->status == D_LINED ? d_lined : k_lined;
}
if(ban == D_LINED && !IsPerson(client_p))
@ -857,10 +850,8 @@ get_client_name(struct Client *client, int showip)
if(ConfigFileEntry.hide_spoof_ips &&
showip == SHOW_IP && IsIPSpoof(client))
showip = MASK_IP;
#ifdef HIDE_SERVERS_IPS
if(IsAnyServer(client))
showip = MASK_IP;
#endif
/* And finally, let's get the host information, ip or name */
switch (showip)
@ -886,49 +877,6 @@ get_client_name(struct Client *client, int showip)
*/
return client->name;
}
const char *
get_server_name(struct Client *target_p, int showip)
{
static char nbuf[HOSTLEN * 2 + USERLEN + 5];
if(target_p == NULL)
return NULL;
if(!MyConnect(target_p) || !irccmp(target_p->name, target_p->host))
return target_p->name;
#ifdef HIDE_SERVERS_IPS
if(EmptyString(target_p->name))
{
rb_snprintf(nbuf, sizeof(nbuf), "[%s@255.255.255.255]",
target_p->username);
return nbuf;
}
else
return target_p->name;
#endif
switch (showip)
{
case SHOW_IP:
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
target_p->name, target_p->username,
target_p->sockhost);
break;
case MASK_IP:
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@255.255.255.255]",
target_p->name, target_p->username);
default:
rb_snprintf(nbuf, sizeof(nbuf), "%s[%s@%s]",
target_p->name, target_p->username,
target_p->host);
}
return nbuf;
}
/* log_client_name()
*
@ -1207,7 +1155,7 @@ exit_aborted_clients(void *unused)
if(IsAnyServer(abt->client))
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Closing link to %s: %s",
get_server_name(abt->client, HIDE_IP), abt->notice);
abt->client->name, abt->notice);
/* its no longer on abort list - we *must* remove
* FLAGS_CLOSING otherwise exit_client() will not run --fl
@ -1332,7 +1280,6 @@ exit_unknown_client(struct Client *client_p, struct Client *source_p, struct Cli
delete_resolver_queries(source_p->localClient->dnsquery);
rb_free(source_p->localClient->dnsquery);
}
del_unknown_ip(source_p);
rb_dlinkDelete(&source_p->localClient->tnode, &unknown_list);
if(!IsIOError(source_p))
@ -1729,10 +1676,6 @@ show_ip(struct Client *source_p, struct Client *target_p)
{
if(IsAnyServer(target_p))
{
#ifndef HIDE_SERVERS_IPS
if(source_p == NULL || IsOper(source_p))
return 1;
#endif
return 0;
}
else if(IsIPSpoof(target_p))
@ -1765,24 +1708,6 @@ show_ip_conf(struct ConfItem *aconf, struct Client *source_p)
return 1;
}
/*
* initUser
*
* inputs - none
* outputs - none
*
* side effects - Creates a block heap for struct Users
*
*/
static rb_bh *user_heap;
void
initUser(void)
{
user_heap = rb_bh_create(sizeof(struct User), USER_HEAP_SIZE, "user_heap");
if(!user_heap)
rb_outofmemory();
}
/*
* make_user
*
@ -2038,7 +1963,7 @@ error_exit_client(struct Client *client_p, int error)
{
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) && !IsServer(client_p) ? L_NETWIDE : L_ALL,
"Server %s closed the connection",
get_server_name(client_p, SHOW_IP));
client_p->name);
ilog(L_SERVER, "Server %s closed the connection",
log_client_name(client_p, SHOW_IP));

View file

@ -208,7 +208,7 @@ struct ConfItem *
find_conf_by_address(const char *name, const char *sockhost,
const char *orighost,
struct sockaddr *addr, int type, int fam,
const char *username)
const char *username, const char *auth_user)
{
unsigned long hprecv = 0;
struct ConfItem *hprec = NULL;
@ -231,12 +231,11 @@ find_conf_by_address(const char *name, const char *sockhost,
if(arec->type == (type & ~0x1) &&
arec->masktype == HM_IPV6 &&
comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
arec->Mask.ipa.bits) && (type & 0x1
||
match(arec->
username,
username))
&& arec->precedence > hprecv)
arec->Mask.ipa.bits) &&
(type & 0x1 || match(arec-> username, username)) &&
(type != CONF_CLIENT || !arec->auth_user ||
(auth_user && match(arec->auth_user, auth_user))) &&
arec->precedence > hprecv)
{
hprecv = arec->precedence;
hprec = arec->aconf;
@ -252,10 +251,12 @@ find_conf_by_address(const char *name, const char *sockhost,
for (arec = atable[hash_ipv4(addr, b)]; arec; arec = arec->next)
if(arec->type == (type & ~0x1) &&
arec->masktype == HM_IPV4 &&
arec->precedence > hprecv &&
comp_with_mask_sock(addr, (struct sockaddr *)&arec->Mask.ipa.addr,
arec->Mask.ipa.bits) &&
(type & 0x1 || match(arec->username, username)))
(type & 0x1 || match(arec->username, username)) &&
(type != CONF_CLIENT || !arec->auth_user ||
(auth_user && match(arec->auth_user, auth_user))) &&
arec->precedence > hprecv)
{
hprecv = arec->precedence;
hprec = arec->aconf;
@ -276,6 +277,8 @@ find_conf_by_address(const char *name, const char *sockhost,
(arec->masktype == HM_HOST) &&
arec->precedence > hprecv &&
match(arec->Mask.hostname, orighost) &&
(type != CONF_CLIENT || !arec->auth_user ||
(auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
@ -294,6 +297,8 @@ find_conf_by_address(const char *name, const char *sockhost,
arec->precedence > hprecv &&
(match(arec->Mask.hostname, orighost) ||
(sockhost && match(arec->Mask.hostname, sockhost))) &&
(type != CONF_CLIENT || !arec->auth_user ||
(auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
@ -314,6 +319,8 @@ find_conf_by_address(const char *name, const char *sockhost,
(arec->masktype == HM_HOST) &&
arec->precedence > hprecv &&
match(arec->Mask.hostname, name) &&
(type != CONF_CLIENT || !arec->auth_user ||
(auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
@ -332,6 +339,8 @@ find_conf_by_address(const char *name, const char *sockhost,
arec->precedence > hprecv &&
(match(arec->Mask.hostname, name) ||
(sockhost && match(arec->Mask.hostname, sockhost))) &&
(type != CONF_CLIENT || !arec->auth_user ||
(auth_user && match(arec->auth_user, auth_user))) &&
(type & 0x1 || match(arec->username, username)))
{
hprecv = arec->precedence;
@ -350,13 +359,13 @@ find_conf_by_address(const char *name, const char *sockhost,
*/
struct ConfItem *
find_address_conf(const char *host, const char *sockhost, const char *user,
const char *notildeuser, struct sockaddr *ip, int aftype)
const char *notildeuser, struct sockaddr *ip, int aftype, char *auth_user)
{
struct ConfItem *iconf, *kconf;
const char *vuser;
/* Find the best I-line... If none, return NULL -A1kmm */
if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user)))
if(!(iconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_CLIENT, aftype, user, auth_user)))
return NULL;
/* Find what their visible username will be.
* Note that the username without tilde may contain one char more.
@ -368,7 +377,7 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
return iconf;
/* Find the best K-line... -A1kmm */
kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, user);
kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, user, NULL);
/* If they are K-lined, return the K-line */
if(kconf)
@ -385,11 +394,11 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
if(p)
{
*p = '\0';
kconf = find_conf_by_address(p+1, NULL, NULL, ip, CONF_KILL, aftype, iconf->name);
kconf = find_conf_by_address(p+1, NULL, NULL, ip, CONF_KILL, aftype, iconf->name, NULL);
*p = '@';
}
else
kconf = find_conf_by_address(iconf->name, NULL, NULL, ip, CONF_KILL, aftype, vuser);
kconf = find_conf_by_address(iconf->name, NULL, NULL, ip, CONF_KILL, aftype, vuser, NULL);
if(kconf)
return kconf;
@ -399,7 +408,7 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
* -- jilles */
if(user != vuser)
{
kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, vuser);
kconf = find_conf_by_address(host, sockhost, NULL, ip, CONF_KILL, aftype, vuser, NULL);
if(kconf)
return kconf;
}
@ -416,10 +425,10 @@ struct ConfItem *
find_dline(struct sockaddr *addr, int aftype)
{
struct ConfItem *eline;
eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL);
eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL, NULL);
if(eline)
return eline;
return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL);
return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL, NULL);
}
/* void find_exact_conf_by_address(const char*, int, const char *)
@ -485,7 +494,7 @@ find_exact_conf_by_address(const char *address, int type, const char *username)
* Side-effects: Adds this entry to the hash table.
*/
void
add_conf_by_address(const char *address, int type, const char *username, struct ConfItem *aconf)
add_conf_by_address(const char *address, int type, const char *username, const char *auth_user, struct ConfItem *aconf)
{
static unsigned long prec_value = 0xFFFFFFFF;
int masktype, bits;
@ -522,6 +531,7 @@ add_conf_by_address(const char *address, int type, const char *username, struct
atable[hv] = arec;
}
arec->username = username;
arec->auth_user = auth_user;
arec->aconf = aconf;
arec->precedence = prec_value--;
arec->type = type;
@ -694,7 +704,7 @@ show_iline_prefix(struct Client *sptr, struct ConfItem *aconf, char *name)
void
report_auth(struct Client *client_p)
{
char *name, *host, *pass, *user, *classname;
char *name, *host, *pass = "*", *user, *classname;
struct AddressRec *arec;
struct ConfItem *aconf;
int i, port;
@ -710,10 +720,13 @@ report_auth(struct Client *client_p)
get_printable_conf(aconf, &name, &host, &pass, &user, &port,
&classname);
if(!EmptyString(aconf->spasswd))
pass = aconf->spasswd;
sendto_one_numeric(client_p, RPL_STATSILINE,
form_str(RPL_STATSILINE),
name, show_iline_prefix(client_p, aconf, user),
name, pass, show_iline_prefix(client_p, aconf, user),
show_ip_conf(aconf, client_p) ? host : "255.255.255.255",
port, classname);
}

View file

@ -1,10 +1,11 @@
/*
* ircd-ratbox: A slightly useful ircd.
* charybdis: A slightly useful ircd.
* ircd.c: Starts up and runs the ircd.
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2002-2005 ircd-ratbox development team
* Copyright (C) 2002-2008 ircd-ratbox development team
* Copyright (C) 2005-2008 charybdis 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
@ -21,7 +22,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: ircd.c 3380 2007-04-03 22:25:11Z jilles $
* $Id$
*/
#include "ratbox_lib.h"
@ -80,31 +81,19 @@ struct Counter Count;
struct ServerStatistics ServerStats;
int maxconnections;
struct timeval SystemTime;
struct Client me; /* That's me */
struct LocalUser meLocalUser; /* That's also part of me */
rb_dlink_list lclient_list = { NULL, NULL, 0 };
rb_dlink_list global_client_list = { NULL, NULL, 0 };
rb_dlink_list global_channel_list = { NULL, NULL, 0 };
rb_dlink_list global_client_list;
/* unknown/client pointer lists */
rb_dlink_list unknown_list; /* unknown clients ON this server only */
rb_dlink_list lclient_list; /* local clients only ON this server */
rb_dlink_list serv_list; /* local servers to this server ONLY */
rb_dlink_list global_serv_list; /* global servers on the network */
rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */
rb_dlink_list oper_list; /* network opers */
time_t startup_time;
int default_server_capabs = CAP_MASK;
int splitmode;
int splitchecking;
int split_users;
int split_servers;
int eob_count;
unsigned long initialVMTop = 0; /* top of virtual memory at init */
const char *logFileName = LPATH;
const char *pidFileName = PPATH;
@ -119,27 +108,15 @@ int ssl_ok = 0;
int zlib_ok = 1;
int testing_conf = 0;
time_t startup_time;
struct config_channel_entry ConfigChannel;
rb_bh *channel_heap;
rb_bh *ban_heap;
rb_bh *topic_heap;
rb_bh *member_heap;
int default_server_capabs = CAP_MASK;
rb_bh *client_heap = NULL;
rb_bh *lclient_heap = NULL;
rb_bh *pclient_heap = NULL;
char current_uid[IDLEN];
/* patricia */
rb_bh *prefix_heap;
rb_bh *node_heap;
rb_bh *patricia_heap;
rb_bh *linebuf_heap;
rb_bh *dnode_heap;
int splitmode;
int splitchecking;
int split_users;
int split_servers;
int eob_count;
void
ircd_shutdown(const char *reason)
@ -192,39 +169,6 @@ print_startup(int pid)
dup2(0, 2);
}
static void
ircd_log_cb(const char *str)
{
ilog(L_MAIN, "%s", str);
}
static void
ircd_restart_cb(const char *str)
{
restart(str);
}
/*
* Why EXIT_FAILURE here?
* Because if ircd_die_cb() is called it's because of a fatal
* error inside libcharybdis, and we don't know how to handle the
* exception, so it is logical to return a FAILURE exit code here.
* --nenolod
*/
static void
ircd_die_cb(const char *str)
{
if(str != NULL)
{
/* Try to get the message out to currently logged in operators. */
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Server panic! %s", str);
inotice("server panic: %s", str);
}
unlink(pidFileName);
exit(EXIT_FAILURE);
}
/*
* init_sys
*
@ -500,6 +444,39 @@ setup_corefile(void)
#endif
}
static void
ircd_log_cb(const char *str)
{
ilog(L_MAIN, "%s", str);
}
static void
ircd_restart_cb(const char *str)
{
restart(str);
}
/*
* Why EXIT_FAILURE here?
* Because if ircd_die_cb() is called it's because of a fatal
* error inside libcharybdis, and we don't know how to handle the
* exception, so it is logical to return a FAILURE exit code here.
* --nenolod
*/
static void
ircd_die_cb(const char *str)
{
if(str != NULL)
{
/* Try to get the message out to currently logged in operators. */
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Server panic! %s", str);
inotice("server panic: %s", str);
}
unlink(pidFileName);
exit(EXIT_FAILURE);
}
struct ev_entry *check_splitmode_ev = NULL;
static int
@ -564,13 +541,34 @@ main(int argc, char *argv[])
return -1;
}
init_sys();
ConfigFileEntry.dpath = DPATH;
ConfigFileEntry.configfile = CPATH; /* Server configuration file */
ConfigFileEntry.klinefile = KPATH; /* Server kline file */
ConfigFileEntry.dlinefile = DLPATH; /* dline file */
ConfigFileEntry.xlinefile = XPATH;
ConfigFileEntry.resvfile = RESVPATH;
ConfigFileEntry.connect_timeout = 30; /* Default to 30 */
umask(077); /* better safe than sorry --SRB */
myargv = argv;
parseargs(&argc, &argv, myopts);
if(chdir(ConfigFileEntry.dpath))
{
fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno));
exit(EXIT_FAILURE);
}
rb_set_time();
/*
* Setup corefile size immediately after boot -kre
*/
setup_corefile();
/* It ain't random, but it ought to be a little harder to guess */
srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
memset(&me, 0, sizeof(me));
memset(&meLocalUser, 0, sizeof(meLocalUser));
me.localClient = &meLocalUser;
@ -593,36 +591,16 @@ main(int argc, char *argv[])
/* Initialise the channel capability usage counts... */
init_chcap_usage_counts();
ConfigFileEntry.dpath = DPATH;
ConfigFileEntry.configfile = CPATH; /* Server configuration file */
ConfigFileEntry.klinefile = KPATH; /* Server kline file */
ConfigFileEntry.dlinefile = DLPATH; /* dline file */
ConfigFileEntry.xlinefile = XPATH;
ConfigFileEntry.resvfile = RESVPATH;
ConfigFileEntry.connect_timeout = 30; /* Default to 30 */
myargv = argv;
umask(077); /* better safe than sorry --SRB */
parseargs(&argc, &argv, myopts);
if(printVersion)
{
printf("ircd: version %s(%s)\n", ircd_version, serno);
exit(EXIT_SUCCESS);
}
if(chdir(ConfigFileEntry.dpath))
{
fprintf(stderr, "Unable to chdir to %s: %s\n", ConfigFileEntry.dpath, strerror(errno));
exit(EXIT_FAILURE);
}
setup_signals();
#ifdef __CYGWIN__
server_state_foreground = 1;
#endif
if (testing_conf)
server_state_foreground = 1;
@ -647,7 +625,6 @@ main(int argc, char *argv[])
}
/* Init the event subsystem */
init_sys();
rb_lib_init(ircd_log_cb, ircd_restart_cb, ircd_die_cb, !server_state_foreground, maxconnections, DNODE_HEAP_SIZE, FD_HEAP_SIZE);
rb_linebuf_init(LINEBUF_HEAP_SIZE);
@ -660,7 +637,6 @@ main(int argc, char *argv[])
init_host_hash();
clear_hash_parse();
init_client();
initUser();
init_hook();
init_channels();
initclass();
@ -760,12 +736,12 @@ main(int argc, char *argv[])
* nick collisions. what a stupid idea. set an event for the IO loop --fl
*/
rb_event_addish("try_connections", try_connections, NULL, STARTUP_CONNECTIONS_TIME);
rb_event_addonce("try_connections_startup", try_connections, NULL, 0);
rb_event_add("check_rehash", check_rehash, NULL, 1);
rb_event_addonce("try_connections_startup", try_connections, NULL, 2);
rb_event_add("check_rehash", check_rehash, NULL, 3);
rb_event_addish("reseed_srand", seed_random, NULL, 300); /* reseed every 10 minutes */
if(splitmode)
check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 2);
check_splitmode_ev = rb_event_add("check_splitmode", check_splitmode, NULL, 5);
print_startup(getpid());

View file

@ -110,7 +110,7 @@ parse_k_file(FILE * file)
user_field, operreason_field, date_field);
if(aconf->host != NULL)
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, NULL, aconf);
}
}

View file

@ -435,7 +435,7 @@ close_listeners()
* any client list yet.
*/
static void
add_connection(struct Listener *listener, rb_fde_t *F, struct sockaddr *sai, void *ssl_ctl, int exempt)
add_connection(struct Listener *listener, rb_fde_t *F, struct sockaddr *sai, void *ssl_ctl)
{
struct Client *new_client;
s_assert(NULL != listener);
@ -467,17 +467,11 @@ add_connection(struct Listener *listener, rb_fde_t *F, struct sockaddr *sai, voi
++listener->ref_count;
if(!exempt)
{
if(check_reject(new_client))
return;
if(add_unknown_ip(new_client))
return;
}
start_auth(new_client);
}
static const char *toofast = "ERROR :Reconnecting too fast, throttled.\r\n";
static int
accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, void *data)
{
@ -512,7 +506,7 @@ accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, voi
return 0;
}
aconf = find_dline(addr, AF_INET);
aconf = find_dline(addr, addr->sa_family);
if(aconf != NULL && (aconf->status & CONF_EXEMPTDLINE))
return 1;
@ -539,6 +533,16 @@ accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, voi
return 0;
}
if(check_reject(F, addr))
return 0;
if(throttle_add(addr))
{
rb_write(F, toofast, strlen(toofast));
rb_close(F);
return 0;
}
return 1;
}
@ -549,7 +553,7 @@ accept_ssld(rb_fde_t *F, struct sockaddr *addr, struct sockaddr *laddr, struct L
rb_fde_t *xF[2];
rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Incoming ssld Connection");
ctl = start_ssld_accept(F, xF[1], rb_get_fd(xF[0])); /* this will close F for us */
add_connection(listener, xF[0], addr, ctl, 1);
add_connection(listener, xF[0], addr, ctl);
}
static void
@ -571,5 +575,5 @@ accept_callback(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t add
if(listener->ssl)
accept_ssld(F, addr, (struct sockaddr *)&lip, listener);
else
add_connection(listener, F, addr, NULL, 1);
add_connection(listener, F, addr, NULL);
}

View file

@ -24,7 +24,7 @@ static const char * replies[] = {
/* 001 RPL_WELCOME, */ ":Welcome to the %s Internet Relay Chat Network %s",
/* 002 RPL_YOURHOST,*/ ":Your host is %s, running version %s",
/* 003 RPL_CREATED, */ ":This server was created %s",
/* 004 RPL_MYINFO, */ "%s %s %s biklmnopstveqrcgzjfILPQF bkloveqjfI",
/* 004 RPL_MYINFO, */ "%s %s %s %s bkloveqjfI",
/* 005 RPL_ISUPPORT, */ "%s :are supported by this server",
/* 006 */ NULL,
/* 007 */ NULL,
@ -235,7 +235,7 @@ static const char * replies[] = {
/* 212 RPL_STATSCOMMANDS, */ "%s %u %u :%u",
/* 213 RPL_STATSCLINE, */ "C %s %s %s %d %s",
/* 214 RPL_STATSNLINE, */ NULL,
/* 215 RPL_STATSILINE, */ "I %s * %s@%s %d %s",
/* 215 RPL_STATSILINE, */ "I %s %s %s@%s %d %s",
/* 216 RPL_STATSKLINE, */ "%c %s * %s :%s%s%s",
/* 217 RPL_STATSQLINE, */ "%c %d %s :%s",
/* 218 RPL_STATSYLINE, */ "Y %s %d %d %d %u %d.%d %d.%d %u",

View file

@ -846,7 +846,7 @@ conf_end_auth(struct TopConf *tc)
collapse(yy_aconf->user);
collapse(yy_aconf->host);
conf_add_class_to_conf(yy_aconf);
add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf);
add_conf_by_address(yy_aconf->host, CONF_CLIENT, yy_aconf->user, yy_aconf->spasswd, yy_aconf);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_aconf_list.head)
{
@ -855,6 +855,9 @@ conf_end_auth(struct TopConf *tc)
if(yy_aconf->passwd)
yy_tmp->passwd = rb_strdup(yy_aconf->passwd);
if(yy_aconf->spasswd)
yy_tmp->spasswd = rb_strdup(yy_aconf->spasswd);
/* this will always exist.. */
yy_tmp->name = rb_strdup(yy_aconf->name);
@ -869,7 +872,7 @@ conf_end_auth(struct TopConf *tc)
conf_add_class_to_conf(yy_tmp);
add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp);
add_conf_by_address(yy_tmp->host, CONF_CLIENT, yy_tmp->user, yy_tmp->spasswd, yy_tmp);
rb_dlinkDestroy(ptr, &yy_aconf_list);
}
@ -909,6 +912,15 @@ conf_set_auth_user(void *data)
rb_dlinkAddAlloc(yy_tmp, &yy_aconf_list);
}
static void
conf_set_auth_auth_user(void *data)
{
if(yy_aconf->spasswd)
memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
rb_free(yy_aconf->spasswd);
yy_aconf->spasswd = rb_strdup(data);
}
static void
conf_set_auth_passwd(void *data)
{
@ -1318,7 +1330,7 @@ conf_set_exempt_ip(void *data)
yy_tmp->passwd = rb_strdup("*");
yy_tmp->host = rb_strdup(data);
yy_tmp->status = CONF_EXEMPTDLINE;
add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, yy_tmp);
add_conf_by_address(yy_tmp->host, CONF_EXEMPTDLINE, NULL, NULL, yy_tmp);
}
static int
@ -1978,6 +1990,7 @@ static struct ConfEntry conf_class_table[] =
static struct ConfEntry conf_auth_table[] =
{
{ "user", CF_QSTRING, conf_set_auth_user, 0, NULL },
{ "auth_user", CF_QSTRING, conf_set_auth_auth_user, 0, NULL },
{ "password", CF_QSTRING, conf_set_auth_passwd, 0, NULL },
{ "class", CF_QSTRING, conf_set_auth_class, 0, NULL },
{ "spoof", CF_QSTRING, conf_set_auth_spoof, 0, NULL },
@ -2051,7 +2064,6 @@ static struct ConfEntry conf_general_table[] =
{ "max_nick_time", CF_TIME, NULL, 0, &ConfigFileEntry.max_nick_time },
{ "max_nick_changes", CF_INT, NULL, 0, &ConfigFileEntry.max_nick_changes },
{ "max_targets", CF_INT, NULL, 0, &ConfigFileEntry.max_targets },
{ "max_unknown_ip", CF_INT, NULL, 0, &ConfigFileEntry.max_unknown_ip },
{ "min_nonwildcard", CF_INT, NULL, 0, &ConfigFileEntry.min_nonwildcard },
{ "nick_delay", CF_TIME, NULL, 0, &ConfigFileEntry.nick_delay },
{ "no_oper_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.no_oper_flood },
@ -2063,6 +2075,8 @@ static struct ConfEntry conf_general_table[] =
{ "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count },
{ "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time },
{ "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration },
{ "throttle_count", CF_INT, NULL, 0, &ConfigFileEntry.throttle_count },
{ "throttle_duration", CF_TIME, NULL, 0, &ConfigFileEntry.throttle_duration },
{ "short_motd", CF_YESNO, NULL, 0, &ConfigFileEntry.short_motd },
{ "stats_c_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_c_oper_only },
{ "stats_e_disabled", CF_YESNO, NULL, 0, &ConfigFileEntry.stats_e_disabled },

View file

@ -181,10 +181,10 @@ flood_recalc(void *unused)
{
client_p = ptr->data;
if(unlikely(IsMe(client_p)))
if(rb_unlikely(IsMe(client_p)))
continue;
if(unlikely(client_p->localClient == NULL))
if(rb_unlikely(client_p->localClient == NULL))
continue;
if(IsFloodDone(client_p))
@ -200,7 +200,7 @@ flood_recalc(void *unused)
parse_client_queued(client_p);
if(unlikely(IsAnyDead(client_p)))
if(rb_unlikely(IsAnyDead(client_p)))
continue;
}

View file

@ -508,7 +508,7 @@ cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
sendto_realops_snomask(SNO_DEBUG, L_ALL,
"Message for %s[%s] from %s",
source_p->name, source_p->from->name,
get_server_name(client_p, SHOW_IP));
client_p->name);
}
else
{
@ -518,7 +518,7 @@ cancel_clients(struct Client *client_p, struct Client *source_p, char *cmd)
source_p->username,
source_p->host,
source_p->from->name,
get_server_name(client_p, SHOW_IP));
client_p->name);
}
}
@ -533,7 +533,7 @@ remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
{
int slen = strlen(lsender);
/* meepfoo is a nickname (KILL)
/* meepfoo is a nickname (ignore)
* #XXXXXXXX is a UID (KILL)
* #XX is a SID (SQUIT)
* meep.foo is a server (SQUIT)
@ -543,14 +543,14 @@ remove_unknown(struct Client *client_p, char *lsender, char *lbuffer)
{
sendto_realops_snomask(SNO_DEBUG, L_ALL,
"Unknown prefix (%s) from %s, Squitting %s",
lbuffer, get_server_name(client_p, SHOW_IP), lsender);
lbuffer, client_p->name, lsender);
sendto_one(client_p,
":%s SQUIT %s :(Unknown prefix (%s) from %s)",
get_id(&me, client_p), lsender,
lbuffer, client_p->name);
}
else
else if(IsDigit(lsender[0]))
sendto_one(client_p, ":%s KILL %s :%s (Unknown Client)",
get_id(&me, client_p), lsender, me.name);
}

View file

@ -17,70 +17,79 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
* $Id: reject.c 3456 2007-05-18 19:14:18Z jilles $
* $Id: reject.c 25119 2008-03-13 16:57:05Z androsyn $
*/
#include "stdinc.h"
#include "config.h"
#include "client.h"
#include "s_conf.h"
#include "reject.h"
#include "s_stats.h"
#include "msg.h"
#include "ircd.h"
#include "send.h"
#include "numeric.h"
#include "parse.h"
#include "hostmask.h"
#include "match.h"
#include "hash.h"
static rb_patricia_tree_t *global_tree;
static rb_patricia_tree_t *reject_tree;
rb_dlink_list delay_exit;
static rb_dlink_list delay_exit;
static rb_dlink_list reject_list;
static rb_dlink_list throttle_list;
static rb_patricia_tree_t *throttle_tree;
static void throttle_expires(void *unused);
static rb_patricia_tree_t *unknown_tree;
struct reject_data
typedef struct _reject_data
{
rb_dlink_node rnode;
time_t time;
unsigned int count;
uint32_t mask_hashv;
};
} reject_t;
typedef struct _delay_data
{
rb_dlink_node node;
rb_fde_t *F;
} delay_t;
typedef struct _throttle
{
rb_dlink_node node;
time_t last;
int count;
} throttle_t;
unsigned long
delay_exit_length(void)
{
return rb_dlink_list_length(&delay_exit);
}
static void
reject_exit(void *unused)
{
struct Client *client_p;
rb_dlink_node *ptr, *ptr_next;
delay_t *ddata;
static const char *errbuf = "ERROR :Closing Link: (*** Banned (cache))\r\n";
RB_DLINK_FOREACH_SAFE(ptr, ptr_next, delay_exit.head)
{
client_p = ptr->data;
if(IsDead(client_p))
continue;
ddata = ptr->data;
/* this MUST be here, to prevent the possibility
* sendto_one() generates a write error, and then a client
* ends up on the dead_list and the abort_list --fl
*
* new disconnect notice stolen from ircu --nenolod
* no, this only happens when someone's IP has some
* ban on it and rejects them rather longer than the
* ircu message suggests --jilles
*/
if(!IsIOError(client_p))
{
if(IsExUnknown(client_p))
sendto_one(client_p, "ERROR :Closing Link: %s (*** Too many unknown connections)", client_p->host);
else
sendto_one(client_p, "ERROR :Closing Link: %s (*** Banned (cache))", client_p->host);
}
close_connection(client_p);
SetDead(client_p);
rb_dlinkAddAlloc(client_p, &dead_list);
rb_write(ddata->F, errbuf, strlen(errbuf));
rb_close(ddata->F);
rb_free(ddata);
}
delay_exit.head = delay_exit.tail = NULL;
delay_exit.length = 0;
delay_exit.head = delay_exit.tail = NULL;
delay_exit.length = 0;
}
static void
@ -88,7 +97,7 @@ reject_expires(void *unused)
{
rb_dlink_node *ptr, *next;
rb_patricia_node_t *pnode;
struct reject_data *rdata;
reject_t *rdata;
RB_DLINK_FOREACH_SAFE(ptr, next, reject_list.head)
{
@ -108,9 +117,10 @@ void
init_reject(void)
{
reject_tree = rb_new_patricia(PATRICIA_BITS);
unknown_tree = rb_new_patricia(PATRICIA_BITS);
throttle_tree = rb_new_patricia(PATRICIA_BITS);
rb_event_add("reject_exit", reject_exit, NULL, DELAYED_EXIT_TIME);
rb_event_add("reject_expires", reject_expires, NULL, 60);
rb_event_add("throttle_expires", throttle_expires, NULL, 10);
}
@ -118,18 +128,18 @@ void
add_reject(struct Client *client_p, const char *mask1, const char *mask2)
{
rb_patricia_node_t *pnode;
struct reject_data *rdata;
reject_t *rdata;
uint32_t hashv;
/* Reject is disabled */
if(ConfigFileEntry.reject_after_count == 0 || ConfigFileEntry.reject_ban_time == 0)
if(ConfigFileEntry.reject_after_count == 0 || ConfigFileEntry.reject_duration == 0)
return;
hashv = 0;
if (mask1 != NULL)
hashv ^= fnv_hash_upper(mask1, 32);
hashv ^= fnv_hash_upper((const unsigned char *)mask1, 32);
if (mask2 != NULL)
hashv ^= fnv_hash_upper(mask2, 32);
hashv ^= fnv_hash_upper((const unsigned char *)mask2, 32);
if((pnode = rb_match_ip(reject_tree, (struct sockaddr *)&client_p->localClient->ip)) != NULL)
{
@ -141,11 +151,11 @@ add_reject(struct Client *client_p, const char *mask1, const char *mask2)
{
int bitlen = 32;
#ifdef RB_IPV6
if(client_p->localClient->ip.ss_family == AF_INET6)
if(GET_SS_FAMILY(&client_p->localClient->ip) == AF_INET6)
bitlen = 128;
#endif
pnode = make_and_lookup_ip(reject_tree, (struct sockaddr *)&client_p->localClient->ip, bitlen);
pnode->data = rdata = rb_malloc(sizeof(struct reject_data));
pnode->data = rdata = rb_malloc(sizeof(reject_t));
rb_dlinkAddTail(pnode, &rdata->rnode, &reject_list);
rdata->time = rb_current_time();
rdata->count = 1;
@ -154,29 +164,28 @@ add_reject(struct Client *client_p, const char *mask1, const char *mask2)
}
int
check_reject(struct Client *client_p)
check_reject(rb_fde_t *F, struct sockaddr *addr)
{
rb_patricia_node_t *pnode;
struct reject_data *rdata;
reject_t *rdata;
delay_t *ddata;
/* Reject is disabled */
if(ConfigFileEntry.reject_after_count == 0 || ConfigFileEntry.reject_ban_time == 0 ||
ConfigFileEntry.reject_duration == 0)
if(ConfigFileEntry.reject_after_count == 0 || ConfigFileEntry.reject_duration == 0)
return 0;
pnode = rb_match_ip(reject_tree, (struct sockaddr *)&client_p->localClient->ip);
pnode = rb_match_ip(reject_tree, addr);
if(pnode != NULL)
{
rdata = pnode->data;
rdata->time = rb_current_time();
if(rdata->count > ConfigFileEntry.reject_after_count)
if(rdata->count > (unsigned long)ConfigFileEntry.reject_after_count)
{
ddata = rb_malloc(sizeof(delay_t));
ServerStats.is_rej++;
SetReject(client_p);
rb_setselect(client_p->localClient->F, RB_SELECT_WRITE | RB_SELECT_READ, NULL, NULL);
SetClosing(client_p);
rb_dlinkMoveNode(&client_p->localClient->tnode, &unknown_list, &delay_exit);
rb_setselect(F, RB_SELECT_WRITE | RB_SELECT_READ, NULL, NULL);
ddata->F = F;
rb_dlinkAdd(ddata, &ddata->node, &delay_exit);
return 1;
}
}
@ -189,7 +198,7 @@ flush_reject(void)
{
rb_dlink_node *ptr, *next;
rb_patricia_node_t *pnode;
struct reject_data *rdata;
reject_t *rdata;
RB_DLINK_FOREACH_SAFE(ptr, next, reject_list.head)
{
@ -207,13 +216,12 @@ remove_reject_ip(const char *ip)
rb_patricia_node_t *pnode;
/* Reject is disabled */
if(ConfigFileEntry.reject_after_count == 0 || ConfigFileEntry.reject_ban_time == 0 ||
ConfigFileEntry.reject_duration == 0)
if(ConfigFileEntry.reject_after_count == 0 || ConfigFileEntry.reject_duration == 0)
return -1;
if((pnode = rb_match_string(reject_tree, ip)) != NULL)
{
struct reject_data *rdata = pnode->data;
reject_t *rdata = pnode->data;
rb_dlinkDelete(&rdata->rnode, &reject_list);
rb_free(rdata);
rb_patricia_remove(reject_tree, pnode);
@ -227,15 +235,15 @@ remove_reject_mask(const char *mask1, const char *mask2)
{
rb_dlink_node *ptr, *next;
rb_patricia_node_t *pnode;
struct reject_data *rdata;
reject_t *rdata;
uint32_t hashv;
int n = 0;
hashv = 0;
if (mask1 != NULL)
hashv ^= fnv_hash_upper(mask1, 32);
hashv ^= fnv_hash_upper((const unsigned char *)mask1, 32);
if (mask2 != NULL)
hashv ^= fnv_hash_upper(mask2, 32);
hashv ^= fnv_hash_upper((const unsigned char *)mask2, 32);
RB_DLINK_FOREACH_SAFE(ptr, next, reject_list.head)
{
pnode = ptr->data;
@ -251,50 +259,57 @@ remove_reject_mask(const char *mask1, const char *mask2)
return n;
}
int
add_unknown_ip(struct Client *client_p)
throttle_add(struct sockaddr *addr)
{
throttle_t *t;
rb_patricia_node_t *pnode;
if((pnode = rb_match_ip(unknown_tree, (struct sockaddr *)&client_p->localClient->ip)) == NULL)
if((pnode = rb_match_ip(throttle_tree, addr)) != NULL)
{
t = pnode->data;
if(t->count > ConfigFileEntry.throttle_count)
return 1;
/* Stop penalizing them after they've been throttled */
t->last = rb_current_time();
t->count++;
} else {
int bitlen = 32;
#ifdef RB_IPV6
if(client_p->localClient->ip.ss_family == AF_INET6)
if(GET_SS_FAMILY(addr) == AF_INET6)
bitlen = 128;
#endif
pnode = make_and_lookup_ip(unknown_tree, (struct sockaddr *)&client_p->localClient->ip, bitlen);
pnode->data = (void *)0;
}
if((unsigned long)pnode->data >= ConfigFileEntry.max_unknown_ip)
{
SetExUnknown(client_p);
SetReject(client_p);
rb_setselect(client_p->localClient->F, RB_SELECT_WRITE | RB_SELECT_READ, NULL, NULL);
SetClosing(client_p);
rb_dlinkMoveNode(&client_p->localClient->tnode, &unknown_list, &delay_exit);
return 1;
}
pnode->data = (void *)((unsigned long)pnode->data + 1);
t = rb_malloc(sizeof(throttle_t));
t->last = rb_current_time();
t->count = 1;
pnode = make_and_lookup_ip(throttle_tree, addr, bitlen);
pnode->data = t;
rb_dlinkAdd(pnode, &t->node, &throttle_list);
}
return 0;
}
void
del_unknown_ip(struct Client *client_p)
static void
throttle_expires(void *unused)
{
rb_dlink_node *ptr, *next;
rb_patricia_node_t *pnode;
if((pnode = rb_match_ip(unknown_tree, (struct sockaddr *)&client_p->localClient->ip)) != NULL)
throttle_t *t;
RB_DLINK_FOREACH_SAFE(ptr, next, throttle_list.head)
{
pnode->data = (void *)((unsigned long)pnode->data - 1);
if((unsigned long)pnode->data <= 0)
{
rb_patricia_remove(unknown_tree, pnode);
}
pnode = ptr->data;
t = pnode->data;
if(t->last + ConfigFileEntry.throttle_duration > rb_current_time())
continue;
rb_dlinkDelete(ptr, &throttle_list);
rb_free(t);
rb_patricia_remove(throttle_tree, pnode);
}
/* this can happen due to m_webirc.c's manipulations, for example */
}

124
src/res.c
View file

@ -60,7 +60,6 @@ struct reslist
{
rb_dlink_node node;
int id;
int sent; /* number of requests sent */
time_t ttl;
char type;
char queryname[128]; /* name currently being queried */
@ -68,6 +67,7 @@ struct reslist
char sends; /* number of sends (>1 means resent) */
time_t sentat;
time_t timeout;
unsigned int lastns; /* index of last server sent to */
struct rb_sockaddr_storage addr;
char *name;
struct DNSQuery *query; /* query callback for this request */
@ -75,6 +75,7 @@ struct reslist
static rb_fde_t *res_fd;
static rb_dlink_list request_list = { NULL, NULL, 0 };
static int ns_timeout_count[IRCD_MAXNS];
static void rem_request(struct reslist *request);
static struct reslist *make_request(struct DNSQuery *query);
@ -131,7 +132,10 @@ static int res_ourserver(const struct rb_sockaddr_storage *inp)
sizeof(struct in6_addr)) == 0) ||
(memcmp(&v6->sin6_addr.s6_addr, &in6addr_any,
sizeof(struct in6_addr)) == 0))
{
ns_timeout_count[ns] = 0;
return 1;
}
break;
#endif
case AF_INET:
@ -139,7 +143,10 @@ static int res_ourserver(const struct rb_sockaddr_storage *inp)
if (v4->sin_port == v4in->sin_port)
if ((v4->sin_addr.s_addr == INADDR_ANY)
|| (v4->sin_addr.s_addr == v4in->sin_addr.s_addr))
{
ns_timeout_count[ns] = 0;
return 1;
}
break;
default:
break;
@ -176,6 +183,7 @@ static time_t timeout_query_list(time_t now)
}
else
{
ns_timeout_count[request->lastns]++;
request->sentat = now;
request->timeout += request->timeout;
resend_query(request);
@ -207,7 +215,11 @@ static struct ev_entry *timeout_resolver_ev = NULL;
*/
static void start_resolver(void)
{
int i;
irc_res_init();
for (i = 0; i < irc_nscount; i++)
ns_timeout_count[i] = 0;
if (res_fd == NULL)
{
@ -315,33 +327,67 @@ void delete_resolver_queries(const struct DNSQuery *query)
}
/*
* send_res_msg - sends msg to all nameservers found in the "_res" structure.
* This should reflect /etc/resolv.conf. We will get responses
* which arent needed but is easier than checking to see if nameserver
* isnt present. Returns number of messages successfully sent to
* nameservers or -1 if no successful sends.
* retryfreq - determine how many queries to wait before resending
* if there have been that many consecutive timeouts
*/
static int retryfreq(int timeouts)
{
switch (timeouts)
{
case 1:
return 3;
case 2:
return 9;
case 3:
return 27;
case 4:
return 81;
default:
return 243;
}
}
/*
* send_res_msg - sends msg to a nameserver.
* This should reflect /etc/resolv.conf.
* Returns number of nameserver successfully sent to
* or -1 if no successful sends.
*/
static int send_res_msg(const char *msg, int len, int rcount)
{
int i;
int sent = 0;
int max_queries = IRCD_MIN(irc_nscount, rcount);
int ns;
static int retrycnt;
/* RES_PRIMARY option is not implemented
* if (res.options & RES_PRIMARY || 0 == max_queries)
retrycnt++;
/* First try a nameserver that seems to work.
* Every once in a while, try a possibly broken one to check
* if it is working again.
*/
if (max_queries == 0)
max_queries = 1;
for (i = 0; sent < max_queries && i < irc_nscount; i++)
for (i = 0; i < irc_nscount; i++)
{
ns = (i + rcount - 1) % irc_nscount;
if (ns_timeout_count[ns] && retrycnt % retryfreq(ns_timeout_count[ns]))
continue;
if (sendto(rb_get_fd(res_fd), msg, len, 0,
(struct sockaddr *)&(irc_nsaddr_list[i]),
GET_SS_LEN(&irc_nsaddr_list[i])) == len)
++sent;
(struct sockaddr *)&(irc_nsaddr_list[ns]),
GET_SS_LEN(&irc_nsaddr_list[ns])) == len)
return ns;
}
return (sent);
/* No known working nameservers, try some broken one. */
for (i = 0; i < irc_nscount; i++)
{
ns = (i + rcount - 1) % irc_nscount;
if (!ns_timeout_count[ns])
continue;
if (sendto(rb_get_fd(res_fd), msg, len, 0,
(struct sockaddr *)&(irc_nsaddr_list[ns]),
GET_SS_LEN(&irc_nsaddr_list[ns])) == len)
return ns;
}
return -1;
}
/*
@ -465,6 +511,7 @@ static void query_name(struct reslist *request)
{
char buf[MAXPACKET];
int request_len = 0;
int ns;
memset(buf, 0, sizeof(buf));
@ -498,7 +545,9 @@ static void query_name(struct reslist *request)
request->id = header->id;
++request->sends;
request->sent += send_res_msg(buf, request_len, request->sends);
ns = send_res_msg(buf, request_len, request->sends);
if (ns != -1)
request->lastns = ns;
}
}
@ -682,9 +731,10 @@ static int proc_answer(struct reslist *request, HEADER * header, char *buf, char
}
/*
* res_readreply - read a dns reply from the nameserver and process it.
* res_read_single_reply - read a dns reply from the nameserver and process it.
* Return value: 1 if a packet was read, 0 otherwise
*/
static void res_readreply(rb_fde_t *F, void *data)
static int res_read_single_reply(rb_fde_t *F, void *data)
{
char buf[sizeof(HEADER) + MAXPACKET]
/* Sparc and alpha need 16bit-alignment for accessing header->id
@ -705,13 +755,13 @@ static void res_readreply(rb_fde_t *F, void *data)
rc = recvfrom(rb_get_fd(F), buf, sizeof(buf), 0, (struct sockaddr *)&lsin, &len);
/* Re-schedule a read *after* recvfrom, or we'll be registering
* interest where it'll instantly be ready for read :-) -- adrian
*/
rb_setselect(F, RB_SELECT_READ, res_readreply, NULL);
/* Better to cast the sizeof instead of rc */
/* No packet */
if (rc == 0 || rc == -1)
return 0;
/* Too small */
if (rc <= (int)(sizeof(HEADER)))
return;
return 1;
/*
* convert DNS reply reader from Network byte order to CPU byte order.
@ -727,16 +777,16 @@ static void res_readreply(rb_fde_t *F, void *data)
* just ignore this response.
*/
if (0 == (request = find_id(header->id)))
return;
return 1;
/*
* check against possibly fake replies
*/
if (!res_ourserver(&lsin))
return;
return 1;
if (!check_question(request, header, buf, buf + rc))
return;
return 1;
if ((header->rcode != NO_ERRORS) || (header->ancount == 0))
{
@ -754,7 +804,7 @@ static void res_readreply(rb_fde_t *F, void *data)
(*request->query->callback) (request->query->ptr, NULL);
rem_request(request);
}
return;
return 1;
}
/*
* If this fails there was an error decoding the received packet,
@ -774,7 +824,7 @@ static void res_readreply(rb_fde_t *F, void *data)
*/
(*request->query->callback) (request->query->ptr, reply);
rem_request(request);
return;
return 1;
}
/*
@ -807,6 +857,14 @@ static void res_readreply(rb_fde_t *F, void *data)
(*request->query->callback) (request->query->ptr, NULL);
rem_request(request);
}
return 1;
}
static void res_readreply(rb_fde_t *F, void *data)
{
while (res_read_single_reply(F, data))
;
rb_setselect(F, RB_SELECT_READ, res_readreply, NULL);
}
static struct DNSReply *make_dnsreply(struct reslist *request)
@ -832,6 +890,6 @@ void report_dns_servers(struct Client *source_p)
ipaddr, sizeof ipaddr))
rb_strlcpy(ipaddr, "?", sizeof ipaddr);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"A %s", ipaddr);
"A %s %d", ipaddr, ns_timeout_count[i]);
}
}

View file

@ -45,9 +45,6 @@ restart(const char *mesg)
abort();
was_here = YES;
#if 0
ilog(L_MAIN, "Restarting Server because: %s, memory data limit: %ld", mesg, get_maxrss());
#endif
ilog(L_MAIN, "Restarting Server because: %s", mesg);
server_reboot();

View file

@ -308,7 +308,8 @@ verify_access(struct Client *client_p, const char *username)
aconf = find_address_conf(client_p->host, client_p->sockhost,
client_p->username, client_p->username,
(struct sockaddr *) &client_p->localClient->ip,
client_p->localClient->ip.ss_family);
client_p->localClient->ip.ss_family,
client_p->localClient->auth_user);
}
else
{
@ -317,7 +318,8 @@ verify_access(struct Client *client_p, const char *username)
aconf = find_address_conf(client_p->host, client_p->sockhost,
non_ident, client_p->username,
(struct sockaddr *) &client_p->localClient->ip,
client_p->localClient->ip.ss_family);
client_p->localClient->ip.ss_family,
client_p->localClient->auth_user);
}
if(aconf == NULL)
@ -818,7 +820,8 @@ set_default_conf(void)
ConfigFileEntry.reject_after_count = 5;
ConfigFileEntry.reject_ban_time = 300;
ConfigFileEntry.reject_duration = 120;
ConfigFileEntry.max_unknown_ip = 2;
ConfigFileEntry.throttle_count = 4;
ConfigFileEntry.throttle_duration = 60;
ServerInfo.default_max_clients = MAXCONNECTIONS;
}
@ -930,7 +933,7 @@ add_temp_kline(struct ConfItem *aconf)
}
aconf->flags |= CONF_FLAGS_TEMPORARY;
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, aconf);
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, NULL, aconf);
}
/* add_temp_dline()
@ -964,7 +967,7 @@ add_temp_dline(struct ConfItem *aconf)
}
aconf->flags |= CONF_FLAGS_TEMPORARY;
add_conf_by_address(aconf->host, CONF_DLINE, aconf->user, aconf);
add_conf_by_address(aconf->host, CONF_DLINE, aconf->user, NULL, aconf);
}
/* expire_tkline()
@ -1474,7 +1477,7 @@ conf_add_d_conf(struct ConfItem *aconf)
}
else
{
add_conf_by_address(aconf->host, CONF_DLINE, NULL, aconf);
add_conf_by_address(aconf->host, CONF_DLINE, NULL, NULL, aconf);
}
}

View file

@ -55,8 +55,6 @@
#include "reject.h"
#include "sslproc.h"
extern char *crypt();
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned int) 0xffffffff)
#endif
@ -297,15 +295,9 @@ try_connections(void *unused)
* error afterwards if it fails.
* -- adrian
*/
#ifndef HIDE_SERVERS_IPS
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Connection to %s[%s] activated.",
server_p->name, server_p->host);
#else
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Connection to %s activated",
server_p->name);
#endif
serv_connect(server_p, 0);
}
@ -349,7 +341,7 @@ check_server(const char *name, struct Client *client_p)
if(ServerConfEncrypted(tmp_p))
{
if(!strcmp(tmp_p->passwd, crypt(client_p->localClient->passwd,
if(!strcmp(tmp_p->passwd, rb_crypt(client_p->localClient->passwd,
tmp_p->passwd)))
{
server_p = tmp_p;
@ -768,7 +760,6 @@ server_estab(struct Client *client_p)
set_chcap_usage_counts(client_p);
rb_dlinkAdd(client_p, &client_p->lnode, &me.serv->servers);
del_unknown_ip(client_p);
rb_dlinkMoveNode(&client_p->localClient->tnode, &unknown_list, &serv_list);
rb_dlinkAddTailAlloc(client_p, &global_serv_list);
@ -800,7 +791,7 @@ server_estab(struct Client *client_p)
/* Show the real host/IP to admins */
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Link with %s established: (%s) link",
get_server_name(client_p, SHOW_IP),
client_p->name,
show_capabilities(client_p));
ilog(L_SERVER, "Link with %s established: (%s) link",
@ -924,7 +915,7 @@ serv_connect_resolved(struct Client *client_p)
if((server_p = client_p->localClient->att_sconf) == NULL)
{
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL, "Lost connect{} block for %s",
get_server_name(client_p, HIDE_IP));
client_p->name);
exit_client(client_p, client_p, &me, "Lost connect{} block");
return 0;
}
@ -1017,7 +1008,7 @@ serv_connect_dns_callback(void *vptr, struct DNSReply *reply)
if (reply == NULL)
{
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL, "Cannot resolve hostname for %s",
get_server_name(client_p, HIDE_IP));
client_p->name);
ilog(L_SERVER, "Cannot resolve hostname for %s",
log_client_name(client_p, HIDE_IP));
exit_client(client_p, client_p, &me, "Cannot resolve hostname");
@ -1078,10 +1069,10 @@ serv_connect(struct server_conf *server_p, struct Client *by)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Server %s already present from %s",
server_p->name, get_server_name(client_p, SHOW_IP));
server_p->name, client_p->name);
if(by && IsPerson(by) && !MyClient(by))
sendto_one_notice(by, ":Server %s already present from %s",
server_p->name, get_server_name(client_p, SHOW_IP));
server_p->name, client_p->name);
return 0;
}
@ -1184,24 +1175,18 @@ serv_connect(struct server_conf *server_p, struct Client *by)
}
}
static void
serv_connect_ev(void *data)
{
struct Client *client_p = data;
serv_connect_callback(client_p->localClient->F, RB_OK, client_p);
}
static void
serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
{
struct Client *client_p = data;
rb_fde_t *xF[2];
rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
if(status != RB_OK)
{
/* XXX deal with failure */
/* Print error message, just like non-SSL. */
serv_connect_callback(F, status, data);
return;
}
rb_connect_sockaddr(F, (struct sockaddr *)&client_p->localClient->ip, sizeof(client_p->localClient->ip));
rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &xF[0], &xF[1], "Outgoing ssld connection");
del_from_cli_fd_hash(client_p);
client_p->localClient->F = xF[0];
@ -1209,7 +1194,7 @@ serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0]));
SetSSL(client_p);
rb_event_addonce("serv_connect_ev", serv_connect_ev, client_p, 1);
serv_connect_callback(client_p->localClient->F, RB_OK, client_p);
}
/*
@ -1258,11 +1243,7 @@ serv_connect_callback(rb_fde_t *F, int status, void *data)
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
"Error connecting to %s[%s]: %s",
client_p->name,
#ifdef HIDE_SERVERS_IPS
"255.255.255.255",
#else
client_p->host,
#endif
rb_errstr(status));
ilog(L_SERVER, "Error connecting to %s[%s]: %s",
client_p->name, client_p->sockhost,
@ -1274,11 +1255,7 @@ serv_connect_callback(rb_fde_t *F, int status, void *data)
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
"Error connecting to %s[%s]: %s (%s)",
client_p->name,
#ifdef HIDE_SERVERS_IPS
"255.255.255.255",
#else
client_p->host,
#endif
rb_errstr(status), errstr);
ilog(L_SERVER, "Error connecting to %s[%s]: %s (%s)",
client_p->name, client_p->sockhost,
@ -1294,7 +1271,7 @@ serv_connect_callback(rb_fde_t *F, int status, void *data)
if((server_p = client_p->localClient->att_sconf) == NULL)
{
sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL, "Lost connect{} block for %s",
get_server_name(client_p, HIDE_IP));
client_p->name);
exit_client(client_p, client_p, &me, "Lost connect{} block");
return;
}

View file

@ -53,12 +53,11 @@
#include "snomask.h"
#include "blacklist.h"
#include "substitution.h"
#include "chmode.h"
static void report_and_set_user_flags(struct Client *, struct ConfItem *);
void user_welcome(struct Client *source_p);
extern char *crypt();
char umodebuf[128];
static int orphaned_umodes = 0;
@ -363,7 +362,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
if(EmptyString(source_p->localClient->passwd))
encr = "";
else if(IsConfEncrypted(aconf))
encr = crypt(source_p->localClient->passwd, aconf->passwd);
encr = rb_crypt(source_p->localClient->passwd, aconf->passwd);
else
encr = source_p->localClient->passwd;
@ -528,7 +527,6 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
Count.invisi++;
s_assert(!IsClient(source_p));
del_unknown_ip(source_p);
rb_dlinkMoveNode(&source_p->localClient->tnode, &unknown_list, &lclient_list);
SetClient(source_p);
@ -1187,7 +1185,7 @@ user_welcome(struct Client *source_p)
sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST),
get_listener_name(source_p->localClient->listener), ircd_version);
sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), creation);
sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, ircd_version, umodebuf);
sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, ircd_version, umodebuf, cflagsmyinfo);
show_isupport(source_p);

View file

@ -73,7 +73,7 @@ _send_linebuf(struct Client *to, buf_head_t *linebuf)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Max SendQ limit exceeded for %s: %u > %lu",
get_server_name(to, HIDE_IP),
to->name,
rb_linebuf_len(&to->localClient->buf_sendq),
get_sendq(to));

Some files were not shown because too many files have changed in this diff Show more