From 7a5ac1ff9f105c032798221517c3d43dffb68dfb Mon Sep 17 00:00:00 2001 From: jbleyel Date: Tue, 29 Oct 2024 18:25:05 +0100 Subject: [PATCH] add support for new checkLogin --- plugin/httpserver.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/plugin/httpserver.py b/plugin/httpserver.py index 0e628981..428d8aee 100644 --- a/plugin/httpserver.py +++ b/plugin/httpserver.py @@ -40,6 +40,28 @@ from .controllers.utilities import toString from .sslcertificate import SSLCertificateGenerator, KEY_FILE, CERT_FILE, CA_FILE, CHAIN_FILE +try: + from enigma import checkLogin +except ImportError: + from crypt import crypt + from pwd import getpwnam + from spwd import getspnam + + def checkLogin(user, passwd): + cpass = None + try: + cpass = getpwnam(user)[1] + except: # nosec # noqa: E722 + return False + if cpass: + if cpass == 'x' or cpass == '*': + try: + cpass = getspnam(user)[1] + except: # nosec # noqa: E722 + return False + return crypt(passwd, cpass) == cpass + return False + global listener, server_to_stop, site, sslsite listener = [] @@ -424,22 +446,7 @@ def login(self, user, passwd, peer): samenet = True if not (ipaddress.ip_address(str(peer)).is_private or samenet): return False - from crypt import crypt - from pwd import getpwnam - from spwd import getspnam - cpass = None - try: - cpass = getpwnam(user)[1] - except: # nosec # noqa: E722 - return False - if cpass: - if cpass == 'x' or cpass == '*': - try: - cpass = getspnam(user)[1] - except: # nosec # noqa: E722 - return False - return crypt(passwd, cpass) == cpass - return False + return checkLogin(user, passwd) class StopServer: