diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-04-22 17:43:31 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-04-22 17:43:31 +0000 |
commit | f5dd670f418fc5b9117869578ba44867a6a648e2 (patch) | |
tree | bebbc00ffdc0855fe060b4ae82f0e77f1998deba /lib/libsndio | |
parent | e153255799cfad37e6558a74e851726a9175cc77 (diff) |
Allow multiple users to share the same aucat server. If aucat is
run by root, it binds a shared address to the socket, cranks the
process priority and drops privileges. sio_open(3) will try to
connect to the private socket first (if any), then to the shared
socket. Only one user may have connections to aucat at a given
time.
based on discussions with henning, pyr and others
ok jacek, deraadt
Diffstat (limited to 'lib/libsndio')
-rw-r--r-- | lib/libsndio/aucat.c | 13 | ||||
-rw-r--r-- | lib/libsndio/mio_thru.c | 15 |
2 files changed, 23 insertions, 5 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c index 65cef3bb5d7..f79f235d532 100644 --- a/lib/libsndio/aucat.c +++ b/lib/libsndio/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.35 2010/04/06 20:07:01 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.36 2010/04/22 17:43:30 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -225,7 +225,16 @@ sio_open_aucat(const char *str, unsigned mode, int nbio) if (errno == EINTR) continue; DPERROR("sio_open_aucat: connect"); - goto bad_connect; + /* try shared server */ + snprintf(ca.sun_path, sizeof(ca.sun_path), + "/tmp/aucat/softaudio%s", unit); + while (connect(s, (struct sockaddr *)&ca, len) < 0) { + if (errno == EINTR) + continue; + DPERROR("sio_open_aucat: connect"); + goto bad_connect; + } + break; } if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) { DPERROR("FD_CLOEXEC"); diff --git a/lib/libsndio/mio_thru.c b/lib/libsndio/mio_thru.c index eb5dd81bdcc..1413f9ee5c2 100644 --- a/lib/libsndio/mio_thru.c +++ b/lib/libsndio/mio_thru.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio_thru.c,v 1.6 2009/10/22 22:26:49 ratchov Exp $ */ +/* $OpenBSD: mio_thru.c,v 1.7 2010/04/22 17:43:30 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -82,8 +82,17 @@ thru_open(const char *str, char *sock, unsigned mode, int nbio) if (errno == EINTR) continue; DPERROR("thru_open: connect"); - goto bad_connect; - } + /* try shared server */ + snprintf(ca.sun_path, sizeof(ca.sun_path), + "/tmp/aucat/%s%s", sock, str); + while (connect(s, (struct sockaddr *)&ca, len) < 0) { + if (errno == EINTR) + continue; + DPERROR("thru_open: connect"); + goto bad_connect; + } + break; + } if (fcntl(s, F_SETFD, FD_CLOEXEC) < 0) { DPERROR("FD_CLOEXEC"); goto bad_connect; |