]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: convert _write_custom_conf_files to use write_new
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 6 Jun 2023 16:25:34 +0000 (12:25 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 6 Jun 2023 18:19:32 +0000 (14:19 -0400)
We double checked the meaning of "w+" and it will open the file
read-write. Since the file is never read there's no real reason
to keep it that way so its OK to convert to `write_new`.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py

index 7f6229d630ce5c00830fd143ca2782e4096f17bf..0434d011c12593da9e920c13269e5b0d77a91e6d 100755 (executable)
@@ -2952,9 +2952,7 @@ def _write_custom_conf_files(ctx: CephadmContext, daemon_type: str, daemon_id: s
     for ccf in config_json['custom_config_files']:
         if all(k in ccf for k in mandatory_keys):
             file_path = os.path.join(custom_config_dir, os.path.basename(ccf['mount_path']))
-            with open(file_path, 'w+', encoding='utf-8') as f:
-                os.fchown(f.fileno(), uid, gid)
-                os.fchmod(f.fileno(), 0o600)
+            with write_new(file_path, owner=(uid, gid), perms=0o600, encoding='utf-8') as f:
                 f.write(ccf['content'])