aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_unix/support.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/support.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/support.c')
-rw-r--r--modules/pam_unix/support.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/pam_unix/support.c b/modules/pam_unix/support.c
index 546ef820..d391973f 100644
--- a/modules/pam_unix/support.c
+++ b/modules/pam_unix/support.c
@@ -352,7 +352,7 @@ int _unix_getpwnam(pam_handle_t *pamh, const char *name,
if (!matched && files && strchr(name, ':') == NULL) {
FILE *passwd;
- passwd = fopen("/etc/passwd", "r");
+ passwd = fopen("/etc/passwd", "re");
if (passwd != NULL) {
size_t n = 0, userlen;
ssize_t r;