From c78e47a61fa8d9a21fece01c83e4c26ce0938d27 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Thu, 19 Feb 2015 23:12:38 +0100 Subject: core, shared: in deserializing, match same files reached via different paths When dbus.socket is updated like this: -ListenStream=/var/run/dbus/system_bus_socket +ListenStream=/run/dbus/system_bus_socket ... and daemon-reload is performed, bad things happen. During deserialization systemd does not recognize that the two paths refer to the same named socket and replaces the socket file with a new one. As a result, applications hang when they try talking to dbus. Fix this by finding a match not only when the path names are equal, but also when they point to the same inode. In socket_address_equal() it is necessary to move the address size comparison into the abstract sockets branch. For path name sockets the comparison must not be done and for other families it is redundant (their sizes are constant and checked by socket_address_verify()). FIFOs and special files can also have multiple pathnames, so compare the inodes for them as well. Note that previously the pathname checks used streq_ptr(), but the paths cannot be NULL. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1186018 --- src/core/socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/socket.c b/src/core/socket.c index 48c43a2880..88aae4815b 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -2100,7 +2100,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, LIST_FOREACH(port, p, s->ports) if (p->type == SOCKET_FIFO && - streq_ptr(p->path, value+skip)) + path_equal_or_files_same(p->path, value+skip)) break; if (p) { @@ -2119,7 +2119,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, LIST_FOREACH(port, p, s->ports) if (p->type == SOCKET_SPECIAL && - streq_ptr(p->path, value+skip)) + path_equal_or_files_same(p->path, value+skip)) break; if (p) { @@ -2138,7 +2138,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value, LIST_FOREACH(port, p, s->ports) if (p->type == SOCKET_MQUEUE && - streq_ptr(p->path, value+skip)) + streq(p->path, value+skip)) break; if (p) { -- cgit v1.2.3-54-g00ecf