mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
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:
parent
af6544a274
commit
19284bd325
1 changed files with 11 additions and 3 deletions
|
|
@ -163,7 +163,7 @@ static int get_tmp_name(char *filename, size_t size)
|
||||||
return 0;
|
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 l = strlen(filename);
|
||||||
size_t size = offsetof(struct sockaddr_un, sun_path) + l;
|
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;
|
int result = -errno;
|
||||||
SYSERR("chmod failed: %s", filename);
|
SYSERR("chmod failed: %s", filename);
|
||||||
close(sock);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +391,7 @@ int snd_pcm_direct_server_create(snd_pcm_direct_t *dmix)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
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)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
dmix->server_fd = ret;
|
dmix->server_fd = ret;
|
||||||
|
|
@ -435,7 +443,7 @@ int snd_pcm_direct_client_connect(snd_pcm_direct_t *dmix)
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char buf;
|
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)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
dmix->comm_fd = ret;
|
dmix->comm_fd = ret;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue