int root_handle;
int constructor_sem_posted;
int allowed;
+ int global;
char sock_path[PATH_MAX];
int socket;
/* Socket from app (connect) to session daemon (listen) for communication */
struct sock_info global_apps = {
.name = "global",
+ .global = 1,
.root_handle = -1,
.allowed = 1,
struct sock_info local_apps = {
.name = "local",
+ .global = 0,
.root_handle = -1,
.allowed = 0, /* Check setuid bit first */
size_t mmap_size = sysconf(_SC_PAGE_SIZE);
int wait_shm_fd, ret;
char *wait_shm_mmap;
+ int mode;
+
+ mode = S_IRUSR | S_IRGRP;
+ if (sock_info->global)
+ mode |= S_IROTH;
/*
* Get existing (read-only) shm, or open new shm.
* First try to open read-only.
*/
wait_shm_fd = shm_open(sock_info->wait_shm_path,
- O_RDONLY, 0700);
+ O_RDONLY, mode);
if (wait_shm_fd >= 0)
goto got_shm;
/*
goto error;
}
wait_shm_fd = shm_open(sock_info->wait_shm_path,
- O_RDWR | O_CREAT | O_EXCL, 0700);
+ O_RDWR | O_CREAT | O_EXCL, mode | S_IWUSR);
if (wait_shm_fd >= 0)
goto created_shm;
if (errno != EEXIST) {
* read-only mode.
*/
wait_shm_fd = shm_open(sock_info->wait_shm_path,
- O_RDWR | O_CREAT | O_EXCL, 0700);
+ O_RDWR | O_CREAT | O_EXCL, mode);
if (wait_shm_fd >= 0)
goto got_shm;
else
wait_shm_fd = -1;
goto error;
}
+ /* Drop write access ASAP */
+ ret = chmod(sock_info->wait_shm_path, mode);
+ if (ret) {
+ PERROR("chmod");
+ }
got_shm:
wait_shm_mmap = mmap(NULL, mmap_size, PROT_READ,
MAP_SHARED, wait_shm_fd, 0);