0002-util-ulockmgr_server-c-conditionally-define-closefrom-fix-glibc-2-34.patch 1.8 KB

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