You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.5 KiB

  1. From 2a1e55dc62c72893d128400334131a56a218ee1a Mon Sep 17 00:00:00 2001
  2. From: Glenn Strauss <gstrauss@gluelogic.com>
  3. Date: Tue, 1 Dec 2020 16:23:49 -0500
  4. Subject: [PATCH] [mod_webdav] define _ATFILE_SOURCE if AT_FDCWD
  5. Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
  6. ---
  7. src/mod_webdav.c | 15 ++++++++++++---
  8. 1 file changed, 20 insertions(+), 5 deletions(-)
  9. diff --git a/src/mod_webdav.c b/src/mod_webdav.c
  10. index c3fe79a2..9c27ad8f 100644
  11. --- a/src/mod_webdav.c
  12. +++ b/src/mod_webdav.c
  13. @@ -182,9 +182,18 @@
  14. #include <string.h>
  15. #include <unistd.h> /* getpid() linkat() rmdir() unlinkat() */
  16. -/* Note: filesystem access race conditions exist without _ATFILE_SOURCE */
  17. +#ifdef AT_FDCWD
  18. #ifndef _ATFILE_SOURCE
  19. +#define _ATFILE_SOURCE
  20. +#endif
  21. +#endif
  22. +
  23. +#ifndef AT_SYMLINK_NOFOLLOW
  24. #define AT_SYMLINK_NOFOLLOW 0
  25. +#endif
  26. +
  27. +/* Note: filesystem access race conditions exist without _ATFILE_SOURCE */
  28. +#ifndef _ATFILE_SOURCE
  29. /*(trigger linkat() fail to fallback logic in mod_webdav.c)*/
  30. #define linkat(odfd,opath,ndfd,npath,flags) -1
  31. #endif
  32. @@ -2371,7 +2380,10 @@ webdav_delete_dir (const plugin_config * const pconf,
  33. buffer_append_string_len(&dst->rel_path, de->d_name, len);
  34. #ifndef _ATFILE_SOURCE
  35. - #ifndef _DIRENT_HAVE_D_TYPE
  36. + #ifdef _DIRENT_HAVE_D_TYPE
  37. + if (de->d_type == DT_UNKNOWN)
  38. + #endif
  39. + {
  40. struct stat st;
  41. if (0 != stat(dst->path.ptr, &st)) {
  42. dst->path.ptr[ (dst->path.used = dst_path_used) -1]='\0';
  43. @@ -2379,6 +2391,6 @@ webdav_delete_dir (const plugin_config * const pconf,
  44. continue; /* file *just* disappeared? */
  45. }
  46. s_isdir = S_ISDIR(st.st_mode);
  47. - #endif
  48. + }
  49. #endif
  50. @@ -2903,7 +2902,10 @@ webdav_copymove_dir (const plugin_config * const pconf,
  51. buffer_append_string_len(&dst->rel_path, de->d_name, len);
  52. #ifndef _ATFILE_SOURCE
  53. - #ifndef _DIRENT_HAVE_D_TYPE
  54. + #ifdef _DIRENT_HAVE_D_TYPE
  55. + if (de->d_type == DT_UNKNOWN)
  56. + #endif
  57. + {
  58. if (0 != stat(src->path.ptr, &st)) {
  59. src->path.ptr[ (src->path.used = src_path_used) -1]='\0';
  60. src->rel_path.ptr[(src->rel_path.used = src_rel_path_used)-1]='\0';
  61. @@ -2912,7 +2914,7 @@ webdav_copymove_dir (const plugin_config * const pconf,
  62. continue; /* file *just* disappeared? */
  63. }
  64. d_type = st.st_mode;
  65. - #endif
  66. + }
  67. #endif
  68. if (S_ISDIR(d_type)) { /* recursive call; depth first */
  69. --
  70. 2.28.0