From 2435bd1c3a55cad4d9bcacf5389a38c7cb0b154e Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 16 Dec 2022 21:39:28 +0100 Subject: [PATCH] Tools: setup-unit: workarounded macOS tmp file permissions. mktemp(1) in macOS uses a weird directory where only the running user has permissions. If we use that for the welcome website, unitd(8) won't be able to read the page. Use a directory at $HOME before trying a tmpdir. Reported-by: Liam Crilly Signed-off-by: Alejandro Colomar --- tools/setup-unit | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/setup-unit b/tools/setup-unit index a41b7f81..d16fe1a3 100755 --- a/tools/setup-unit +++ b/tools/setup-unit @@ -562,6 +562,9 @@ unit_ctl_welcome() www='/srv/www/unit/index.html'; if test -e "$www" && ! test -v force || ! test -w /srv; then + www="$HOME/srv/www/unit/index.html"; + fi; + if test -e "$www" && ! test -v force; then www="$(mktemp)"; mv "$www" "$www.html"; www="$www.html" @@ -624,7 +627,7 @@ unit_ctl_welcome() dry_run_echo 'Create a file to serve:'; dry_run_eval "mkdir -p $(dirname $www);"; - dry_run_eval "cat >'$www'"' <<__EOF__; + dry_run_eval "tee '$www' >/dev/null"' <<__EOF__;