mirror of https://gitee.com/openkylin/libvirt.git
virSecurityDACSetOwnershipInternal: Don't overwrite @path argument
As shown in the previous commit, @path can be NULL. However, in that case @src->path is also NULL. Therefore, trying to "fix" @path to be not NULL is not going to succeed. The real value of NULLSTR() is in providing a non-NULL string for error reporting. Well, that can be done in the error reporting without overwriting argument. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5cfb3369b1
commit
b332c2cf89
|
@ -679,8 +679,6 @@ virSecurityDACSetOwnershipInternal(const virSecurityDACData *priv,
|
||||||
|
|
||||||
if (src && priv->chownCallback) {
|
if (src && priv->chownCallback) {
|
||||||
rc = priv->chownCallback(src, uid, gid);
|
rc = priv->chownCallback(src, uid, gid);
|
||||||
/* here path is used only for error messages */
|
|
||||||
path = NULLSTR(src->path);
|
|
||||||
|
|
||||||
/* on -2 returned an error was already reported */
|
/* on -2 returned an error was already reported */
|
||||||
if (rc == -2)
|
if (rc == -2)
|
||||||
|
@ -712,20 +710,20 @@ virSecurityDACSetOwnershipInternal(const virSecurityDACData *priv,
|
||||||
if (errno == EOPNOTSUPP || errno == EINVAL) {
|
if (errno == EOPNOTSUPP || errno == EINVAL) {
|
||||||
VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
|
VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
|
||||||
"supported by filesystem",
|
"supported by filesystem",
|
||||||
(long)uid, (long)gid, path);
|
(long)uid, (long)gid, NULLSTR(path));
|
||||||
} else if (errno == EPERM) {
|
} else if (errno == EPERM) {
|
||||||
VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
|
VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
|
||||||
"permitted",
|
"permitted",
|
||||||
(long)uid, (long)gid, path);
|
(long)uid, (long)gid, NULLSTR(path));
|
||||||
} else if (errno == EROFS) {
|
} else if (errno == EROFS) {
|
||||||
VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
|
VIR_INFO("Setting user and group to '%ld:%ld' on '%s' not "
|
||||||
"possible on readonly filesystem",
|
"possible on readonly filesystem",
|
||||||
(long)uid, (long)gid, path);
|
(long)uid, (long)gid, NULLSTR(path));
|
||||||
} else {
|
} else {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("unable to set user and group to '%ld:%ld' "
|
_("unable to set user and group to '%ld:%ld' "
|
||||||
"on '%s'"),
|
"on '%s'"),
|
||||||
(long)uid, (long)gid, path);
|
(long)uid, (long)gid, NULLSTR(path));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue