Add password file path management in the Glances server mode

This commit is contained in:
nicolargo 2022-10-23 16:36:14 +02:00
parent 09224f1476
commit fe1cf36688

View File

@ -67,7 +67,8 @@ class GlancesXMLRPCHandler(SimpleXMLRPCRequestHandler, object):
if username in self.server.user_dict:
from glances.password import GlancesPassword
pwd = GlancesPassword()
pwd = GlancesPassword(username=username,
config=self.config)
return pwd.check_password(self.server.user_dict[username], password)
else:
return False
@ -93,10 +94,14 @@ class GlancesXMLRPCServer(SimpleXMLRPCServer, object):
finished = False
def __init__(self, bind_address, bind_port=61209, requestHandler=GlancesXMLRPCHandler):
def __init__(self, bind_address,
bind_port=61209,
requestHandler=GlancesXMLRPCHandler,
config=None):
self.bind_address = bind_address
self.bind_port = bind_port
self.config = config
try:
self.address_family = socket.getaddrinfo(bind_address, bind_port)[0][0]
except socket.error as e:
@ -191,7 +196,10 @@ class GlancesServer(object):
# Init the XML RPC server
try:
self.server = GlancesXMLRPCServer(args.bind_address, args.port, requestHandler)
self.server = GlancesXMLRPCServer(args.bind_address,
args.port,
requestHandler,
config=config)
except Exception as e:
logger.critical("Cannot start Glances server: {}".format(e))
sys.exit(2)