Comment 3 for bug 1658977

Revision history for this message
Ralf Haferkamp (rhafer) wrote :

I am a bit lost about how to fix this. Here's some more details about the race. This is from oslo_rootwrap/daemon.py:

111 try:
112 # allow everybody to connect to the socket
[..]
117 try:
118 # In Python 3 we have to use buffer to push in bytes directly
119 stdout = sys.stdout.buffer
120 except AttributeError:
121 stdout = sys.stdout
122 stdout.write(socket_path.encode('utf-8'))
123 stdout.write(b'\n')
124 stdout.write(bytes(server.authkey))

If the client (e.g. openvswitch-agent) exits before this, that's ok. We will notice as we receive a SIGPIPE. But now we're closing our communications channel with the client until the server.serve_forever() call (line 133) and until the client connected to it. If the client exit for whatever reason during this time, the rootwrap-daemon won't notice that will not stop. (Note: It's also not possible have the client kill the server as it's running as root, while the client is likely running as an unprivileged user.

125 sys.stdin.close()
126 sys.stdout.close()
127 sys.stderr.close()
128 # Gracefully shutdown on INT or TERM signals
129 stop = functools.partial(daemon_stop, server)
130 signal.signal(signal.SIGTERM, stop)
131 signal.signal(signal.SIGINT, stop)
132 LOG.info("Starting rootwrap daemon main loop")
133 server.serve_forever()
134 finally:

Any hints on how to fix this are highly appreciated.