From 63f0b672487536de798d28c7d79981704fcdf46c Mon Sep 17 00:00:00 2001 From: "lxt_wangyi@163.com" Date: Thu, 6 Mar 2025 15:32:54 +0800 Subject: [PATCH] Modified USBguard append-rule to add support to the beginning of the configuration file (-a 0 command) Signed-off-by: lxt_wangyi@163.com --- src/Library/public/usbguard/Policy.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Library/public/usbguard/Policy.cpp b/src/Library/public/usbguard/Policy.cpp index 136d502f..d8b0e68e 100644 --- a/src/Library/public/usbguard/Policy.cpp +++ b/src/Library/public/usbguard/Policy.cpp @@ -60,6 +60,17 @@ namespace usbguard USBGUARD_LOG(Trace) << "parent_id=" << parent_id; auto rule = std::make_shared(_rule); + if (parent_id == 0) { + auto ruleset = _rulesets_ptr.front(); + + if (rule->getRuleID() == Rule::DefaultID) { + assignID(rule); + } + + auto rules = ruleset->getRules(); + return ruleset->appendRule(*rule, 0); + } + // If the parent_id is set to Rule::LastID then we get the the ID of the last rule in rulesets if (parent_id == Rule::LastID) { auto ruleset = _rulesets_ptr.back();