diff --git a/src/util/util.c b/src/util/util.c index 2fd0f2c158..64e4a75529 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -2531,9 +2531,18 @@ virGetUserIDByName(const char *name, uid_t *uid) } if (rc != 0) { - virReportSystemError(rc, _("Failed to get user record for name '%s'"), - name); - goto cleanup; + /* We explicitly test for the known error values returned by + * getpwnam_r as the manpage says: + * ERRORS + * 0 or ENOENT or ESRCH or EBADF or EPERM or ... + * The given name or uid was not found. + */ + if ((rc == EINTR) || (rc == EIO) || (rc == EMFILE) || + (rc == ENFILE) || (rc == ENOMEM)) { + virReportSystemError(rc, _("Failed to get user record for name '%s'"), + name); + goto cleanup; + } } if (!pw) {