mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-21 08:56:52 -05:00
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.
This commit is contained in:
parent
13c7364997
commit
4e1723f9a5
2 changed files with 8 additions and 5 deletions
|
|
@ -57,7 +57,8 @@
|
||||||
|
|
||||||
int snd_pcm_direct_semaphore_create_or_connect(snd_pcm_direct_t *dmix)
|
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)
|
if (dmix->semid < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -104,11 +105,12 @@ int snd_pcm_direct_shm_create_or_connect(snd_pcm_direct_t *dmix)
|
||||||
int tmpid, err;
|
int tmpid, err;
|
||||||
|
|
||||||
retryget:
|
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;
|
err = -errno;
|
||||||
if (dmix->shmid < 0){
|
if (dmix->shmid < 0){
|
||||||
if (errno == EINVAL)
|
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 (!shmctl(tmpid, IPC_STAT, &buf))
|
||||||
if (!buf.shm_nattch)
|
if (!buf.shm_nattch)
|
||||||
/* no users so destroy the segment */
|
/* no users so destroy the segment */
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,12 @@ static int shm_sum_create_or_connect(snd_pcm_direct_t *dmix)
|
||||||
dmix->shmptr->s.buffer_size *
|
dmix->shmptr->s.buffer_size *
|
||||||
sizeof(signed int);
|
sizeof(signed int);
|
||||||
retryshm:
|
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;
|
err = -errno;
|
||||||
if (dmix->u.dmix.shmid_sum < 0){
|
if (dmix->u.dmix.shmid_sum < 0){
|
||||||
if (errno == EINVAL)
|
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 (!shmctl(tmpid, IPC_STAT, &buf))
|
||||||
if (!buf.shm_nattch)
|
if (!buf.shm_nattch)
|
||||||
/* no users so destroy the segment */
|
/* no users so destroy the segment */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue