Blame SOURCES/fuse2-0005-remove-closefrom-function.patch

25247e
From ae2352bca9b4e607538412da0cc2a9625cd8b692 Mon Sep 17 00:00:00 2001
25247e
From: Sam James <sam@gentoo.org>
25247e
Date: Sat, 24 Jul 2021 22:02:45 +0100
25247e
Subject: [PATCH] util/ulockmgr_server.c: conditionally define closefrom (fix
25247e
 glibc-2.34+)
25247e
25247e
closefrom(3) has joined us in glibc-land from *BSD and Solaris. Since
25247e
it's available in glibc 2.34+, we want to detect it and only define our
25247e
fallback if the libc doesn't provide it.
25247e
25247e
Bug: https://bugs.gentoo.org/803923
25247e
Signed-off-by: Sam James <sam@gentoo.org>
25247e
---
25247e
 configure.ac           | 1 +
25247e
 util/ulockmgr_server.c | 6 ++++++
25247e
 2 files changed, 7 insertions(+)
25247e
25247e
diff --git a/configure.ac b/configure.ac
25247e
index 9946a0efa..a2d481aa9 100644
25247e
--- a/configure.ac
25247e
+++ b/configure.ac
25247e
@@ -55,6 +55,7 @@ fi
25247e
 
25247e
 AC_CHECK_FUNCS([fork setxattr fdatasync splice vmsplice utimensat])
25247e
 AC_CHECK_FUNCS([posix_fallocate])
25247e
+AC_CHECK_FUNCS([closefrom])
25247e
 AC_CHECK_MEMBERS([struct stat.st_atim])
25247e
 AC_CHECK_MEMBERS([struct stat.st_atimespec])
25247e
 
25247e
diff --git a/util/ulockmgr_server.c b/util/ulockmgr_server.c
25247e
index 273c7d923..a04dac5c6 100644
25247e
--- a/util/ulockmgr_server.c
25247e
+++ b/util/ulockmgr_server.c
25247e
@@ -22,6 +22,10 @@
25247e
 #include <sys/socket.h>
25247e
 #include <sys/wait.h>
25247e
 
25247e
+#ifdef HAVE_CONFIG_H
25247e
+	#include "config.h"
25247e
+#endif
25247e
+
25247e
 struct message {
25247e
 	unsigned intr : 1;
25247e
 	unsigned nofd : 1;
25247e
@@ -124,6 +128,7 @@ static int receive_message(int sock, void *buf, size_t buflen, int *fdp,
25247e
 	return res;
25247e
 }
25247e
 
25247e
+#if !defined(HAVE_CLOSEFROM)
25247e
 static int closefrom(int minfd)
25247e
 {
25247e
 	DIR *dir = opendir("/proc/self/fd");
25247e
@@ -141,6 +146,7 @@ static int closefrom(int minfd)
25247e
 	}
25247e
 	return 0;
25247e
 }
25247e
+#endif
25247e
 
25247e
 static void send_reply(int cfd, struct message *msg)
25247e
 {