Commit Graph

701 Commits

Author SHA1 Message Date
Loïc Gomez
40ac98214a
Add missing defines for SOFT_FAIL/HARD_FAIL in util.h
This is for these previous 2 commits:
  * 428c1b6 Allow checking ssl files are readable (check_ssl_files)
  * a03b123 Also reload SSL context on bip reload, allowing for SSL cert updates
2024-03-20 23:27:33 +09:00
Loïc Gomez
a03b12319a
Also reload SSL context on bip reload, allowing for SSL cert updates
- on BIP reload, check if SSL files are readable, and try to load new
  SSL context.
- on success only, update SSL context for new client connections

This allows for SSL certificate/key updates on /BIP reload or SIGHUP.

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:42:01 +09:00
Loïc Gomez
428c1b6173
Allow checking ssl files are readable (check_ssl_files)
- adds a new check_path_exists() method to path_util
- move code checking if SSL-related files exist with assertions (thus
  causing a fatal error) to a new check_ssl_files() method, allowing for
  soft or hard fail modes

This will allow for non-fatal checks of SSL files existence on reload.

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:33:31 +09:00
Loïc Gomez
f2443aaf23
Move SSL context code to get/set_ssl_context methods
- Move code setting up SSL context from accept_new() to new
  get/set_ssl_context() methods
- set_ssl_context() will allow setting context only if not already set,
  or force re-setting context even if already present
- set_ssl_context() will return 1 if SSL context has been set
- if getting the new SSL context fails, set_ssl_context() will not break
  current SSL context

This is preparatory work for reloading SSL certificates/key on BIP
reload.

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:29:05 +09:00
Loïc Gomez
400b0d66de
Fix deprecation notices for OpenSSL 3 and failure to build on GCC12
Tested with libssl 3.0.10-1ubuntu2.1 (Ubuntu 23.10) and 1.1.1f-1ubuntu2.20
(Ubuntu 20.04).

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:27:20 +09:00
Loïc Gomez
e643cd4944
Fix endless loop on /BIP LIST connections with long on_connect_send
- when the line to send to IRC was over a specific limit, the code was
  not moving to the next item in the on_connect_send list after sending
  the text to the client
- this change also adds a hard limit of 10 on_connect_send to display
  for each connection

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:19:28 +09:00
Loïc Gomez
8f3b313776
Fix file descriptor leak on erroring client disconnects
- Client connections in error also need to be closed/freed
- This fixes a file descriptor leak that would result in a bip crash

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:18:09 +09:00
Loïc Gomez
d49f135370
Move strict gcc compilation flags to configure.ac to avoid breaking incompatible environments
- Move gcc hardening/warning/advanced warnings flags to configure.ac to avoid
  breaking incompatible environments
- Use -Warith-conversion only with gcc 10 and later
- Keep -Wundef -Wpedantic enabled globally

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:16:25 +09:00
Loïc Gomez
5f054bdded
Fix bipmkpw compilation issues per external variables
- Add missing extern stanza to global variables

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:10:37 +09:00
Loïc Gomez
76c9ee11de
Handle CAP requests from clients, reply with no capabilities
Some clients require the server to handle CAP requests (IRCv3).
This adds basic support for CAP requests during the authentication
phase, sending no capabilities on CAP LS or CAP LIST, and CAP NAK
with all requested capabilities listed on CAP REQ.

This will be a base for adding capabilities later.

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 22:07:43 +09:00
Loïc Gomez
b810ba0f77
Add method to stringify a line struct, skipping first N elements
- adds an internal method _irc_line_to_string with current irc_line_to_string
  code, adding capability to skip the first N elements
- call this internal method from irc_line_to_string with N=0
- call this internal method from new irc_line_to_string_skip method

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-03-20 21:53:45 +09:00
Loïc Gomez
d19099eb3c
Log unhandled IRC errors as LOG_INFO in bip.log
This will allow for user feedback in main bip.log when an IRC error
occurs, like:
- 401 ERR_NOSUCHNICK
- 404 ERR_CANNOTSENDTOCHAN
- 432 ERR_ERRONEUSNICKNAME

These should not be logged as LOG_ERROR as they are not bip errors but
usually on the end user instead.

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-02-18 23:45:12 +01:00
Loïc Gomez
99a1244e46
Allow a user to /BIP JUMP [-f] [other_conn] (within their list).
This can be useful when a connection is very slow to reconnect and the
user wants to force an immediate reconnection.

Also:
- fix message when JUMPing on some already reconnecting link
- add find_link() method
- add reconnect timer info if any (else display 0s)
- add -f flag to reset reconnect timer

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-02-18 23:39:27 +09:00
Loïc Gomez
edd460a8fa
Set default recon_timer (and step) to 30s
Waiting 2 minutes on the first disconnect is depressing.
With this the maximum of 10min wait time is reached after 20 attempts
instead of the current 5 attempts.

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-02-18 00:07:41 +01:00
Loïc Gomez
4cd5bdb381
Set default backlog_lines = 0 (fixes Debian bug #818374)
This would have defaults move to backlog_always=false / log=true /
backlog_lines=0, which should not cause much trouble as backlog will
be reset after being displayed.

Also, it is doubtfuk anyone would be keeping the default of 10 for
backlog as it is pretty much an undesirable configuration.

We need to annouce this change as important though, so users having
log = false are aware memory usage could increase if they don't set
it manually to another value.

Signed-off-by: Loïc Gomez <bip@animanova.fr>
2024-02-17 03:29:45 +01:00
c6a872ed61
Add bipgenconfig.1 to dist_man_MANS
Fix 1df884545f
2022-03-20 11:42:09 +01:00
f797d25e06
Add -git to version string. 2022-03-10 15:57:31 +01:00
0a93c8cfd3
Update version and ChangeLog for bip-0.9.3 release. 2022-03-10 15:57:25 +01:00
18665b1501
Update NEWS file (SASL, GCC flags, /bip user info) 2022-03-10 14:38:26 +01:00
f2fd1824ca
Format the whole code using clang-format 2022-03-10 14:21:01 +01:00
Loïc Gomez
8d9658ca43
Build lexer in a separate unit without AM_CFLAGS 2022-03-10 14:20:58 +01:00
Loïc Gomez
e04f97c78f
ignore some issues related to array_get
ignore "passing argument X of .... with different width due to prototype"
2022-03-10 14:20:55 +01:00
Loïc Gomez
26d347dec6
sanitize: fix const char * being used as non-const 2022-03-10 14:20:52 +01:00
Loïc Gomez
ee6ee0bd34
irc_cli_part set cname to proper const char * 2022-03-10 14:20:49 +01:00
Loïc Gomez
edf78eadb1
sanitize: pragmas for our code 2022-03-10 14:20:46 +01:00
Loïc Gomez
efb79b1e80
sanitize: a bit evolved size_t cast for get_str_elem 2022-03-10 14:20:43 +01:00
Loïc Gomez
79d9be4e71
sanitize: ftell/fseek & len/file_offset type fixes 2022-03-10 14:20:41 +01:00
Loïc Gomez
dbf8ccd4de
sanitize: more NULL pointer failsafes 2022-03-10 14:20:35 +01:00
Loïc Gomez
f54775fe92
sanitize: ignore warnings related to external libs 2022-03-10 14:20:32 +01:00
Loïc Gomez
f379eb35d2
sanitize: oidentd handler fixes 2022-03-10 14:20:29 +01:00
Loïc Gomez
ce4cf8b6a0
sanitize: add bip_clock_gettime util function 2022-03-10 14:20:26 +01:00
Loïc Gomez
368149575d
sanitize: null writes, write errors, oversized int,
and set incoming_end to size_t
2022-03-10 14:20:23 +01:00
Loïc Gomez
b990a071b3
sanitize: fix pid/pidfile handling 2022-03-10 14:20:20 +01:00
Loïc Gomez
af590f83b7
lag shouldn't be allowed to go negative 2022-03-10 14:20:17 +01:00
Loïc Gomez
62fd77dc17
l_clientc should not be allowed to go negative 2022-03-10 14:20:15 +01:00
Loïc Gomez
dd5343b710
use proper types, safe casts (mostly size_t) 2022-03-10 14:20:12 +01:00
Loïc Gomez
94fe272018
handle more config errors, use char not int:1 2022-03-10 14:20:06 +01:00
Loïc Gomez
fbfae37d65
sanitize: configuration parsing 2022-03-10 14:20:03 +01:00
Loïc Gomez
9d6394679f
sanitize: check return value 2022-03-10 14:20:00 +01:00
Loïc Gomez
2a5e7b6f7b
sanitize: add trivial casts to types
and add missing default cases
2022-03-10 14:19:57 +01:00
Loïc Gomez
e694dae31c
functions without parameters: add missing void 2022-03-10 14:19:51 +01:00
Loïc Gomez
26d34bafab
sanitize: add bipmkpw_fatal & fix bipmkpw warnings 2022-03-10 14:19:46 +01:00
Loïc Gomez
fe108e390f
Add secure / strict CFLAGS
Ref: https://airbus-seclab.github.io/c-compiler-security/#gcc-tldr
2022-03-10 14:19:40 +01:00
Loïc Gomez
e7d82acfff
Update build configuration 2022-03-10 14:19:37 +01:00
Loïc Gomez
51a46a1454
Add compiled stuff to gitignore 2022-03-10 14:19:34 +01:00
Loïc Gomez
7680af6a09
Add make lint calling clang-format & force 80 cols 2022-03-10 14:19:31 +01:00
Loïc Gomez
34b3c4b0c3
Move /BIP to bip_strcat{,f}_fit memccpy wrapper
instead of snprintf.
2022-03-10 14:19:28 +01:00
Loïc Gomez
399a104d1e
fix /bip user info command 2022-03-10 14:19:22 +01:00
Loïc Gomez
dc43d75d1f
Add SASL authentication support (EXTERNAL, PLAIN) 2022-03-10 14:19:19 +01:00
1df884545f
Add a man page for the bipgenconfig script
This man page comes from the Debian package.
2021-10-17 12:52:00 +02:00