From c4eff321f28ff5abd0125a78811986b98817abac Mon Sep 17 00:00:00 2001 From: dlandon Date: Mon, 10 Jun 2024 13:21:00 -0500 Subject: [PATCH] Use atomic file write. --- emhttp/plugins/dynamix/include/UpdateOne.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/include/UpdateOne.php b/emhttp/plugins/dynamix/include/UpdateOne.php index 16bff2a60..8a5d2b576 100644 --- a/emhttp/plugins/dynamix/include/UpdateOne.php +++ b/emhttp/plugins/dynamix/include/UpdateOne.php @@ -51,7 +51,7 @@ switch ($data['id']) { if ($cpus != $cpuset || strlen($cpus) != strlen($cpuset)) { $changes[] = $name; /* used by UpdateTwo.php to read new assignments */ - file_put_contents("/var/tmp/$name.tmp", $cpuset); + file_put_contents_atomic("/var/tmp/$name.tmp", $cpuset); } } $reply = ['success' => (count($changes) ? implode(';', $changes) : '')]; @@ -78,7 +78,7 @@ switch ($data['id']) { if ($ct['CPUset'] != $cpuset || strlen($ct['CPUset']) != strlen($cpuset)) { $changes[] = $name; /* used by UpdateTwo.php to read new assignments */ - file_put_contents($file, $xml->saveXML()); + file_put_contents_atomic($file, $xml->saveXML()); exec("sed -ri 's/^(<(\\/Container)/>\\n <\\1/' \"$file\""); /* aftercare */ } } @@ -87,7 +87,7 @@ switch ($data['id']) { case 'is': /* report changed isolcpus in temporary file */ foreach ($map as $name => $isolcpu) { - file_put_contents("/var/tmp/$name.tmp", $isolcpu); + file_put_contents_atomic("/var/tmp/$name.tmp", $isolcpu); $changes[] = $name; } $reply = ['success' => (count($changes) ? implode(';', $changes) : '')];