Subject: [PATCH] [SV 63111] Set osync handle to noinherit

From: Andreas Schwab <[email-masked]>
Date: Tue, 27 Sep 2022 16:23:04 +0200

* src/posixos.c (osync_setup, osync_parse_mutex): Set osync_handle
to noinherit.
---
 src/posixos.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/posixos.c b/src/posixos.c
index d587f9c8..4097ce15 100644
--- a/src/posixos.c
+++ b/src/posixos.c
@@ -628,7 +628,10 @@ osync_setup ()
 {
   osync_handle = get_tmpfd (&osync_tmpfile);
   if (osync_handle >= 0)
-    sync_parent = 1;
+    {
+      fd_noinherit (osync_handle);
+      sync_parent = 1;
+    }
 }
 
 char *
@@ -662,6 +665,8 @@ osync_parse_mutex (const char *mutex)
     OSS (fatal, NILF, _("cannot open output sync mutex %s: %s"),
          osync_tmpfile, strerror (errno));
 
+  fd_noinherit (osync_handle);
+
   return 1;
 }
 
-- 
2.37.3

-- 
Andreas Schwab, SUSE Labs, [email-masked]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."