Commit 52ddcf88 authored by Дмитрий Никулин's avatar Дмитрий Никулин Committed by Никита Ефремов

Add support for changing password via PAM

parent 44cea6a4
...@@ -3,7 +3,7 @@ from settingsd import const ...@@ -3,7 +3,7 @@ from settingsd import const
from settingsd import config from settingsd import config
from settingsd import service from settingsd import service
from settingsd import shared from settingsd import shared
from pam import pam from pamela import authenticate, change_password, PAMError
SERVICE_NAME = "pam_authentication" SERVICE_NAME = "pam_authentication"
...@@ -12,8 +12,22 @@ SERVICE_NAME = "pam_authentication" ...@@ -12,8 +12,22 @@ SERVICE_NAME = "pam_authentication"
class PamAuthentication(service.FunctionObject) : class PamAuthentication(service.FunctionObject) :
@service.functionMethod("pam", in_signature="ss", out_signature="b") @service.functionMethod("pam", in_signature="ss", out_signature="b")
def authenticate(self, login, password): def authenticate(self, login, password):
authenticator = pam() try:
return authenticator.authenticate(login, password) authenticate(login, password)
return True
except PAMError:
return False
@service.functionMethod("pam", in_signature="sss", out_signature="b")
def change_password(self, login, old_password, new_password):
if len(new_password) == 0:
return False
try:
change_password(login, new_password)
return True
except PAMError as err:
print(err)
return False
class Service(service.Service) : class Service(service.Service) :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment