Commit Graph

2109 Commits

Author SHA1 Message Date
Alexander Barton 1f59821270 Update Copyright notices for 2013 2013-01-01 19:23:56 +01:00
Alexander Barton 289a26e9e4 Implement Help() function parsing and returning the help text
This function parses the already read in help text and sends the requested
portions to the user. Parsing is done as following when a user user
issues a "HELP <cmd>" command:

 1. Search the file for a line "- <cmd>",
 2. Output all subsequent lines that start with a TAB (ASCII 9) character
    to the client using NOTICE commands, treat lines containing a single "."
    after the TAB as empty lines.
 3. Break at the first line not starting with a TAB character.

This format allows to have information to each command stored in this file
which will not be sent to an IRC user requesting help which enables us to
have additional annotations stored here which further describe the origin,
implementation details, or limits of the specific command.

A special "Intro" block is returned to the user when the HELP command is
used without a command name.
2013-01-01 14:57:03 +01:00
Alexander Barton 3e47bc9af5 Allow ERROR command on server and service links only
Ignore it and add a penalty time on all other link types.
2012-12-31 21:46:48 +01:00
Alexander Barton f68aa02272 Implement new configuration option "HelpFile"
This new configuration option allows to specify a specially formatted
text file which can be used by the HELP command to provide information
about the commands and their syntaxes.
2012-12-31 19:29:52 +01:00
Alexander Barton 588af510a3 IRC_HELP(): Code cleanup 2012-12-31 19:27:32 +01:00
Alexander Barton 9e1c25a889 Refactor Read_Motd() into Read_TextFile()
Now this function allows to read arbitrary text files into arrays.
2012-12-31 19:26:31 +01:00
Alexander Barton 5d92198487 Get rid of Conn_ResetPenalty(), it is unused 2012-12-31 18:23:21 +01:00
Alexander Barton 20ddffca0d Mode setting: only check channel user modes when on channel
Only check the channel user modes of the initiator if he is joined to
this channel and not an IRC operator enforcing modes (which requires
the configuration option "OperCanUseMode" to be enabled), because trying
to check channel user modes of a non-member results in this assertion:

 Assertion failed: (cl2chan != NULL), function Channel_UserModes,
  file channel.c, line 742.

This closes bug #147, thanks to James Kirwill <james.kirwill@bk.ru>
for tracking this down!
2012-12-31 18:13:18 +01:00
Alexander Barton 25e56a5e83 Add some more casts in assert() statemens
This fixes the following warning messages of gcc 4.5.3 on Cygwin when
building with debug code enabled:

 ng_ipaddr.c: In function ‘ng_ipaddr_init’:
 ng_ipaddr.c:52:2: warning: comparison between signed and
                   unsigned integer expressions
 ng_ipaddr.c:53:20: warning: comparison between signed and
                    unsigned integer expressions

 resolve.c: In function ‘ForwardLookup’:
 resolve.c:271:3: warning: comparison between signed and
                  unsigned integer expressions
2012-12-25 19:21:40 +01:00
Alexander Barton b5b3dd9cfd Add Cygwin binaries (*.exe) to .gitignore files 2012-12-25 18:52:49 +01:00
Alexander Barton 92fba63ad8 Add a cast in ForwardLookup() to fix a gcc warning on Cygwin
This fixes the following warning message of 4.5.3 on Cygwin:

 resolve.c: In function ‘ForwardLookup’:
 resolve.c:273:21: warning: comparison between signed and
                   unsigned integer expressions
2012-12-25 18:49:28 +01:00
Alexander Barton 1342f78b09 Allow user names up to 20 characters
This patch allows user names up to 20 characters when ngIRCd has not been
configured for "strict RFC mode".

Patch suggested by Brett Smith <brett@w3.org>, see
<http://arthur.barton.de/pipermail/ngircd-ml/2012-October/000579.html>.
2012-12-10 10:41:36 +01:00
Alexander Barton 35e2dcff88 Rework cloaked hostname handling, implement "METADATA cloakhost"
Now ngIRCd uses two fields internally, one to store the "real" hostname
and one to save the "cloaked" hostname. And both fields can be set
independently using the "METADATA host" and "METADATA cloakhost" commands.

This allows "foreign servers" (aka "IRC services") to alter the real and
cloaked hostnames of clients without problems, even when the user itself
issues additional "MODE +x" and "MODE -x" commands.
2012-11-24 16:15:35 +01:00
Alexander Barton dc89e42ef5 RPL_UMODEIS: send correct target name, even on server links 2012-11-24 15:57:45 +01:00
Alexander Barton 4a2d74c9ab Client_HostnameCloaked() -> Client_HostnameDisplayed() 2012-11-24 13:37:56 +01:00
Alexander Barton 8061056cec Test suite: correctly execute tests when stdout is redirected 2012-11-13 22:46:06 +01:00
Alexander Barton 44926b7f9f Add a few casts, fix compiler warnings on NetBSD 5
This fixes a few warnings of this type:
  XXX.c: In function 'AAA':
  XXX.c:YY: warning: array subscription has type 'char'

Tested on NetBSD 5.0.2 with gcc 4.1.3.
2012-11-12 22:39:57 +01:00
Alexander Barton d11a700589 irc-info.c: Use strlcpy() instead of strcpy()
This fixes the following warning of gcc (tested on OpenBSD 5.0:)
  irc-info.c:990: warning: strcpy() is almost always misused,
                  please use strlcpy
2012-11-11 16:46:57 +01:00
Alexander Barton 4123118d5a conf.c: Use strlcpy() instead of strcpy()
This fixes the following warning of gcc on OpenBSD 5.0:
  conf.c:728: warning: strcpy() is almost always misused, please use strlcpy()
2012-11-11 11:18:53 +01:00
Alexander Barton e29d198700 tool.h: Don't check for and #define PF_INET
This is correctly handled by ipaddr/ng_ipaddr.h today, and the check
in tool.h isn't required any more -- and caused errors on OpenBSD 5.0:

  In file included from ./../tool/tool.h:23:
  /usr/include/arpa/inet.h:74:
    warning: "struct in_addr" declared inside parameter list
2012-11-11 11:05:21 +01:00
Alexander Barton 6f531a3c99 conf-ssl.h: Use "gnutls_session_t" instead of "gnutls_session"
This fixes the following warning with current versions of GnuTLS:
  conf-ssl.h:36: warning: "gnutls_session" is deprecated
2012-11-11 10:50:32 +01:00
Alexander Barton 53917fa4b8 Add new IRC+ server flag "X": "XOP modes supported"
This flag indicates, that the server supports the enhanced "xop channel
user modes", like channel owner, admin, and halfop. This information is
used to make sure that no unsupported CHANINFO commands are sent to
servers not supporting such mode prefixes, for example.
2012-11-10 23:33:19 +01:00
Alexander Barton f0b86e6c26 Correctly add irc-metadata.{c|h} to Makefile.ng ... 2012-11-05 23:57:14 +01:00
Alexander Barton 40e3daf560 Generate "METADATA host" commands on "MODE +/-x"
Use "METADATA host" commands to let servers supporting this command
know which (possibly cloaked) hostname is in effect for a specific
client. This prevents "double cloaking" of hostnames and even cloaked
hostnames are in sync on all servers supporting "METADATA" now.
2012-11-05 23:49:12 +01:00
Alexander Barton 44b7ff02fd Don't cloak already cloaked hostname when using METADATA
A client for which a METADATA command has been received from one of
its peers got the client flag "M" set. So it's safe to assume that
such a client gets "METADATA host" commands for its cloaked hostname
and the server must not cloak the hostname on its own, even when the
client mode "+x" is set.
2012-11-05 23:46:26 +01:00
Alexander Barton 35ed57e6c1 Implement METADATA command to update client metadata
The METADATA command can be used by other servers to update "metadata"
of registered clients, like the client info text ("real name"), user
name, and hostname:

  :<prefix> METADATA <target> <key> :<value>

It is distributed in the network, unknown <key> names are silently ignored
and passed on, too. This allows for further extensions.
2012-11-05 23:34:21 +01:00
DNS777 a7f37cebdc PredefChannelsOnly: Fix message for non pre-defined channels
If PredefChannelsOnly is enabled, and if someone tries to create
a channel which does not exist, then the error message is a 474.
The 474 Error message changed recently and does not match anymore:
'Cannot join channel (+b) -- You are banned'.

Changed the error message to numeric 403 'No such channel'.

Bug introduced by commit 9a82304a.

(cherry picked from commit 2c2e08f34187a33c1da745995c5f213e33a91410)
2012-11-04 20:38:36 +01:00
Alexander Barton 47b99c69cc Test suite: add some "remote checks" to whois-test.e 2012-11-04 19:50:02 +01:00
Alexander Barton 757f3497bc Send NICK commands with prefix of (target) user
Now NICK commands are always generated using the prefix of the target
user, even when the nickname change has been initiated by some other
(pseudo) server or using the SVSNICK command. In this case, the prefix
of the initiator has been used, but this isn't compatible with clients
(at least weechat and irssi don't handle such NICK commands correctly).
2012-11-04 18:01:49 +01:00
Alexander Barton e3f300d323 Implement SVSNICK command to change remote nicknames
The SVSNICK command allows other servers (and services on
"pseudo-servers") to forcefully change nicknames of remote users.

Syntax: ":<from> SVSNICK <oldnick> <newnick>"

The SVSNICK command itself doesn't change the nickname, but it becomes
forwarded to the server to which the user is connected to. And then this
server initiates the real nickname changing using regular NICK commands.

This allows to still run networks with old servers not supporting the
SVSNICK command, because SVSNICK commands for nicknames on such servers
are silently ignored and don't cause a desync of the network.
2012-11-02 17:50:31 +01:00
Alexander Barton 497edbaf3e IRC_NICK(): Code cleanup, new function Change_Nick() 2012-11-02 14:36:29 +01:00
Alexander Barton 48326e061a Spelling fix: "nick name" -> "nickname" 2012-11-02 14:30:19 +01:00
Alexander Barton 30b32e84fe Fix warning message introduced when cleaning up IRC_SERVER()
This reverts a not intentional code change and fixes the following compiler
warning message (tested with gcc 4.4.5):

 irc-server.c: In function "IRC_SERVER":
 irc-server.c:142: warning: suggest parentheses around operand of "!"
                            or change "&" to "&&" or "!" to "~"
2012-10-29 11:44:45 +01:00
Alexander Barton fb92493376 Make server reconnect time a little bit more random
Add randomly up to 15 seconds to the reconnect delay for outgoing server
links when the connection has been "short" and therefore the "ConnectRetry"
delay is being enforced.

This should make it even more unlikely that two servers deadlock each
other when both are trying to connect to the other one at the same time,
for example in test environments.
2012-10-29 11:33:49 +01:00
Alexander Barton eb4f9eac0c Don't accept connections for servers already beeing linked
If two servers try to link each other, there was a time frame that
could result in one connection overwriting the other, e. g. the incoming
connection overwriting the status of the outgoing one. And this could
lead to all kind of weirdness (even crashes!) later on.

So now such incoming connections are dropped. But this most probably
prevents the two servers from linking until timing changes somehow
(network latency?) because each server drops the incoming connection of
the other one, so no connection survives in the end.

But this has to be addressed by an other patch ...
2012-10-29 11:33:49 +01:00
Alexander Barton d7b5dd1bbf IRC_SERVER(): Code cleanup 2012-10-29 11:33:49 +01:00
Alexander Barton b18e81b631 Use lowercase "package name" for syslog logging again
This is how ngIRCd up to release 19.2 behaved; "bug" introduced by commit
67e882, "configure.in: require autoconf 2.67 and automake 1.11", which
changed the "PACKAGE_NAME" to "ngIRCd"; so use "PACKAGE" which still is
the lowercase version for initializing syslog logging.
2012-10-29 10:24:27 +01:00
Brett Smith 32f63abb59 Make the maximum /list reply length a configurable limit. 2012-10-25 14:46:29 -04:00
Alexander Barton 8d9cfa157a Allow remote servers and IRC Ops to change channel topics
Remote servers are always allowed to change all channel topics,
and IRC Operators are allowed to change all channel topics if the
configuration option "OperCanUseMode" is enabled.

Bug introduced by commit 7b01bb8 and reported by DNS777.
2012-10-19 19:45:44 +02:00
DNS 58abd0777b Increased maximum number of possible user and channel modes
Currntly ngIRCd supports 13 user and 15 channel modes, because there
have been quite a few additions since our last release. But our data
structures can only hold 15 user and -- even worse! -- only 9 channel
modes! So enlarge the buffers to 20 bytes (actually 21 including NULL)
to allow storing of all mode characters and to have some space left
for more modes to come ...

(cherry picked from commit 8996d777621d88d4bcc439ab4792b2814920687f)
2012-10-19 18:44:15 +02:00
DNS777 3ee98d9f72 Update error messages for user mode +b and channel Mode +M.
Replaced error message for channel mode +M with ERR_NEEDREGGEDNICK_MSG
(used by Bahamut, inspircd, ircu & Unreal too) and using numeric 477
and the msg simliar like inspircd.

Replaced the error message ERR_CANNOTSENDTONICK_MSG for user mode +b
with ERR_NONONREG_MSG and using numeric 486, similar like unrealircd.

(cherry picked from commit 55a61ab17f63a9e757b7c7598c31b98ce5a132e8
and commit 3737d9ab7da1ea0485cefc07c65dc5308bf0db02)
2012-10-19 18:38:46 +02:00
Alexander Barton b1a5ade88f Test suite: add more checks to whois-test.e 2012-10-15 21:39:08 +02:00
Alexander Barton e0da56fc7b Disable UID/GID checks on "single user OS"
Don't abort on "single user operating systems" that don't know more than
one user account and therefore can't change user and group IDs.

Currently, the only such system supported by ngIRCd is Haiku, a BeOS
clone.
2012-10-11 14:54:13 +00:00
Alexander Barton 538e612a47 Test suite: add test for user mode "b" 2012-10-08 12:15:34 +02:00
DNS777 9d97004a28 Implement user mode "b": block messages
When a user has set mode "b", all private messages and notices to this
user are blocked if they don't originate from a registered user, an IRC Op,
server or service. The originator gets an error numeric sent back in this
case, ERR_CANNOTSENDTONICK_MSG(976), which is/was(?) used by KineIRCd, too.

This closes bug #144.
2012-10-08 12:11:04 +02:00
Alexander Barton 87deb43012 Fix ERR_CANNOTSENDTOCHAN_MSG message
This error message is not only used if one can not send to a channel
because it is moderated, but for _all_ reasons when a message can not
be delivered (moderated, banned, no external messages, ...), so strip
the "(+m) -- Moderated" part of the error message again.

Bug introduced by commit 9a82304a.
2012-10-07 15:11:05 +02:00
Alexander Barton 161adbb1aa WHOIS: show RPL_WHOISHOST_MSG to all IRC Ops in the network
Not only show RPL_WHOISHOST_MSG to local IRC opreators, but show
it to all IRC operators in the network. And don't show it to anybody
if the "more privacy" configuration option is enabled.

This closes bug #134.
2012-10-07 00:05:25 +02:00
Alexander Barton de2fa78d92 Test suite: make expect scripts more verbose
Now tests.sh transforms each expect script it executes using sed(1)
and inserts a 'puts -nonewline stderr "."' in front of each "expect"
command.
2012-10-06 23:17:07 +02:00
Alexander Barton 8bede388af Test suite: remove indentation of messages 2012-10-06 23:17:06 +02:00
Alexander Barton c9d166747d Merge branch 'bug141-ModesQq'
This closes bug #141.

* bug141-ModesQq:
  KICK-protect IRC services
  Implement channel mode "Q" and user mode "q"

Conflicts:
	src/ngircd/defines.h
	src/ngircd/messages.h
2012-10-06 22:37:57 +02:00
DNS777 56cdc2175c Show active user modes in WHOIS reply
Implement numeric RPL_WHOISMODES_MSG(379) and show user modes in the
reply of the WHOIS command for the user himself or, if MorePrivacy
isn't set, for request initiated by an IRC operator.

Numeric 379 is used by Unreal and InspIRCd for this purpose, too.

Closes bug #129.
2012-10-06 21:56:59 +02:00
DNS777 de453d71cb Implement channel mode 'V' (invite disallow)
If the new channel mode "V" is set, the INVITE command becomes invalid
and all clients get the new ERR_NOINVITE_MSG(518) reply.

Unreal and InspIRCd uses this mode, too.

This closes bug #143.
2012-10-06 20:49:35 +02:00
DNS777 23b07bdf50 Allow channel admins to "de-admin" channel members
This patch fixes unsetting of channel user mode "+a" (channel admin)
and adds a better error message: without this patch, a channel admin is
unable to unset this mode.

This closes bug #142.
2012-10-06 19:52:15 +02:00
Alexander Barton 9ac94339dc KICK-protect IRC services 2012-10-06 19:23:05 +02:00
Alexander Barton 46b0eef721 Merge branch 'bug109-CHARCONV'
This closes bug #109.

* bug109-CHARCONV:
  Debian: require "telnet" or "telnet-ssl" for building
  Debian ngircd-full[-dbg]: enable CHARCONV
  Add "CHARCONV" to "feature string" when enabled
  Implement new IRC+ "CHARCONV" command
  Added new configure option "--with-iconv"

Conflicts:
	src/ngircd/messages.h
2012-10-06 18:26:25 +02:00
Alexander Barton d3ae351236 Implement channel mode "Q" and user mode "q"
Both modes protect users from channel kicks: only IRC operators and
servers can kick users having mode "q" or in channels with mode "Q".

Original patch by DNS777 <dns@rbose.org>, thanks!

This closes bug #141.
2012-10-06 18:13:01 +02:00
Alexander Barton c66e20ce6e Fix spelling: ERR_CHANOPPRIVTOLOW_MSG -> ERR_CHANOPPRIVTOOLOW_MSG
Thanks to DNS for pointing this out, see bug #126!
2012-10-06 17:21:32 +02:00
Alexander Barton cf9f9e1f30 Test suite: don't use "mkdir -p"
"mkdir -p" is not supported on all platforms.
Tested with Apple A/UX 3.1.x.
2012-09-27 00:57:37 +02:00
Federico G. Schwindt 19ce256a95 ERR_CHANNELISFULL_MSG: better wording
(cherry picked from commit 0fcfa7e00fa8e098dd3724c7188c88ac82a52881)
2012-09-27 00:22:48 +02:00
Alexander Barton eba53f652c Fix getpid.sh to work on Apple A/UX again 2012-09-27 00:19:31 +02:00
Federico G. Schwindt d8ee498a65 Send RPL_REHASHING if rehash was accepted
(cherry picked from commit f1b171a09cd076f743a7fff221fa7aa752abb374)
2012-09-27 00:07:40 +02:00
Federico G. Schwindt e3a1a61868 Change variable name "SSLDHFile" to "DHFile" in log messages
(cherry picked from commit d96db0a2e56d310177edb45d0a8b164a37992ab1)
2012-09-27 00:05:07 +02:00
Federico G. Schwindt 1a2bdd9e4c Move ConnSSL_InitLibrary() "dummy" from header into C file
(cherry picked from commit 5fd88c81a70d0c9e627f08522e57d251586288eb)
2012-09-27 00:03:56 +02:00
Alexander Barton 384f965fba NJOIN: correctly reset channel level flags
This fixes commit 7b01bb83.
Bug reported by DNS777 <dns@rbose.org>, thanks!
2012-09-26 23:51:48 +02:00
Alexander Barton 005340c83f Simplify check for valid user names in IRC_USER().
Patches from Federico G. Schwindt, thanks!

(cherry picked from commit a44b7126227ba1118ec02b399e31b08102af5e8c
and 6fbe9583753b2620da275676cde46a89cb4d06c2)
2012-09-26 23:28:13 +02:00
Alexander Barton d21afce2b6 Allow user mode +x only when "CloakHostModeX" is set
Allow users to "cloak" their hostname only when the configuration
variable "CloakHostModeX" (introduced in 19.2) is set. Otherwise, only
IRC opertators, other servers, and services are allowed to set mode +x.

This prevents regular users from changing their hostmask to the name
of the IRC server itself, which confused quite a few people ;-)

This fixes bug #133.
2012-09-26 22:55:10 +02:00
DNS777 808c291c76 New configuration option "OperChanPAutoOp"
If disabled, IRC operators don't become channel operators in persistent
channels when joining. Enabled by default, which has been the behavior
of ngIRCd up to this patch.

Closes bug #135.

(Cosmetic fixes by Alex.)
2012-09-25 13:08:39 +02:00
DNS777 62a07596d6 Allow opers to see secret (+s) channels in LIST command
As long as 'MorePrivacy' isn't enabled in the configuration file, local
IRC operators can see secret (+s) channels when using the LIST command.

Closes bug #136.
2012-09-25 12:55:07 +02:00
Alexander Barton 3e22fc32f3 Remove all geneerated Makefile.am on "make maintainer-clean" 2012-09-24 20:45:37 +02:00
Alexander Barton 8cfb910441 Merge branch 'automake-am11-am12'
* automake-am11-am12:
  autogen.sh: detect automake version format a.b.c and a.b
  configure.ng: don't require GIT tree to detect version string
  Include .mailmap file in distribution archives
  Include all build-system files into distribution archives
  Change build system to support new and old GNU automake
2012-09-24 20:28:02 +02:00
Alexander Barton d4df626d88 automake: don't use INCLUDES, it's AM_CPPFLAGS nowadays 2012-09-24 17:45:15 +02:00
Alexander Barton 8e1beae4e7 Include all build-system files into distribution archives 2012-09-24 14:34:16 +02:00
Alexander Barton e3e181f4b3 Merge branch 'bug92-xop'
By Alexander Barton (5) and Sebastian Köhler (2)

* bug92-xop:
  Fix NAMES/WHO response when client has multi-prefix
  Fix prefix of "halfop" when "multi-prefix" is active
  Clean up doc/.gitignore
  doc/Modes.txt: add version number to new channel modes
  Fix some "whitespace glitches"
  Tests and documentation for xop
  Implemented xop support

Conflicts (because of "multi-prefix fix"):
	src/ngircd/irc-info.c

This fixes bug #92 "ngircd does not support XOP usermodes".
2012-09-23 20:06:14 +02:00
Alexander Barton 1f2aa4da6f Fix NAMES/WHO response when client has multi-prefix
This has been fixed by commit 16f94546 "Fix NAMES response when
client has multi-prefix" in the master branch, fix it in this patch
series, too.
2012-09-23 19:37:06 +02:00
Alexander Barton fc39146f48 Fix prefix of "halfop" when "multi-prefix" is active 2012-09-23 19:23:23 +02:00
Alexander Barton 192e304b94 Change build system to support new and old GNU automake
Starting with GNU automake 1.12, the "de-ANSI-fication support" has been
removed, which ngIRCd used to enable building itself on very old systems.

Now the problem is, that using automake >= 1.12 isn't working because of
the now unsupported M4 macros. Therefore the solution that this patch
implements is to dynamically generate the automake input files with our
own ./autogen.sh script:

  configure.ng => configure.in
  Makefile.ng => Makefile.am

This is quite an ugly approach, but it works and enables us to:

  1. use current automake >= 1.12 for development and "private builds",
  2. still build distribution archives using automake 1.11.x that have
     "de-ANSI-fication support" enabled in the generated Makefile's.

And if you are using Makefile's generated with a automake version newer
than 1.11.x (without "de-ANSI-fication support"), the ./configure script
warns you not to use this generated build system to generate distribution
archives.

Drawback of this patch: you MUST use our autogen.sh script, you can't call
the autoconf/automake commands directly any more; but autoreconf should
still work ...
2012-09-23 18:13:55 +02:00
Alexander Barton ef82ef4ddb Free all listen ports on initialization
Now you can reconfigure listen ports and reload the server configuration
on runtime. Without this patch, no ports could be removed.
2012-09-21 10:41:03 +02:00
Alexander Barton bb20aeb9bc Initialize SSL when needed only, and disable SSL on errors
With this patch, the SSL subsystem will only be initialized if at least
one SSL ports is configured; so you won't get "SSL initialization failed"
messages if you didn't configured it at all.

And if SSL initialization fails, no SSL listen ports will be enabled
later which never could establish a working SSL connection at all ...
2012-09-21 10:36:09 +02:00
Alexander Barton e9d0b2f039 Add "CHARCONV" to "feature string" when enabled 2012-09-17 01:00:05 +02:00
Alexander Barton 222ecbffbb Implement new IRC+ "CHARCONV" command
See bug 109 and doc/Protocol.txt for details and documentation.
2012-09-17 00:56:36 +02:00
Alexander Barton 1413a4886f Sort "feature string" alphabetically 2012-09-17 00:55:30 +02:00
Alexander Barton cfec819f0d Include CAP command even when using "strict RFC mode" 2012-09-16 14:08:52 +02:00
Alexander Barton 107bfdc821 Merge branch 'autoconf-update'
Update GNU autoconf and automake infrastructure.
Tested on modern systems as well as Apple A/UX :-)

* autoconf-update:
  AUTOMAKE_OPTIONS: fix ansi2knr option, include path
  Don't use AC_FUNC_MALLOC and AC_FUNC_REALLOC
  Make our own targets "silent", if enabled
  configure.in: use AC_CHECK_{FUNCS|HEADERS}_ONCE
  Updated config.{guess|sub} to version 2012-08-14
  Make autogen.sh more verbose when VERBOSE=1 is set
  configure.in: use AC_SEARCH_LIBS (not AC_CHECK_LIB)
  configure.in: use AS_HELP_STRING macro
  configure.in: use AC_CANONICAL_HOST (not AC_CANONICAL_TARGET)
  configure.in: inttypes.h is an optional header file
  Use HAVE_SETSID #define when testing for setsid()
  Don't include <stdint.h>, it is included by "portab.h"
  Don't check type.h availability, it is required
  configure.in: Use AC_CONFIG_FILES macro
  configure.in: Don't use AC_C_PROTOTYPES
  configure.in: Update checks for required and optional features
  configure.in: require autoconf 2.67 and automake 1.11
  configure.in: sort some lists (templates, output, ...)
2012-09-16 13:05:23 +02:00
Alexander Barton 5c160921ff AUTOMAKE_OPTIONS: fix ansi2knr option, include path
Set correct relative path to ansi2knr.c in AUTOMAKE_OPTIONS, so that
ansi2knr.{1|c} is only included once in the distribution archive.
2012-09-16 12:43:12 +02:00
Brett Smith 85abfd84be Allow limited punctuation in usernames, for better PAM integration. 2012-09-14 11:56:38 -04:00
Alexander Barton 82bf4eb059 configure.in: use AC_CANONICAL_HOST (not AC_CANONICAL_TARGET)
See the autoconf manual for details:
http://www.gnu.org/software/autoconf/manual/autoconf.html#Specifying-Target-Triplets
2012-09-13 00:06:08 +02:00
Alexander Barton a072180c92 Merge pull request #2 from briancollins/master
Fix IRC_Send_NAMES not sending correct prefix for certain clients.
2012-09-11 11:29:14 -07:00
Alexander Barton 0fd9a8505a Correctly re-initialize signal handlers on RESTART
This fixes part 2 of bug #127 :-)
2012-09-11 15:44:31 +02:00
Alexander Barton b2482b39e4 Use HAVE_SETSID #define when testing for setsid() 2012-09-11 14:38:19 +02:00
Alexander Barton 74c7d7131f Don't include <stdint.h>, it is included by "portab.h" 2012-09-11 14:37:31 +02:00
Alexander Barton 4dd1c31dc7 Don't check type.h availability, it is required 2012-09-11 14:36:34 +02:00
Alexander Barton f5441d2170 New_Connection(): mark "IsSSL" parameter as UNUSED
This fixes the following warning message when building without SSL support:

 conn.c: In function "New_Connection":
 conn.c:1365: warning: unused parameter "IsSSL"

Introduced by commit 01b62202.
2012-09-11 13:15:16 +02:00
Alexander Barton 0d67be3f30 Fix some "whitespace glitches"
Some have been introduced by commit 7b01bb83, some are older.
2012-09-11 12:48:51 +02:00
Alexander Barton f37600ee01 Merge branch 'xop' of https://github.com/kart0ffelsack/ngircd into bug92-xop
* 'xop' of https://github.com/kart0ffelsack/ngircd:
  Tests and documentation for xop
  Implemented xop support

Conflicts (because of merge of the 'cmode-M' branch):
	src/ngircd/channel.c
	src/ngircd/defines.h
	src/ngircd/messages.h
2012-09-11 12:30:19 +02:00
Alexander Barton f38a9035e5 Show a warning on startup if config file is not a full path
ngIRCd is a long-running process and changes its working directory to "/" to
not block mounted filesystems and the like when running as daemon ("not in the
foreground"); therefore the path to the configuration file must be relative to
"/" (or the chroot() directory), which basically is "not relative", to ensure
that "kill -HUP" and the "REHASH" command work as expected later on.

This fixes parts of bug #127.
2012-09-11 11:40:47 +02:00
Alexander Barton a12d6ff257 Create &SERVER channel after predefined channels
This patch allows you to define &SERVER in a [Channel] block yourself
and to overwrite the built-in topic and channel modes.

Fixes bug #131.
2012-09-10 17:59:15 +02:00
Alexander Barton 2205227c3b WHO #channel: don't limit list size
It makes no sense to limit the list size when doing WHO for a channel
and not to return all the users in that channel, so I removed the check.
But if there are more than MAX_RPL_WHO(25) replies, the client requesting
the list will be "penalized" one second more (then 2 in total).

This fixes bug #125.
2012-09-10 12:43:44 +02:00
Alexander Barton d2d867ea36 Define EV_SET() for kqueue() on systems that don't have it
Some systems, notably FreeBSD 4.x, do have the kqueue() function but
lack the definition of EV_SET() in their header files -- but don't
worry, we can #define it on our own ;-)

Definition taken from /usr/include/sys/event.h of FreeBSD 8.1.
Patch tested on FreeBSD 4.1 by Götz Hoffart. Thanks!
2012-09-04 23:28:32 +02:00
Alexander Barton 01b62202b2 New function Conn_StartLogin() to finish connection initialization
Conn_StartLogin() is called after the connection has been established and
fully innitialized, including the SSL handshake, for example.

Up to this patch, the "NoticeAuth" option broke the SSL handshake ...
2012-08-29 17:24:19 +02:00
Alexander Barton b68bb560e9 Convert CONN_ID and Conf_MaxConnections to "int" datatype
We can't handle more connections than accept(2) can supply, and
accept(2) returns an "int" ...
2012-08-29 17:03:41 +02:00
Alexander Barton 21467c76f1 Introduce numeric RPL_HOSTHIDDEN_MSG(396)
This numeric is sent to the client each time it changes its displayed
hostname using "MODE +/-x", and if "CloakHost" is set right after the
MOTD has been sent.
2012-08-28 23:28:56 +02:00
Alexander Barton 33fae67579 Always cloak client hostname, if needed
Not only cloak the hostname in Client_MaskCloaked(), but also in
Client_HostnameCloaked() -- so move the actual cloaking to this function
and call it in Client_MaskCloaked() to get the (cloaked) hostname.

This fixes USERHOST not displaying the correctly cloaked hostname,
for example.
2012-08-28 23:26:43 +02:00
Alexander Barton 864015fa3f NoticeAuth: make sure messages are flushed immediately 2012-08-28 22:09:06 +02:00
Alexander Barton 1d3def0cc6 Merge branch 'umode-B'
This patch series allows ngIRCd to support the user mode "B" ("Bot flasg"):
it is settable and unsettable by every (non-restricted) client.
According to DNS777, this is how Unreal and InspIRCd do behave, so do we :-)

By Alexander Barton (1) and DNS777 (1)

* umode-B:
  Add new user mode "B" to doc/Modes.txt
  Implement an Unreal-like user mode "B" ("Bot mode")
2012-08-27 23:27:30 +02:00
Alexander Barton e01e8f1cb6 Merge branch 'recognize-umode-R'
By Alexander Barton (1) and DNS777 (1)

* recognize-umode-R:
  Only allow IRC services to modify user mode "R"
  Recognize user mode "R"
2012-08-27 23:21:28 +02:00
Alexander Barton 186ab51137 Only allow IRC services to modify user mode "R" 2012-08-27 23:20:32 +02:00
Alexander Barton 74be904018 ngt_RandomStr(): : make it buildable with pre-ANSI C compilers 2012-08-27 22:42:52 +02:00
Alexander Barton 298cd9a327 Get_CAP_String(): make it buildable with pre-ANSI C compilers 2012-08-27 22:42:04 +02:00
Alexander Barton 414bfe65eb Enhance "NOTICE AUTH": show hostname and IDENT reply 2012-08-27 22:05:55 +02:00
Alexander Barton c519ba9920 Merge branch 'cmode-M'
By Alexander Barton (2) and DNS777 (1)

* cmode-M:
  Add new channel mode "M" to doc/Modes.txt
  Remove Can_Send_To_Channel_Identified()
  Implement channel mode "M"
2012-08-27 21:22:58 +02:00
Alexander Barton fee591b759 Remove Can_Send_To_Channel_Identified()
Move the functionality directly into Can_Send_To_Channel() function.
There should be no functional change ...
2012-08-27 21:15:12 +02:00
Brian Collins 16f94546f5 Fix NAMES response when client has multi-prefix
Two fixes here: IRC_Send_NAMES was checking the capability of the
wrong client when responding, and it didn't return any prefix for
clients that had either +v or +o but not both.
2012-08-27 16:23:57 +01:00
Alexander Barton 55859c1bef Merge branch 'better-chan-errors'
By Alexander Barton (1) and DNS777 (1)

* better-chan-errors:
  Remove unused ERR_CANNOTSENDTOCHAN2_MSG message
  Add some more information to channel error numerics
2012-08-26 19:42:08 +02:00
Alexander Barton bcefdef1ea Merge branch 'move-connection-password' of git://arthur.barton.de/ngircd-alex
This patch series converts the statically allocated password buffer in the
CLIENT structure into a dynamically (and only when needed) allocated buffer
which is referenced by the CONNECTION structure.

This a) saves memory for clients not using passwords at all and b) allows
for "arbitrarily" long passwords.

By Brett Smith (5) and Alexander Barton (2).

* 'move-connection-password' of git://arthur.barton.de/ngircd-alex:
  Login_User(): use "conn" insted of calling Client_Conn(Client)
  Free already saved password when storing a new one
  Indentation and style fixes.
  Connection password is not constant.
  Implementation clean-ups.
  Dynamically allocate memory for connection password.
  Move client password from the Client to the Connection struct.
2012-08-26 19:14:29 +02:00
Alexander Barton f79d41e927 Login_User(): use "conn" insted of calling Client_Conn(Client) 2012-08-26 19:11:44 +02:00
Alexander Barton 1680ea02da Free already saved password when storing a new one
This shouldn't happen (clients aren't allowed to send more than one PASS
command), but who knows ...
2012-08-26 19:07:38 +02:00
DNS777 1aaf54ac24 Implement channel mode "M"
Only the server, identified users and IRC operators are able to talk.
2012-08-26 16:40:49 +02:00
Alexander Barton a5984c702a Remove unused ERR_CANNOTSENDTOCHAN2_MSG message 2012-08-26 16:15:44 +02:00
DNS777 9a82304ae9 Add some more information to channel error numerics 2012-08-26 16:14:40 +02:00
DNS777 c2b39fdede Implement an Unreal-like user mode "B" ("Bot mode") 2012-08-26 15:58:37 +02:00
DNS777 8349a1c0d9 Recognize user mode "R"
This allows users to unset the user mode "R".
2012-08-26 15:30:49 +02:00
Alexander Barton 360a254be0 Enhance "ServiceMask" to handle a list of masks
The "ServiceMask" variable in "Server" blocks now can handle more than
one mask using the new MatchCaseInsensitiveList() function.

This makes marking "service clients" much more specific, which is a
good thing per se, but which is the prerequisite for reasonably
blocking these nick names, too (see commit a6dd2e3 for details).
2012-08-26 13:24:54 +02:00
Alexander Barton ab1fcebeff New function MatchCaseInsensitiveList() to check list of patterns 2012-08-26 13:11:45 +02:00
Alexander Barton a6dd2e33c2 Block nicknames that are reserved for services
This patch introduces the new function Conf_NickIsBlocked() which checks
if a given nick name matches with the "service mask" of a configured server.
And Client_CheckNick() uses this information to deny such names for regular
IRC users.

So nick names intended for IRC services are more protected and can't be used
by regular users even when the "services pseudo-server" isn't connected to
the network.

But please note:

Up to now, there can be only one "ServiceMask" pattern per server, which
most probably blocks much more nick names than really required ...
So "ServiceMask" should allow more than one pattern which can be more
specific, and most probably it should be possible to block nick names in
the global server configuration as well.

Nick names introduced by other servers/services are never restricted.
2012-08-26 12:33:21 +02:00
Alexander Barton 9d8974d509 Rename Conf_IsService() to Conf_NickIsService() 2012-08-26 12:27:51 +02:00
Alexander Barton 037b4b76df Check_Connections(): code cleanup 2012-08-26 12:04:40 +02:00
Brett Smith be97fa8ab1 Indentation and style fixes. 2012-08-23 14:18:15 -04:00
Brett Smith 164954a788 Connection password is not constant.
Saying otherwise makes a warning when we assign this to
conv.appdata_ptr in pam.c.
2012-08-23 13:59:17 -04:00
Brett Smith c1d7f6216f Implementation clean-ups.
* Have Conn_Password return an empty string when no password has been set,
  to play better with pam.c.

* Use strdup in Conn_SetPassword.
2012-08-23 12:24:34 -04:00
Brett Smith 7df4c12da9 Dynamically allocate memory for connection password. 2012-08-23 12:12:15 -04:00
Brett Smith 0d5de60584 Move client password from the Client to the Connection struct.
This is a relatively naive implementation, basically doing the bare minimum
necessary to make the switchover go.  Subsequent commits can focus on
improving the implementation.
2012-08-23 11:07:08 -04:00
Alexander Barton 922540306e ngt_RandomStr(): Add implicit cast to "unsigned".
This fixes the following warning of Xcode 4.5:

 src/tool/tool.c:150:19:
  Implicit conversion loses integer precision: 'long' to 'unsigned int'
2012-08-18 12:34:11 +02:00
Alexander Barton d48e440a72 Fix a buffer overflow when initializing the random salt for "+x"
This "off by one" buffer overflow has been introduced in commit 49385a98,
"Implemented hashed cloaked hostnames for +x".
2012-08-16 23:51:28 +02:00
Sebastian Köhler 097c72aa65 Tests and documentation for xop 2012-08-06 04:42:20 +02:00
Sebastian Köhler 7b01bb833f Implemented xop support
3 new channel user modes have been added.

Half Op: +h(Prefix: %) can set the channel modes +imntvIbek
and kick all +v and normal users.

Admin: +a(Prefix: &) can set channel modes +imntvIbekoRsz and kick all
+o, +h, +v and normal users.

Owner: +q(Prefix: ~) can set channel modes +imntvIbekoRsz and kick all
+a, +o, +h, +v and normal users
2012-08-06 04:42:09 +02:00
Alexander Barton cfd0bddc30 Fix compiler warning when not building with ZLIB support
This fixes:

 irc.c: In function ‘Option_String’:
 irc.c:333:9: error: variable ‘options’ set but not used
2012-08-06 01:35:56 +02:00
Sebastian Köhler d0bb185cf5 Hashed hostnames for CloakHost
Implemented support for hashed hostnames for CloakHost. The admin can
use '%x' in both the CloakHost and CloakHostModeX setting. The config
option CloakHostModeX was renamed to CloakHostSalt. This salt is used
for both cloaking options.
2012-08-03 04:10:11 +02:00
Sebastian Köhler 49385a98b2 Implemented hashed cloaked hostnames for +x
CloakHostModeX can now contain '%x'. It will be replace by the hash of
the original client hostname. The new config option CloakHostModeXSalt
defines the salt for the hash function. When CloakHostModeXSalt is not
set a random salt will be generated after each server restart.

Spelling fix in defines.h
2012-08-03 04:09:37 +02:00
Alexander Barton 7b6b492bdd Rename "CloakModeHost" option to "CloakHostModeX" 2012-06-09 01:58:40 +02:00
Christoph Biedl aa7db2c0e9 Introduce new configuration option "CloakModeHost"
This closes bug #124.
2012-06-09 01:58:25 +02:00
Alexander Barton 684e50f0a4 Correctly handle asynchronously re-established server links
Don't try to establish an outgoing server link after DNS lookup when this
server re-connected on its own in the meantime.
In addition, log a warning message if we try to update the connection
index of an already connected server structure -- and ignore it.

Up to now, both behaviour could lead to a race when the remote server
connects to this daemon while it still prepares the outgoing connection:

 - The local server prepares the new outgoing connection ...
 - in the meantime the remote server becomes connected and registered.
 - Now the new outgoing connection overwrites the (correct) socket handle,
 - then the 2nd connection becomes disconnected: "already registered",
 - and the 1st connection becomes unhandled ("gets lost") because the
   configuration structure is reset because of the wrong socket handle.

This patch hopefully fixes all these problems.
2012-06-09 01:03:48 +02:00
Alexander Barton 4a90959cb5 Log a debug message when SIGUSR2 is handled 2012-06-08 22:08:52 +02:00
Alexander Barton e7e47e77a3 NoticeAuth: Fix test if IDENT reply has been invalid
This fixes

 conn.c: In function ‘cb_Read_Resolver_Result’:
 conn.c:2252: warning: comparison between pointer and integer
2012-06-02 00:32:19 +02:00
Alexander Barton 695df6532e IDENT reply: only allow alphanumeric characters in user name
Only alphanumeric characters are allowed in the user name, so ignore
all IDENT replies that would violate this rule and use the one supplied
by the USER command.
2012-06-02 00:24:53 +02:00
Alexander Barton 6680b536c4 USER command: only allow alphanumeric characters in user name
Only alphanumeric characters are allowed in the user name, so terminate
the connection if any "strage" characters have been supplied by the user.

This is how other IRC daemons (like ircd2.11 and ircd-seven) behave ...
2012-06-01 23:57:51 +02:00
Alexander Barton c0d059cd0e Change wording of "TLS initialized" message
Don't use the word "socket" to identify the connection number, but use the
word "connection" like on all the other messages logged.
2012-05-23 17:12:31 +02:00
Alexander Barton 7faa3ed7d6 Pidfile_Create(): Don't leak file descriptor on error path
Detected by cppcheck:
 [src/ngircd/ngircd.c:502]: (error) Resource leak: pidfd
2012-05-22 13:31:08 +02:00
Alexander Barton 5e5377a063 Numeric 005 (ISUPPORT), CHANMODES: add missing mode "r" 2012-05-01 13:42:57 +02:00
Alexander Barton a8aa8c6cbc irc-cap.c: mark arguments of Handle_CAP_ACK() as "unused"
This fixes

 irc-cap.c: In function ‘Handle_CAP_ACK’:
 irc-cap.c:163: warning: unused parameter ‘Client’
 irc-cap.c:163: warning: unused parameter ‘Arg’
2012-04-29 12:39:28 +02:00
Alexander Barton f01b09ce84 irc-login.c, login.c: add missing include of "string.h"
This fixes the following warnings with GCC 4.4.5 on Linux:

 irc-login.c: In function ‘IRC_PASS’:
 irc-login.c:92: warning: implicit declaration of function ‘strlen’
 irc-login.c:92: warning: incompatible implicit declaration of built-in function ‘strlen’
 irc-login.c:113: warning: incompatible implicit declaration of built-in function ‘strlen’
 irc-login.c:129: warning: implicit declaration of function ‘strchr’
 irc-login.c:129: warning: incompatible implicit declaration of built-in function ‘strchr’
 irc-login.c:133: warning: implicit declaration of function ‘strcmp’
 irc-login.c: In function ‘IRC_SERVICE’:
 irc-login.c:556: warning: incompatible implicit declaration of built-in function ‘strchr’
 login.c: In function ‘Login_User’:
 login.c:131: warning: implicit declaration of function ‘strcmp’
2012-04-29 12:36:23 +02:00
Alexander Barton 76565022fb Merge branch 'capabilities'
* capabilities:
  "multi-prefix" capability 2/2: adjust NAME and WHO handlers
  "multi-prefix" capability 1/2: implement complete CAP infrastructure
  IRC_Send_NAMES(): Code cleanup
  New function Client_CapSet() in addition to Client_Cap{Add|Del}
  "CAP REQ" starts capability negotiation and delays user registration
  Correctly handle "CAP END", new client type CLIENT_WAITCAPEND
  Implement core IRC capability handling and "CAP" command
  New "login" source file
  Introduce_Client() => Client_Introduce(), and move it to client.c
2012-04-28 00:49:37 +02:00
Alexander Barton 4602cb9891 "multi-prefix" capability 2/2: adjust NAME and WHO handlers
The NAME and WHO commands now return multiple usermode prfixes when
the "multi-prefix" capability is in effect for the requesting client.

See <http://ircv3.atheme.org/extensions/multi-prefix-3.1>
2012-04-28 00:39:21 +02:00
Alexander Barton 1d7e99531a "multi-prefix" capability 1/2: implement complete CAP infrastructure
Now ngIRCd is able to handle "CAP LS", "CAP REQ", "CAP LIST", and
"CAP CLEAR" commands.

"multi-prefix" can be set/unset, but has no functionality - yet!
2012-04-28 00:36:41 +02:00
Alexander Barton f0a9dbe3ad IRC_Send_NAMES(): Code cleanup 2012-04-28 00:20:42 +02:00
Alexander Barton 245782897b New function Client_CapSet() in addition to Client_Cap{Add|Del} 2012-04-27 23:56:56 +02:00
Alexander Barton 2327b17656 "CAP REQ" starts capability negotiation and delays user registration
New helper function Set_CAP_Negotiation().
2012-04-27 22:47:22 +02:00
Alexander Barton d67d077a71 Fix 8ec17063: "Lists_Add(): use size of destination when copying data"
Thanks to Florian Westphal for spotting my silliness ...
2012-04-18 17:54:54 +02:00
Alexander Barton 8ec17063a6 Lists_Add(): use size of destination when copying data
This fixes the following warning of clang:

/src/ngircd/lists.c:152:44:
 warning: size argument in 'strlcpy' call appears to be size of the
 source; expected the size of the destination [-Wstrlcpy-strlcat-size]

But it isn't a real problem, because the size of the source always is the
same than the size of the destination ...
2012-04-17 12:54:38 +02:00
Alexander Barton da4c1ebe81 Correctly handle "CAP END", new client type CLIENT_WAITCAPEND 2012-03-31 16:37:31 +02:00
Alexander Barton bd3a7ccb15 Implement core IRC capability handling and "CAP" command
This patch implements the core functions to support "IRC Capabilities"
and the IRC "CAP" command as used by other servers and specified here:
<http://www.leeh.co.uk/draft-mitchell-irc-capabilities-02.html>.

It enables ngIRCd to support the defined handshake, but it doesn't
implement any capabilities, so "CAP LS" and "CAP LIST" always return
the empty set and "CAP REQ ..." always fails with "CAP NAK".
2012-03-31 15:59:06 +02:00
Alexander Barton edfcc2f9d5 New "login" source file
Rename Hello_User[_PostAuth] to Login_User[_PostAuth] and move it to the
new login.c; and move cb_Read_Auth_Result(), too. This will enable further
code to easily call Login_User() when required.
2012-03-31 15:38:46 +02:00
Alexander Barton ee362b3bd2 Introduce_Client() => Client_Introduce(), and move it to client.c 2012-03-31 15:24:30 +02:00
Alexander Barton 67bd1bf34f Makefiles: list each source files on a separate line
Patches that add/remove source files become much nicer this way :-)
2012-03-31 12:52:58 +02:00
Alexander Barton 88c3d4896a Don't ignore "permission denied" errors when enabling chroot
Up to now, ngIRCd silently ignored permission denied errors when trying
to enable a chroot setup: only the "not running chrooted" message became
logged later on.

This patch lets ngIRCd exit with a fatal error when the chroot can't
be enabled on startup -- this is the much safer bevahiour!
2012-03-28 11:30:48 +02:00
Alexander Barton 0d9740b9fa Fix gcc warning, initialize "list" variable to NULL
This fixes the following warning with gcc 4.6.3.:

  irc-mode.c: In function "Channel_Mode":
  irc-mode.c:947:26: error: "list" may be used uninitialized
                     in this function
  irc-mode.c:884:25: error: "list" may be used uninitialized
                     in this function

(The variable has never been used uninitialized, so don't worry)
2012-03-12 22:27:55 +01:00
Alexander Barton 17ffda1c8a Fix typo: recieved -> received
Thanks to Christoph Biedl.
2012-03-12 09:47:19 +01:00
Christoph Biedl 257fe922d2 getpid.sh: Fix testcase error for Debian using sbuild
When

 * building the ngircd Debian package (on Linux at least) and
 * using the sbuild build system,

the command "ps -af" does not include the commands running inside the
sbuild system. Therefore, start-server.sh will report a fail as getpid.sh
cannot not  find the ./T-ngircd1 just started although it's actually
running. This results in a funny build log ...

         starting server 1 ... failure!
   FAIL: start-server1
         running connect-test ... ok.
   PASS: connect-test

The self-test of getpid.sh however will likely succeed as it's happy if
it sees any process with "sh" somewhere in the name. Things go downhill
from there.

The confusing things are:

  * The alternative cowbuilder/pbuilder does not have this problem.
  * The alternative usage "ps ax" does fine.

So, as a quick hack, the patch attached adds another switch to getpid.sh.
2012-03-03 18:53:03 +01:00
Alexander Barton 1068f88377 Don't log "ngIRCd hello message" two times
Start "regular" logging not until the configuration file has been read in
and "SyslolgFacility" is set, and log all configuration errors using the
generic "daemon" facility.

So if there are no configuration errors, logging starts right after parsing
the configuration and we log the configuration file used _after_ reading it.
But this is no problem because every configuration error message includes
the configuration file name as well.

(The "double hello" has been introduced by commit 3641e51109)
2012-03-02 09:41:13 +01:00
Alexander Barton c38751191f Don't accept "[SSL]" in config when no SSL support is built in 2012-02-26 15:52:12 +01:00
Alexander Barton 5cbdcf4f0d Fix C syntax: duplicate ";;" should be ";"
Using gcc 2.7.2, this fixes:

 irc-channel.c: In function `join_allowed':
 irc-channel.c:86: parse error before `const'
2012-02-26 15:27:04 +01:00
Alexander Barton 3641e51109 Correctly re-open syslog logging after reading of configuration
Syslog logging has been initialized before reading the configuraton
file, so ngIRCd always used the default facility and ignored the
"SyslogFacility" configuration option.

Thanks to Patrik Schindler for reporting this issue!
2012-02-14 11:01:13 +01:00
Alexander Barton 3f46e93ccc Logging: remove "Activating ..." info message 2012-02-14 10:32:58 +01:00
Alexander Barton 391aa8d1f7 Fix forwarding of LIST commands
Bug reported by Cahata, thanks!
2012-02-12 13:51:43 +01:00
Alexander Barton c16133c5ee New_Connection(): don't set the client hostname twice
Setting the hostname twice doesn't do much harm a lot, but isn't elegant.
And for IPv6 addresses, it isn't correct the first time (missing []) ...
2012-01-25 17:11:44 +01:00
Alexander Barton 4888984429 Client_SetHostname(): Code cleanup, more debug logging 2012-01-25 17:11:00 +01:00
Florian Westphal 44bb22d23e io: use define for number of possible events 2012-01-24 22:25:22 +01:00
Florian Westphal c7dd5ea0ba io: remove outer do {} while loops for epoll/kqueue/devpoll backends
simplifies things a bit. io_dispatch() is called repeatedly from the
main loop.
2012-01-24 21:57:23 +01:00
Alexander Barton 871760583c Enhance server command limits
This patch updates the limits for handling commands from a remote server:

 - "<user count> / 5 + <min>" using "<min>=10" during normal operation,
 - the above count multiplied with 5 while servers are syncing.

The intention is to a) make the limit dependent of the number of users
in the network (the more users, the more commands required to sync) and
b) to significantly rise this limit while servers are joining the network
to make the login and synchronization faster.
2012-01-24 02:55:53 +01:00
Alexander Barton bc20f9ec10 Send a PING at the end of the server sync to detect it
At the end of sending all "state" to the remote server, a PING command
is sent to request a PONG reply. Until then, no "regual" PING was sent,
so Conn_LastPing(<connection>) is null and now becomes non-null in the
PONG command handler.

So the servers are still synchronizing when Conn_LastPing(<connection>)
is 0, which could easily be tested.
2012-01-24 02:46:12 +01:00
Alexander Barton 5a200e1543 New function Conn_UpdatePing() to update the "ping timestamp" 2012-01-24 02:44:57 +01:00
Alexander Barton d2df7396a8 Conn_UpdateIdle(): Code cleanup 2012-01-24 02:43:55 +01:00
Alexander Barton 3d27073d61 RPL_ISUPPORT_MSG(005): add "EXCEPTS=e INVEX=I"
Thanks to Cahata for the idea!
2012-01-23 22:07:40 +01:00
Alexander Barton b6f19ea8fe Fix "MAXLIST=beI:50": the limit is the sum of all lists
"Modes which are specified in the same pair share the same maximum size",
so "beI:50" means a total of 50 entries, regardless of the list.

See <http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt>,
thanks to Cahata for reporting this!
2012-01-23 21:51:38 +01:00
Alexander Barton 594fdd02aa New RPL_WHOISHOST_MSG(378): show hostname and IP address
The numeric RPL_WHOISHOST_MSG(378) returns the DNS hostname (if
available) and the IP address of a client in the WHOIS reply.

Only the user itself and local IRC operators get this numeric.
2012-01-22 22:41:39 +01:00
Alexander Barton 6a308fcb42 New function Conn_GetIPAInfo(): get IP address of a connection 2012-01-22 22:35:27 +01:00
Alexander Barton 1537c79132 G/K-Lines: only add and delete valid IRC masks 2012-01-22 18:53:16 +01:00
Alexander Barton e0c9931ad8 Check G/K-Lines before the client has been registered, too
This allows to use "*!<user>@<host>" or "*!*@<host>" masks to reject
clients even before receiving PASS, NICK and USER commands and before
forking authentication child processes which reduces resource usage.
2012-01-22 18:35:54 +01:00
Alexander Barton eba95bb0d2 Streamline handling of connection rejects (bad password, G/K-line)
- Use Client_Reject(), get rid of Reject_Client().
 - Refactor Class_IsMember() to Class_GetMemberReason(),
 - New function Class_HandleServerBans().
2012-01-22 18:33:45 +01:00
Alexander Barton 51a6a33056 New function Client_Reject() to reject clients on connect 2012-01-22 18:17:28 +01:00
Alexander Barton 6e28f4a7d1 New function Lists_CheckReason() to get reason of list entries 2012-01-22 18:11:24 +01:00
Alexander Barton 73781c1b38 Fix ERR_{SUMMON|USERS}DISABLED: don't repeat command name in reply 2012-01-22 15:42:11 +01:00
Alexander Barton f2fa1045e2 Implement channel exception list (mode 'e')
This allows a channel operator to define exception masks that allow users
to join the channel even when a "ban" would match and prevent them from
joining: the exception list (e) overrides the ban list (b).
2012-01-21 19:59:57 +01:00
Alexander Barton 33a165721b {Add|Del}_Ban_Invite > {Add_To|Del_From}_List(): more generic 2012-01-21 19:27:03 +01:00
Alexander Barton a3a4b5f696 Rename ShowInvitesBans() to ShowChannelList(), make it more flexible 2012-01-21 13:48:31 +01:00
Alexander Barton 39412d6486 PRIVMSG/NOTICE: handle nick!user@host masks case-insensitive
And enhance our test suite to check this a little bit better :-)
2012-01-21 13:21:36 +01:00
Alexander Barton c1656256df PRIVMSG/NOTICE: don't stop list processing on invalid target
Process further targets, even if one has been a server ID:
just skip this one with an error message and continue.
2012-01-16 12:37:37 +01:00
Alexander Barton 1f4711a547 Implement user mode 'C': require "same channel" to send message
If the target user of a PRIVMSG or NOTICE command has the user mode 'C'
set, it is required that both sender and receiver are on the same channel.

This prevents private flooding by completely unknown clients.
2012-01-16 11:43:22 +01:00
Alexander Barton 4d0069c3a8 New RPL_WHOISREGNICK_MSG(307) numeric: indicate if nick is registered 2012-01-16 02:18:24 +01:00
Alexander Barton 12c60a670e IRC_WHOIS_SendReply(): Code cleanup 2012-01-16 02:15:41 +01:00
Alexander Barton 2f7d0c0839 Limit channel invite and ban lists to 50 entries
- New function Lists_Count().
 - New limit #define MAX_HNDL_CHANNEL_LISTS = 50.
 - New numeric #define ERR_LISTFULL_MSG(478).
 - Adjust numeric RPL_ISUPPORT2_MSG(005) accordingly ("MAXLIST")
2012-01-16 00:29:36 +01:00
Alexander Barton 1afbf71236 Make Send_ListChange() a little bit more generic 2012-01-16 00:15:26 +01:00
Alexander Barton 7ed08f01ef Remove unused prototype of Lists_AlreadyRegistered()
This prototype has been introduced by commit fa7bb279 in 2006,
but as far as I can see, this function never existed ...
2012-01-15 19:46:00 +01:00
Alexander Barton 81cc5f82b5 Channel lists: Fix duplicate check and error messages
- Check correct list for duplicates when adding items.
 - Don't generate any messages when adding duplicates or removing
   non-existing items (this is how ircd-seven and ircu behave).
 - Code cleanup: Add_Ban_Invite(), Del_Ban_Invite().
2012-01-15 19:11:03 +01:00
Alexander Barton 78a3b4c7d6 Don't enforce MAX_HNDL_MODES_ARG on server and service links 2012-01-15 14:33:04 +01:00
Alexander Barton d4d8102fc9 Don't stop join handling on faulty channel, skip it (part #2)
Commit 565523cb allowed processing of further channel names given to the
JOIN command when a single name was invalid.

After this patch, the JOIN command handler continues to process channel
name lists even after errors like "channel is full", "too many channels",
and the like and generates appropriate error messages for all the
channels given by the client.
2012-01-13 10:50:00 +01:00
Alexander Barton 77f68b4fd1 JOIN command: don't check channel limit if already member
Don't check the channel limit and don't report "too many channels"
when trying to join a channel that the client is already a member of.
2012-01-13 10:40:20 +01:00
Alexander Barton 2f8877ded4 Return ERR_UNKNOWNMODE(472) for unknown channel modes
The daemon reported ERR_UMODEUNKNOWNFLAG(501), which is wrong.
2012-01-09 23:18:39 +01:00
Alexander Barton 4bff3daf92 Numberic 005 (ISUPPORT), CHANMODES: add "O", "R", "z" modes 2012-01-09 12:34:55 +01:00
Alexander Barton c5beca8aab Limit list replies of LIST, WHO, WHOIS, and MAX_RPL_WHOWAS
Introduce new #define's MAX_RPL_LIST(100), MAX_RPL_WHO(25),
MAX_RPL_WHOIS(10), and MAX_RPL_WHOWAS(25).
2012-01-06 20:06:25 +01:00
Alexander Barton f8405b1a4f New function IRC_CheckListTooBig() to check size of list replies
It the limit is reached, a NOTICE is sent to the client and list
processing should stop.
2012-01-06 20:05:07 +01:00
Alexander Barton fdfc27265e LIST command: compare pattern case insensitive 2012-01-06 19:55:21 +01:00
Alexander Barton a4d1e6007f IRC_LIST(): Code cleanup 2012-01-06 19:54:23 +01:00
Alexander Barton 9260759cec DEFAULT_WHOWAS->DEF_RPL_WHOWAS; MAX_CMODES_ARG->MAX_HNDL_MODES_ARG
To streamline naming, in preparation for MAX_RPL_WHO and MAX_RPL_WHOWAS :-)
2012-01-06 18:57:31 +01:00
Alexander Barton c2ac1ad3ba defines.h: Code cleanup and (a little bit) more documentation 2012-01-06 18:25:10 +01:00
Alexander Barton 470d2e2362 RPL_ISUPPORT (numeric 005): Report MODES=<MAX_CMODES_ARG>
"Maximum number of channel modes with parameter allowed per MODE command."
See <http://www.irc.org/tech_docs/005.html> for details.
2012-01-06 17:46:52 +01:00
Alexander Barton 888664435a Channel modes: really break handling when MAX_CMODES_ARG is hit
This fixes 98493077.
2012-01-06 17:43:20 +01:00
Alexander Barton 98493077a2 channel modes: only handle MAX_CMODES_ARG modes with arguments
Limit the MODE command to handle a maximum of MAX_CMODES_ARG (5) channel
modes that require an argument (+Ibkl) per call.

Please note: Further modes that require arguments are silently ignored
and end the handling of any further modes.
This is similar to the behavior of ircd2.11 (silently ignores but seems
to handle other modes) as well as ircd-seven (silently ignores but handles
some(!) other modes) ...
2012-01-06 17:27:29 +01:00
Alexander Barton 1fa2af5b3a Fix handling of channel mode sequence with/without arguments
For example, don't generate wrong error messages when handling
"MODE #chan +IIIIItn *!aa@b *!bb@c *!cc@d *!dd@e *!ee@f".
2012-01-06 17:24:55 +01:00
Alexander Barton 05cc9bf9b0 Conn_Write(): Make sure there is a client when detecting its type
The assert(client != NULL) got triggered during our tests, so there is
an error path that resulted in the connection being still established
(sock >= 0) but the client structure already freed.

So Conn_Write() should handle it!
2012-01-06 03:26:24 +01:00
Alexander Barton cc06e1ff89 Proc_Close(): Only close socket if it is still valid
It could be invalid when calling Proc_Close() a 2nd time, for exmaple,
which could happen when we hit a timeout doing IDENT requests :-(
2012-01-06 02:26:04 +01:00
Alexander Barton 9fbf592924 WHOIS command: make sure matching is case-insensitive
And make sure that RPL_ENDOFWHOIS replies with the unmodified mask
like it has been received from the client.
2012-01-05 00:51:39 +01:00
Alexander Barton adf92302bf WHOIS command: don't anser queries for IRC servers
Thanks to Cahata for spotting this!
2012-01-05 00:24:46 +01:00
Alexander Barton 566a451299 WHOIS command: make sure the reply ends with RPL_ENDOFWHOIS
Up to now, each reply for itself ended in RPL_ENDOFWHOIS and queries
for unknown nick names lacked the RPL_ENDOFWHOIS -- both is wrong.
2012-01-05 00:22:57 +01:00
Alexander Barton 5e3449a241 LINKS command: support <mask> parameter
The <mask> can be used to limit the servers shown in the listing.
2012-01-04 22:51:02 +01:00
Alexander Barton 762b0325df IRC_LINKS(): Code cleanup; more documentation 2012-01-04 22:49:18 +01:00
Alexander Barton 6b62a5ec4f Add 1 second penalty for every further target on PRIVMSG/NOTICE
This reduces the possibility of flooding channels with commands like
"PRIVMSG/NOTICE #a,#n,#c,... :message" a little bit.

Problem noticed by Cahata -- thanks!
2012-01-04 21:46:58 +01:00
Alexander Barton b24d645ca1 Conn_SetPenalty(): Add new "penalty time" on each function call
Until now, the penalty time has only been set when longer as the
already set one, so it didn't accumulate.

And add documentation for and clean up code in Conn_SetPenalty() and
Conn_ResetPenalty() functions.
2012-01-04 21:39:46 +01:00
Alexander Barton 1bb2fbedcc Enhance log messages when setting user and group 2012-01-03 21:05:35 +01:00
Alexander Barton 3193d5477c NGIRCd_getNobodyID(): Code cleanup 2012-01-03 20:49:42 +01:00
Alexander Barton edab86e0f8 Display correct error message when "Server{UID|GID}" is invalid
This partly closes bug #118. ngIRCd still starts up even when
Server{UID|GID} is invalid: then the daemon falls back to "nobody"
when running with root(0) privileges (as before).
2012-01-03 20:37:41 +01:00
Alexander Barton e4006a93e3 NGIRCd_Init(): Code cleanup 2012-01-03 19:34:54 +01:00
Alexander Barton 9069380ddf main(): Code cleanup 2012-01-03 19:25:31 +01:00
Alexander Barton 5eb9f2e717 Update Copyright notices for 2012 2012-01-03 11:30:45 +01:00
Florian Westphal abfc5c6e27 lists: don't crash if reason ptr is NULL
commit 15fec92ed7
(Update list item, if it already exists) can make ngircd
crash because 'Reason' can be NULL, as reported by
Cahata on the ngircd mailing list.

Doesn't affect any released ngircd versions.

Also, make sure that we do not pass NULL as arguments
to a '%s' printf-like function.
2012-01-02 23:43:13 +01:00
Alexander Barton 565523cbb4 Don't stop join handling on faulty channel, skip it
When JOIN is received with more than one channel name, don't stop
processing on the first error (e.g. bad name, wrong channel key, ...)
but report an error and continue with the other given channel names.

Reported by Cahata -- thanks!
2012-01-02 15:23:17 +01:00
Alexander Barton 013298d4c6 IRC_JOIN(): Code cleanup 2012-01-02 15:22:52 +01:00
Alexander Barton af13732ec7 ISON command: reply with correct upper-/lowercase nick names
Reported by Cahata -- thanks!
2012-01-02 15:06:44 +01:00
Alexander Barton 408a74b865 IRC_ISON(): Code cleanup 2012-01-02 15:04:40 +01:00
Alexander Barton f47904bf95 Remove unused "bool have_arg" from IRC_WHO()
This fixes:

 irc-info.c: In function ‘IRC_WHO’:
 irc-info:936:18: warning: variable ‘have_arg’ set but not used
2012-01-02 00:56:31 +01:00
Alexander Barton 56b7e67307 New configuration option "PAMIsOptional"
When "PAMIsOptional" is set, clients not sending a password are still
allowed to connect: they won't become "identified" and keep the "~"
character prepended to their supplied user name.
2012-01-01 17:12:36 +01:00
Alexander Barton b681aa5b9f PAM: don't use global password buffer for conv struct
Use the pointer of the password of the client directly.
Eventually we can get rid of the global password again ...
2011-12-31 18:06:17 +01:00
Alexander Barton 1a5ed654b4 Fixed handling of WHO commands
This fixes two bugs:
 - "WHO <nick>" returned nothing at all if the user was "+i"
   (reported by Cahata, thanks).
 - "WHO <nick|nickmask>" returned channel names instead of "*"
   when the user was member of a (visible) channel.

Clean up code and add documentation as well.
2011-12-30 14:57:12 +01:00
Alexander Barton 9cbb8f3bb8 Remove unused "time_t now" from Lists_Check()
This fixes:

 lists.c: In function ‘Lists_Check’:
 lists.c:330:9: warning: variable ‘now’ set but not used
2011-12-30 01:03:59 +01:00
Alexander Barton e19ce437ca Fixed some spelling errors in documentation and code comments
Thanks to Christoph Biedl!
2011-12-30 00:50:27 +01:00
Alexander Barton 765c2f26ea Fixed typo in two error messages
Thanks to Christoph Biedl!
2011-12-30 00:32:11 +01:00
Alexander Barton 69fa6f268a LUSERS reply: only count "visible" channels
Rename Channel_Count() to Channel_CountVisible() and only count channels
that are visible to the requesting client, so the existence of secret
channels is no longer revealed by using LUSERS.

Reported by Cahata -- thanks!
2011-12-28 15:11:01 +01:00
Alexander Barton 43509fd22c IRC_Send_LUSERS(): Code cleanup 2011-12-28 14:52:21 +01:00
Alexander Barton a71abfef4b Don't stop mode handling on unknown modes; skip it
Unknown user and channel modes no longer stop the mode parser, but are
simply ignored. Therefore modes after the unknown one are now handled.

This is how ircd2.10/ircd2.11/ircd-seven behave, at least.

Reported by Cahata -- thanks!
2011-12-28 14:46:17 +01:00
Alexander Barton 8a8e8a3a23 IRC_xLINE(): output an error message for unexpected "lines"
This fixes:

 irc-oper.c: In function ‘IRC_xLINE’:
 irc-oper.c:429: warning: ‘class’ may be used uninitialized in this function
 irc-oper.c:430: warning: ‘class_c’ may be used uninitialized in this function
2011-12-25 20:11:43 +01:00
Alexander Barton 15fec92ed7 Update list item, if it already exists
This updates the "validity" (timeout) as well as the "reason" text,
if given.
2011-12-25 19:43:00 +01:00