mirror of
https://github.com/systemd/systemd.git
synced 2024-10-26 08:55:40 +03: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:
parent
fb8e05cc43
commit
953c60e2f1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user