[pve-devel] [PATCH v5 pve-storage 07/11] cephconfig: escape un-escaped comment literals on write

Max Carrara m.carrara at proxmox.com
Tue Apr 2 16:55:19 CEST 2024


in order to prevent configuration errors or the configuration being
misinterpreted.

Signed-off-by: Max Carrara <m.carrara at proxmox.com>
---
Changes v3 --> v4:
  * new

Changes v4 --> v5:
  * escape *all* comment literals (that are not escaped) instead of only
    escaping them within values

 src/PVE/CephConfig.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/CephConfig.pm b/src/PVE/CephConfig.pm
index 845b7d2..0def1f2 100644
--- a/src/PVE/CephConfig.pm
+++ b/src/PVE/CephConfig.pm
@@ -105,6 +105,9 @@ sub write_ceph_config {
 	$cond_write_sec->($re);
     }
 
+    # Escape comment literals that aren't escaped already
+    $out =~ s/(?<!\\)([;#])/\\$1/gm;
+
     return $out;
 }
 
-- 
2.39.2





More information about the pve-devel mailing list