Commit Graph

644 Commits

Author SHA1 Message Date
Kevin Easton
eb4b2a29d6 Remove unused function quote_it()
This function is no longer needed.  It was problematic anyway because it didn't have a way for
the caller to specify the destination buffer size.
2016-10-13 01:44:29 +11:00
Kevin Easton
04cf832604 Change send_msg_to_channels() to remove 'channels' argument and always use PRIVMSG
The 'channels' argument was unnecessary because the channel list passed to it would
always be from get_server_channels(server) anyway.

Changing the message argument from a protocol message format string to a plain payload
string for PRIVMSG means printf-escaping of the argument is avoided in the caller.
This simplifies the callers and means we can remove the last use of quote_it().

This change also switches set_server_away() to use send_msg_to_channels() instead of
open-coding the equivalent, which simplifies that function a lot.

We are changing the signature of a function exported to modules here; however none
of the in-tree modules use this function so it should be OK.
2016-10-13 01:36:19 +11:00
Kevin Easton
08e3c99720 Remove use of quote_it() from LameKick() and masskick()
The use of quote_it() is unnecessary - we can just directly use my_send_to_server()
to construct the message.

Preparation to remove quote_it() entirely.
2016-10-09 23:22:18 +11:00
Kevin Easton
41d98dc5f5 Rename reserved identifiers in irc_std.h
Identifiers beginning with two underscores or one underscore and a capital
letter are reserved in all contexts, including macros.

The __N macro in irc_std.h is in this space, and was conflicting with a macro
definition in gcc 5.4.0's xmmintrin.h under cygwin, making the build fail.

Reported-By: ice-man
2016-10-08 00:35:46 +11:00
Kevin Easton
0fd11b3d75 Ensure masskick(), massban(), unban(), ban() and remove_bans() send command to correct server
These commands use prepare_command() to find a channel to act on, which returns the server to use.
The code should then use my_send_to_server() to ensure that it sends the command to that server -
these functions were using send_to_server() which sends to 'from_server', which means that they
could send the commands to the wrong place, for example if they were called from a hook on a
different server.

This patch was created with the following coccinelle script:

// Detects pairing preprare_command() with send_to_server() (which uses from_server)

@prepare3@
identifier s;
local idexpression c;
expression E1, E2, E3, E4, E5;
@@

(
if ((c = prepare_command(&s,...)) != NULL && ...)
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
|
if ((c = prepare_command(&s,...)) == NULL || ...) { ... return ...; }
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
)
2016-10-08 00:12:47 +11:00
Kevin Easton
58588946e0 Simplify send_to_server functions by adding server parameter to vsend_to_server() 2016-10-02 22:44:06 +11:00
Kevin Easton
729b029385 Code and comment cleanups to the Karll array functions
There should be no behavioural change.
2016-10-01 01:37:27 +10:00
Kevin Easton
e2b351b9ce Remove unnecessary NULL checks in expr.c
The first is unnecessary because after_expand() never returns NULL, and the 'rest' pointer has been
dereferenced multiple times anyway.

The second is unnecessary because parse_number(&ptr) cannot set ptr to NULL.
2016-09-30 23:44:15 +10:00
Kevin Easton
7e3c39a464 Fix implied operators under NEW_MATH
This fixes several issues with the implied operators when NEW_MATH is enabled:

* None of the implied operators were returning the correct value, which should be the value
assigned to the LHS.

* The &&=, ||= ad ^^= operators were also operating on uninitialized variables and so behaving
unpredictably.

* The /= and %= operators would crash the client when the RHS was zero, because after outputting
the "Divide by zero" error they would go on to perform the operation anyway.
2016-09-29 01:11:29 +10:00
Kevin Easton
a625650c4a Remove unnecessary NULL checks in assigncmd() and stubcmd()
In both cases, the args pointer has already been dereferenced so it cannot be NULL.
2016-09-28 14:58:43 +10:00
Kevin Easton
dc17b059eb Make 'distclean' Makefile target remove .config.h 2016-08-02 23:46:55 +10:00
Kevin Easton
d9b522cd0b Add back Makefile rules to create .config.h
This fixes a bug introduced in commit f2ae2327, which improved the Makefiles for parallel builds
but in doing so removed the rule to create an empty .config.h file.

.config.h isn't included in the source distribution - it's created by bxconfigure if you run it.
If you don't run it, the build systems needs to create an empty one.  This commit adds a rule to
both the toplevel Makefile.in and source/Makefile.in (the latter in case you're running 'make' just
in the source/ directory).  The toplevel one is required for building the modules tree under dll/,
since the module Makefiles don't have the right dependencies wired up.

This also makes 'distclean' remove the .config.h file.
2016-08-02 23:36:01 +10:00
Kevin Easton
bc5c20ef5c Remove old file README-1.2 from debian/docs and update debian/changelog for 1.2.1
Reported by Solbu.
2016-07-25 23:00:24 +10:00
Kevin Easton
5a91e0b1d8 Add /SCANB command to scan for users on the userlist with the BOT flag
This is analagous to the /SCANF command that scans for friends etc.
2016-05-25 23:41:34 +10:00
Kevin Easton
23967ba5be Wire up /FSET WHOIS_BOT for users on the userlist with the BOT flag
This FSET has existed for a long while but has been unused for some time,
since before the userlist was reworked to use flags instead of levels.  This
means that the default value for the FSET also has to be updated.
2016-05-25 23:38:11 +10:00
Kevin Easton
95a422cd27 Directly link string format to numargs in do_dirlasttype()
This is just a simplification - the string format should always match the arguments passed,
and none of the options are using anything but plain %s formats.

This also requires modifying /RELI to store the invited-channel in .last_msg so that it
can use the numargs = 3 format.
2016-05-15 22:43:01 +10:00
Kevin Easton
2c805c096f Use /FSET RELSN to format /RELSN relayed messages
The RELSN format already existed but wasn't used - instead it used SEND_NOTICE.  The other relay
types already used similar formats for their relayed messages.

The default /FSET RELSN looks just like the default /FSET SEND_NOTICE so this shouldn't be
noticeable to anyone using the defaults.

This required updating the NOTICE-sending code to correctly stash the 'to' in the right place.
2016-05-15 22:05:16 +10:00
Kevin Easton
9fb317b07d Improve formatting of SERVER_NOTICE_CLIENT_CONNECT and SERVER_NOTICE_CLIENT_EXIT 2016-05-10 18:49:18 +10:00
Kevin Easton
43d482a444 Change /FSETs SERVER_NOTICE_KLINE and SERVER_NOTICE_GLINE to show the ban type
The ban type (eg. K-Line, G-Line, D-Line etc.) is now passed in the second-last
argument of these formats.
2016-05-10 18:30:55 +10:00
Kevin Easton
df2e250ccf Clean up handling of oper server notices
This switches from somewhat gory string parsing based on strncmp() and next_arg() to a simpler alternative
based on sscanf().  I think these are much easier to understand now, and shouldn't have any subtle bugs
lurking like the old code.

This also removes support for some obsolete messages that don't seem to be in any modern ircds:
"Identd reponse differs"; bot messages like "Rejecting vlad/joh/com bot:" except for "is a possible spambot"
which is still in use; and the "High-traffic mode" messages.
2016-05-07 00:44:29 +10:00
Kevin Easton
e53d1cab7b Unify handling of SWATCH NONE between OperView and non-OperView modes
Previously, SWATCH NONE meant "show no server notices" if OperView was
enabled, but "show all server notices" if OperView was disabled.  Now,
it always means "show no server notices" (the default SWATCH is ALL,
so the default will behave the same).

This allows us to simplify the code a great deal as well.

Also trim off leading "***" if the server messages are handled by
handle_oper_vision(), as they already are in parse_server_notice().
2016-04-15 00:11:08 +10:00
Kevin Easton
7c3648bb2c Don't hide first word of server notices containing "***"
Using strstr() here is entirely wrong.  The intention is to catch notices
prefixed by *** or similar, and that's already detected further up in the code,
stored in the flag variable.
2016-04-14 23:18:54 +10:00
Kevin Easton
6b0aa0f8fe Remove unnecssary space at the start of SERVER_NOTICE_* formats
Also fix up similar hardcoded formats in notice.c.

The space isn't needed because serversay() adds a space (and has done for
a very long time).
2016-04-14 22:22:05 +10:00
Kevin Easton
d236b19410 Don't double-up server notices in the /RELS list
serversay() calls add_last_type(), so there's no need for the callers to do so
as well.

Remove the first argument to serversay() because it was always called with 1
anyway.
2016-04-14 21:51:49 +10:00
Kevin Easton
d296739f6f Don't fire the SERVER_NOTICE hook more than once per NOTICE
The previous code would fire the hook twice per NOTICE if handle_oper_vision()
didn't handle the NOTICE (eg. /set SWATCH NONE).
2016-04-12 23:05:34 +10:00
Kevin Easton
0b91d61496 Fix conversion of SWATCH flags to string form
This was broken in commit [07cdd587], where 'sizeof' was used on a pointer
instead of the buffer pointed-to.

Fix this by having the caller of ircop_flags_to_str() supply a buffer and
length, since there's only two callers and both can use happily use stack
objects.
2016-04-10 21:38:38 +10:00
Kevin Easton
9e4602360a Remove the extra space from default SERVER_NOTICE format
Remove the extra space in the default /fset SERVER_NOTICE, and similarly
the extra space in the HUMBLE /set SERVER_PROMPT.

The code in the client always _intended_ to add a space between SERVER_PROMPT
and SERVER_NOTICE_FSET but a bug in 75p3 and below meant it that it didn't.
This bug was fixed in 1.0b but the formats were never updated.

Also remove replace the embedded ANSI in the default SERVER_PROMPT with
% color code.
2016-04-09 00:36:08 +10:00
Kevin Easton
1f64201362 Always treat NOTICEs received before registration as local server notices
We don't know the server's proper name until registration, so the test against
that isn't reliable.  We shouldn't be able to receive messages from anyone else
until we're registered, so this should be safe.

This requires changing serversay() to accept the from name instead of the
from_server.  While we're there, replace the use of alloca() with simpler
logic based on m_sprintf().
2016-04-07 00:11:27 +10:00
Kevin Easton
d19c050837 Fix handling of "host.domain" style server names in ov_server()
The old code would return "omain" rather than "domain" in this case.

Also remove unneccesary checks on the return value of get_server_itsname() -
this function already falls back to 'name' if 'itsname' isn't set yet.
2016-04-06 22:22:39 +10:00
Kevin Easton
74ee653d24 Remove unnecessary extern declaration of ov_server()
It is declared in output.h, which is already included by status.c.
2016-04-06 21:33:06 +10:00
Kevin Easton
b1277f75d4 Add /on NOTICE_GROUP and /fset NOTICE_GROUP analogous to MSG_GROUP
This hook and format are used for NOTICEs where the destination isn't
a channel and isn't yourself - eg. global targets like $$*.org.  This was
already the case for PRIVMSGs (using the MSG_GROUP hook and format).

Previously these were being routed like a normal NOTICE, and those don't
display the target, so it looked exactly like a private NOTICE to you.

This will also catch server notices sent before you're registered.
2016-03-31 23:55:14 +11:00
Kevin Easton
05eb8d946f Removed unused DEFAULT_FORMAT_MSG_GROUP_AR_FSET macros
There is no MSG_GROUP_AR fset.
2016-03-31 21:39:20 +11:00
Kevin Easton
d464bd91fb Remove unnecessary inclusions of <numbers.h>
Functions display_msg() and check_sync() are only used in numbers.c, so they
can be static.

Remove inclusions of <numbers.h> from .c files that don't need it.
2016-03-24 11:21:09 +11:00
Kevin Easton
f129ca29e7 Move got_initial_version_28() from notice.c to numbers.c, where it belongs 2016-03-24 00:08:57 +11:00
Kevin Easton
83741aca7a Add configure check for <sys/sockio.h>
Some systems need <sys/sockio.h> for the SIOCGIFCONF ioctl - this switches
to using a proper configure check for that header rather than just assuming
it'll be there if we can't find SIOCGIFCONF.  Should be more robust.
2016-03-20 23:48:31 +11:00
Kevin Easton
94f4e1c2a3 Don't #include <sys/ioctl.h> or <unistd.h> more than once
<unistd.h> is included by irc.h so it does not need to be included again here.

<sys/ioctl.h> only needs to be included once.
2016-03-18 16:46:36 +11:00
Kevin Easton
82d606979b Add HAVE_*_H checks around inclusions of netinet/in.h and sys/socket.h
Only include <netinet/in.h> and <sys/socket.h> if the system supplies them.
This is necessary to try and get the mingw32 build working again.

No need to include <sys/types.h> and <netinet/in.h> from cdns.c - these are
already included by <irc.h>.
2016-03-17 21:39:17 +11:00
Kevin Easton
f21b89e428 Improve /WINDOW DESCRIBE output
Instead of showing a meaningless pointer value for Screen:, we show the
screen number and ttyname.

Also take the CO, LI values from the window's screen.

Don't show the Prompt: unless one is set.
2016-03-16 23:50:38 +11:00
Kevin Easton
9427b3db84 Try all addresses returned by getaddrinfo() until we find one that socket() is happy with
Someone reported being unable to connect with the error "Address family not
supported", which is probably being returned by socket().  It is likely a
system where getaddrinfo() is returning AF_INET6 addresses, but socket()
won't create AF_INET6 sockets.

To handle this case, we loop over all the addresses returned by getaddrinfo()
until we find one that socket() will accept.
2016-03-08 23:53:16 +11:00
Kevin Easton
c2a2d68d8d Only show version once with -v command line option
Reported by cpet.
2016-02-24 17:23:38 +11:00
Kevin Easton
6dc89247e2 Drop group privileges before dropping user privileges when execing
This ensures that the saved-set-gid is also set, although this shouldn't
matter in practice since we always call execve() soon after, which
overwrites the saved-set-gid with the effective gid anyway.
2016-02-24 16:52:33 +11:00
Kevin Easton
1359f013e8 Make autogen.sh prompt to run configure
Patch from cpet, thanks!
2016-02-19 23:09:30 +11:00
Kevin Easton
f2ae2327e3 Improve toplevel Makefile "all" target to work better with parallel make
Change the all: target in the toplevel Makefile so that it doesn't try to
resolve build dependencies at the top level - instead, it just recursively
builds the all: target in source/ and dll/.

Change the all: target in the source/Makefile so that it builds the EXTRAS
(scr-bx and wserv) as well as the main client binary.

The upshot of all this is that one "make" invocation is responsible for both
scr-bx and wserv, which is necessary for parallel make (make -j) to work
correctly as these binaries share some object files.
2016-02-19 22:54:50 +11:00
Kevin Easton
04f5138a6c Improve a couple of messages in /window create 2015-11-11 17:05:58 +11:00
Kevin Easton
8886c20c1b Improve messages shown by /window size 2015-11-11 14:59:21 +11:00
Kevin Easton
4ee14e00c2 Minor cleanup in add_userhost_to_dcc() 2015-10-29 22:17:10 +11:00
Kevin Easton
a2e8e103e0 Modularise handling of DCC offers
There's several different types of DCC offers, all of which need slightly
different handling.  Previously they were all handled by the monster function
register_dcc_type() - this breaks them out into seperate functions for handling
SEND, RESEND, CHAT and BOT offers, moves common code into static helper
functions and renames the entry point from ctcp.c to handle_dcc_offer().

This will allow adding a way for modules to register DCC offer types that
they're interested in.

This also moves rename_file() from misc.c into dcc.c, where its only user is.
2015-10-28 21:46:38 +11:00
Kevin Easton
af3b0c920a Change find_name_in_genericlist() to take const char * argument 2015-10-28 21:42:33 +11:00
Kevin Easton
f2262d5b01 Change hash_nickname() to take a const char * argument 2015-10-28 21:38:26 +11:00
Kevin Easton
a24f1d12ec Convert lookup_userlevelc() to accept const char * parameters
Also converted dependant functions check_channel_match() and
find_bestmatch() to use const char *.
2015-10-20 23:12:33 +11:00