From a392e80732b91d4b4150ae52642db2863ea2f462 Mon Sep 17 00:00:00 2001 From: Thiebaud Weksteen Date: Mon, 27 May 2019 10:54:37 +0200 Subject: [PATCH] Add option to filter rules by label when listing Redefine listRules IPC method to only return vector and not a RuleSet. The query parameter is reused for matching against the label of the rule. --- src/CLI/usbguard-list-rules.cpp | 25 ++++++++++++----------- src/DBus/DBusBridge.cpp | 7 +++---- src/Daemon/Daemon.cpp | 13 ++++++++++-- src/Daemon/Daemon.hpp | 2 +- src/Library/IPC/Policy.proto | 3 +-- src/Library/IPCClientPrivate.cpp | 18 ++++------------ src/Library/IPCClientPrivate.hpp | 2 +- src/Library/IPCServerPrivate.cpp | 10 ++++----- src/Library/public/usbguard/IPCClient.cpp | 2 +- src/Library/public/usbguard/IPCClient.hpp | 4 ++-- src/Library/public/usbguard/Interface.hpp | 2 +- 11 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/CLI/usbguard-list-rules.cpp b/src/CLI/usbguard-list-rules.cpp index 0c06efc6..54bbd2e3 100644 --- a/src/CLI/usbguard-list-rules.cpp +++ b/src/CLI/usbguard-list-rules.cpp @@ -29,11 +29,12 @@ namespace usbguard { - static const char* options_short = "hd"; + static const char* options_short = "hdl:"; static const struct ::option options_long[] = { { "help", no_argument, nullptr, 'h' }, { "show-devices", no_argument, nullptr, 'd'}, + { "label", required_argument, nullptr, 'l' }, { nullptr, 0, nullptr, 0 } }; @@ -44,6 +45,7 @@ namespace usbguard stream << " Options:" << std::endl; stream << " -d, --show-devices Show all devices which are affected by the specific rule." << std::endl; stream << " -h, --help Show this help." << std::endl; + stream << " -l, --label