diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-02-03 19:44:59 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-02-03 19:44:59 +0000 |
commit | 43a7da6ca36bc6f538024c99f4829330e44b9e6f (patch) | |
tree | 5918bc4729b704187a534caad4dcde9fac5244a4 /lib | |
parent | a71cd502a66a21e4f232d1da33cae8eb5d594b83 (diff) |
in server mode, create /tmp/aucat-userid/ directory with
permissions 0700, and create sockets in it. This prevents
one local user to eavesdrop or disturb audio programs of
other users.
if you're using the ``-s socket'' option with an absolute
path as argument, please update it to use a socket name.
requested by many, bits from jakemsr and otto
ok jakemsr
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libsndio/aucat.c | 12 | ||||
-rw-r--r-- | lib/libsndio/sndio.h | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c index e04c3cfe2ac..7acef2189a2 100644 --- a/lib/libsndio/aucat.c +++ b/lib/libsndio/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.11 2009/01/10 20:34:44 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.12 2009/02/03 19:44:58 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -79,9 +79,17 @@ sio_open_aucat(char *path, unsigned mode, int nbio) struct aucat_hdl *hdl; struct sockaddr_un ca; socklen_t len = sizeof(struct sockaddr_un); + uid_t uid; if (path == NULL) path = SIO_AUCAT_PATH; + uid = geteuid(); + if (strchr(path, '/') != NULL) + return NULL; + snprintf(ca.sun_path, sizeof(ca.sun_path), + "/tmp/aucat-%u/%s", uid, path); + ca.sun_family = AF_UNIX; + hdl = malloc(sizeof(struct aucat_hdl)); if (hdl == NULL) return NULL; @@ -90,8 +98,6 @@ sio_open_aucat(char *path, unsigned mode, int nbio) s = socket(AF_UNIX, SOCK_STREAM, 0); if (s < 0) goto bad_free; - ca.sun_family = AF_UNIX; - memcpy(ca.sun_path, path, strlen(path) + 1); while (connect(s, (struct sockaddr *)&ca, len) < 0) { if (errno == EINTR) continue; diff --git a/lib/libsndio/sndio.h b/lib/libsndio/sndio.h index 1e2059d13e8..27c6c599dd7 100644 --- a/lib/libsndio/sndio.h +++ b/lib/libsndio/sndio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sndio.h,v 1.6 2009/01/21 21:29:01 ratchov Exp $ */ +/* $OpenBSD: sndio.h,v 1.7 2009/02/03 19:44:58 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -109,9 +109,9 @@ struct sio_cap { #define SIO_SUN_PATH "/dev/audio" /* - * default socket for the aucat(1) back-end + * default socket name for the aucat(1) back-end */ -#define SIO_AUCAT_PATH "/tmp/aucat.sock" +#define SIO_AUCAT_PATH "default" /* * maximum value of volume, eg. for sio_setvol() |