Commit Graph

2020 Commits

Author SHA1 Message Date
Mantas Mikulėnas e273bd226a Show account name in WHOIS
This uses the same numeric as Charybdis and ircu families.
2014-01-20 14:25:11 +02:00
Alexander Barton e73d70ce6f Remove "range matching" functionality
Don't support "range marching" in our pattern matching code using
the "[...]" syntax, because [ and ] are valid characters in nick
names and one has to quote them currently using the "\" character,
which is quite unexpected. For example:

  Nick "te[st" => "MODE #channel +b te\[st"

And remove quoting altogether, too, because "*" and "?" don't need
to be quoted because these characters are not allowed in IRC masks,
nicks, and hostnames.

Reported by "hifi" (Toni Spets) on IRC, thanks!
2014-01-15 14:58:57 +01:00
Alexander Barton fe73835666 Client_SetHostname(): Don't use strlen() to test for value 2014-01-10 19:57:05 +01:00
Alexander Barton 8ae2cdfce9 Send "fake '*' key" in "MODE -k" replies
According to RFC 2812 3.2.3 "Channel mode message" and the examples
there, it looks like clients should use "MODE -k <key>" to unset channel
keys; and that's how other servers and services behave and do expect it.

(But please note that this is NOT the case for "MODE -l"!)

In the end, it doesn't make sense to specify a key when UNsetting it at
all, and different services behave diffrently when clients do not send
the currently set key to unset it - some ignore such calls, for example!

But this implementation is quite relaxed, it accepts any key when
unsetting channel mode "k" and even accepts no key at all. But the reply
will always include an "*" character for every "-k" parameter.
2014-01-08 14:24:03 +01:00
Alexander Barton 5d88030bd1 Support non-standard vsnprintf() return code
C99 states that vsnprintf() "returns the number of characters that
would have been printed if the n were unlimited"; but according to the
Linux manual page "glibc until 2.0.6 would return -1 when the output
was truncated" -- so we have to handle both cases ...
2014-01-04 23:57:05 +01:00
Alexander Barton 788da901ee Update Copyright notices for 2014 2014-01-02 15:27:07 +01:00
Alexander Barton 2a40112f09 Merge branch 'bug167-WebircIPAnoDNS' of git://arthur.barton.de/ngircd-alex
* 'bug167-WebircIPAnoDNS' of git://arthur.barton.de/ngircd-alex:
  WEBIRC: Don't respect hostname when DNS is disabled
2014-01-02 00:45:05 +01:00
Alexander Barton 61b7932e82 Merge branch 'bug165-005-NETWORK' of git://arthur.barton.de/ngircd-alex
* 'bug165-005-NETWORK' of git://arthur.barton.de/ngircd-alex:
  Implement new configuration option "Network"
2014-01-02 00:44:42 +01:00
Federico G. Schwindt 9230f2fff1 Fix permanent k/gline
Reported by Toni Spets (hifi - at - jnz - dot - fi).
2013-12-29 01:14:28 +01:00
Alexander Barton 86bdf6e1d4 Implement new configuration option "Network"
The new configuration variable "Network" is used to set the (completely
optional) "network name", to which this instance of the daemon belongs.
When set, this name is used in the ISUPPORT(005) numeric which is sent to
all clients connecting to the server after logging in.

Closes bug #165.
2013-12-27 23:16:11 +01:00
Alexander Barton 1a628fff51 WEBIRC: Don't respect hostname when DNS is disabled
When DNS lookups are disabled, don't set the hostname received by the
WEBIRC command, but use the IP address instead.

Reported by Toni Spets <toni.spets@iki.fi>, thanks!

Closes bug #167.
2013-12-27 22:34:47 +01:00
Alexander Barton b8433e9261 Check for working getaddrinfo() function
At least AIX 4.3.3 and 5.1 have a broken implementation of getaddrinfo()
which doesn't handle "0" as numeric service correctly. This patch adds
a configure check for this case and changes all calling functions to only
use getaddrinfo() if it "works".

See <http://www.stacken.kth.se/lists/heimdal-discuss/2004-05/msg00059.html>
2013-12-27 21:35:13 +01:00
Federico G. Schwindt 5a424f60da Fix spelling 2013-12-07 22:48:31 +00:00
Alexander Barton ae00c100ac Only use unsetenv() when it is available
AIX 4.3 dosn't support it, for example.
2013-11-10 17:08:51 +01:00
Alexander Barton 61d1c864c5 conf-ssl.h: make code compatible with pre-ANSI C compilers 2013-11-09 23:42:56 +01:00
Federico G. Schwindt 9ee3760493 Add comments around some IRC_SetPenalty() calls 2013-11-07 18:17:58 +00:00
Federico G. Schwindt 344185b1bd Rework the penalty handling slightly
Increase the penalty for a command before checking its arguments.  This
makes the handling more consistent and allow us to move more penalties to
Handle_Request().
2013-11-07 16:53:29 +00:00
Federico G. Schwindt fcf61e9e02 Move IRC_SetPenalty() to Handle_Request() when possible
This centralizes the penalty handling. It also exposes some commands that
lack it for our attention.
2013-11-07 16:29:21 +00:00
Federico G. Schwindt 9f236c4b91 Introduce a macro to define the command list
This will pave the way to other changes and simplifies the entries somewhat.
2013-11-07 13:20:08 +00:00
Federico G. Schwindt 00249f3c80 When sending an error use the IRC_WriteErrClient() variant
This ensures that all errors have a 2 second penalty.
2013-11-07 10:45:34 +00:00
Federico G. Schwindt 925b4de298 On bad /oper set the penalty to 10 seconds
This helps against brute-force attempts.
2013-11-06 21:46:53 +00:00
Federico G. Schwindt 48ea69d778 Remove unneded IRC_SetPenalty() calls
IRC_WriteErrClient() already calls IRC_SetPenalty().  While here convert
some IRC_SetPenalty() + IRC_WriteStrClient() to IRC_WriteErrClient().
2013-11-06 18:28:09 +00:00
Federico G. Schwindt 80d0613bf2 Use sizeof() intead of the explicit size 2013-11-06 18:25:11 +00:00
Alexander Barton 4ab688c5e8 Remove wrong #ifdef in Option_String()
This fixes the following error when compiling without zlib support:

  irc.c: In function ‘Option_String’:
  irc.c:487: error: ‘options’ undeclared (first use in this function)

Reported by "der_baer" on #ngircd.
2013-11-01 19:12:35 +01:00
Federico G. Schwindt 8e6db769ac Check and call arc4random_stir() if present
FreeBSD prior to 10.0 does not automatically stir on fork(). Same with
current NetBSD. If arc4random_stir() is present assume is needed and
call it instead of srand().
2013-10-23 16:00:26 +01:00
Federico G. Schwindt 62865f7e19 Add support for longer config lines
With the introduction of CipherList we could have longer config lines.
Handle up to 1024 bytes and warn if the line will be truncated.
2013-10-17 22:10:53 +01:00
Federico G. Schwindt a7dda1b28c Report the correct file on error 2013-10-17 21:52:15 +01:00
Federico G. Schwindt 17589534d0 Add support for arc4random
If arc4random is present it will be used over the srand/rand interface.
This fixes some warnings in OpenBSD-current.
2013-10-16 16:32:06 +01:00
Federico G. Schwindt ea26fd2840 Fix another strcat warning missed in commit 4c5b43 2013-10-16 10:41:40 +01:00
Alexander Barton 4c5b439992 ngircd.c, main(): use strlcat() instead of strcat()
This fixes the following warning on OpenBSD 5.3:

 ngircd.o(.text+0xeb4): In function `main':
  src/ngircd/ngircd.c:300: warning: strcat() is almost always misused,
                                    please use strlcat()

Thanks to Götz Hoffart for reporting this!
2013-10-07 21:56:09 +02:00
Alexander Barton 2798a12444 Actually KILL clients on GLINE/KLINE
Kill all clients that match a new GLINE/KLINE mask and genrate apropriate
KILL commands. These KILL commands can be superfluous, but are required
when the IRC Operator isn't allowd to set remote G-Lines or if there are
older servers in the network that don't kill clients on GLINE/KLINE.

Closes bug #156.
2013-10-01 12:26:34 +02:00
Alexander Barton 02182143c3 Don't forward KILL commands for unknown clients 2013-10-01 12:20:23 +02:00
Alexander Barton b5faf3055b New function IRC_KillClient() to kill clients
The old local function Kill_Nick() in irc.c has been an ugly hack. This
patch implements a generic function for killing clients.

Adjust all callers of Kill_Nick() and respect the return code!
2013-10-01 12:13:17 +02:00
Alexander Barton cccd8fc957 Adjust log messages for invalid and spoofed prefixes
Now invalid prefixes aren't logged no more when originating from an other
server (besides in debug mode), and spoofed prefixes are correctly logged
using LOG_WARNING (from an other server) or LOG_ERR (from a client) levels.

In addition, the log message texts have been adjusted to better reflect
what will happen: commands with invalid prefixes are ignored and logged,
commands with spoofed prefixes will result in the client being disconncted
(regular users) or the command being ignored (other servers).

This cleans up logging of commands related to already KILL'ed clients.
2013-09-26 02:28:16 +02:00
Alexander Barton eccbd97e1f Remove CLIENT.oper_by_my, Client_SetOperByMe() and Client_OperByMe()
All places where Client_OperByMe() is used can either be converted to
Client_HasMode(Client, 'o') or Op_Check().

And Op_Check() itself can use the connection handle for deciding whether
the IRC Operator is a local user or not.
2013-09-25 01:29:23 +02:00
Federico G. Schwindt ec5ab4fcd1 Add support to show user links using "STATS L"
Change "stats L" to show servers and user links and restrict it to
IRC Operators.
2013-09-24 21:17:35 +02:00
Alexander Barton 13a5358a3d Log an error (not info) when working directory can't be changed 2013-09-24 00:04:54 +02:00
Federico G. Schwindt 27b9d32bf2 Change the certificate fingerprint digest to sha256
While here correct some indentation.
2013-09-17 17:35:56 +01:00
Federico G. Schwindt 0985d69cc6 Change cipher defaults
Switch cipher defaults to HIGH:!aNULL:@STRENGTH (OpenSSL) or
SECURE128 (GnuTLS).
2013-09-17 17:15:24 +01:00
Alexander Barton d0977258ee Merge remote-tracking branch 'alex/bug162-SSLCipherList'
* alex/bug162-SSLCipherList:
  Cipher list selection for GnuTLS
  ConnSSL_Init_SSL(): correctly set CONN_SSL flag
  Cipher list selection for OpenSSL
  ConnSSL_InitLibrary(): Code cleanup
2013-09-16 17:32:25 +02:00
Federico G. Schwindt 2cebfc54f5 Fix server reconnection
In some error cases conn_id will be left as SERVER_WAIT and
subsequently ignored in Check_Servers(). Ensure conn_id is set to
NONE before returning from New_Server() if we couldn't establish
the connection.

Prompted by a report from gabrielgi-at-gmail-dot-com.
2013-09-16 02:15:49 +01:00
Alexander Barton de3e5fa77c Don't ignore SSL-related errors during startup
Without this patch, ngIRCd ignores SSL-related messages and continues
to start up but only listens on plain text communication ports -- and
this most probably isn't what the administrator wanted ...

Closes bug #163.
2013-09-16 00:31:03 +02:00
Alexander Barton b9006acee3 Cipher list selection for GnuTLS
This patch implements the missing functionality for cipher list selection
using GnuTLS (our OpenSSL code has this already).
2013-09-15 17:57:47 +02:00
Alexander Barton 51231ac8d4 ConnSSL_Init_SSL(): correctly set CONN_SSL flag
The CONN_SSL flag must be set before any calls to ConnSSL_Free()!
2013-09-15 17:35:52 +02:00
Alexander Barton 84ed46d4c1 Cipher list selection for OpenSSL
This patch introduces the possibility to arbitrarily select ciphers which
should be promoted resp. declined when establishing a SSL connection
with a client by implementing the new configuration option "CipherList".

By default, OpenSSL would accept low and medium strength and RC-4 ciphers,
which nowadays are known to be broken.

This patch only implements the feature for OpenSSL. A GnuTLS counterpart
has to be implemented in another patch ...

Original patch by Bastian <bastian-ngircd@t6l.de>.

Closes bug #162.
2013-09-15 15:09:36 +02:00
Alexander Barton 849f85a05c ConnSSL_InitLibrary(): Code cleanup 2013-09-15 14:09:31 +02:00
Alexander Barton e8e0351985 TRACE: fix error message when there are too many parameters
ircd 2.11 ignores additional parameters silently, but I don't think
that this is the correct behaviour either ...
2013-09-07 00:19:21 +02:00
Alexander Barton 131364def1 IRC_SetPenalty(): Code cleanup 2013-09-07 00:05:49 +02:00
Federico G. Schwindt bcb45da1b4 Add more penalty times
Ensure before every numeric 461 there is a call to IRC_SetPenalty().
2013-09-06 23:02:01 +01:00
Federico G. Schwindt 08f9d31d60 Rework check for number of parameters
Move most of the checks that return numeric 461 into Handle_Request().
2013-09-06 23:01:59 +01:00
Federico G. Schwindt 37609d6a4f Reorder checks
Move oper and Conf_MorePrivacy checks after checking the number of
parameters.
2013-09-05 17:31:57 +01:00
Federico G. Schwindt 33c2d5e4e2 Move the IRC_SetPenalty() call after the asserts 2013-09-05 17:31:57 +01:00
Federico G. Schwindt a98bbc8e0b Correct numeric returned by whois
As per RFC whois should return 431 if no nick is provided.  While
here convert upper check to use irc-macros. As a bonus we get to set
the penalty for free.
2013-09-05 17:31:56 +01:00
Federico G. Schwindt 9f74c0ff07 Minor cosmetic change
Add a define to indicate any client.  While I'm here use hex values
instead of decimal, it's somewhat clearer that they could be OR'ed
together.
2013-09-05 17:31:55 +01:00
Alexander Barton aad92ceafe Don't enforce channel types for other servers
The configuration option "AllowedChannelTypes" must only be enforced for
regular clients and not for remote servers. Channels created by other
servres are always allowed, because they already exist and the daemon
must stay in sync with the network.
2013-09-03 17:13:46 +02:00
Alexander Barton 4102e8fdfe Only log "IDENT ... no result" when IDENT was looked up
Without this patch, ngIRCd logged the "IDENT lookup for connection X:
no result"-message even when IDENT lookups have been disabled using the
"Ident = no" configuration option, which is a little bit misleading.

Reported by "btwe" in #ngircd.
2013-09-02 16:42:20 +02:00
Florian Westphal f8f8a9a041 ngircd: use setgid/setuid errno value in error path
Need to use saved errno value as strerror argument, else you
get bogus output ('success') in the log message.
2013-08-31 22:42:56 +02:00
Alexander Barton 04b947cdc3 Show connection flag "s" (SSL) in RPL_TRACE{LINK|SERVER}
Now you can check if a server-to-server link is SSL-encrypted or not
using the IRC "TRACE" command.

Idea by Götz Hoffart, thanks!
2013-08-31 14:15:24 +02:00
Federico G. Schwindt be2e611680 Change away to be allocated dynamically 2013-08-27 00:06:03 +01:00
Alexander Barton 41f75b6974 Ignore "operation not permitted" while dropping groups
Without this exception, you can't start ngIRCd as user any more,
it is analog to setting the user and group ID.
2013-08-27 00:41:36 +02:00
Florian Westphal e009ccbe66 ngircd: discard supplementary group ids on startup
The intention was to switch to JUST uid:gid, but setgid is not
sufficient.

Reported-by:  Michael Scherer <misc@zarb.org>
2013-08-27 00:19:31 +02:00
Alexander Barton 44698e44e8 Merge branch 'bug159-WebircIPA'
* bug159-WebircIPA:
  Introduce Free_Client() function to free CLIENT structure
  Save client IP address text for "WebIRC" users
2013-08-26 23:22:20 +02:00
Alexander Barton 0ff33777fe Introduce Free_Client() function to free CLIENT structure 2013-08-26 22:55:00 +02:00
Alexander Barton 1dc93286a0 Save client IP address text for "WebIRC" users
This patch introduces a new field in the CLIENT structure, "ipa_text",
which points to an optional textual representation of the client IP
address (or NULL) which can be used to store the "real" IP address
information of a client using the "WEBIRC" protocol.

Without this patch, ngIRCd ignored the <ip-address> paramater ...

In addition, the functions Client_SetIPAText() and Client_IPAText()
have been introduced to set and get the textual representation of the
client IP address.

Client_IPAText() can be used even when no "IP address text" has been
set before, it then returns the real IP address of the connection.

Closes bug #159.
2013-08-26 22:54:00 +02:00
Alexander Barton 2bacb8210b Implement new configuration option "DefaultUserModes"
The new configuration option "DefaultUserModes" lists user modes that
become automatically set on new local clients right after login.

Please note that only modes can be set that the client could set on
itself, you can't set "a" (away) or "o" (IRC Op), for example! User
modes "i" (invisible) or "x" (cloaked) etc. are "interesting", though.

Default: set no modes (like without this patch).

Closes bug #160.
2013-08-26 21:17:10 +02:00
Federico G. Schwindt 3b65f4e38d Change strdup() to strndup() 2013-08-26 12:18:46 +01:00
Federico G. Schwindt 8d01be7bbd Silence warning
Cast the result of the operation to long, not the time(NULL) call.
On systems where sizeof(time_t) is other than long this will produce
a warning.
2013-08-25 05:24:11 +01:00
Federico G. Schwindt eb86d234f8 Plug memory leak 2013-08-25 05:24:11 +01:00
Federico G. Schwindt 3af0ece2bc Implement account login support
This is done via the `accountname' METADATA command and used to
automatically identify users after netsplits or across service
restarts.
2013-08-25 05:24:08 +01:00
Federico G. Schwindt a9ffbdea3f Fix spelling 2013-08-24 17:51:44 +01:00
Alexander Barton 309122017e Correctly handle return code of Handle_Write()
There have been code paths that ignored the return code of Handle_Write()
when sending "notice auth" messages to new clients connecting to the
server. But because Handle_Write() would have closed the client connection
again if an error occurred, this would have resulted in new errors and
assert()'s later on that could have crashed the server (denial of service).

Only setups having the configuration option "NoticeAuth" enabled are
affected, which is not the default.

CVE-2013-5580.
2013-08-23 21:40:51 +02:00
Alexander Barton 8f530eb315 Enhance log messages on "recursive" connection errors 2013-08-21 01:16:16 +02:00
Alexander Barton c8b12af1d2 Merge branch 'ssl-log-messages'
* ssl-log-messages:
  Make SSL-related log messages more readable
  ConnSSL_HandleError: Code cleanup, more documentation
2013-08-17 22:05:59 +02:00
Alexander Barton a919e02ba1 Make SSL-related log messages more readable
- Don't use internal function names but describe the error.
 - Streamline wording, use "SSL" for SSL and TLS.
 - Streamline punctuation.
2013-08-14 10:56:09 +02:00
Federico G. Schwindt b081cfb628 Use _IRC_ARGC_BETWEEN_OR_RETURN_ when possible 2013-08-14 00:07:12 +01:00
Alexander Barton dd4c60cf39 ConnSSL_HandleError: Code cleanup, more documentation 2013-08-13 00:09:04 +02:00
Alexander Barton 4828bae8d3 Change log level of "SSL connection shutting down" 2013-08-12 00:02:40 +02:00
Federico G. Schwindt cd38e9580e Fix 2 bugs introduced in 74514b8c23
Channel_Modes() and Channel_Topic() return static memory that is zeroed at
creation time. Fix checking for empty modes and topic so they're propagated
correctly.
2013-08-11 20:57:11 +01:00
Alexander Barton 298158501d IRC_SERVER(): Code cleanup 2013-08-07 00:13:08 +02:00
Alexander Barton 904c8a4375 Introduce new function IRC_WriteErrClient()
This function is used to send "error messages", including numerics,
back to clients and to automatically enforce a 2 second penalty. With
this patch, all error results enforces a delay for the client.

All callers of IRC_WriteStrClient(ERR_xxx) have been converted.

Please note that this patch prolongs the time "make check" needs
to complete its tests, because of lots of new enforced penalties ...
2013-08-07 00:10:50 +02:00
Alexander Barton b86e33ef49 irc-macros.h: Update copyright, don't forget contributors! 2013-08-06 23:36:16 +02:00
Alexander Barton 0a3d8d60d3 irc-write.c: Clean up code and add more documentation comments 2013-08-06 23:21:48 +02:00
Alexander Barton 08d49a8fa0 Fix return code of some IRC_WriteXXX() functions
These functions usually write to more than one target, and therefore
can't return value indicating success or failure in a sane way. And, even
more omportant, these functions should send to as much as possible clients
and not stop at the first client which isn't reachable any more!
2013-08-06 23:18:57 +02:00
Alexander Barton 8f5cbe51a7 Streamline punctuation of log messages
See commit d38d153f for details.
2013-08-06 21:34:32 +02:00
Federico G. Schwindt 7db8481500 Inline who_flags_status 2013-08-05 11:05:12 +01:00
Federico G. Schwindt 74514b8c23 Convert more code to use Channel_HasMode 2013-08-04 21:16:03 +01:00
Federico G. Schwindt c74115f25c Simplify mode checking on channels and users within a channel
Add Channel_HasMode() and Channel_UserHasMode() and use it where
possible.
2013-08-04 18:28:04 +01:00
Federico G. Schwindt 672a167963 Use Client_HasMode and Client_HasFlag where appropriate 2013-08-04 17:25:24 +01:00
Alexander Barton 139f5961a0 Merge branch 'bug152-AllowedChannelTypes'
* bug152-AllowedChannelTypes:
  Implement new configuration option "AllowedChannelTypes"
  Introduce "CHANTYPES" #define
2013-08-04 14:11:12 +02:00
Alexander Barton 5258fb7f7c Implement new configuration option "AllowedChannelTypes"
The new configuration variable "AllowedChannelTypes" lists all allowed
channel types (channel prefixes) for newly created channels on the local
server. By default, all supported channel types are allowed.

If set to the empty string, local clients can't create new channels at
all, which equals the old "PredefChannelsOnly = yes" setting.

This patch deprecates the "PredefChannelsOnly" variable, too, but it is
still supported and translated to the apropriate "AllowedChannelTypes"
setting. When "PredefChannelsOnly" is processed, a warning message is
logged.

Closes bug #152.
2013-08-04 14:10:12 +02:00
Federico G. Schwindt 15dfdaac82 More spelling fixes
Remove superflous comments, mostly in German. Fix spelling and
use american variants for consistency.
2013-08-04 12:45:11 +01:00
Federico G. Schwindt bb8d207efa Change cloaked hostname to be malloc'd on demand
This shaves a few bytes when cloaked hostnames are not used and
restricts the cloakhost announcement iif there is something to
send.
2013-08-04 10:15:11 +01:00
Federico G. Schwindt e03d8eb728 Add Client_HasFlag() to check if a client has certain flag 2013-08-04 04:00:34 +01:00
Federico G. Schwindt a95d3e05e7 Fix spelling 2013-08-04 03:15:27 +01:00
Federico G. Schwindt 646a97de5f Rename XXX_Fingerprint to XXX_CertFp 2013-08-04 03:14:27 +01:00
Federico G. Schwindt 8e60fac73b Improved client announcement
Move Announce_User() to client.c and rename it to Client_Announce().
Use this in cb_introduceClient() instead of duplicating the code.
This fix the certificate fingerprint announcement for new clients.
Also ensure the certificate fingerprint is only announced if the
client supports it (`M' flag).
2013-08-04 00:22:38 +01:00
Alexander Barton 5e775a3fae Introduce "CHANTYPES" #define
This #define lists all the prefix characters of all supported channel
types, this is "#&+" at the moment.
2013-08-04 00:35:08 +02:00
Alexander Barton 69ce65bacb Merge remote-tracking branch 'fgsch/certfp'
* fgsch/certfp:
  Simplify MOTD handling
  Add certificate fingerprint support
2013-08-03 00:29:12 +02:00
Federico G. Schwindt bf8e03c466 Simplify MOTD handling
Merge Show_MOTD_Start, Show_MOTD_Sendline and Show_MOTD_End into
IRC_Show_MOTD.
2013-08-02 23:24:18 +01:00
Federico G. Schwindt 1254d315b9 Add certificate fingerprint support 2013-08-02 23:24:06 +01:00
Alexander Barton 4ec19c0332 Update irc-server.c to use irc-macros.h
And add some comments :-)
2013-08-03 00:00:47 +02:00
Alexander Barton 78c8212280 Update irc-oper.c to use irc-macros.h 2013-08-02 23:27:11 +02:00
Alexander Barton 888c524683 Update irc-mode.c to use irc-macros.h
This includes code cleanups and more comments, too.
2013-08-02 01:48:35 +02:00
Alexander Barton ae0af66d50 Update irc-channel.c to use irc-macros.h
This includes code cleanups, too :-)
2013-08-02 01:46:57 +02:00
Alexander Barton 771e539c18 Show IRC Operator name when logging a successful OPER command 2013-08-01 00:24:10 +02:00
Alexander Barton 313881d0c1 Add penalty times in error paths of generic IRC helper macros
Add a 2 second penalty time when the number of parameters is invalid.
2013-07-30 22:08:04 +02:00
Alexander Barton 3bd973037a Add more penalty times in error paths
This patch changes the handlers of the "PASS", "NICK", "USER",
and "SERVICE" commands to enforce a 2 second penalty when an error
like "need more/other parameters" occurs.

More functions should follow, I think ...
2013-07-30 22:05:00 +02:00
Alexander Barton f494023b0d Update irc-login.c to use irc-macros.h
This includes code cleanups, too :-)
2013-07-30 21:18:42 +02:00
Alexander Barton fa15eb1698 Update irc.c to use irc-macros.h
This includes code cleanups and better documentation for some
functions, too.
2013-07-18 23:35:33 +02:00
Federico G. Schwindt 7adc4b8e99 Handle services in IRC_WHOIS_SendReply()
If the target is a service, advertise it as such and ignore operator mode.
2013-07-18 19:52:17 +01:00
Federico G. Schwindt 5021977bb1 Fix spelling 2013-07-18 17:51:02 +01:00
Alexander Barton 9d3800fd15 Merge pull request #3 from Cofyc/master
irc-info.c: some commands use LINE_LEN as command buffer len
2013-05-30 08:55:48 -07:00
Yecheng Fu 4f525d39d4 LINE_LEN -> COMMAND_LEN
LINE_LEN is configuration file line length
2013-05-30 13:53:33 +08:00
Alexander Barton 7ea3864a93 IncludeDir: default to "$SYSCONFDIR/ngircd.conf.d"
Now "IncludeDir" defaults to "$SYSCONFDIR/ngircd.conf.d" instead
of no directory, but a missing directory is only reported as an
error if it has explicitely configured in the main configuration
file and simply ignored otherwise.

Therefore it is now possible not to touch the default (sample)
configuration file at all, and set all distribution and/or system
specific configuration options in "*.conf" files stored in
"$SYSCONFDIF/ngircd.conf.d/".

Thanks to "Elmasloco" for the idea!
2013-05-25 00:25:38 +02:00
Alexander Barton 891dbd2acc "IncludeDir" can't be overwritten by included files 2013-05-24 22:40:23 +02:00
Alexander Barton f206fda8ae Implement new configuration option "IncludeDir"
The option "IncludeDir" in the [Options] section can be used
to specify a directory which can contain further configuration
files and configuration file snippets matching the pattern
"*.conf" that should be read in after the main configuration
file ("ngircd.conf" by default) has been parsed.

Closes bug #157.
2013-05-24 22:34:53 +02:00
Alexander Barton 6beb0fad3f conf.c: New function Read_Config_File()
This function reads in and parses a single configuration file.
Adjust all other functions to display the correct name of the
file being read in currently.
2013-05-24 21:57:42 +02:00
Alexander Barton 27fd92d580 Rename "Mask" variables into "Pattern" in assert() statements
This completes commit 3ab00e3a11 which broke debug builds.
2013-04-21 15:58:46 +02:00
Federico G. Schwindt 51e5ba94b3 Ensure there is enough space for the mask
As pointed by Alex while strl{cat,cpy} take the full length
we need to leave space to ensure a proper mask is always created
so revert the removal of - N from my last change.
2013-04-20 10:53:16 +01:00
Federico G. Schwindt b4d0a40383 Better description for Lists_CheckReason() 2013-04-20 00:44:05 +01:00
Federico G. Schwindt 3ab00e3a11 Change Lists_MakeMask() to receive a buffer for the mask
Change callers accordingly so they don't rely on a global buffer and
rename Mask to Pattern where it makes sense since some functions
where indeed receiving a pattern and not a mask.
2013-04-20 00:43:47 +01:00
Federico G. Schwindt cde2e8a277 Fix use-after-free on Lists_CheckReason()
Change Lists_CheckReason() to receive a buffer where the reason
will be stored and its length.  Change callers accordingly.

Change Class_GetMemberReason() (and its callers) in a similar way
so it doesn't rely on a global buffer for the rejected reason.
2013-04-20 00:43:35 +01:00
Sebastian Köhler 0131e1e00b Lists_CheckReason(): Check for Client_MaskCloaked()
Look for possible cloaked Masks in Lists. Users with +x usermode can be
banned with their cloaked hostname now.
2013-03-20 03:40:31 +01:00
Alexander Barton a2e26aad1e Conn_Handler(): Don't test for penalty times
The Conn_Handler() main loop calls Handle_Buffer() which checks for the
"penalty time" of each client itself, so don't do it twice.
2013-03-09 17:58:10 +01:00
Alexander Barton b4393277ea Don't read SSL client data before DNS resolver is finished
Fix the cb_clientserver_ssl() callback function to not read in and store SSL
encrypted client data before the asynchronous DNS resolver sub-process has
finished: This could have resulted in discarding the resolved client hostname
and IDENT reply afterwards, because in some situations (timing dependent) the
NICK and USER commands could have already been read in from the client,
stored in the buffer, and been processed.

Thanks to Julian Brost for reporting the issue and testing, and to Federico
G. Schwindt <fgsch@lodoss.net> for helping to debug it!
2013-03-09 17:44:34 +01:00
Alexander Barton b33da9b8f3 Increase password length limit to 64 characters
Closes bug #154.
2013-03-08 19:31:57 +01:00
Alexander Barton 3228f1b267 irc-op.c: use irc-macros.h 2013-02-24 18:51:54 +01:00
Alexander Barton a53de63ba7 irc-cap.c: use irc-macros.h 2013-02-24 18:51:43 +01:00
Alexander Barton e8f512bfe7 irc-op.c: Update source code documentation 2013-02-24 18:50:12 +01:00
Alexander Barton bb31d7b88c irc-cap.c: Update source code documentation 2013-02-24 18:49:07 +01:00
Alexander Barton 7f99f7c14f Add new _IRC_ARGC_EQ_OR_RETURN_ macro to irc-macros.h 2013-02-24 16:20:27 +01:00
Alexander Barton 883a8fa6f1 Add new _IRC_ARGC_BETWEEN_OR_RETURN_ macro to irc-macros.h 2013-02-24 16:14:13 +01:00
Alexander Barton a7b04ce6cf irc-cap.c: move static functions to the top of the file
And remove now unnecessary (local) prototypes.
2013-02-24 16:08:17 +01:00
Alexander Barton 221365d8ef irc-login.c: conenction -> connection
Introduced by commit d3ef2239 as of Sun Jan 16 2011 ...
Thanks to Patrik Schindler <poc@pocnet.net> for reporting this!
2013-02-22 15:15:27 +01:00
Alexander Barton 65359ff8f7 Merge branch 'bug153-ServerMask' into master
* bug153-ServerMask:
  Update irc-info.c to use irc-macros.h
  Add new irc-macros.h to project
  irc-info.c: add/streamline function documentation comments
  irc-info: move static functions at the top of the file
  Implement new function Client_SearchServer()

Conflicts:
	src/ngircd/irc-info.c
2013-02-15 21:59:06 +01:00
Sebastian Köhler 0e63fb3fa7 KICK: Fix denial of service bug
Test if the user that it is to be kicked is on the channel before user
channel modes are tested. Otherwise assert( cl2chan != NULL ); in
line 742 would fail and stop the service.
2013-02-15 10:21:58 +01:00
Alexander Barton 3e72331896 sighandlers.c: Update some log messages 2013-02-13 00:27:05 +01:00
Alexander Barton 1438771124 my_sd_listen_fds(): really return an "int"
This fixes the following warning using Apple LLVM version 4.2
(clang-425.0.24) on OS X:

  src/ngircd/conn.c:157:9: Implicit conversion loses integer
                           precision: 'long' to 'int'
2013-02-11 23:25:13 +01:00
Alexander Barton b95dfb3ffd Merge branch 'bug155-allowAtInUser'
* bug155-allowAtInUser:
  Allow "@" character in user names for authentication
2013-02-11 13:58:30 +01:00
Alexander Barton 4b15f10fbb Allow "@" character in user names for authentication
The "@" character isn't allowed in IRC usernames, because it is the
separator between user name and hostname in IRC masks:

  <nickname>!<username>@<hostname>

This patch accepts user names including "@" characters, saves the
unmodified name for authentication but stores only the part in front
of the "@" character as "IRC user name". And the latter is how
ircd2.11, Bahamut, and irc-seven behave as well.

Closes bug #155.
2013-02-11 13:57:54 +01:00
Alexander Barton 628c14d656 Merge branch 'systemd'
* systemd:
  ngircd.sock: explicitely bind to IPv4 and IPv6 addresses
  Show address and port of sockets passed-in by systemd(8)
  Check type of sockets passed-in by systemd(8)
  Adjust severity levels of some log messages
  New configuration option "IdleTimeout": exit daemon when idle
  Implement support for systemd(8) "socket activation"
  contrib/README: add more files
2013-02-10 20:43:56 +01:00
Alexander Barton 69c3f96998 Show address and port of sockets passed-in by systemd(8) 2013-02-10 20:21:53 +01:00
Alexander Barton 5c6875d768 Check type of sockets passed-in by systemd(8)
This patch makes sure that ngIRCd doesn't try to handle sockets of
unsupported types, for example of AF_INET6 sockets when ngIRCd isn't
compiled with support for IPv6 ...
2013-02-10 20:20:58 +01:00
Alexander Barton a78c7b3898 Adjust severity levels of some log messages 2013-02-10 20:18:44 +01:00
Alexander Barton 5dce3301bd Update irc-info.c to use irc-macros.h
This includes:

 - move IRC_SetPenalty() at the beginning of the handler functions,
 - use macros provided by irc-macros.h,
 - code cleanup.

The main benefits of this patch are core size reduction, streamlined
structure of the handler functions, and enhanced functionality:
because of the _IRC_GET_TARGET_SERVER_OR_RETURN_() macro using the
Client_SearchServer() function, the target of the specific IRC command
can now be given server names, server mask, or the nickname of a user
connected to the server.

Closes bug #153.
2013-02-09 23:58:11 +01:00
Alexander Barton a917514546 Add new irc-macros.h to project
This file prvides some macros for common tasks required by functions
implementing handlers for IRC commands:

 * _IRC_ARGC_LE_OR_RETURN_
 * _IRC_ARGC_GE_OR_RETURN_
 * _IRC_GET_SENDER_OR_RETURN_
 * _IRC_GET_TARGET_SERVER_OR_RETURN_
2013-02-09 23:55:42 +01:00
Alexander Barton 4dc940f59e irc-info.c: add/streamline function documentation comments
Add missing comments, streamline wording, and remove references to the
RFCs: this will be added to ./doc/Commands.txt with an other patch and
we want to avoid redundancy ...
2013-02-09 23:33:29 +01:00
Alexander Barton 5facf5c15e irc-info: move static functions at the top of the file 2013-02-09 23:18:49 +01:00
Alexander Barton 1e8b775a7a "WHO <hostmask>": use displayed hostname for matching
Use the currently "displayed hostname" (which can be cloaked!) for
hostname matching, not the real one. In other words: don't display
all the cloaked users on a specific real hostname!

Thanks to DNS <dns@rbose.org> for reporting this issue.
2013-02-08 17:18:43 +01:00
Alexander Barton 0ad0fe207a Implement new function Client_SearchServer()
This function returns the server structure of a client or a given "mask";
it is useful for implemention handlers for commands like "COMMAND *.net",
which should work on a server matching "*.net".

Please note that the local server is always returned when it matches the
mask, but besides that, the order is completely arbitrary.
2013-02-05 13:06:08 +01:00