direct plugins - change group according ipc_gid for the socket file

This patch fixes problem when ipc_perm are 0660 and you want to share dmix
with more users in the specified group.
This commit is contained in:
Jaroslav Kysela 2005-09-08 06:48:30 +00:00
parent af6544a274
commit 19284bd325

View file

@ -163,7 +163,7 @@ static int get_tmp_name(char *filename, size_t size)
return 0;
}
static int make_local_socket(const char *filename, int server, mode_t ipc_perm)
static int make_local_socket(const char *filename, int server, mode_t ipc_perm, int ipc_gid)
{
size_t l = strlen(filename);
size_t size = offsetof(struct sockaddr_un, sun_path) + l;
@ -194,6 +194,14 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm)
int result = -errno;
SYSERR("chmod failed: %s", filename);
close(sock);
unlink(filename);
return result;
}
if (chown(filename, -1, ipc_gid) < 0) {
int result = -errno;
SYSERR("chmod failed: %s", filename);
close(sock);
unlink(filename);
return result;
}
}
@ -383,7 +391,7 @@ int snd_pcm_direct_server_create(snd_pcm_direct_t *dmix)
if (ret < 0)
return ret;
ret = make_local_socket(dmix->shmptr->socket_name, 1, dmix->ipc_perm);
ret = make_local_socket(dmix->shmptr->socket_name, 1, dmix->ipc_perm, dmix->ipc_gid);
if (ret < 0)
return ret;
dmix->server_fd = ret;
@ -435,7 +443,7 @@ int snd_pcm_direct_client_connect(snd_pcm_direct_t *dmix)
int ret;
unsigned char buf;
ret = make_local_socket(dmix->shmptr->socket_name, 0, dmix->ipc_perm);
ret = make_local_socket(dmix->shmptr->socket_name, 0, -1, -1);
if (ret < 0)
return ret;
dmix->comm_fd = ret;