linuxmint/cinnamon-screensaver

Newline in PAM message breaks unlock

fredtj opened this issue · 1 comments

Hello,

In some cases, PAM info messages contain a new line. Specifically, for domain joined machines using pbis-open:
lsass/interop/auth/pam/pam-acct.c: sprintf(szMessage, "Your password will expire in %u days\n",

This causes a crash in authClient.py as it expects a _ at the end of the message, which doesn't appear if there is a newline.

In cinnamon-screensaver-pam-helper.c :

send_info (const gchar *msg)
{
    printf (CS_PAM_AUTH_SET_INFO_ "%s_\n", msg);
    fflush (stdout);
}

This message is picked up by authClient.py

if "CS_PAM_AUTH_SET_INFO" in output:
  info = re.search('(?<=CS_PAM_AUTH_SET_INFO_)(.*)(?=_)', output).group(0)
  self.emit_auth_info(info)

Since the PAM message has a newline, the regex does not match, as the newline breaks the required underscore at the end of the message:
CS_PAM_AUTH_SET_INFO_Your password will expire in 14 days

Leading to a crash:

cinnamon-session[2043]: WARNING: t+7301.41548s: Detected that screensaver has appeared on the bus
cinnamon-screensaver-pam-helper[25513]: pam_ecryptfs: seteuid error
cinnamon-screensaver-pam-helper[25513]: gkr-pam: unlocked login keyring
org.cinnamon.ScreenSaver[25482]: Traceback (most recent call last):
org.cinnamon.ScreenSaver[25482]:   File "/usr/share/cinnamon-screensaver/pamhelper/authClient.py", line 179, in message_from_child
org.cinnamon.ScreenSaver[25482]:     info = re.search('(?<=CS_PAM_AUTH_SET_INFO_)(.*)(?=_)', output).group(0)
org.cinnamon.ScreenSaver[25482]: AttributeError: 'NoneType' object has no attribute 'group'
org.cinnamon.ScreenSaver[25482]: Error in sys.excepthook:
org.cinnamon.ScreenSaver[25482]: Traceback (most recent call last):
org.cinnamon.ScreenSaver[25482]:   File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 153, in apport_excepthook
org.cinnamon.ScreenSaver[25482]:     with os.fdopen(os.open(pr_filename,
org.cinnamon.ScreenSaver[25482]: FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_share_cinnamon-screensaver_cinnamon-screensaver-main.py.2130707596.crash'
org.cinnamon.ScreenSaver[25482]: Original exception was:
org.cinnamon.ScreenSaver[25482]: Traceback (most recent call last):
org.cinnamon.ScreenSaver[25482]:   File "/usr/share/cinnamon-screensaver/pamhelper/authClient.py", line 179, in message_from_child
org.cinnamon.ScreenSaver[25482]:     info = re.search('(?<=CS_PAM_AUTH_SET_INFO_)(.*)(?=_)', output).group(0)
org.cinnamon.ScreenSaver[25482]: AttributeError: 'NoneType' object has no attribute 'group'

I fixed this (hacky) by adding a _ if one is not present for CS_PAM_AUTH_SET_INFO. But I believe this issue should probably be fixed in cinnamon-screensaver-pam-helper.c, although authClient.py probably needs a small fix to fail nicely to test for NoneType in output.

Thanks

This problem, reported last year, seems fairly serious . .