Commit Graph

1295 Commits

Author SHA1 Message Date
Alexander Barton 8644cbf197 Don't allow stray \r or \n in command parameters
If ngircd receives an input line like "COMMAND arg\nIRRELEVANT\r\n",
"arg\nIRRELEVANT" is passed as an argument to COMMAND. This can lead
to output like:

:ngircd.test.server 322 nick #chan 1 :
topicwithprecedingnewline
:ngircd.test.server 322 nick #nxtchan 1 :
[..]

Worse, this allows clients to piggyback irc commands, e.g.
"TOPIC #a :test\n:fake!~a@nonexistant JOIN :#a\r\n", which
causes the client to receive a JOIN command during /LIST output.

Bug reported by Scott Perry, first patch by Florian Westphal.
2008-05-30 14:58:25 +02:00
Alexander Barton 6f7b669bec --configtest: return non-zero exit code if there are errors 2008-05-28 00:31:20 +02:00
Alexander Barton 951314cb79 Handle_Buffer(): code cleanup.
Both callers ignore the return code of this function, so get rid of it,
but make sure that the client is disconnected on errors.
2008-05-26 23:38:32 +02:00
Alexander Barton d360871394 Conn_Handler(): cleanup code, add/translate comments.
In addition, the "timeout" variable has been removed because it is
unnecessary today: Handle_Buffer() handles all the data it can handle,
and io_dispatch() returns immediately when new data is available. So
we don't have to double-check but better sleep. Pointed out by Florian.
2008-05-26 21:38:27 +02:00
Scott Perry b90f71ca2a Use strtok_r instead of strchr in IRC_JOIN.
This patch does significant cleanup on the join code by using strtok_r
instead of mangling strchr to parse channel names and keys in parallel when
a JOIN command contains a list of channels and keys.

Also adds an strtok_r implementation to libportab.
2008-05-26 21:20:03 +02:00
Alexander Barton 956bbe2c28 Reset client idle time on NICK, JOIN, and PART 2008-05-24 21:50:54 +02:00
Florian Westphal e19f7a8c19 Remove ListenIPv4/ListenIPv6 options.
Use "Listen = list,of,addresses" instead.
2008-05-19 14:34:48 +02:00
Florian Westphal 4ed2cb1a02 make Listen parameter a comma-seperated list of addresses.
this also obsoletes ListenIPv4 and ListenIPv6 options.
If Listen is unset, it is treated as Listen="::,0.0.0.0".

Note: ListenIPv4 and ListenIPv6 options are still recognized,
but ngircd will print a warning if they are used in the config file.

Also, some plattforms require that ai_socktype
is set in the getaddrinfo() hints structure.
2008-05-19 14:27:35 +02:00
Jari Aalto 818a206a42 Add option aliases -V (for --version) and -h (for --help).
This patch adds -h and -V short options (to complement the usage).

It is based on a patch attached to Debian bug #466063, see
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466063>.

Idea by Jari Aalto <jari.aalto@cante.net>,
patch adapted by Alexander Barton <alex@barton.de>.
2008-05-18 16:19:41 +02:00
Brandon Beresini 5d87f6ba80 Add tests for MOTD, VERSION, TIME, USERHOST
The misc-test.e file is also somewhat reorganized and commented here.

Patch from Brandon Beresini, Bryan Caldwell and Dana Dahlstrom.
2008-05-15 11:13:45 +02:00
Alexander Barton d02b083543 Merge commit 'aad49bd260494878aed6795c7a897ad1d28c3082' 2008-05-13 12:14:14 +02:00
Scott Perry 70254a5553 This patch implements a (maybe) compliant WHOWAS command.
It is hard to test this in the test suite because we 1) shouldn't rely on
previous tests populating WHOWAS and 2) don't connect a user for more than 30
seconds.

Also makes WHOWAS return ERR_NONICKNAMEGIVEN_MSG as implied by RFC.
2008-05-12 18:56:31 +02:00
Florian Westphal b1d38de4d2 If bind() fails, also print ip address and not just the port number. 2008-05-12 18:46:55 +02:00
Alexander Barton d90cc7add0 GIT: ignore symbolic links to tests in testsuite directory
Added symbolic links to new tests (invite-test, join-test, and kick-test)
to .gitignore file.
2008-05-11 15:20:46 +02:00
Alexander Barton 149859c5fe Fixes to who-test: accept "localhost.<domain>" as well as "localhost"
Some operating systems, for example OpenBSD, use "localhost.<domain>"
instead of "localhost", so the "who-test" expecting "localhost" failed
on such systems.
2008-05-11 15:17:22 +02:00
Florian Westphal d9c26f3aeb ng_ipaddr.h must include netinet/in.h.
compile on FreeBSD 5.4 failed with:
./../ipaddr/ng_ipaddr.h:34: error: field `sin4' has incomplete type

Reported and tested by Jefferson S Almeida.
2008-05-10 21:49:51 +02:00
Brandon Beresini 0510bbe958 Removed space after # so that Cygwin's version of expect recognizes comments. 2008-05-09 21:54:47 +02:00
Ali Shemiran 12cd554af1 Fix secret channel information leak
/who on a secret channel that the user is not a member of
now returns proper RPL_ENDOFWHO_MSG instead of nothing.
2008-05-09 21:47:31 +02:00
ashemira@ucsd.edu 5cf5ba31eb Added Cygwin uid kludge. (verified working) 2008-05-08 13:04:25 +02:00
Eric Grunow 75b719a0c8 Anglified and improved comments in channel.c and channel.h
[Dana Dahlstrom: repair tab/space conversion in patch]
2008-05-08 03:15:04 +02:00
Alexander Barton 4e56e5341f Implement IRC commands SERVICE, SERVLIST, and SQUERY as dummy functions
SERVICE, SERVLIST, and SQUERY are required by RFC 2812 (it states in
section 3 that "all commands described in this section MUST be implemented
by any server for this protocol." -- So we implement them without (much)
actual functionality ...
2008-05-05 18:06:43 +02:00
Florian Westphal 3895b42d1b Add invite-test.e to test suite. 2008-05-05 16:12:41 +02:00
Dana Dahlstrom 6c81ffaece Tests for the INVITE command. 2008-05-05 16:12:41 +02:00
Dana Dahlstrom 97cc58fb13 Invite: prefix last argument with colon when necessary. 2008-05-05 16:12:41 +02:00
Dana Dahlstrom c63d8fd051 tests for JOIN and various replies
Brandon Beresini sent me a patch yesterday adding tests for JOIN under
various circumstances, which I believe he worked on with Bryan Caldwell
and Ali Shemiran. I made a few modifications; the result is below.
2008-05-05 16:12:41 +02:00
Bryan Caldwell 3d8eda9c86 Allow KICK to handle comma-delimited lists (of channels, nicks).
includes test cases.

[fw@strlen.de:
	- move code around to avoid duplication
	- use const where possible
	- integrate test case]
2008-05-05 16:12:41 +02:00
Florian Westphal 3283d275ba Invite: Send RPL_AWAY to client sending the invite if target is away. 2008-05-05 15:52:41 +02:00
Dana Dahlstrom faf9b6ea16 Fixes to who-test: accept any ident, escape some '*' flags.
This prevents who-test.e from failing when ngircd
is performing ident lookups and an ident server is running.
2008-05-05 15:40:00 +02:00
Florian Westphal 452fb28394 IRC_INVITE: coding style cleanup. 2008-05-05 15:39:54 +02:00
Florian Westphal 0428a1c4ea Constify some of Channel_Kick()s arguments. 2008-05-05 15:38:47 +02:00
Florian Westphal 98a8ea105c constify Client_Search() argument. 2008-05-05 15:38:43 +02:00
Rolf Eike Beer 83bfdddf99 Allow IRC ops to ignore channel limits when joining
Allow IRC ops to ignore any channel limit (bans, invite only etc.) when they
want to join a channel.
2008-05-05 14:45:28 +02:00
Alexander Barton 2a790861a1 Handle 1-character messages terminated with CR or LF correctly
Code cleanup and fix for Bug #83, "ngIRCd chokes on 1-character messages" in
function Handle_Buffer(): the buffer is now correctly cleared when ngIRCd
receives 1-character messages terminated with either CR or LF (in violation
to RFC 2812, section 2.3 "Messages", 5th paragraph).
2008-05-02 02:14:15 +02:00
Alexander Barton 4e507881f3 On AIX (for example) socklen_t is defined in sys/socket.h
On AIX and probably other systems socklen_t is defined in sys/socket.h,
so we have to include it here explicitly (tested by Florian).
2008-05-01 20:25:39 +02:00
Florian Westphal f7c2e8223f Always enable modeless channels.
Modeless channels (+channels) are described in RFC 2811;
so my modifications to
530112b114
('Add support for modeless channels')
to disable +channels for --strict-rfc configurations
were wrong. This reverts those changes.
2008-05-01 18:08:07 +02:00
Alexander Barton 60acc62af7 Prevent GIT to complain about opless-channel-test link 2008-05-01 16:31:13 +02:00
Ali Shemiran 530112b114 Add support for modeless channels
Add support for modeless channels (+channels).

[fw@strlen.de:
 - integrate test cases
 - don't support +channels when compiled with --strict-rfc
 - do not set +o mode for channel creator
 - force +nt mode when channel is created ]
2008-05-01 15:55:12 +02:00
Alexander Barton 4a81367dac --configtest: fix missing whitespace at "ConnectIPv4" option. 2008-04-29 15:27:44 +02:00
Alexander Barton bb6ee46892 Merge branch 'master' of git://git.breakpoint.cc/fw/ngircd-fw 2008-04-29 15:15:28 +02:00
Florian Westphal 9194319399 Testsuite: remove erroneous ConfUID setting in config file.
The config file for ngircds test suite contained obsolete
ConfUID/ConfGID settings, causing ngircd to needlesly complain when
started as non-root (which is hopefully the _normal_ case...)
2008-04-29 13:32:29 +02:00
Alexander Barton 33b1204349 Get rid of cvs-version.* and CVSDATE definition.
(cherry picked from commit b187fac244f4e14705f882ba7c43eef0238e2830)
2008-04-25 00:14:11 +02:00
Alexander Barton 523a6fad09 Report ERR_NOTONCHANNEL when trying to part a channel one is not member of.
When trying to part a channel ("PART #channel") the client is not member of
the daemon now correctly reports the numeric ERR_NOTONCHANNEL (442) insted
of ERR_NOSUCHCHANNEL (403).
2008-04-24 23:52:54 +02:00
Alexander Barton 54b17fc201 Channel_Part(): Code and comment cleanup. 2008-04-24 23:47:33 +02:00
Alexander Barton 25f48a2a34 IRC_PART(): code and comment cleanup. 2008-04-24 23:46:59 +02:00
Florian Westphal 22fa782be7 IPv6: Add config options to disabe ipv4/ipv6 support.
This also enables ipv6-only setups.
2008-04-21 00:45:19 +02:00
Alexander Barton a0efcdccfa Updated copyright notice to read "2001-2008". 2008-04-20 15:48:22 +02:00
Florian Westphal 8df445316a Channel_Mode: Remove duplicate code.
Incidentially, this doesn't even change the
generated code...
2008-04-19 16:58:00 +02:00
Florian Westphal 11af32466f Channel_Mode: change order of if (set) and if (client) check. 2008-04-19 16:51:42 +02:00
Florian Westphal 5538115537 Channel_Mode: Re-indent switch.
No functional changes were made.
2008-04-19 16:45:31 +02:00
Florian Westphal b8643477ba Channel_Mode: check return type of Invite/Ban Add/Del function 2008-04-19 16:17:11 +02:00
Florian Westphal 796dcf6a62 Channel_Mode: unify 'b' and 'I' switch/case handling. 2008-04-19 14:16:17 +02:00
Florian Westphal 6b0c094809 Channel_Mode: Unify Del_Invite and Del_Ban handler 2008-04-19 14:12:06 +02:00
Florian Westphal b36fc3b095 Constify Lists_MakeMask argument and return type. 2008-04-19 14:11:25 +02:00
Florian Westphal 2dd51a98e4 Channel_Mode: Unify Add_Invite and Add_Ban handler 2008-04-19 14:02:54 +02:00
Alexander Barton 7b33424c13 Added "portabtest" binary to .gitignore file in src/portabtest/. 2008-04-09 19:46:26 +02:00
Alexander Barton bc63064d5c Moved .cvsignore files to .gitignore
Since we are using GIT starting from now, I converted all the
.cvsignore files to .gitignore files.
2008-04-09 18:54:52 +02:00
Florian Westphal be844d74d3 Fix client.c sparse warnings.
client.c:72:6: warning: symbol 'Max_Users' was not declared. Should it be static?
client.c:72:21: warning: symbol 'My_Max_Users' was not declared. Should it be static?
2008-04-04 23:22:06 +02:00
Florian Westphal 637d739285 io.c: kill select FD_SETSIZE sanity check in io_library_init.
We already have way too many.
2008-04-03 23:20:26 +02:00
Florian Westphal 66e68de16a io.c: fix select FD_SETSIZE check when using epoll as io backend 2008-04-03 23:20:22 +02:00
Florian Westphal 7f44a2ad1c io.c: try to cut down the number of ifdefs.
consolidate backend-specific helpers and
add empty statinc inle stubs in the ifndef case
to let the compiler remove the functions at compile time.
2008-03-27 16:53:39 +01:00
Florian Westphal abb1abeb77 Do not exit unconditionally if config file cannot be opened
ngircd will exit if the config file cannot be opened. While
thats okay if ngircd starts up for the first time, it isn't
when we are re-reading the config file after a /REHASH or SIGHUP.
2008-03-26 21:31:13 +01:00
Alexander Barton ab1f48a346 Fix #include's: search log.h locally, include string.h. The latter is required because we include conn.h, which includes resolve.h, which includes ng_ipaddr.h, which contains a macro using strlcpy() ... 2008-03-11 15:42:58 +01:00
Florian Westphal feb31e4200 IPv6 support.
all references to struct sockaddr/in_addr have been
removed from src/ngircd.
libngipaddr (in src/ipaddr/) hides all the gory details.
See src/ipaddr/ng_ipaddr.h for API description.
2008-02-26 23:50:35 +01:00
Rolf Eike Beer 44cdf1b1ca Fix sending of JOINs between servers.
This does hit only operators that join a channel with at least 2 servers active in the net
the server the oper connects to sends "channel^Go" to the other servers
the other server first searches for the channel and then strips the modes from the channel name
he has to do the other way round: first strip and then check the channel name.
2008-02-26 23:49:33 +01:00
Florian Westphal e710e8ae37 Channel_Mode cleanups
- better indentation
- move answering request into seperate function.
2008-02-26 23:49:33 +01:00
Alexander Barton 5147b675cb Removed the SQUIT test for now, actually we don't support it yet. 2008-02-26 23:49:33 +01:00
Alexander Barton ddecfcd831 Implemented IRC commands INFO, USERS (dummy), and SUMMON (dummy). 2008-02-26 23:49:33 +01:00
Dana Dahlstrom 2f71fbb2a1 Include flags in RPL_WHOREPLY messages.
RPL_WHOREPLY messages generated by IRC_WHO don't include flags (*,@,+)
that should appear according to this description:

http://www.mishscript.de/reference/rawhelp3.htm#raw352

Other IRC servers do include the flags.

Modify who-test.e to expose missing flags,
modify ngircd-test.conf to accommodate who-test.e, and fix
irc-info.c to correct these problems.
2008-02-26 23:49:33 +01:00
Dana Dahlstrom 1784180bf3 Don't send trailing space in MODE messages
Under some circumstances ngIRCd currently issues a channel MODE message
with a trailing space after the last parameter, which isn't permitted by
the grammar in RFC 2812 section 2.3.1:

http://tools.ietf.org/html/rfc2812#section-2.3.1

The following patch modifies mode-test.e to expose this, and modifies
irc-mode.c to correct it.
2008-02-26 23:49:33 +01:00
Florian Westphal 634ef8c131 IRC_JOIN cleanups.
- put sending of mode and forwarding of JOIN to other clients
 into seperate function.
- put sending of topic/channel names into seperate function.
- put access check into seperate function.
- translate/remove remaining german comments.
- stop if JOIN to a channel in a list (JOIN #a,#,b,#c...) fails
(This doesn't change the behaviour: skip-to-next-channel-on-error
did never work as intended)
2008-02-26 23:49:33 +01:00
Florian Westphal 4d152b771e Make IRC_WHO also search username/servername/hostname.
Dana Dahlstrom reported that IRC_WHO did not follow
RFC 2812, Section 3.6.1. Specifically:

- IRC_WHO did not send "G" flag instead if "H" if client was away
- did not search username/servername/hostname etc. if argument
  was not a channel.

Fix all of the above and tidy things up a bit.
Also add IRC_WHO test script contributed by Dana.
2008-02-26 23:49:33 +01:00
Dana Dahlstrom c634303765 Remove duplicate Channel_FirstChannelOf().
noticed there's a way to make the loop
slightly more elegant.

[fw@strlen.de: Extra () to silence gcc.]
2008-02-26 23:49:33 +01:00
Florian Westphal cb0d594e61 Make Channel_Part name and reason parameters 'const'. 2008-02-26 23:49:33 +01:00
Dana Dahlstrom 6bd35bf090 Implement RFC 2812 handling of "0" argument to JOIN
The students in my software-engineering class are writing IRC clients in
Java, and I'm running ngIRCd as a sandbox for them to play in. We
noticed ngIRCd doesn't obey the "JOIN 0" command specified in RFC 2812:

   JOIN 0             ; Leave all currently joined
                      channels.

http://tools.ietf.org/html/rfc2812#section-3.2.1
I believe the following patch addresses this. Cheers!

[fw@strlen.de: put it into a seperate function]
2008-02-26 23:49:33 +01:00
Florian Westphal 3022d7cff3 Don't use Client_Type after command has been processed.
This caused a read from already free'd memory, if the processed
command (IRC_QUIT) calls Client_Destroy.
2008-02-26 23:49:33 +01:00
Florian Westphal 42db159d26 Fix wrong strncpy usage if CVSDATE defined
Hello_User() used strncpy with overlapping src/dest.
Use memmove instead.
2008-02-26 23:49:33 +01:00
Florian Westphal 59b19ea6a3 This adds support for sending NOTICEs to a channel.
[also see Bug #70 in ngircd bugzilla].

Based on a patch by Fabian Schlager <fabian.schlager@gmail.com>.
2008-02-26 23:49:33 +01:00
Florian Westphal 4add9c29ed [Parser]: Fix minor sparse warnings
parse.c:56:9: warning: symbol 'My_Commands' was not declared. Should it be static?
parse.c:107:9: warning: symbol 'My_Numerics' was not declared. Should it be static?

Also move handling of numerics into a seperate helper function.
2008-01-13 16:12:49 +00:00
Florian Westphal 463c5cb7c5 IRC_PART could reference invalid memory. 2008-01-07 11:42:00 +00:00
Florian Westphal 61e6b5c0aa [Resolver]: Use dotted-decimal IP address if hostname is >= 64 2008-01-02 11:03:29 +00:00
Florian Westphal 91a6fffaa0 io_event_disable: return if event-to-disable is already off 2008-01-02 10:29:51 +00:00
Florian Westphal 2ce5b734bd kqueue: check for EV_ERROR in .flags
if kevent() returns events, check for EV_ERROR in event flags, too.
2007-12-27 18:25:26 +00:00
Florian Westphal f99f9a8f02 Fix format arg: ListenAddress was printed instead of Bind address. 2007-12-13 01:30:16 +00:00
Florian Westphal 4715ccf9ca Fix format string in error path: didn't print strerror(errno) 2007-12-13 01:05:01 +00:00
Florian Westphal 8974e90552 implement '/STAT u' (uptime) 2007-12-11 11:29:43 +00:00
Florian Westphal 2fe13f0a45 Fix fmt string: int, not long 2007-12-07 21:19:01 +00:00
Florian Westphal 20ce56cc5b include <arpa/inet.h> inside tool.h
In file included from hash.c:24:
../tool/tool.h:27: warning: `struct in_addr' declared inside parameter list
2007-11-25 18:42:37 +00:00
Florian Westphal 47a0379e2b remove ip-string from Conf_Server struct
struct Conf_Server stored the ip address to connect to
in dotted-decimal notation; but we only need this for connect()
so long-time storage isn't necessary.
2007-11-23 16:28:37 +00:00
Florian Westphal 82d32ffb28 bind ListenAddress for outgoing connections
ngircd would always use INADDR_ANY for outgoing connections;
which might not be desirable. Added new [Server] option
"Bind" to set source ip.
2007-11-23 16:26:03 +00:00
Alexander Barton 024588dbe7 Funktions to handle numerics sent to the server. 2007-11-21 12:20:32 +00:00
Alexander Barton 47ca178a21 Introduce option to configure the maximum nick name lenth in ngircd.conf
- New configuration option "MaxNickLength" to specify the allowed maximum
  length of user nick names. Note: must be unique in an IRC network!
- Enhanced the IRC+ protocol to support an enhanced "server handshake" and
  enable server to recognice numeric 005 (ISUPPORT) and 376 (ENDOFMOTD).
  See doc/Protocol.txt for details.
2007-11-21 12:16:33 +00:00
Alexander Barton 53b98fd7e9 Fixes the wrong logging output when nested servers are introduced
to the network as well as the wrong output of the LINKS command.
2007-11-20 20:02:40 +00:00
Alexander Barton 68f896eee0 Adjust test suite to be usable on HP/UX 11.11 :-) 2007-11-18 15:07:16 +00:00
Alexander Barton 06bfb3adfb Fix code to compile using K&R C compiler and ansi2kr again. 2007-11-18 15:05:35 +00:00
Florian Westphal ad7361dfe0 if ngircd doesn't run chrooted, it tries to chdir
to the users working directory (as returned by getpwuid()).
Failing to chdir to that directory isn't an error; so
log with LOG_INFO and prefix the message with "Notice".
2007-11-15 01:03:01 +00:00
Florian Westphal 001c00b273 New config option NoDNS: disables all DNS queries. 2007-10-25 11:01:19 +00:00
Florian Westphal b861f536b2 configtest would still print "-1" for MaxConnections, MaxConnectionsIP and MaxJoins
if any of those values was set to 0.
2007-10-24 00:48:41 +00:00
Alexander Barton 8f162f4e17 Fixed propagation of channel mode 'P' on server links. 2007-10-14 12:08:57 +00:00
Florian Westphal d223b587e4 accoring to comments in the code, MaxConnections, MaxConnectionsIP and MaxJoins
options allow setting values < 0 -- this isn't the case. Comments adjusted.
2007-10-13 19:11:06 +00:00
Alexander Barton d4ed056147 Numeric 317: implemented "signon time" (displayed in WHOIS result). 2007-10-04 15:03:55 +00:00