Files
void-packages/srcpkgs/elogind/patches/003-musl-missing.patch
Jürgen Buchmüller 3b7e93a1f7 elogind: fix musl
Closes #5887
2017-03-05 17:41:57 +01:00

254 lines
7.7 KiB
Diff

This library is a masterpiece of writing non-portable code.
The patches are trying to be minimally invasive and are, for
the most part, just simple macros replacing glibc extensions
with their POSIX counterparts.
The file src/musl_missing.h is included whereever the code
expects functions and constants which are specific to glibc.
--- src/libelogind/sd-bus/bus-message.c 2015-04-19 13:32:24.607347468 +0200
+++ src/libelogind/sd-bus/bus-message.c 2017-03-04 12:12:45.277329646 +0100
@@ -23,6 +23,7 @@
#include <fcntl.h>
#include <sys/mman.h>
+#include "musl_missing.h"
#include "util.h"
#include "utf8.h"
#include "strv.h"
--- src/libelogind/sd-bus/bus-objects.c 2015-04-19 13:32:24.611347468 +0200
+++ src/libelogind/sd-bus/bus-objects.c 2017-03-04 12:12:52.469343136 +0100
@@ -19,6 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "musl_missing.h"
#include "strv.h"
#include "set.h"
#include "bus-internal.h"
--- src/libelogind/sd-bus/bus-util.c 2015-04-19 13:32:24.611347468 +0200
+++ src/libelogind/sd-bus/bus-util.c 2017-03-04 12:13:00.357357928 +0100
@@ -21,6 +21,7 @@
#include <sys/socket.h>
+#include "musl_missing.h"
#include "sd-daemon.h"
#include "sd-event.h"
#include "util.h"
--- src/libelogind/sd-bus/sd-bus.c 2016-03-06 16:00:52.027398234 +0100
+++ src/libelogind/sd-bus/sd-bus.c 2017-03-04 12:13:08.163372562 +0100
@@ -27,6 +27,7 @@
#include <sys/mman.h>
#include <pthread.h>
+#include "musl_missing.h"
#include "util.h"
#include "macro.h"
#include "strv.h"
--- src/libelogind/sd-device/sd-device.c 2015-04-19 13:32:24.611347468 +0200
+++ src/libelogind/sd-device/sd-device.c 2017-03-04 12:35:03.255797997 +0100
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <net/if.h>
+#include "musl_missing.h"
#include "util.h"
#include "macro.h"
#include "path-util.h"
--- src/shared/arphrd-list.c 2017-03-04 15:31:15.633884536 +0100
+++ src/shared/arphrd-list.c 2017-03-04 15:32:05.646967582 +0100
@@ -22,6 +22,7 @@
#include <net/if_arp.h>
#include <string.h>
+#include "musl_missing.h"
#include "util.h"
#include "arphrd-list.h"
--- src/shared/cgroup-util.c 2016-03-06 16:00:52.183398132 +0100
+++ src/shared/cgroup-util.c 2017-03-04 13:22:38.379366996 +0100
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <ftw.h>
+#include "musl_missing.h"
#include "cgroup-util.h"
#include "set.h"
#include "macro.h"
--- src/shared/import-util.c 2015-04-19 13:32:24.659347470 +0200
+++ src/shared/import-util.c 2017-03-04 13:50:12.978234609 +0100
@@ -19,6 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "musl_missing.h"
#include "util.h"
#include "import-util.h"
--- src/shared/log.c 2015-04-19 13:32:24.659347470 +0200
+++ src/shared/log.c 2017-03-04 12:13:13.650382848 +0100
@@ -29,6 +29,11 @@
#include <stddef.h>
+#if defined(__GLIBC__)
#include <printf.h>
+#else
+#include "musl_missing.h"
+#include "parse-printf-format.h"
+#endif
#include "log.h"
#include "util.h"
#include "missing.h"
--- src/shared/mkdir.c 2015-04-19 13:32:24.663347471 +0200
+++ src/shared/mkdir.c 2017-03-04 13:24:40.815495150 +0100
@@ -22,6 +22,7 @@
#include <string.h>
#include <errno.h>
+#include "musl_missing.h"
#include "util.h"
#include "path-util.h"
#include "mkdir.h"
--- src/shared/pager.c 2015-04-19 13:32:24.663347471 +0200
+++ src/shared/pager.c 2017-03-04 13:10:55.917202529 +0100
@@ -25,6 +25,7 @@
#include <string.h>
#include <sys/prctl.h>
+#include "musl_missing.h"
#include "pager.h"
#include "util.h"
#include "macro.h"
--- src/shared/path-util.c 2015-04-19 13:32:24.663347471 +0200
+++ src/shared/path-util.c 2017-03-04 12:13:29.919413335 +0100
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <sys/statvfs.h>
+#include "musl_missing.h"
#include "macro.h"
#include "util.h"
#include "log.h"
--- src/shared/socket-util.c 2015-04-19 13:32:24.663347471 +0200
+++ src/shared/socket-util.c 2017-03-04 13:13:24.833441863 +0100
@@ -29,6 +29,7 @@
#include <stddef.h>
#include <netdb.h>
+#include "musl_missing.h"
#include "macro.h"
#include "path-util.h"
#include "util.h"
--- src/shared/strbuf.c 2015-04-19 13:32:24.663347471 +0200
+++ src/shared/strbuf.c 2017-03-04 12:44:52.010758521 +0100
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
+#include "musl_missing.h"
#include "util.h"
#include "strbuf.h"
--- src/shared/uid-range.c 2015-04-19 13:32:24.667347471 +0200
+++ src/shared/uid-range.c 2017-03-04 13:46:38.443975396 +0100
@@ -19,6 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "musl_missing.h"
#include "util.h"
#include "uid-range.h"
--- src/shared/util.c 2015-04-19 13:32:24.667347471 +0200
+++ src/shared/util.c 2017-03-04 12:13:25.146404392 +0100
@@ -74,6 +74,7 @@
#include <sys/auxv.h>
#endif
+#include "musl_missing.h"
#include "config.h"
#include "macro.h"
#include "util.h"
--- /dev/null 2017-02-27 11:29:25.507373858 +0100
+++ src/musl_missing.h 2017-03-04 12:07:03.302685073 +0100
@@ -0,0 +1,65 @@
+/****************************************************************
+ * musl_missing.h - work around glibc extensions for musl libc.
+ *
+ * Implements glibc functions missing in musl libc as macros.
+ * Is to be included where these functions are used.
+ * Also defines some glibc only constants as either 0 or
+ * as found in the corresponding glibc header file.
+ *
+ * Juergen Buchmueller <pullmoll@t-online.de> for Void Linux
+ * Public Domain; no warranties whatsoever. Thank you Mr. P.
+ *
+ ****************************************************************/
+
+#if !defined(__GLIBC__)
+#include "config.h"
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+ * Possibly TODO according to http://man7.org/linux/man-pages/man3/getenv.3.html
+ * + test if the process's effective user ID does not match its real user ID or
+ * the process's effective group ID does not match its real group ID;
+ * typically this is the result of executing a set-user-ID or set-
+ * group-ID program. Is calling issetugid() sufficient here?
+ * + test if the effective capability bit was set on the executable file
+ * + test if the process has a nonempty permitted capability set
+ */
+#define secure_getenv(name) \
+ (issetugid() ? NULL : getenv(name))
+
+/* Poor man's basename */
+#define basename(path) \
+ (strrchr(path, '/') ? strrchr(path, '/')+1 : path)
+
+/* strndupa may already be defined in another compatibility header */
+#if !defined(strndupa)
+#define strndupa(src, n) \
+ (__extension__ ({const char *in = (src); \
+ size_t len = strnlen(in, (n)) + 1; \
+ char *out = (char *) alloca(len); \
+ out[len-1] = '\0'; \
+ (char *) memcpy(out, in, len-1);}) \
+ )
+#endif
+
+/* See http://man7.org/linux/man-pages/man3/canonicalize_file_name.3.html */
+#define canonicalize_file_name(path) \
+ realpath(path, NULL)
+
+typedef int (*__compar_fn_t)(const void *, const void *);
+
+/* GLOB_BRACE is another glibc extension - ignore it for musl libc */
+#define GLOB_BRACE 0
+
+/* getnameinfo(3) glibc extensions are undefined in musl libc */
+#define NI_IDN 0
+#define NI_IDN_USE_STD3_ASCII_RULES 0
+
+/* Taken from glibc's net/if_arp.h */
+#if !defined(ARPHRD_IEEE802154_PHY)
+#define ARPHRD_IEEE802154_PHY 805 /* IEEE 802.15.4 PHY header. */
+#endif
+
+#endif /* !defined(__GLIBC__) */
--- Makefile.am 2016-03-06 16:00:51.919398304 +0100
+++ Makefile.am 2017-03-04 13:06:34.982792357 +0100
@@ -482,7 +482,9 @@
src/shared/import-util.c \
src/shared/import-util.h \
src/shared/sysctl-util.c \
- src/shared/sysctl-util.h
+ src/shared/sysctl-util.h \
+ src/shared/parse-printf-format.c \
+ src/shared/parse-printf-format.h
nodist_libelogind_shared_la_SOURCES = \
src/shared/errno-from-name.h \