From 096da69df90df13dd3388b74fda14e2a422f8dd6 Mon Sep 17 00:00:00 2001 From: ratchov Date: Sat, 28 Jul 2018 09:11:55 +0000 Subject: [PATCH] Move libsndio session cookie in its own $HOME/.sndio/ directory to make libsndio easier to use with unveil(2). "make sense" deraadt --- lib/libsndio/aucat.c | 14 ++++++++++++-- lib/libsndio/sio_open.3 | 6 +++--- lib/libsndio/sndio.7 | 6 +++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c index 600216db984..f2d9cd559b9 100644 --- a/lib/libsndio/aucat.c +++ b/lib/libsndio/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.71 2016/01/09 08:27:24 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.72 2018/07/28 09:11:55 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -205,7 +205,8 @@ _aucat_wdata(struct aucat *hdl, const void *buf, size_t len, static int aucat_mkcookie(unsigned char *cookie) { -#define COOKIE_SUFFIX "/.aucat_cookie" +#define COOKIE_DIR "/.sndio" +#define COOKIE_SUFFIX "/.sndio/cookie" #define TEMPL_SUFFIX ".XXXXXXXX" struct stat sb; char *home, *path = NULL, *tmp = NULL; @@ -264,11 +265,20 @@ bad_gen: /* * try to save the cookie */ + if (home == NULL) goto done; tmp = malloc(path_len + sizeof(TEMPL_SUFFIX)); if (tmp == NULL) goto done; + + /* create ~/.sndio directory */ + memcpy(tmp, home, home_len); + memcpy(tmp + home_len, COOKIE_DIR, sizeof(COOKIE_DIR)); + if (mkdir(tmp, 0755) < 0 && errno != EEXIST) + goto done; + + /* create cookie file in it */ memcpy(tmp, path, path_len); memcpy(tmp + path_len, TEMPL_SUFFIX, sizeof(TEMPL_SUFFIX)); fd = mkstemp(tmp); diff --git a/lib/libsndio/sio_open.3 b/lib/libsndio/sio_open.3 index f3fc59c7cc8..fc5b68edba0 100644 --- a/lib/libsndio/sio_open.3 +++ b/lib/libsndio/sio_open.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sio_open.3,v 1.46 2017/01/03 20:29:28 natano Exp $ +.\" $OpenBSD: sio_open.3,v 1.47 2018/07/28 09:11:55 ratchov Exp $ .\" .\" Copyright (c) 2007 Alexandre Ratchov .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 3 2017 $ +.Dd $Mdocdate: July 28 2018 $ .Dt SIO_OPEN 3 .Os .Sh NAME @@ -690,7 +690,7 @@ promises. and .Va cpath are needed to read, write or create the authentication cookie -.Pa ~/.aucat_cookie . +.Pa ~/.sndio/cookie . .It .Va rpath , .Va wpath , diff --git a/lib/libsndio/sndio.7 b/lib/libsndio/sndio.7 index 264777d24cd..afbfde0e94c 100644 --- a/lib/libsndio/sndio.7 +++ b/lib/libsndio/sndio.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sndio.7,v 1.19 2017/12/07 15:43:03 schwarze Exp $ +.\" $OpenBSD: sndio.7,v 1.20 2018/07/28 09:11:55 ratchov Exp $ .\" .\" Copyright (c) 2007 Alexandre Ratchov .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 7 2017 $ +.Dd $Mdocdate: July 28 2018 $ .Dt SNDIO 7 .Os .Sh NAME @@ -191,7 +191,7 @@ Users are identified by their which is automatically generated by audio or MIDI applications upon the first connection to the server. The cookie is stored in -.Pa "$HOME/.aucat_cookie" +.Pa "$HOME/.sndio/cookie" and contains 128 bits of raw random data. .Pp If a session needs to be shared between multiple users, they -- 2.20.1