Commit Graph

1916 Commits

Author SHA1 Message Date
Alexander Barton 8d8201502f IRC_WHO_Channel(): Use strlcpy() instead of strcpy()
This fixes the following warning, at least on OpenBSD 4.8:

 irc-info.o(.text+0x2427): In function `IRC_WHO':
 src/ngircd/irc-info.c:896: warning: strcpy() is almost always misused,
                            please use strlcpy()
2013-01-27 01:00:32 +01:00
Alexander Barton d38d153f51 Streamline punctuation of log messages
Make sure that all log messages end with a correct punctuation mark.

The rules for formatting log messages are:

 1. Add punctuation marks to all messages passed to the actual logging
    functions like Log() and LogDebug().
 2. Don't add any punctuation marks to messages that are stored in
    variables for later use or are passed over the network.
 3. IP addresses, DNS host names and IRC server names should be quoted.
 4. Messages originating in the network should be quoted (at least if
    they are "untrusted" or variable).

Most probably this patch doesn't fix all mistakes, but it should be a
good starting point ...
2013-01-26 17:00:03 +01:00
Alexander Barton 508ca3044d Return better "Connection not registered as server link" errors
Now ngIRCd returns a more specific error message for numeric
ERR_NOTREGISTERED(451) when a regular user tries to use a command that
isn't allowed for users but for servers: ERR_NOTREGISTEREDSERVER(451).
2013-01-22 10:54:06 +01:00
Alexander Barton d8f2964710 MODE: don't report error on "more modes than parameters"
Don't report ERR_NEEDMOREPARAMS(461) when a MDOE command with more modes
than nicknames is handled, as well as for channel limit and key changes
without specifying the limit or key parameters.

This is how a lot (all?) other IRC servers behave, including ircd2.11,
InspIRCd, and ircd-seven. And because of clients (tested with Textual and
mIRC) sending bogus MODE commands like "MODE -ooo nick", end-users got the
expected result as well as correct but misleading error messages ...

If ngIRCd is compiled using "strict mode", these errors are still reported.

Reported-by: Tim <tim@stackwatch.net>
2013-01-13 17:18:04 +01:00
Alexander Barton ab00997698 Correctly detect when SSL subsystem must be initialized
This patch introduces the new function Conf_SSLInUse() to check when the
current server configuration requires the SSL subsystem to be initialized
and accounts incoming as well as outgoing connections -- so this fixes
commit bb20aeb9 ("Initialize SSL when needed only, and disable SSL on
errors") which only handled the inbound case  ...

Tested-by: Brett Smith <brett@w3.org>
2013-01-07 20:34:55 +01:00
Alexander Barton 68cb1a8c2e Merge branch 'bug145-ProvideHelp'
* bug145-ProvideHelp:
  Use "${docdir}/Commands.txt" as help text file
  Add a note that "help file" is updated on startup and REHASH only
  Add doc/Commands.txt which should document all commands
  Implement Help() function parsing and returning the help text
  Document "HelpFile" in sample-ngircd.conf and ngircd.conf.5
  Implement new configuration option "HelpFile"
  IRC_HELP(): Code cleanup
  Refactor Read_Motd() into Read_TextFile()
2013-01-02 23:41:46 +01:00
Alexander Barton 950aeec3ff Use "${docdir}/Commands.txt" as help text file 2013-01-01 19:25:06 +01:00
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