1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-19 09:15:30 +03:00
aports/testing/usbguard/musl.patch
Michał Polański 5a43b33f94 testing/usbguard: new aport
Software framework for implementing USB device authorization policies
https://usbguard.github.io
2020-10-16 14:27:11 +00:00

90 lines
2.8 KiB
Diff

Reason: Fix compilation on musl
Upstream: No
Got it from Void Linux:
https://github.com/void-linux/void-packages/commit/427d50c6a66e4a1338dbe230a41b98a2419116a9
--- a/src/CLI/usbguard.cpp
+++ b/src/CLI/usbguard.cpp
@@ -26,10 +26,8 @@
#include <map>
#include <iostream>
-#ifndef _GNU_SOURCE
- #define _GNU_SOURCE
-#endif
-#include <cstring> /* GNU version of basename(3) */
+#include <cstring>
+#include <libgen.h>
#include "usbguard.hpp"
#include "usbguard-get-parameter.hpp"
@@ -99,7 +97,7 @@
static int usbguard_cli(int argc, char* argv[])
{
- usbguard_arg0 = ::basename(argv[0]);
+ usbguard_arg0 = ::basename(strdup(argv[0]));
if (argc == 1) {
showTopLevelHelp();
--- a/src/CLI/usbguard-rule-parser.cpp
+++ b/src/CLI/usbguard-rule-parser.cpp
@@ -24,10 +24,8 @@
#include "RuleParser.hpp"
#include <iostream>
-#ifndef _GNU_SOURCE
- #define _GNU_SOURCE
-#endif
#include <cstring>
+#include <libgen.h>
#include <fstream>
#include <getopt.h>
@@ -43,8 +41,10 @@
static void showHelp(std::ostream& stream, const char* usbguard_arg0)
{
- stream << " Usage: " << ::basename(usbguard_arg0) << " [OPTIONS] <rule_spec>" << std::endl;
- stream << " Usage: " << ::basename(usbguard_arg0) << " [OPTIONS] -f <file>" << std::endl;
+ char *usbguard_arg0_copy = strdup(usbguard_arg0);
+ stream << " Usage: " << ::basename(usbguard_arg0_copy) << " [OPTIONS] <rule_spec>" << std::endl;
+ stream << " Usage: " << ::basename(usbguard_arg0_copy) << " [OPTIONS] -f <file>" << std::endl;
+ free(usbguard_arg0_copy);
stream << std::endl;
stream << " Options:" << std::endl;
stream << " -f, --file Interpret the argument as a path to a file that should be parsed." << std::endl;
--- a/src/DBus/gdbus-server.cpp
+++ b/rc/DBus/gdbus-server.cpp
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <iostream>
#include <getopt.h>
+#include <libgen.h>
#include "DBusBridge.hpp"
static usbguard::DBusBridge* dbus_bridge = nullptr;
@@ -208,7 +209,9 @@
static void showHelp(std::ostream& stream)
{
- stream << " Usage: " << ::basename(usbguard_arg0) << " [OPTIONS]" << std::endl;
+ char *usbguard_arg0_copy = strdup(usbguard_arg0);
+ stream << " Usage: " << ::basename(usbguard_arg0_copy) << " [OPTIONS]" << std::endl;
+ free(usbguard_arg0_copy);
stream << std::endl;
stream << " Options:" << std::endl;
stream << " -s, --system Listen on the system bus." << std::endl;
--- a/src/Library/public/usbguard/Exception.hpp
+++ b/src/Library/public/usbguard/Exception.hpp
@@ -116,7 +116,8 @@
static std::string reasonFromErrno(const int errno_value)
{
char buffer[1024];
- return std::string(strerror_r(errno_value, buffer, sizeof buffer));
+ strerror_r(errno_value, buffer, sizeof buffer);
+ return std::string(buffer);
}
};