File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
intelmq/bots/collectors/api Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 88"""
99from threading import Thread
1010from typing import Optional
11+ import grp
1112import os
1213import socket
1314
@@ -42,6 +43,8 @@ class APICollectorBot(CollectorBot):
4243 _is_multithreadable : bool = False
4344 use_socket = False
4445 socket_path = '/tmp/imq_api_default_socket'
46+ socket_perms = '600'
47+ socket_group = ''
4548 _server : Optional ['HTTPServer' ] = None
4649 _unix_socket : Optional [socket .socket ] = None
4750 _eventLoopThread : Optional [Thread ] = None
@@ -56,7 +59,12 @@ def init(self):
5659
5760 if self .use_socket :
5861 self .server = HTTPServer (app )
59- self ._unix_socket = bind_unix_socket (self .socket_path )
62+ self ._unix_socket = bind_unix_socket (self .socket_path , mode = int (self .socket_perms , 8 ))
63+ if self .socket_group :
64+ group = grp .getgrnam (self .socket_group )
65+ gid = group .gr_gid
66+ os .chown (self .socket_path , - 1 , gid )
67+
6068 self .server .add_socket (self ._unix_socket )
6169 else :
6270 self .server = app .listen (self .port )
You can’t perform that action at this time.
0 commit comments