]> git.alsa-project.org Git - alsa-lib.git/commitdiff
More strict permission for IPC shm and sem
authorTakashi Iwai <tiwai@suse.de>
Thu, 19 May 2005 14:36:04 +0000 (14:36 +0000)
committerTakashi Iwai <tiwai@suse.de>
Thu, 19 May 2005 14:36:04 +0000 (14:36 +0000)
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
src/pcm/pcm_dmix.c

index e842adbd5a906d44163572c9877e3b7eeb94b026..a8ce4a2276a1e0c322330e0e12f4781ce4a07f5f 100644 (file)
@@ -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 */
index 38ea3d5cc7d9e3b4eaa8862dca7b4fe125d44246..e5104db4419ddd01ff49917c8c9cb413c4aa9b3c 100644 (file)
@@ -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 */