permchannels: isolate the load-time mode applier in catch_unwind so a panicking mode handler can't leave mode_sudo stuck true — which would silently disable rank/oper gating for every subsequent MODE; the flag is now always reset

This commit is contained in:
Jean Chevronnet 2026-08-19 01:14:34 +00:00
parent 14eb982db5
commit 928026c49e

View file

@ -89,9 +89,12 @@ fn apply_modes(s: &mut Server, name: &str, key: &str, modes: &str) {
return;
};
let args: Vec<&str> = it.collect();
s.mode_sudo = true;
// Isolate a panicking mode handler: otherwise it would leave `mode_sudo` stuck
// on, silently disabling rank/oper gating for every subsequent MODE.
let outcome = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
let mut ai = 0usize;
let mut adding = true;
s.mode_sudo = true;
for c in letters.chars() {
match c {
'+' => {
@ -118,7 +121,11 @@ fn apply_modes(s: &mut Server, name: &str, key: &str, modes: &str) {
};
let _ = h.apply(s, name, key, 0, adding, param);
}
}));
s.mode_sudo = false;
if outcome.is_err() {
eprintln!("[permchannels] a mode handler panicked applying {name}; skipped its remaining modes");
}
}
/// Recreate one parsed record as a live (member-less) channel.