90
90
manager_cls = get_manager_class(config, filters)
91
91
manager = manager_cls(address=socket_path)
92
92
server = manager.get_server()
93
# allow everybody to connect to the socket
94
rw_rw_rw_ = (stat.S_IRUSR | stat.S_IWUSR |
95
stat.S_IRGRP | stat.S_IWGRP |
96
stat.S_IROTH | stat.S_IWOTH)
97
os.chmod(socket_path, rw_rw_rw_)
99
# In Python 3 we have to use buffer to push in bytes directly
100
stdout = sys.stdout.buffer
101
except AttributeError:
103
stdout.write(socket_path.encode('utf-8'))
105
stdout.write(bytes(server.authkey))
109
# Gracefully shutdown on INT or TERM signals
110
stop = functools.partial(daemon_stop, server)
111
signal.signal(signal.SIGTERM, stop)
112
signal.signal(signal.SIGINT, stop)
113
LOG.info("Starting rootwrap daemon main loop")
114
server.serve_forever()
94
# allow everybody to connect to the socket
95
rw_rw_rw_ = (stat.S_IRUSR | stat.S_IWUSR |
96
stat.S_IRGRP | stat.S_IWGRP |
97
stat.S_IROTH | stat.S_IWOTH)
98
os.chmod(socket_path, rw_rw_rw_)
100
# In Python 3 we have to use buffer to push in bytes directly
101
stdout = sys.stdout.buffer
102
except AttributeError:
104
stdout.write(socket_path.encode('utf-8'))
106
stdout.write(bytes(server.authkey))
110
# Gracefully shutdown on INT or TERM signals
111
stop = functools.partial(daemon_stop, server)
112
signal.signal(signal.SIGTERM, stop)
113
signal.signal(signal.SIGINT, stop)
114
LOG.info("Starting rootwrap daemon main loop")
115
server.serve_forever()
117
conn = server.listener
118
# This will break accept() loop with EOFError if it was not in the
119
# main thread (as in Python 3.x)
121
# Closing all currently connected client sockets for reading to
122
# break worker threads blocked on recv()
123
for cl_conn in conn.get_accepted():
127
# Most likely the socket have already been closed
128
LOG.debug("Failed to close connection")
129
LOG.info("Waiting for all client threads to finish.")
130
for thread in threading.enumerate():
132
LOG.debug("Joining thread %s", thread)
116
conn = server.listener
117
# This will break accept() loop with EOFError if it was not in the main
118
# thread (as in Python 3.x)
120
# Closing all currently connected client sockets for reading to break
121
# worker threads blocked on recv()
122
for cl_conn in conn.get_accepted():
126
# Most likely the socket have already been closed
127
LOG.debug("Failed to close connection")
128
LOG.info("Waiting for all client threads to finish.")
129
for thread in threading.enumerate():
131
LOG.debug("Joining thread %s", thread)
133
135
LOG.debug("Removing temporary directory %s", temp_dir)
134
136
shutil.rmtree(temp_dir)