From 4e1723f9a55be339cca46a1c5022fb6559f97fc1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 19 May 2005 14:36:04 +0000 Subject: [PATCH] More strict permission for IPC shm and sem Use more strict permission for IPC shm and sem, too. The permission follows to the value of ipc_perm config option, as default 0600. --- src/pcm/pcm_direct.c | 8 +++++--- src/pcm/pcm_dmix.c | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index e842adbd..a8ce4a22 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -57,7 +57,8 @@ int snd_pcm_direct_semaphore_create_or_connect(snd_pcm_direct_t *dmix) { - dmix->semid = semget(dmix->ipc_key, DIRECT_IPC_SEMS, IPC_CREAT | 0666); + dmix->semid = semget(dmix->ipc_key, DIRECT_IPC_SEMS, + IPC_CREAT | dmix->ipc_perm); if (dmix->semid < 0) return -errno; return 0; @@ -104,11 +105,12 @@ int snd_pcm_direct_shm_create_or_connect(snd_pcm_direct_t *dmix) int tmpid, err; retryget: - dmix->shmid = shmget(dmix->ipc_key, sizeof(snd_pcm_direct_share_t), IPC_CREAT | 0666); + dmix->shmid = shmget(dmix->ipc_key, sizeof(snd_pcm_direct_share_t), + IPC_CREAT | dmix->ipc_perm); err = -errno; if (dmix->shmid < 0){ if (errno == EINVAL) - if ((tmpid = shmget(dmix->ipc_key, 0, 0666)) != -1) + if ((tmpid = shmget(dmix->ipc_key, 0, dmix->ipc_perm)) != -1) if (!shmctl(tmpid, IPC_STAT, &buf)) if (!buf.shm_nattch) /* no users so destroy the segment */ diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index 38ea3d5c..e5104db4 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -71,11 +71,12 @@ static int shm_sum_create_or_connect(snd_pcm_direct_t *dmix) dmix->shmptr->s.buffer_size * sizeof(signed int); retryshm: - dmix->u.dmix.shmid_sum = shmget(dmix->ipc_key + 1, size, IPC_CREAT | 0666); + dmix->u.dmix.shmid_sum = shmget(dmix->ipc_key + 1, size, + IPC_CREAT | dmix->ipc_perm); err = -errno; if (dmix->u.dmix.shmid_sum < 0){ if (errno == EINVAL) - if ((tmpid = shmget(dmix->ipc_key + 1, 0, 0666)) != -1) + if ((tmpid = shmget(dmix->ipc_key + 1, 0, dmix->ipc_perm)) != -1) if (!shmctl(tmpid, IPC_STAT, &buf)) if (!buf.shm_nattch) /* no users so destroy the segment */ -- 2.47.1