1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

user-util: fix fgetxxent_sane on musl

musl's implementation does not set errno to ENOENT when the end of file
is reached. It returns NULL and leaves errno unchanged.
This commit is contained in:
Mike Gilbert 2024-06-07 12:28:41 -04:00 committed by Lennart Poettering
parent fb8e05cc43
commit 953c60e2f1

View File

@ -977,8 +977,8 @@ int fgetpwent_sane(FILE *stream, struct passwd **pw) {
errno = 0;
struct passwd *p = fgetpwent(stream);
if (!p && errno != ENOENT)
return errno_or_else(EIO);
if (!p && !IN_SET(errno, 0, ENOENT))
return -errno;
*pw = p;
return !!p;
@ -990,8 +990,8 @@ int fgetspent_sane(FILE *stream, struct spwd **sp) {
errno = 0;
struct spwd *s = fgetspent(stream);
if (!s && errno != ENOENT)
return errno_or_else(EIO);
if (!s && !IN_SET(errno, 0, ENOENT))
return -errno;
*sp = s;
return !!s;
@ -1003,8 +1003,8 @@ int fgetgrent_sane(FILE *stream, struct group **gr) {
errno = 0;
struct group *g = fgetgrent(stream);
if (!g && errno != ENOENT)
return errno_or_else(EIO);
if (!g && !IN_SET(errno, 0, ENOENT))
return -errno;
*gr = g;
return !!g;
@ -1017,8 +1017,8 @@ int fgetsgent_sane(FILE *stream, struct sgrp **sg) {
errno = 0;
struct sgrp *s = fgetsgent(stream);
if (!s && errno != ENOENT)
return errno_or_else(EIO);
if (!s && !IN_SET(errno, 0, ENOENT))
return -errno;
*sg = s;
return !!s;