From: Bruno Haible Date: Wed, 27 May 2020 18:02:57 +0000 (+0200) Subject: mountlist: Make more robust in multithreaded applications. X-Git-Tag: v1.0~4039 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=fb884731c692656b8147b22f9df3cd4f7b7631c0;p=gnulib.git 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'. --- diff --git a/ChangeLog b/ChangeLog index b034e30a6a..774183ea62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-05-28 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-28 Bruno Haible login_tty: Make more robust in multithreaded applications. diff --git a/lib/mountlist.c b/lib/mountlist.c index 4cb19c87f1..9cf78c82e0 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 5bb45edf64..7542048e45 100644 --- a/modules/mountlist +++ b/modules/mountlist @@ -10,6 +10,7 @@ m4/mountlist.m4 Depends-on: fopen-gnu getline +open stdbool stdint strstr-simple