commit f2b48c669ee5b69e3b46f64979739d15f41338c2
parent 49292644fd4a8c983928738fe36ac9daaebc755d
Author: Quentin Rameau <quinq@fifth.space>
Date: Wed, 19 Feb 2020 21:36:37 +0100
Use a random temporary directory instead of a fixed one
Thanks to the persons who asked for this.
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -23,5 +23,5 @@
/* default plumber */
static char *plumber = "xdg-open";
-/* temporary directory */
-static char *tmpdir = "/tmp/sacc";
+/* temporary directory template (must end with six 'X' characters) */
+static char tmpdir[] = "/tmp/sacc-XXXXXX";
diff --git a/sacc.c b/sacc.c
@@ -976,7 +976,7 @@ setup(void)
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
- if (mkdir(tmpdir, S_IRWXU) < 0 && errno != EEXIST)
+ if (!mkdtemp(tmpdir))
die("mkdir: %s: %s", tmpdir, strerror(errno));
if(interactive = isatty(1)) {
uisetup();