Commit Graph

31 Commits

Author SHA1 Message Date
Kevin Easton
492d5658d1 Simplify handling of /DETACH socket path
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().
2017-05-03 00:13:24 +10:00
Kevin Easton
b462cf0001 Simplify show_version()
Re-order the code to squash two copies of the formatting code into one.
2016-10-18 23:54:46 +11:00
Kevin Easton
0a90a9d9db Minor cleanups in commands2.c
Remove some unused expressions after comma operators.

parm.termid is an array so it is pointless to compare it to NULL.
2016-10-18 23:46:43 +11:00
Kevin Easton
c2d6a184a3 Act on channel mode lock as half-op
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.
2016-10-18 23:32:23 +11: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
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
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
ff251080da Add get_kill_reason() that uses BitchX.kill, and convert all /KILL users to it
Previously only send_kill() used BitchX.kill - the other KILL commands (eg.
/WHOKILL) were using the random kick reasons.  Standardise them all on
BitchX.kill, and add this file to the source so it can be installed along
with the other random reason files.
2015-06-27 23:18:38 +10:00
Kevin Easton
9f7cf6b6c2 Alter the way PINGs for /sping and lag check are used.
We now send PING <server> :<server> for /spings, and
PING LAG!<cookie>.<tv_sec>.<tv_usec> :<server> for lag checks.  The cookie is
set randomly at server connect time, and means that clients connected to the
same bouncer shouldn't act on each other's lag checks.

We can now remove in_sping entirely - previously it would get out of synch if
you disconnected with a sping in progress.
2015-05-04 00:13:08 +10:00
Kevin Easton
443b87a8aa Remove alternate /sping implementation for systems without gettimeofday()
This changes the code to use struct timeval and get_time() on all systems,
which simplifies the code by removing most of the checks for HAVE_GETTIMEOFDAY.

The only user-visible change is that ancient systems without gettimeofday()
will see message like "Server pong from irc.choopa.net 1.0000 seconds" instead
of "Server pong from irc.choopa.net 1.x seconds".  And really, I seriously
doubt that there's any systems like that left out there anyway.
2015-03-29 20:35:57 +11:00
Kevin Easton
e7c8240622 Use long instead of time_t in send_kline(), and cast time_t values to long in sping() when using %ld format.
This fixes bugs on netbsd i386, where time_t is longer than long.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@466 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-15 13:57:46 +00:00
Tim Cava
4ba3f45a89 Cleanup check_mode_lock() a little bit. Use strlcat, rather than strcat.
Prefer m_strdup over malloc_strcpy.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@366 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-23 04:49:54 +00:00
Kevin Easton
641565d4eb Strengthen the algorithm that generates a random cookie for /detach.
This is a backwards-compatible change, no update to the scr-bx binary
is necessary.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@358 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 14:51:28 +00:00
Kevin Easton
176be1cff2 Add the ability to bind listening sockets to addresses, and use this for the
/detach IPC socket.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@330 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-15 14:05:15 +00:00
Tim Cava
975bc2bc57 Don't compare an array to NULL, but check that the first character isn't
NULL. Found by Coverity.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@308 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-09 07:30:54 +00:00
Tim Cava
4309055cf7 Including dcc.h in commands2.c is unnecessary.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@291 13b04d17-f746-0410-82c6-800466cd88b0
2013-07-15 06:02:23 +00:00
Tim Cava
27ed98a03d Make the addrlen passed to my_accept() a socklen_t everywhere.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@278 13b04d17-f746-0410-82c6-800466cd88b0
2013-07-14 03:09:16 +00:00
Kevin Easton
791c49986e Remove unnecessary termios.h includes.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@272 13b04d17-f746-0410-82c6-800466cd88b0
2013-07-14 00:51:58 +00:00
Tim Cava
d7a0c781f8 Convert simple uses of alloca/strcpy to LOCAL_COPY.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@232 13b04d17-f746-0410-82c6-800466cd88b0
2013-02-24 07:32:59 +00:00
Kevin Easton
cb0c2aabc2 Improve error handling in /detach - will now soft-fail the detach instead
of killing the whole client.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@163 13b04d17-f746-0410-82c6-800466cd88b0
2012-04-30 08:05:04 +00:00
Kevin Easton
ed16081a2b Remove bogus F_SETOWN use in /detach code.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@146 13b04d17-f746-0410-82c6-800466cd88b0
2012-02-01 13:26:50 +00:00
Kevin Easton
5cf8ed2c79 Cleanup create_ipc_socket() and ensure it detects all errors in
connect_by_number().  Make function static since it is only used in one
source file.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@145 13b04d17-f746-0410-82c6-800466cd88b0
2012-02-01 13:21:47 +00:00
Kevin Easton
c89a718fa1 Change the channel mode flags from const ints in names.c to #define macros in names.h.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@134 13b04d17-f746-0410-82c6-800466cd88b0
2011-08-30 14:50:42 +00:00
Kevin Easton
3f8952f20a Fix some memory leaks that occur when clearing the URL-grabber list.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@133 13b04d17-f746-0410-82c6-800466cd88b0
2011-06-01 12:53:30 +00:00
Kevin Easton
52753a9e15 Further cleanups in the URL grabber - remove unnecessary globals, change
url_list from extern to static.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@132 13b04d17-f746-0410-82c6-800466cd88b0
2011-05-17 14:16:34 +00:00
Kevin Easton
b628217600 Fix a memory leak in the URL grabber - as old URLs were expired from the list,
they weren't being freed.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@131 13b04d17-f746-0410-82c6-800466cd88b0
2011-05-17 14:03:29 +00:00
Kevin Easton
f71e26acc7 Correct count in /CLONES (reported by t3gah), and format output nicely
using an /fset.

/CLONES now uses the same formats as the /U command.  Also tweaked those
formats at the same time.



git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@98 13b04d17-f746-0410-82c6-800466cd88b0
2010-09-06 13:40:13 +00:00
Kevin Easton
7a046f56ab Add missing third argument to open().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@64 13b04d17-f746-0410-82c6-800466cd88b0
2009-09-08 12:37:39 +00:00
Kevin Easton
3de93b1dbc Far-reaching changes to make BitchX compatible with 64 bit architectures
like x86-64, where sizeof(int) != sizeof (void *).  This involves correctly
casting every function pointer from the global table to the correct
function type, which has the added benefit of allowing type-checking of
function arguments and return values.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@26 13b04d17-f746-0410-82c6-800466cd88b0
2008-04-30 13:57:56 +00:00
Kevin Easton
533c3dbcbf Turn on SVN keyword replacement for $Date$, $Author$, $Revision$, $Id$ for all
*.c and *.h files.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/branches/ircii-pana-1.1@3 13b04d17-f746-0410-82c6-800466cd88b0
2008-02-25 09:49:14 +00:00
Kevin Easton
28febcfea9 Initial import of the ircii-pana-1.1-final source tree.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/tags/ircii-pana-1.1-final@1 13b04d17-f746-0410-82c6-800466cd88b0
2008-02-25 09:25:32 +00:00