Commit Graph

36 Commits

Author SHA1 Message Date
Ed Kellett b860ad5ffa
chmode: end the grace period more intelligently (#84)
We were ending the flood grace period for any channel mode command other
than `MODE #foo [bq]` by means of a hardcoded check. I've moved that to
after we parse the mode string, so we can correctly identify all
requests to change modes and end the grace period on exactly those.

It would have been entirely possible to move the check even further down
and flood_endgrace on only mode commands that *actually* change modes,
but I don't like the idea of making it sensitive to external conditions.
2020-11-30 09:24:32 +00:00
jess a922755512
make more snotes L_NETWIDE 2020-11-08 14:30:41 -05:00
Eric Mertens d295a3986d
Stop using chm_nosuch as a sentinel value (#53)
Remove chmode compat modules

This removes the need for chm_nosuch as well. Unknown mode detection happens in mode parsing now.
2020-11-08 09:50:17 -08:00
Eric Mertens 92c6e47b4a
Clean up duplication in ChannelModeFunc prototypes (#52) 2020-11-07 16:45:12 -08:00
Ed Kellett 047b56e70e chmode: Generate a canonical mode string
Primarily because I want to use it in tests, but it also means people
reading override snotes don't have as much mental overhead. I hope.
2020-11-08 00:26:27 +00:00
Ed Kellett ea41b24fd4 chmode: Get elevated access for op-only queries 2020-11-08 00:26:27 +00:00
Ed Kellett 04952c32ad Rework channel mode handling
Incoming MODE processing is split into a parsing step and an execution
step, instead of a mode's effector function being involved in its own
parsing. Modes can no longer use custom logic to control their parsing,
and instead supply a combination of CHM_* flags to the parser. As a
result, we know before we try to effect any mode changes what all of
them will be.

The reauthorize hack for override is no longer necessary. A side effect
of its introduction was that `MODE #foo b x!y@z` no longer worked; in
removing it we restore that behaviour.

We gain the ability to reject various invalid inputs that:
- mutate or query unknown modes
- supply excess mode arguments
- query modes that can't be queried

In each case, whether we *should* reject it is an open question; for now
I'm rejecting the first one.
2020-11-08 00:26:27 +00:00
Ed Kellett b5c8d52d82 chmode: Make mode table manageable 2020-11-08 00:26:27 +00:00
Ed Kellett a6f63a829e
Innovation by sed 2020-10-15 15:52:41 +01:00
Ariadne Conill f5d60bb5cd chmode: use NULL for priv argument when auspex:cmodes priv is not needed
Otherwise, sendto_channel_local_priv() will only distribute mode changes
to opers only.  This is because HasPrivilege(target_p, "") will evaluate
as false due to the target not being opered.

Thanks to Devin Brown for bisecting this issue.
2020-09-09 12:10:11 -06:00
Ed Kellett d3fd88a406
Send hidden mode changes to auspex:cmodes 2020-08-04 22:58:30 +01:00
Ed Kellett 076973363a
chmode: priv checks only for local clients 2020-08-04 22:58:30 +01:00
Ed Kellett 80303ab70e
chm_staff: use oper:cmodes, don't check op status 2020-08-04 22:58:30 +01:00
Ed Kellett d4f7eb4ce6
Replace most checks for +o with oper:general
I'm preparing to PR a succession of privs changes with the ultimate goal
of severely limiting the scope of the binary oper/user dichotomy and
move conceptually distinct oper functions into their own privs.

Accomplishing this is a non-trivial task, and can wait, but it's
inconvenient now to have such functions enabled by the same mechanism
that grants any privs at all--so I'm moving all of them to a
transitional priv with the intention of eroding that later.
2020-08-04 22:58:30 +01:00
Simon Arlott 4b1cce65ed
ircd: send tags on every message
Simplify linebuf by introducing fsnprint to manage a list of printfs.
Add a msgbuf unparse cache for send functions that loop.
2017-08-06 16:21:29 +01:00
Simon Arlott d8f0b5d763
cppcheck: fix various warnings/errors
[ircd/match.c:316]: (error) Shifting a negative value is undefined behaviour
[librb/src/patricia.c:55]: (error) Shifting a negative value is undefined behaviour
[modules/m_alias.c:64]: (portability) '(void*)message' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.
[modules/m_time.c:111]: (warning) %u in format string (no. 9) requires 'unsigned int' but the argument type is 'signed int'.
[modules/m_time.c:111]: (warning) %u in format string (no. 10) requires 'unsigned int' but the argument type is 'signed int'.
[librb/src/dictionary.c:819]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'.
[librb/src/radixtree.c:1080]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'.
[ircd/s_user.c:351] -> [ircd/s_user.c:357]: (warning) Either the condition '0!=source_p' is redundant or there is possible null pointer dereference: source_p.
[extensions/ip_cloaking_3.0.c:109]: (warning, inconclusive) The buffer 'buf' may not be null-terminated after the call to strncpy().
[ircd/chmode.c:256]: (style) Clarify calculation precedence for '&' and '?'.
[modules/m_help.c:100]: (style) Clarify calculation precedence for '&' and '?'.
[modules/m_knock.c:169]: (style) Clarify calculation precedence for '&' and '?'.
[modules/m_stats.c:628]: (style) Clarify calculation precedence for '&' and '?'.
[modules/m_stats.c:727]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:601]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:704]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:739]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:763]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:768]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:774]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:781]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:786]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:791]: (style) Clarify calculation precedence for '&' and '?'.
[librb/src/radixtree.c:804]: (style) Clarify calculation precedence for '&' and '?'.
[ircd/wsproc.c:372]: (style) Unused variable: len
[modules/core/m_modules.c:382]: (style) Unused variable: i
[modules/m_stats.c:741]: (style) Unused variable: amsg
[ircd/authproc.c:390]: (style) Unused variable: iter
[ircd/authproc.c:391]: (style) Unused variable: client_p
2016-10-28 20:13:36 +01:00
Aaron Jones b2c9df4786
chmode: remove unreachable break statement 2016-06-01 20:00:48 +00:00
Aaron Jones 73d759aeb4
chmode: silence harmless uninitialised variable warning 2016-06-01 20:00:11 +00:00
William Pitcock b5f3e5e5e8 ircd: Channel.bants is not a serial but a timestamp.
Previously, the IRCd would increment bants instead of resyncing the timestamp, causing the potential of
false negatives from the bancache system.
2016-04-29 18:59:32 -05:00
Matt Ullman e0a9b5d3bf chmode: Move check_forward() to a boolean 2016-03-24 14:42:54 -04:00
Matt Ullman a383180a0a chmode: Move add_id() to a boolean 2016-03-24 14:37:52 -04:00
Matt Ullman 9aa639eddd chmode: Move allow_mode_change() to a boolean 2016-03-24 14:26:02 -04:00
Matt Ullman 4b11f39115 Move away from BSD data types 2016-03-23 19:11:42 -04:00
Elizabeth Myers 79435744c7 common.h: raison d'être is gone, so out it goes.
Fold whatever was left into ircd_defs.h
2016-03-23 09:33:56 -05:00
Elizabeth Myers 07554369bd Detect stdbool.h and add conformant shims if it isn't available
Charybdis requires C99 already, so it's high time we start using
stdbool. I've converted a few pieces of code already.

A lot of the old code that uses YES/NO should probably be updated too
because that's fucking hideous.
2016-03-08 04:54:04 -06:00
Elizabeth Myers 7e6b5384b3 Convert 2.8 style ToUpper/ToLower names to irctoupper/irctolower 2016-03-07 19:04:24 -06:00
Elizabeth Myers cbeab4bc34 Remove $Id tags from everything.
These are obsolete and none have changed since 10 years gao...
2016-03-06 02:47:27 -06:00
Valerii Iatsko 5203cba5ce Remove libratbox's snprintf.c, update related ircd code 2016-02-10 02:25:32 +01:00
Simon Arlott 87c44482d0 ircd: chmode: Avoid referencing beyond the end of the flags_list array in set_channel_mode
We're setting flags to flags_list[3] at the end of the loop, but the
array only has 3 elements. Unless the compiler optimises this away
(because flags will not be used again) we're accessing memory beyond
the end of the array.

With gcc-4.9:
chmode.c: In function 'set_channel_mode':
chmode.c:1548:54: warning: iteration 2u invokes undefined behavior [-Waggressive-loop-optimizations]
  for(j = 0, flags = flags_list[0]; j < 3; j++, flags = flags_list[j])
                                                      ^
chmode.c:1548:2: note: containing loop
  for(j = 0, flags = flags_list[0]; j < 3; j++, flags = flags_list[j])

Explicitly set "flags = flags_list[j]" at the start of each loop
iteration, which will avoid referencing off the end of the array.
2016-02-09 10:41:37 -06:00
William Pitcock 1046ac77af ircd: chmode: change CHFL_CHANOP checks where appropriate to allow levels above CHFL_CHANOP
this is the same behaviour as other checks in other places in the code.
2016-01-16 01:55:57 -06:00
William Pitcock 3ee43bcf29 ircd: get_channel_access(): do not derive channel pointer from membership 2016-01-13 22:16:44 -06:00
William Pitcock b4e3861bf9 ircd: get_channel_access(): allow override hooks to work without a membership pointer 2016-01-13 16:56:05 -06:00
William Pitcock fd8e3f892c ircd: chmode: clean up chm_hidden() a little bit 2016-01-13 16:37:25 -06:00
William Pitcock be29ec793d ircd: import hidden channel modes framework, from ircd-seven
This allows for modules to define channel modes which are only visible to opers.
2016-01-13 16:34:27 -06:00
William Pitcock b870a5f8e9 extensions/override: display mode-change string in override messages 2016-01-11 22:40:32 -06:00
William Pitcock ff12cc9479 rename src to ircd, libcore to libircd 2016-01-06 01:16:08 -06:00