Skip to content

Commit

Permalink
Merge r1920081 from trunk:
Browse files Browse the repository at this point in the history
use 0600 perms for named shared mem consistently



git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1920082 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
covener committed Aug 20, 2024
1 parent 695af89 commit 1b4da06
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions shmem/unix/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,9 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
status = APR_SUCCESS;

#if APR_USE_SHMEM_MMAP_TMP
/* FIXME: Is APR_OS_DEFAULT sufficient? */
status = apr_file_open(&file, filename,
APR_READ | APR_WRITE | APR_CREATE | APR_EXCL,
APR_OS_DEFAULT, pool);
status = apr_file_open(&file, filename,
APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_EXCL,
APR_FPROT_UREAD | APR_FPROT_UWRITE, pool);
if (status != APR_SUCCESS) {
return status;
}
Expand Down Expand Up @@ -319,8 +318,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
}
#endif /* APR_USE_SHMEM_MMAP_TMP */
#if APR_USE_SHMEM_MMAP_SHM
/* FIXME: SysV uses 0600... should we? */
tmpfd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0644);
tmpfd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0600);
if (tmpfd == -1) {
return errno;
}
Expand Down Expand Up @@ -361,10 +359,9 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
#elif APR_USE_SHMEM_SHMGET
new_m->realsize = reqsize;

/* FIXME: APR_OS_DEFAULT is too permissive, switch to 600 I think. */
status = apr_file_open(&file, filename,
status = apr_file_open(&file, filename,
APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_EXCL,
APR_OS_DEFAULT, pool);
APR_FPROT_UREAD | APR_FPROT_UWRITE, pool);
if (status != APR_SUCCESS) {
return status;
}
Expand Down Expand Up @@ -555,8 +552,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
#if APR_USE_SHMEM_MMAP_SHM
const char *shm_name = make_shm_open_safe_name(filename, pool);

/* FIXME: SysV uses 0600... should we? */
tmpfd = shm_open(shm_name, O_RDWR, 0644);
tmpfd = shm_open(shm_name, O_RDWR, 0600);
if (tmpfd == -1) {
return errno;
}
Expand Down

0 comments on commit 1b4da06

Please sign in to comment.