# Always create temporary directories with the mktemp command, then create your
# actual temporary files inside those directories.
# By doing this, you can set restrictive permissions on the directory that will
# prevent an attacker from deleting your files and replacing them

# if you specify the -d flag, the mktemp command creates a new directory with the
# specified template, ensuring that a file or directory with that name does not
# already exist.

# always use umask to specify initial permissions on files and directories
umask 0177
TMPDIR="$(mktemp -d /tmp/mytempfile.XXXXXX)"

echo "My password is secret!" > "${TMPDIR}"/mypublicdata

# ...

PUBLICDATA="$(cat "${TMPDIR}"/mypublicdata)"
echo "${PUBLICDATA}" | nc 192.168.1.102 3333
