Hide Forgot
Description of problem: When configured to use the "session" function of a PAM module, sudo calls pam_open_session(), but never calls pam_close_session() or pam_end() to close the session. Version-Release number of selected component (if applicable): sudo-1.7.4p5-7.el6 How reproducible: With the code instrumented to show the pid and status of the pamh handle in both places, this is clear: $ sudo true ** pam_init: pid 24820, pamh is set ** pam_end_session: pid 24819, pamh is null Steps to Reproduce: 1. 2. 3. Actual results: pam_close_session() or pam_end() are never called to end the session Expected results: pam_close_session() or pam_end() are called appropriately Additional info: In auth/pam.c, there is this: static pam_handle_t *pamh; /* global due to pam_prep_user() */ This defines a static global variable to hold the PAM handle, which is initialized in pam_init(), and should be used in pam_end_session() to end the session. The use of the global variable for coordination is broken, however, because pam_init() is called in a subprocess, whereas pam_end_session() is called later in the parent process; thus, the handle is always NULL when pam_end_session() runs, and sudo never calls the PAM session close method.
Hi, does this bug has any consequences that can be observed? I mean, is there any memory leak, error message,.. Can we check the bug/fix in some "common way", different from mentioned approach, gdb or systemtap...?
The issue was identified through code analysis, rather than through any known ill effect, afaik. The argument is that sudo does not follow PAM conventions, and it could prevent PAM modules from working correctly, in perhaps significant ways. A module may rely on being called at session close in order to release resources or make important administrative changes, which now won't happen. This is especially a concern considering that this is a security-critical component.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2013-0363.html