Skip to content

Commit d25ee06

Browse files
committed
[Next] cs_user.py: Switch from pam passwd to system-auth or common-auth with login fallback
1 parent 673dc2e commit d25ee06

File tree

1 file changed

+12
-2
lines changed
  • files/usr/share/cinnamon/cinnamon-settings/modules

1 file changed

+12
-2
lines changed

files/usr/share/cinnamon/cinnamon-settings/modules/cs_user.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,23 @@ def _on_new_password_icon_released(self, widget, icon_pos, event):
374374
def _on_show_password_toggled(self, widget):
375375
self.set_passwords_visibility()
376376

377+
def _get_pam_service(self):
378+
import os
379+
if os.path.exists('/etc/pam.d/system-auth'):
380+
return 'system-auth'
381+
elif os.path.exists('/etc/pam.d/common-auth'):
382+
return 'common-auth'
383+
else:
384+
return 'login'
385+
377386
def auth_pam(self):
378-
if not pam.pam().authenticate(GLib.get_user_name(), self.current_password.get_text(), 'passwd'):
387+
service = self._get_pam_service()
388+
if not pam.pam().authenticate(GLib.get_user_name(), self.current_password.get_text(), service):
379389
raise PasswordError("Invalid password")
380390

381391
def auth_PyPAM(self):
382392
auth = PAM.pam()
383-
auth.start('passwd')
393+
auth.start(self._get_pam_service())
384394
auth.set_item(PAM.PAM_USER, GLib.get_user_name())
385395
auth.set_item(PAM.PAM_CONV, self.pam_conv)
386396
try:

0 commit comments

Comments
 (0)