aboutsummaryrefslogtreecommitdiff
path: root/libpam/pam_modutil_sanitize.c
Commit message (Collapse)AuthorAgeFilesLines
* libpam: use close_range() to close file descriptorsIker Pedrosa2023-10-251-2/+17
| | | | | | | | | | | | * configure.ac: check whether close_range() is available in the system. * libpam/pam_modutil_sanitize.c: use close_range() to close all file descriptors. If the interface isn't available use the previous approach. Link: https://github.com/linux-pam/linux-pam/pull/276 Resolves: https://issues.redhat.com/browse/RHEL-5099 Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
* pam_modutil_sanitize_fds: Add explicit casts to avoid warningsTomas Mraz2020-10-201-3/+3
|
* Revert "libpam/pam_modutil_sanitize.c: optimize the way to close fds"Tomas Mraz2020-10-201-59/+14
| | | | This reverts commit 1b087edc7f05237bf5eccc405704cd82b848e761.
* pam_modutil_sanitize_helper_fds: fix SIGPIPE effect of PAM_MODUTIL_PIPE_FDDmitry V. Levin2020-02-261-29/+1
| | | | | | | | | | | | | | | | When pam_modutil_sanitize_helper_fds() is invoked with PAM_MODUTIL_PIPE_FD to provide a dummy pipe descriptor for stdout or stderr, it closes the read end of the newly created dummy pipe. The negative side effect of this approach is that any write to such descriptor triggers a SIGPIPE. Avoid this by closing the write end of the dummy pipe and using its read end as a dummy pipe descriptor for output. Any read from such descriptor returns 0, and any write just fails with EBADF, which should work better with unprepared writers. * libpam/pam_modutil_sanitize.c (redirect_out_pipe): Remove. (redirect_out): Call redirect_in_pipe instead of redirect_out_pipe. Fixes: b0ec5d1e ("Introduce pam_modutil_sanitize_helper_fds")
* libpam/pam_modutil_sanitize.c: optimize the way to close fdsChristophe Besson2019-08-261-14/+59
|
* Introduce pam_modutil_sanitize_helper_fdsDmitry V. Levin2014-01-271-0/+175
This change introduces pam_modutil_sanitize_helper_fds - a new function that redirects standard descriptors and closes all other descriptors. pam_modutil_sanitize_helper_fds supports three types of input and output redirection: - PAM_MODUTIL_IGNORE_FD: do not redirect at all. - PAM_MODUTIL_PIPE_FD: redirect to a pipe. For stdin, it is implemented by creating a pipe, closing its write end, and redirecting stdin to its read end. Likewise, for stdout/stderr it is implemented by creating a pipe, closing its read end, and redirecting to its write end. Unlike stdin redirection, stdout/stderr redirection to a pipe has a side effect that a process writing to such descriptor should be prepared to handle SIGPIPE appropriately. - PAM_MODUTIL_NULL_FD: redirect to /dev/null. For stdin, it is implemented via PAM_MODUTIL_PIPE_FD because there is no functional difference. For stdout/stderr, it is classic redirection to /dev/null. PAM_MODUTIL_PIPE_FD is usually more suitable due to linux kernel security restrictions, but when the helper process might be writing to the corresponding descriptor and termination of the helper process by SIGPIPE is not desirable, one should choose PAM_MODUTIL_NULL_FD. * libpam/pam_modutil_sanitize.c: New file. * libpam/Makefile.am (libpam_la_SOURCES): Add it. * libpam/include/security/pam_modutil.h (pam_modutil_redirect_fd, pam_modutil_sanitize_helper_fds): New declarations. * libpam/libpam.map (LIBPAM_MODUTIL_1.1.9): New interface. * modules/pam_exec/pam_exec.c (call_exec): Use pam_modutil_sanitize_helper_fds. * modules/pam_mkhomedir/pam_mkhomedir.c (create_homedir): Likewise. * modules/pam_unix/pam_unix_acct.c (_unix_run_verify_binary): Likewise. * modules/pam_unix/pam_unix_passwd.c (_unix_run_update_binary): Likewise. * modules/pam_unix/support.c (_unix_run_helper_binary): Likewise. * modules/pam_xauth/pam_xauth.c (run_coprocess): Likewise. * modules/pam_unix/support.h (MAX_FD_NO): Remove.