diff --git a/libsndio/aucat.c b/libsndio/aucat.c index 34b2b29..023dab3 100644 --- a/libsndio/aucat.c +++ b/libsndio/aucat.c @@ -244,7 +244,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; @@ -311,11 +312,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/libsndio/sndio.7 b/libsndio/sndio.7 index 171235f..08b39f7 100644 --- a/libsndio/sndio.7 +++ b/libsndio/sndio.7 @@ -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