Don't use ${CONF_PATH}.qubes, because it may override some existing file, and is racy approach (even if not against user, but another script instance). QubesOS/qubes-issues#1282
@@ -50,7 +50,8 @@ update_conf() {
fi
# Prepare config block
- cat > ${CONF_PATH}.qubes <<EOF
+ local tmpfile=`mktemp`
+ cat > ${tmpfile} <<EOF
# This part of configuration, until QUBES END, is automatically generated by
# $0. All changes here will be overriden.
# If you want to override any option set here, set it again to desired value,
@@ -62,8 +63,9 @@ EOF
sed -i -e "/^$BEGIN_MARKER$/,/^$END_MARKER$/{
/^$END_MARKER$/b
/^$BEGIN_MARKER$/!d
- r ${CONF_PATH}.qubes
+ r ${tmpfile}
}" ${CONF_PATH}
+ rm -f ${tmpfile}
}
### helper functions end