diff --git a/src/util/virutil.c b/src/util/virutil.c index 34f59983a6..39d47171b6 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -692,11 +692,16 @@ virGetUserEnt(uid_t uid, char **name, gid_t *group, char **dir) if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) goto cleanup; } - if (rc != 0 || pw == NULL) { + if (rc != 0) { virReportSystemError(rc, _("Failed to find user record for uid '%u'"), (unsigned int) uid); goto cleanup; + } else if (pw == NULL) { + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Failed to find user record for uid '%u'"), + (unsigned int) uid); + goto cleanup; } if (name && VIR_STRDUP(*name, pw->pw_name) < 0) @@ -746,9 +751,16 @@ static char *virGetGroupEnt(gid_t gid) } } if (rc != 0 || gr == NULL) { - virReportSystemError(rc, - _("Failed to find group record for gid '%u'"), - (unsigned int) gid); + if (rc != 0) { + virReportSystemError(rc, + _("Failed to find group record for gid '%u'"), + (unsigned int) gid); + } else { + virReportError(VIR_ERR_SYSTEM_ERROR, + _("Failed to find group record for gid '%u'"), + (unsigned int) gid); + } + VIR_FREE(strbuf); return NULL; }