notroj commented on code in PR #59: URL: https://github.com/apache/apr/pull/59#discussion_r1706676303
########## shmem/unix/shm.c: ########## @@ -705,6 +705,47 @@ APR_PERMS_SET_IMPLEMENT(shm) if (shmctl(shmid, IPC_SET, &shmbuf) == -1) { return errno; } + return APR_SUCCESS; +#elif APR_USE_SHMEM_MMAP_SHM + apr_shm_t *shm = (apr_shm_t *)theshm; + const char *shm_name; + int fd; + apr_status_t rv; + + if (!shm->filename) + return APR_ENOTIMPL; + + shm_name = make_shm_open_safe_name(shm->filename, shm->pool); + + fd = shm_open(shm_name, O_RDWR, 0); + if (fd == -1) + return errno; + + if (fchown(fd, uid, gid)) { + rv = errno; + close(fd); + return rv; + } + + if (fchmod(fd, apr_unix_perms2mode(perms))) { + rv = errno; + close(fd); + return rv; + } + + return APR_SUCCESS; +#elif APR_USE_SHMEM_MMAP_TMP + apr_shm_t *shm = (apr_shm_t *)theshm; + + if (!shm->filename) + return APR_ENOTIMPL; + + if (chown(shm->filename, uid, gid)) + return errno; + + if (chmod(shm->filename, apr_unix_perms2mode(perms))) + return errno; + return APR_SUCCESS; Review Comment: I think we need to assume that the caller controls the shm segment and there's no need to try to avoid races. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@apr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org