>From a36ae88ccb65931124cb6aafc1a8d2dac63bd699 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 27 May 2020 20:02:57 +0200 Subject: [PATCH 11/18] mountlist: Make more robust in multithreaded applications. * lib/mountlist.c (read_file_system_list): Pass an O_CLOEXEC flag to open(). * modules/mountlist (Depends-on): Add 'open'. --- ChangeLog | 7 +++++++ lib/mountlist.c | 2 +- modules/mountlist | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7c7d6b5..a840c8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2020-05-27 Bruno Haible + mountlist: Make more robust in multithreaded applications. + * lib/mountlist.c (read_file_system_list): Pass an O_CLOEXEC flag to + open(). + * modules/mountlist (Depends-on): Add 'open'. + +2020-05-27 Bruno Haible + login_tty: Make more robust in multithreaded applications. * lib/login_tty.c (login_tty): Pass an O_CLOEXEC flag to open(). * modules/login_tty (Depends-on): Add 'open'. diff --git a/lib/mountlist.c b/lib/mountlist.c index 4cb19c8..9cf78c8 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -902,7 +902,7 @@ read_file_system_list (bool need_fs_type) # ifndef MNTTAB_LOCK # define MNTTAB_LOCK "/etc/.mnttab.lock" # endif - lockfd = open (MNTTAB_LOCK, O_RDONLY); + lockfd = open (MNTTAB_LOCK, O_RDONLY | O_CLOEXEC); if (0 <= lockfd) { struct flock flock; diff --git a/modules/mountlist b/modules/mountlist index 5bb45ed..7542048 100644 --- a/modules/mountlist +++ b/modules/mountlist @@ -10,6 +10,7 @@ m4/mountlist.m4 Depends-on: fopen-gnu getline +open stdbool stdint strstr-simple -- 2.7.4