]> 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)
committerAdam King <adking@redhat.com>
Thu, 31 Aug 2023 17:35:13 +0000 (13:35 -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>
(cherry picked from commit 642985c6894f8f62a313cd70c915d066f9c53d6e)

src/cephadm/cephadm.py

index 8202304296f3eb3de1a10017c9c188257450c84c..0ee95a2fcee7b0b4cced41898be66c7d9ceb56c2 100755 (executable)
@@ -2964,9 +2964,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'])