0004-Merge-r1920082-from-1.8.x.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 36ea6d5a2bfc480dd8032cc8651e6793552bc2aa Mon Sep 17 00:00:00 2001
  2. From: Eric Covener <covener@apache.org>
  3. Date: Tue, 20 Aug 2024 21:50:42 +0000
  4. Subject: [PATCH] Merge r1920082 from 1.8.x:
  5. use 0600 perms for named shared mem consistently
  6. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1920083 13f79535-47bb-0310-9956-ffa450edef68
  7. Upstream: https://github.com/apache/apr/commit/36ea6d5a2bfc480dd8032cc8651e6793552bc2aa
  8. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  9. ---
  10. shmem/unix/shm.c | 18 +++++++-----------
  11. 1 file changed, 7 insertions(+), 11 deletions(-)
  12. diff --git a/shmem/unix/shm.c b/shmem/unix/shm.c
  13. index 096884d99..ea9b94277 100644
  14. --- a/shmem/unix/shm.c
  15. +++ b/shmem/unix/shm.c
  16. @@ -287,10 +287,9 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
  17. status = APR_SUCCESS;
  18. #if APR_USE_SHMEM_MMAP_TMP
  19. - /* FIXME: Is APR_OS_DEFAULT sufficient? */
  20. - status = apr_file_open(&file, filename,
  21. - APR_READ | APR_WRITE | APR_CREATE | APR_EXCL,
  22. - APR_OS_DEFAULT, pool);
  23. + status = apr_file_open(&file, filename,
  24. + APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_EXCL,
  25. + APR_FPROT_UREAD | APR_FPROT_UWRITE, pool);
  26. if (status != APR_SUCCESS) {
  27. return status;
  28. }
  29. @@ -319,8 +318,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
  30. }
  31. #endif /* APR_USE_SHMEM_MMAP_TMP */
  32. #if APR_USE_SHMEM_MMAP_SHM
  33. - /* FIXME: SysV uses 0600... should we? */
  34. - tmpfd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0644);
  35. + tmpfd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0600);
  36. if (tmpfd == -1) {
  37. return errno;
  38. }
  39. @@ -361,10 +359,9 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
  40. #elif APR_USE_SHMEM_SHMGET
  41. new_m->realsize = reqsize;
  42. - /* FIXME: APR_OS_DEFAULT is too permissive, switch to 600 I think. */
  43. - status = apr_file_open(&file, filename,
  44. + status = apr_file_open(&file, filename,
  45. APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_EXCL,
  46. - APR_OS_DEFAULT, pool);
  47. + APR_FPROT_UREAD | APR_FPROT_UWRITE, pool);
  48. if (status != APR_SUCCESS) {
  49. return status;
  50. }
  51. @@ -555,8 +552,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
  52. #if APR_USE_SHMEM_MMAP_SHM
  53. const char *shm_name = make_shm_open_safe_name(filename, pool);
  54. - /* FIXME: SysV uses 0600... should we? */
  55. - tmpfd = shm_open(shm_name, O_RDWR, 0644);
  56. + tmpfd = shm_open(shm_name, O_RDWR, 0600);
  57. if (tmpfd == -1) {
  58. return errno;
  59. }
  60. --
  61. 2.39.5