chanserv: SOP protect tier over AOP (+ao), founder owner (+qo); resolve op access by capability not mode string
All checks were successful
CI / check (push) Successful in 3m59s

This commit is contained in:
Jean Chevronnet 2026-07-17 15:43:16 +00:00
parent c8106035df
commit 2f6fd41465
No known key found for this signature in database
7 changed files with 139 additions and 37 deletions

View file

@ -1,5 +1,5 @@
use echo_api::Store;
use echo_api::{Sender, ServiceCtx};
use echo_api::{status_mode, Sender, ServiceCtx};
use echo_api::NetView;
// ENFORCE <#channel>: re-apply the channel's settings to everyone present —
@ -19,7 +19,7 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, net:
let members: Vec<String> = net.channel_members(chan);
for uid in members {
match net.account_of(&uid).and_then(|a| info.join_mode(a)) {
Some(m) => ctx.channel_mode(me, chan, &format!("{m} {uid}")),
Some(m) => ctx.channel_mode(me, chan, &status_mode(m, &uid)),
None => {
let nick = net.nick_of(&uid).unwrap_or("*");
let host = net.host_of(&uid).unwrap_or("*");

View file

@ -1,4 +1,4 @@
use echo_api::{NetView, Sender, ServiceCtx, Store};
use echo_api::{status_mode, NetView, Sender, ServiceCtx, Store};
// UP <#channel>: (re)apply the status mode your access entitles you to.
// DOWN <#channel>: drop your channel status modes. `up` selects which.
@ -22,14 +22,14 @@ pub fn handle(me: &str, from: &Sender, up: bool, args: &[&str], ctx: &mut Servic
if up {
match info.join_mode(account) {
Some(mode) => {
ctx.channel_mode(me, chan, &format!("{mode} {}", from.uid));
ctx.channel_mode(me, chan, &status_mode(mode, from.uid));
ctx.notice(me, from.uid, format!("Your status in \x02{chan}\x02 has been applied."));
}
None => ctx.notice(me, from.uid, format!("You have no status access in \x02{chan}\x02.")),
}
} else {
// Strip op and voice; the ircd ignores any mode you don't currently hold.
ctx.channel_mode(me, chan, &format!("-ov {} {}", from.uid, from.uid));
// Strip owner, admin, op, halfop and voice; the ircd ignores any you don't hold.
ctx.channel_mode(me, chan, &status_mode("-qaohv", from.uid));
ctx.notice(me, from.uid, format!("Your status in \x02{chan}\x02 has been removed."));
}
}