BSD: Ensure UNIX socket credentials are valid

Ensure that the socket credentials we got back on BSD are valid before
using them.
This commit is contained in:
Doug Goldstein 2013-09-04 12:21:45 -05:00
parent 8294aa0c17
commit 68674169af
1 changed files with 12 additions and 0 deletions

View File

@ -1166,6 +1166,18 @@ int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
return -1;
}
if (cr.cr_version != XUCRED_VERSION) {
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Failed to get valid client socket identity"));
return -1;
}
if (cr.cr_ngroups == 0) {
virReportError(VIR_ERR_SYSTEM_ERROR, "%s",
_("Failed to get valid client socket identity groups"));
return -1;
}
*pid = -1;
*uid = cr.cr_uid;
*gid = cr.cr_gid;