From beb08e1b35157d84e235e5245cb8f060b88167d4 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 9 Jan 2026 18:10:28 +0900 Subject: [PATCH] server/auth: allow inline comments for denylist, add test for parser --- src/server/authorization.rs | 50 +++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/server/authorization.rs b/src/server/authorization.rs index c791cc7..0b3369f 100644 --- a/src/server/authorization.rs +++ b/src/server/authorization.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, path::Path}; +use std::{collections::HashSet, path::Path, str::Lines}; use anyhow::Context; use nix::unistd::Group; @@ -41,14 +41,23 @@ pub fn read_and_parse_group_denylist(denylist_path: &Path) -> anyhow::Result GroupDenylist { + let mut groups = HashSet::::new(); + + for (line_number, line) in lines.enumerate() { + let trimmed_line = if let Some(comment_start) = line.find('#') { + &line[..comment_start] + } else { + line } + .trim(); let parts: Vec<&str> = trimmed_line.splitn(2, ':').collect(); if parts.len() != 2 { @@ -137,5 +146,32 @@ pub fn read_and_parse_group_denylist(denylist_path: &Path) -> anyhow::Result