accountsservice: Hack musl build fix

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Andreas Müller
2019-12-09 09:36:12 +01:00
committed by Khem Raj
parent 4ce1faf54d
commit 079137f59b
3 changed files with 86 additions and 0 deletions
@@ -0,0 +1,36 @@
From 2a1c7103839c20df5ca9ce2fa863535d802f8f3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Sun, 8 Dec 2019 23:42:00 +0100
Subject: [PATCH] musl: Hack to fix configure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
meson.build | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
index 4465a26..726c9fe 100644
--- a/meson.build
+++ b/meson.build
@@ -82,8 +82,14 @@ if cc.has_header_symbol('utmpx.h', 'WTMPX_FILENAME', prefix: '#define _GNU_SOURC
elif cc.has_header_symbol('paths.h', '_PATH_WTMPX')
config_h.set('PATH_WTMP', '_PATH_WTMPX')
else
- assert(run_command('test', '-e', '/var/log/utx.log').returncode() == 0, 'Do not know which filename to watch for wtmp changes')
- config_h.set_quoted('PATH_WTMP', '/var/log/utx.log')
+ # musl: This is just a build fix hack.
+ # As usual they know better, consider all other projects crap and offer zero
+ # alternatives: So wtmp is a dead stub only [1] (= /dev/null/wtmp - taken
+ # from musl sources).
+ # Maybe a hero comes along and adds utmps [2] to make accountsservice useful for musl
+ # [1] https://wiki.musl-libc.org/faq.html#Q:-Why-is-the-utmp/wtmp-functionality-only-implemented-as-stubs?
+ # [2] https://github.com/skarnet/utmps
+ config_h.set_quoted('PATH_WTMP', '/dev/null/wtmp')
endif
# compiler flags
--
2.21.0
@@ -0,0 +1,46 @@
From 820249ea8e38c568e6a36fbd9c852718c7665b56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Mon, 9 Dec 2019 00:12:08 +0100
Subject: [PATCH] musl: add missing fgetspent_r
Stolen from void-linux
Upstream-Status: Inappropriate [musl-specific]
---
src/daemon.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/daemon.c b/src/daemon.c
index c52bda3..a7676fe 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -164,6 +164,26 @@ remove_cache_files (const gchar *user_name)
g_remove (icon_filename);
}
+/* Musl libc does not support fgetspent_r(), write own
+ * wrapper
+ */
+static int fgetspent_r(FILE *fp, struct spwd *spbuf, char *buf, size_t buflen, struct spwd **spbufp) {
+ struct spwd *shadow_entry = fgetspent(fp);
+ if(!shadow_entry)
+ return -1;
+ size_t namplen = strlen(shadow_entry->sp_namp);
+ size_t pwdplen = strlen(shadow_entry->sp_pwdp);
+
+ if(namplen + pwdplen + 2 > buflen)
+ return -1;
+
+ *spbufp = memcpy(spbuf, shadow_entry, sizeof(struct spwd));
+ spbuf->sp_namp = strncpy(buf, shadow_entry->sp_namp, namplen + 1);
+ spbuf->sp_pwdp = strncpy(buf + namplen + 1, shadow_entry->sp_pwdp, pwdplen + 1);
+
+ return 0;
+}
+
static struct passwd *
entry_generator_fgetpwent (Daemon *daemon,
GHashTable *users,
--
2.21.0
@@ -13,6 +13,10 @@ inherit meson gobject-introspection gtk-doc features_check systemd
REQUIRED_DISTRO_FEATURES = "polkit"
SRC_URI = "https://www.freedesktop.org/software/${BPN}/${BPN}-${PV}.tar.xz"
SRC_URI_append_libc-musl = " \
file://0001-musl-Hack-to-fix-build.patch \
file://0002-musl-add-missing-fgetspent_r.patch \
"
SRC_URI[md5sum] = "6e4c6fbd490260cfe17de2e76f5d803a"
SRC_URI[sha256sum] = "ff2b2419a7e06bd9cb335ffe391c7409b49a0f0130b890bd54692a3986699c9b"