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