From fb884731c692656b8147b22f9df3cd4f7b7631c0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 27 May 2020 20:02:57 +0200 Subject: [PATCH] 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 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 -- 2.39.5