Set umask on swapfile creation (#2436)

Make sure the swapfile is only readable by the owner.
This commit is contained in:
Stefan Agner 2023-03-28 18:18:58 +02:00
parent 858a5efe4b
commit 466db83901
No known key found for this signature in database
GPG Key ID: 22D95D15D3A36E95

View File

@ -14,6 +14,7 @@ if [ ! -s "${swapfile}" ] || [ "$(stat "${swapfile}" -c '%s')" -lt $((swapsize *
fi fi
echo "[INFO] Creating swapfile of size $((swapsize *4))k" echo "[INFO] Creating swapfile of size $((swapsize *4))k"
umask 0077
dd if=/dev/zero of="${swapfile}" bs=4k count="${swapsize}" dd if=/dev/zero of="${swapfile}" bs=4k count="${swapsize}"
fi fi