This allows building against recent libtcl versions.
A fallback definition of Tcl_GetStringResult() is included so that building against libtcl 7 still works.
Encrypted messages to a channel need to use their own format. This also fixes the use of ENCRYPTED_PRIVMSG
and ENCRYPTED_NOTICE - they were being called with too many arguments so the destination nick was being prepended
to the message text.
Actual encryped messages and notices are now printed directly from do_sed() / do_reply_sed().
Inline CTCP replacement is only done if the message cannot be decrypted (for the [ENCRYPTED MESSAGE]
placeholder).
This removes the need for the global flag 'sed' to alter the NOTICE and PRIVMSG handling.
A side-effect of this is that SED PRIVMSGs now do not go through the usual PRIVMSG ignore
and flood handling. This is acceptable because messages can only go through this path if
the sender has actually been added as a SED peer with /ENCRYPT, and it still goes through
the CTCP ignore and flood handling.
When a SED-encrypted NOTICE is scanned for CTCPs within the decrypted portion, they should be
handled with do_notice_ctcp() so they are treated as CTCP replies.
This flag is for tracking if we've sent a KICK for a nick. It means we can avoid
sending duplicate KICKs (eg for floods, channel protection etc).
MODULE_VERSION is bumped because NickList is a struct exported to modules.
Neither compat.c nor ircsig.c are compiled different for wserv or scr-bx, so there's no reason these
binaries can't just link to the same .o files as the main BitchX binary.
This also cleans up the build rules around wserv and scr-bx a little.
init_socketpath() was building a sprintf() format string intended to be used by /DETACH to create the socket
file name. This included the actual socket path, plus a %d for the port, plus the sanitised tty name and
hostname.
Only one caller needed all this though - the /DETACH command - and the other callers (in scr-bx.c) just
wanted to truncate it to the actual socket path. The format string also wasn't safe - if the home directory
path, hostname or ttyname contained % characters these werent being escaped.
It simplifies things to have init_socketpath() just return the actual socket path, after creating the 'screens'
directory if necessary. This lets the code in scr-bx.c use it as-is, and removes the need for the global
socket_path variable. The code to include the sanitised tty name and hostname in the socket file name can
be moved to the create_ipc_socket() function.
There's no need to check access() for the socket path before trying to create it - just call mkdir() regardless,
since it will fail if the path already exists, which is fine.
This commit also adds error handling to the create_ipc_socket() function for the case where creation of the
socket file fails, and switches the chmod() and chown() for the opened file to the more appropriate fchmod()
and fchown().
Previously these codepaths were dead because it was passing an argument like "+HOST" to check_whowas_nick_buffer()
in place of the channel name, so it would never find anything.
Now that function supports a NULL channel to mean "any channel", so we can use that. The actual code itself needed to be
fixed as well, it's now similar to the way userhost_unban() is written.
The use of the whowas cache in userhost_unban() would never work, because it was passing 'args' as the channel
name which also included the window number.
Rework this substantially, including using lookup_channel() and set_display_target() in place of prepare_command().
Previously you could unset CMDCHARS and the effect would be to treat it like it was set to DEFAULT_CMDCHARS,
except that some code was missing the fallback (eg. ignore_last_nick()) which would make it crash.
Instead of having the fallback everywhere, just make it so that you can't unset the variable - if you try, it
sets it to DEFAULT_CMDCHARS. This reflects what the behaviour has always been, it just makes it explicit to
the user and the bonus is we don't have the test it for NULL everywhere.
The 'free_it' variable was only initialised to zero at the start of the function, so when non-main screens
were processed in the later iterations of the loop, it could keep a value of 1 from the previous iteration.
We don't actually need a free_it variable at all - just use a NULL value of ptr_free to indicate that there
is nothing to free (and passing a NULL to new_free() is a no-op).
This also simplifies a test because ptr is always non-NULL (strip_ansi() never returns NULL).
If wserv is told to connect to "localhost" it might try to connect to ::1, which won't work because
the wserv socket is AF_INET only.
So explicitly bind the socket and make the connection to "127.0.0.1" instead.
Previously, INVITE and WALLOP were tracked for flooding, but if the flood triggered then the auto-ignore
didn't happen. As far as I can tell, this was just an oversight.
This aligns the function with the documentation and what EPIC4/5 do. I couldn't find any example of an existing
script that actually called this function, so hopefully no-one is relying on the old behaviour.
The static 'pos' variable in check_flooding() would not stay in sync with the number of entries in
flood_list after clean_flood_list() was called. This meant that check_flooding() would always end up
removing all previous entries if it tried to add a new one.
Fix this by removing the tracking of number of flood_list entries, and just removing stale ones (older
than /SET FLOOD_RATE).
As always, the funcion pointers should be cast to the correct type before calling them, rather
than calling them with the wrong type and trying to cast the result. Fixes a warning compiling
mail.c on 64 bit architectures, and this might well have caused a crash when using the qmail plugin
on those architectures too.
Checking before truncation means you can sneak a privileged port past the check.
This change also collects the various broken-out parts of a CTCP DCC offer into a struct so that
it's easier to pass them all around together.
parse_offer_params() was being run unconditionally by check_dcc_init() even if it didn't find a
custom init_func() to call, which is the usual case. It then gets called again by the hardwired
DCC init function, which led to the error message appearing twice. This has check_dcc_init() only
call parse_offer_params() when its about to dispatch to a custom init func.
This also improves the message a bit (making it [host:port] rather than the other way around) and
combines the 'privileged port' message and "zero address" message together.
Previously waiting (inactive) file-type offers were shown different to others, omitting the
time-since-offer. Unify them to use the same format, which also cuts out a few lines of code.
Also tweaks the DCC_BAR_TYPE 1 format to include the DCC state (always Active) where the
completion bar would be in the DCC_BAR_TYPE 0 format. This just looks a bit more consistent.
s->time on the SocketList is set to the time that the chat offer will expire, so it's in the future.
This shows up as a very large positive time. Instead, use n->lasttime as that is set to the time
when the offer is made.
Also adjust the format for non-file offers so that it all lines up properly.
This now calculates a 'pcomplete' value for proportion of transfer complete (0.0 to 1.0).
From this we can calculate most other things easily - percent complete, ETA, and the size
of the completion bars.
User-visible change is that the DCC_BAR_TYPE 1 bar now matches the % complete for the RESUMEd
file case.
The only user-visible change here is that the bar displayed for DCC_BAR_TYPE 1 is now shown
as empty for a zero-length file rather than full, matching the 0.0% complete that is shown
and the bar displayed in the DCC_BAR_TYPE 0 case.
With DCC_BAR_TYPE 1 set, the stat line for active DCC file connections was not aligned
correctly with the header (the mm:ss field spilled into the KB/s column.)
This also simplifies things by always generating the inline bar, so the only difference
between the line printed for DCC_BAR_TYPE 0 and 1 is now the format itself.
There's no reason you shouldn't be able to use modelock as a half-op.
Also a few other minor cleanups in this function - eg. use my_send_to_server()
with the passed server number instead of implicitly using from_server.
glob_commands() would run off the end of the irc_command array if given a match that matched
the last command. It also leaked memory because it used m_s3cat() to construct the string,
then passed that to m_strdup().
This fixes these problems by reworking glob_commands(), and at the same time removes the use
of alloca() and wild_match() by using strncmp() instead to match the start of a string. Move
glob_commands() to alias.c and make it static since it's only used for aliasctl().
Change the 'name' argument of find_command() and find_dll_command() to const char * at the same
time, so that glob_commands()'s prefix argument can be const char * too.
cdcc_numpacks is unsigned, so %u should be used instead of %d.
Fix some memory leaks in /CDCC PLIST and /CDCC NOTICE where malloc_sprintf() was called
and the string never freed.
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
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);
)
...>
}
)
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.
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.
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.
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.
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().
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.
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.