]> git.alsa-project.org Git - alsa-lib.git/commitdiff
direct plugins - change group according ipc_gid for the socket file
authorJaroslav Kysela <perex@perex.cz>
Thu, 8 Sep 2005 06:48:30 +0000 (06:48 +0000)
committerJaroslav Kysela <perex@perex.cz>
Thu, 8 Sep 2005 06:48:30 +0000 (06:48 +0000)
This patch fixes problem when ipc_perm are 0660 and you want to share dmix
with more users in the specified group.

src/pcm/pcm_direct.c

index 23dfe3e40c1bd8247afdaea9b8dc0e398424aab7..33ed68a7285095e9434433fe31e849f338a757ba 100644 (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;