I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions.
Is there any way to specify file permissions at the same time as creating the file? C’s creat function allows me to specify S_IRUSR | S_IWUSR. Is there any equivalent in Elixir?
fwiw, I wrapped my Elixir script in a shell script that sets umask before invoking it.
#!/bin/sh
# We want the keys to be u=rw,go=, but there's no way to do that in
# Elixir without race conditions, afaict, so we use umask:
umask 077
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
exec elixir "$SCRIPTPATH/certs.exs" "$@"