Bug 193370

Summary: ainit creates semaphores and shmem with wrong permissions
Product: [Fedora] Fedora Reporter: Roberto Ragusa <bugzillaredhat-56f0>
Component: alsa-libAssignee: Martin Stransky <stransky>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-07-21 08:59:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Roberto Ragusa 2006-05-27 21:10:55 UTC
Description of problem:

The ipc_perm parameter in dmix.template and dsnoop_template
has no effect, because ainit always uses 0600 as permission.


Version-Release number of selected component (if applicable):

alsa-utils-1.0.11-4.rc2


How reproducible:

100%


Steps to Reproduce:
1. Modify /etc/alsa/dmix.template, changing for example
     ipc_perm 0600
   into
     ipc_perm 0666
2. ainit <name_of_the_user> start
3. ipcs -a
  
Actual results:

The shared memory segments and the semaphore arrays have
been created with permission 0600 and not 0666.


Expected results:

Permission should be respected.


Additional info:

I want to mix audio from many users, so I tried to set ipc_perm
to 0666 in /etc/alsa/dmix.template and /etc/alsa/dsnoop.template
(in addition to 0666 permission on the devices).
This doesn't work well, because when ainit creates
/etc/alsa/dmix.conf and /etc/alsa/dsnoop.conf it allocates
ipc_key and ipc_semaphore using an hardcoded permission of 0600.
The generated *.conf files do contain the "ipc_perm 0666" line,
but the keys and the semaphore have already been incorrectly created.

The problem is here (hardcoded 0600):

/* Checking if IPC key/semaphore already exist
*/
int check_ipc_key(key_t key)
{
  int shm_id = shmget(key, 1, IPC_CREAT | IPC_EXCL | 0600);
  return (shm_id >= 0);
}

int check_ipc_semaphore(key_t key)
{
  int shm_id = semget(key, 1, IPC_CREAT | IPC_EXCL | 0600);
  return (shm_id >= 0);
}

Comment 1 Martin Stransky 2006-07-21 08:59:24 UTC
fixed in rawhide, I removed all ainit stuffs, they're not needed any more in the
latest upstream.