提交 c8f08e48 编写于 作者: J Jim Fehlig

systemd: fix ready notification on abstract socket

At least with systemd v210, NOTIFY_SOCKET is abstact, e.g.
@/org/freedesktop/systemd1/notify. sendmsg() fails on such a socket
with "Connection refused". The unix(7) man page contains the following
details wrt abstract socket addresses

abstract: an abstract socket address is distinguished (from a
          pathname socket) by the fact that sun_path[0] is a null byte
          ('\0').  The socket's address in this namespace is given by the
          additional bytes in sun_path that are covered by the specified
          length of the address structure.  (Null bytes in the name have
          no special significance.)

So we need to be more precise about the address length, setting it to
the sizeof sa_family_t + length of address copied to sun_path instead
of setting it to the sizeof the entire sockaddr_un struct.

Resolves: https://bugzilla.opensuse.org/show_bug.cgi?id=987668Signed-off-by: NJim Fehlig <jfehlig@suse.com>
上级 8ddc56e7
......@@ -495,7 +495,6 @@ virSystemdNotifyStartup(void)
};
struct msghdr mh = {
.msg_name = &un,
.msg_namelen = sizeof(un),
.msg_iov = &iov,
.msg_iovlen = 1,
};
......@@ -515,6 +514,8 @@ virSystemdNotifyStartup(void)
if (un.sun_path[0] == '@')
un.sun_path[0] = '\0';
mh.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(path);
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
VIR_WARN("Unable to create socket FD");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册