aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_unix/pam_unix_passwd.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2024-01-04 18:23:59 +0100
committerDmitry V. Levin <ldv@strace.io>2024-01-15 20:01:23 +0000
commit9f19e7da7a014e022cdbba06accca171adef27e0 (patch)
treecd4fa183681f2c2725e68a4016521cacf76399ec /modules/pam_unix/pam_unix_passwd.c
parent8e577fb4c55674260143a325c01f47d8dff712af (diff)
downloadpam-9f19e7da7a014e022cdbba06accca171adef27e0.tar.gz
pam-9f19e7da7a014e022cdbba06accca171adef27e0.tar.bz2
pam-9f19e7da7a014e022cdbba06accca171adef27e0.zip
pam_unix: set close-on-exec
Since the module operates on sensitive files set the close-on-exec flag, to avoid file descriptor leaks if there is ever any sibling thread. The fopen(3) mode "e" is supported in glibc since version 2.7 (released in 2007), and ignored prior, see: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=65d834b0add966dbbdb5ed1e916c60b2b2d87f10
Diffstat (limited to 'modules/pam_unix/pam_unix_passwd.c')
-rw-r--r--modules/pam_unix/pam_unix_passwd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/pam_unix/pam_unix_passwd.c b/modules/pam_unix/pam_unix_passwd.c
index fe3f566a..3a223949 100644
--- a/modules/pam_unix/pam_unix_passwd.c
+++ b/modules/pam_unix/pam_unix_passwd.c
@@ -346,7 +346,7 @@ static int check_old_password(const char *forwho, const char *newpass)
size_t n = 0;
size_t len = strlen(forwho);
- opwfile = fopen(OLD_PASSWORDS_FILE, "r");
+ opwfile = fopen(OLD_PASSWORDS_FILE, "re");
if (opwfile == NULL)
return PAM_ABORT;