1Upstream-Status: Pending
2
3From: Sam James <sam@gentoo.org>
4Date: Sat, 24 Jul 2021 22:02:45 +0100
5Subject: [PATCH] util/ulockmgr_server.c: conditionally define closefrom (fix
6 glibc-2.34+)
7
8closefrom(3) has joined us in glibc-land from *BSD and Solaris. Since
9it's available in glibc 2.34+, we want to detect it and only define our
10fallback if the libc doesn't provide it.
11
12Bug: https://bugs.gentoo.org/803923
13Signed-off-by: Sam James <sam@gentoo.org>
14
15--- a/configure.ac
16+++ b/configure.ac
17@@ -55,6 +55,7 @@ fi
18
19 AC_CHECK_FUNCS([fork setxattr fdatasync splice vmsplice utimensat])
20 AC_CHECK_FUNCS([posix_fallocate])
21+AC_CHECK_FUNCS([closefrom])
22 AC_CHECK_MEMBERS([struct stat.st_atim])
23 AC_CHECK_MEMBERS([struct stat.st_atimespec])
24
25--- a/util/ulockmgr_server.c
26+++ b/util/ulockmgr_server.c
27@@ -22,6 +22,10 @@
28 #include <sys/socket.h>
29 #include <sys/wait.h>
30
31+#ifdef HAVE_CONFIG_H
32+	#include "config.h"
33+#endif
34+
35 struct message {
36 	unsigned intr : 1;
37 	unsigned nofd : 1;
38@@ -124,6 +128,7 @@ static int receive_message(int sock, voi
39 	return res;
40 }
41
42+#if !defined(HAVE_CLOSEFROM)
43 static int closefrom(int minfd)
44 {
45 	DIR *dir = opendir("/proc/self/fd");
46@@ -141,6 +146,7 @@ static int closefrom(int minfd)
47 	}
48 	return 0;
49 }
50+#endif
51
52 static void send_reply(int cfd, struct message *msg)
53 {
54