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/aucat.c | |
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/aucat.c')
-rw-r--r-- | lib/libsndio/aucat.c | 13 |
1 files changed, 11 insertions, 2 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"); |