提交 5d30db09 编写于 作者: J Jiri Denemark

Support changing UNIX socket owner in virNetSocketNewListenUNIX

This patch allows owner's UID to be changed as well.
上级 70e4295b
......@@ -182,6 +182,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
if (virNetSocketNewListenUNIX(path,
mask,
-1,
grp,
&svc->socks[0]) < 0)
goto error;
......
......@@ -302,6 +302,7 @@ error:
#if HAVE_SYS_UN_H
int virNetSocketNewListenUNIX(const char *path,
mode_t mask,
uid_t user,
gid_t grp,
virNetSocketPtr *retsock)
{
......@@ -344,10 +345,10 @@ int virNetSocketNewListenUNIX(const char *path,
/* chown() doesn't work for abstract sockets but we use them only
* if libvirtd runs unprivileged
*/
if (grp != 0 && chown(path, -1, grp)) {
if (grp != 0 && chown(path, user, grp)) {
virReportSystemError(errno,
_("Failed to change group ID of '%s' to %u"),
path, (unsigned int) grp);
_("Failed to change ownership of '%s' to %d:%d"),
path, (int) user, (int) grp);
goto error;
}
......
......@@ -47,6 +47,7 @@ int virNetSocketNewListenTCP(const char *nodename,
int virNetSocketNewListenUNIX(const char *path,
mode_t mask,
uid_t user,
gid_t grp,
virNetSocketPtr *addr);
......
......@@ -214,7 +214,7 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED)
}
}
if (virNetSocketNewListenUNIX(path, 0700, getgid(), &lsock) < 0)
if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(), &lsock) < 0)
goto cleanup;
if (virNetSocketListen(lsock, 0) < 0)
......@@ -263,7 +263,7 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED)
}
}
if (virNetSocketNewListenUNIX(path, 0700, getgid(), &lsock) < 0)
if (virNetSocketNewListenUNIX(path, 0700, -1, getgid(), &lsock) < 0)
goto cleanup;
if (STRNEQ(virNetSocketLocalAddrString(lsock), "127.0.0.1;0")) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册