From bd1c6cd22397963688ace8624fb803f528b7e87c Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 27 Sep 2024 19:57:26 -0400 Subject: [PATCH] internals: Root conversation and closure data If the conversation and closure data are not rooted to the class then they can be garbage collected before the conversation function is invoked. That leads to a crash in pam_lastlog during session open time. This commit addressed the issue by assigning the state to the class as properties. --- src/pam/__internals.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pam/__internals.py b/src/pam/__internals.py index 99a0397..9e33188 100644 --- a/src/pam/__internals.py +++ b/src/pam/__internals.py @@ -311,11 +311,11 @@ def __conv(n_messages, messages, p_response, app_data): # do this up front so we can safely throw an exception if there's # anything wrong with it - app_data = {'msgs': self.messages, 'password': password, 'encoding': encoding} - conv = PamConv(__conv, c_void_p.from_buffer(py_object(app_data))) + self.app_data = {'msgs': self.messages, 'password': password, 'encoding': encoding} + self.conv = PamConv(__conv, c_void_p.from_buffer(py_object(self.app_data))) self.handle = PamHandle() - retval = self.pam_start(service, username, byref(conv), + retval = self.pam_start(service, username, byref(self.conv), byref(self.handle)) if retval != PAM_SUCCESS: # pragma: no cover