Sfoglia il codice sorgente

updates-proxy-setup: use temporary file for config snippet

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
Marek Marczykowski-Górecki 8 anni fa
parent
commit
f9c7394c2f
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 4 2
      network/update-proxy-configs

+ 4 - 2
network/update-proxy-configs

@@ -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