From 03a5e6d9b9978c4e2fc6b904da379407ab9452bf Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 13 Dec 2021 12:19:05 -0600 Subject: [PATCH] io: use opendirectory for UID/GID lookups on macOS macOS has no concept of a chroot-specific UID/GID database, as the database is actually LDAP. ref #10794 --- src/io.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/io.c b/src/io.c index b60c58d..f4ae651 100644 --- a/src/io.c +++ b/src/io.c @@ -1187,8 +1187,11 @@ static void idcache_load_users(int root_fd, struct apk_id_hash *idh) do { #ifdef HAVE_FGETPWENT_R fgetpwent_r(in, &pwent, buf, sizeof(buf), &pwd); -#else +#elif !defined(__APPLE__) pwd = fgetpwent(in); +#else +# warning macOS does not support nested /etc/passwd databases, using system one. + pwd = getpwent(); #endif if (!pwd) break; idcache_add(idh, APK_BLOB_STR(pwd->pw_name), pwd->pw_uid); @@ -1217,8 +1220,11 @@ static void idcache_load_groups(int root_fd, struct apk_id_hash *idh) do { #ifdef HAVE_FGETGRENT_R fgetgrent_r(in, &grent, buf, sizeof(buf), &grp); -#else +#elif !defined(__APPLE__) grp = fgetgrent(in); +#else +# warning macOS does not support nested /etc/group databases, using system one. + grp = getgrent(); #endif if (!grp) break; idcache_add(idh, APK_BLOB_STR(grp->gr_name), grp->gr_gid);