Use a random temporary directory instead of a fixed one - sacc - sacc(omys), simple console gopher client HTML git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/ DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit f2b48c669ee5b69e3b46f64979739d15f41338c2 DIR parent 49292644fd4a8c983928738fe36ac9daaebc755d HTML 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: M config.def.h | 4 ++-- M sacc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) --- DIR 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"; DIR 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();