Skip to content

Commit

Permalink
add support for new checkLogin
Browse files Browse the repository at this point in the history
  • Loading branch information
jbleyel committed Oct 29, 2024
1 parent 2c89463 commit 7a5ac1f
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions plugin/httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7a5ac1f

Please sign in to comment.