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().
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.
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 also fixes a few others - eg /KBI now kicks-then-bans, and
/BKI bans-then-kicks (previously these were the wrong way around).
Reported by profiler.
get_reason() is then used only for the implementation of get_kick_reason()
and for the $getreason() scripting function. Add current nick as an
explicit argument for get_reason(), which pushes all use of from_server
out of the ransom reason functions.
Also switch a few instances of send_to_server() to my_send_to_server() where
the current server has been returned by prepare_command().
Re-checking the command name to see if it's a timed ban means that the
compiler can't see that it's the same check.
This also makes sure you can't specify a negative timeout.
Initialise ip_str so that it isn't used uninitialised.
Don't strip server flags from user@ portion of the hostmask, so that it will
not miss matching bans.
Switch ip_str from alloca() to malloc_sprintf() / new_free() - there's no
particular need for alloca() here.
The logic in the massop function to exclude already-voiced users from
massvoice was faulty - it was equivalent to just !nick_isop().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@500 13b04d17-f746-0410-82c6-800466cd88b0
An incorrect pointer was being passed to malloc_sprintf(), causing a
crash. Use m_sprintf() instead.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@471 13b04d17-f746-0410-82c6-800466cd88b0
* Restore from_server in doop() when prepare_command() fails
* Make /bans &channel work
* Make /unban #channel #number work (caf)
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@296 13b04d17-f746-0410-82c6-800466cd88b0
doop() and dodeop() - they could do with a bit more though.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@53 13b04d17-f746-0410-82c6-800466cd88b0