mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
virGet{User,Group}Ent() don't say success on fail
When virGetUserEnt() and virGetGroupEnt() fail due to the uid or gid not existing on the machine they'll print a message like: $ virsh -c vbox:///session list error: failed to connect to the hypervisor error: Failed to find user record for uid '32655': Success The success at the end is a bit confusing. This changes it to: $ virsh -c vbox:///session list error: failed to connect to the hypervisor error: Failed to find user record for uid '32655'
This commit is contained in:
parent
ec81852f46
commit
4c7d1eab6e
@ -692,11 +692,16 @@ virGetUserEnt(uid_t uid, char **name, gid_t *group, char **dir)
|
|||||||
if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
|
if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (rc != 0 || pw == NULL) {
|
if (rc != 0) {
|
||||||
virReportSystemError(rc,
|
virReportSystemError(rc,
|
||||||
_("Failed to find user record for uid '%u'"),
|
_("Failed to find user record for uid '%u'"),
|
||||||
(unsigned int) uid);
|
(unsigned int) uid);
|
||||||
goto cleanup;
|
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)
|
if (name && VIR_STRDUP(*name, pw->pw_name) < 0)
|
||||||
@ -746,9 +751,16 @@ static char *virGetGroupEnt(gid_t gid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rc != 0 || gr == NULL) {
|
if (rc != 0 || gr == NULL) {
|
||||||
virReportSystemError(rc,
|
if (rc != 0) {
|
||||||
_("Failed to find group record for gid '%u'"),
|
virReportSystemError(rc,
|
||||||
(unsigned int) gid);
|
_("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);
|
VIR_FREE(strbuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user