accountsservice: write new musl patch that does more than just compile

This commit is contained in:
Enno Boland 2018-03-26 13:14:51 +02:00
parent 1e066864f2
commit 106b948b01
No known key found for this signature in database
GPG Key ID: D09964719BDE9971

View File

@ -1,34 +1,32 @@
Musl libc does not support fgetspent_r(), so fall back diff --git a/src/daemon.c b/src/daemon.c
to using the non-thread-safe fgetspent() function. index 312394a..e7b3c58 100644
--- src/daemon.c
--- src/daemon.c 2016-09-06 21:48:50.000000000 +0200 +++ src/daemon.c
+++ src/daemon.c 2016-11-25 10:41:01.614534302 +0100 @@ -140,6 +140,26 @@ error_get_type (void)
@@ -174,7 +174,7 @@ #define MAX_LOCAL_USERS 50
int ret = 0; #endif
shadow_entry_buffers = g_malloc0 (sizeof (*shadow_entry_buffers)); +#ifndef __GLIBC__
- + /* Musl libc does not support fgetspent_r(), write own
+#if defined(__GLIBC__) + * wrapper
ret = fgetspent_r (fp, &shadow_entry_buffers->spbuf, shadow_entry_buffers->buf, sizeof (shadow_entry_buffers->buf), &shadow_entry); + */
if (ret == 0) { +static int fgetspent_r(FILE *fp, struct spwd *spbuf, char *buf, size_t buflen, struct spwd **spbufp) {
g_hash_table_insert (shadow_users, g_strdup (shadow_entry->sp_namp), shadow_entry_buffers); + struct spwd *shadow_entry = fgetspent(fp);
@@ -185,6 +185,19 @@ + size_t namplen = strlen(shadow_entry->sp_namp);
break; + size_t pwdplen = strlen(shadow_entry->sp_pwdp);
}
}
+#else
+ /* Musl libc does not support fgetspent_r(), so fall back
+ * to using the non-thread-safe fgetspent() function.
+ */
+ shadow_entry = fgetspent(fp);
+ if (shadow_entry == NULL) {
+ g_free (shadow_entry_buffers);
+ +
+ if (errno != EINTR) { + if(namplen + pwdplen + 2 > buflen)
+ break; + 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;
+}
+#endif +#endif
} while (shadow_entry != NULL); +
static struct passwd *
fclose (fp); entry_generator_fgetpwent (Daemon *daemon,
GHashTable *users,