sys-apps/usbguard: Support >=dev-libs/protobuf-30

Closes: https://bugs.gentoo.org/953624
Signed-off-by: Sebastian Pipping <sping@gentoo.org>
This commit is contained in:
Sebastian Pipping
2025-05-11 17:54:51 +02:00
parent 1dc8057fc3
commit 6edcb7bb44
2 changed files with 192 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
From 2838890f097fb2f5419523801e71e54905a7d1dd Mon Sep 17 00:00:00 2001
From: Christian Heusel <christian@heusel.eu>
Date: Tue, 11 Mar 2025 21:43:51 +0100
Subject: [PATCH] Adapt for protobuf 30.0 API changes
Fixes https://github.com/USBGuard/usbguard/issues/649
Link: https://protobuf.dev/support/migration/
Signed-off-by: Christian Heusel <christian@heusel.eu>
---
src/Library/IPCClientPrivate.cpp | 2 +-
src/Library/IPCClientPrivate.hpp | 2 +-
src/Library/IPCServerPrivate.cpp | 6 +++---
src/Library/IPCServerPrivate.hpp | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Library/IPCClientPrivate.cpp b/src/Library/IPCClientPrivate.cpp
index 6aa52013..452ecd41 100644
--- a/src/Library/IPCClientPrivate.cpp
+++ b/src/Library/IPCClientPrivate.cpp
@@ -225,7 +225,7 @@ namespace usbguard
std::string payload;
message.SerializeToString(&payload);
struct qb_ipc_request_header hdr;
- hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(message.GetTypeName());
+ hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(std::string(message.GetTypeName()));
hdr.size = sizeof hdr + payload.size();
struct iovec iov[2];
iov[0].iov_base = &hdr;
diff --git a/src/Library/IPCClientPrivate.hpp b/src/Library/IPCClientPrivate.hpp
index d92a1d47..a33022e2 100644
--- a/src/Library/IPCClientPrivate.hpp
+++ b/src/Library/IPCClientPrivate.hpp
@@ -84,7 +84,7 @@ namespace usbguard
template<class T>
void registerHandler(MessageHandler::HandlerType method)
{
- const uint32_t type_number = IPC::messageTypeNameToNumber(T::default_instance().GetTypeName());
+ const uint32_t type_number = IPC::messageTypeNameToNumber(std::string(T::default_instance().GetTypeName()));
_handlers.emplace(type_number, MessageHandler::create<T>(*this, method));
}
diff --git a/src/Library/IPCServerPrivate.cpp b/src/Library/IPCServerPrivate.cpp
index 548a7261..b976f025 100644
--- a/src/Library/IPCServerPrivate.cpp
+++ b/src/Library/IPCServerPrivate.cpp
@@ -311,7 +311,7 @@ namespace usbguard
message->SerializeToString(&payload);
struct qb_ipc_response_header hdr;
struct iovec iov[2];
- hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(message->GetTypeName());
+ hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(std::string(message->GetTypeName()));
hdr.size = sizeof hdr + payload.size();
hdr.error = 0;
iov[0].iov_base = &hdr;
@@ -555,7 +555,7 @@ namespace usbguard
std::string payload;
message->SerializeToString(&payload);
struct qb_ipc_response_header hdr = { };
- hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(message->GetTypeName());
+ hdr.id = QB_IPC_MSG_USER_START + IPC::messageTypeNameToNumber(std::string(message->GetTypeName()));
hdr.size = sizeof hdr + payload.size();
hdr.error = 0;
struct iovec iov[2];
@@ -563,7 +563,7 @@ namespace usbguard
iov[0].iov_len = sizeof hdr;
iov[1].iov_base = (void*)payload.data();
iov[1].iov_len = payload.size();
- qbIPCBroadcastData(iov, 2, messageTypeNameToAccessControlSection(message->GetTypeName()));
+ qbIPCBroadcastData(iov, 2, messageTypeNameToAccessControlSection(std::string(message->GetTypeName())));
iov[0].iov_base = nullptr;
iov[1].iov_base = nullptr;
}
diff --git a/src/Library/IPCServerPrivate.hpp b/src/Library/IPCServerPrivate.hpp
index 25f9ac38..3b3dcc51 100644
--- a/src/Library/IPCServerPrivate.hpp
+++ b/src/Library/IPCServerPrivate.hpp
@@ -134,7 +134,7 @@ namespace usbguard
void registerHandler(MessageHandler::HandlerType method, IPCServer::AccessControl::Section section,
IPCServer::AccessControl::Privilege privilege)
{
- const uint32_t type_number = IPC::messageTypeNameToNumber(T::default_instance().GetTypeName());
+ const uint32_t type_number = IPC::messageTypeNameToNumber(std::string(T::default_instance().GetTypeName()));
_handlers.emplace(type_number, MessageHandler::create<T>(*this, method, section, privilege));
}

View File

@@ -0,0 +1,106 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit autotools bash-completion-r1
DESCRIPTION="Daemon protecting your computer against BadUSB"
HOMEPAGE="https://github.com/USBGuard/usbguard"
SRC_URI="https://github.com/USBGuard/usbguard/releases/download/${P}/${P}.tar.gz"
LICENSE="GPL-2+"
SLOT="0/1" # due to libusbguard.so.<1>.0.0
KEYWORDS="~amd64 ~x86"
IUSE="dbus ldap policykit selinux static-libs systemd test umockdev"
# https://github.com/USBGuard/usbguard/issues/449
# https://bugs.gentoo.org/769692
REQUIRED_USE+=" test? ( static-libs )"
CDEPEND="
dev-libs/pegtl
>=dev-libs/libsodium-0.4.5:=
>=dev-libs/protobuf-2.5.0:=[protoc(+)]
>=sys-cluster/libqb-0.16.0:=
sys-devel/gcc:*[cxx]
>=sys-libs/libcap-ng-0.7.0
>=sys-libs/libseccomp-2.0.0
>=sys-process/audit-2.7.7
dbus? (
dev-libs/glib:2
sys-apps/dbus
sys-auth/polkit[introspection]
)
ldap? ( net-nds/openldap:= )
systemd? ( sys-apps/systemd )
umockdev? ( dev-util/umockdev )
"
RDEPEND="${CDEPEND}
virtual/udev
selinux? ( sec-policy/selinux-usbguard )
"
DEPEND="${CDEPEND}
app-text/asciidoc
<dev-cpp/catch-3:0
dbus? (
dev-libs/libxml2
dev-libs/libxslt
dev-util/gdbus-codegen
)
"
RESTRICT="!test? ( test )"
PATCHES=(
# https://bugs.gentoo.org/953624
"${FILESDIR}"/${P}-protobuf-30.patch
)
src_prepare() {
default
eautoreconf
}
src_configure() {
local myargs=(
--with-bash-completion-dir=$(get_bashcompdir)
--localstatedir=/var # i.e. not /var/lib, bug 852296
$(use_with dbus)
$(use_with dbus polkit)
$(use_with ldap)
$(use_enable static-libs static)
$(use_enable systemd)
$(use_enable umockdev)
)
econf "${myargs[@]}"
}
src_install() {
default
keepdir /etc/usbguard/IPCAccessControl.d # bug 808801
keepdir /etc/usbguard/rules.d # bug 933878
keepdir /var/log/usbguard
chmod 0600 "${ED}"/etc/usbguard/IPCAccessControl.d/.keep* || die # bug 808801
chmod 0600 "${ED}"/etc/usbguard/rules.d/.keep* || die # bug 933878
newinitd "${FILESDIR}"/${PN}-0.7.6-usbguard.openrc usbguard
use dbus && newinitd "${FILESDIR}"/${PN}-0.7.6-usbguard-dbus.openrc usbguard-dbus
find "${D}" -name '*.la' -delete || die # bug 850655
}
pkg_postinst() {
ewarn
ewarn 'BEFORE STARTING USBGUARD please be sure to create/generate'
ewarn ' a rules file at /etc/usbguard/rules.conf'
ewarn ' so that you do not'
ewarn ' GET LOCKED OUT'
ewarn " of this system (\"$(hostname)\")."
ewarn
ewarn 'This command may be of help:'
ewarn ' sudo sh -c "usbguard generate-policy > /etc/usbguard/rules.conf"'
ewarn
}