From 7a0a2d0e48664bd6b6970ffcb1d30c739372b3a7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 25 Aug 2026 10:35:35 -0400 Subject: [PATCH] Create a copy instead of rename of /etc/hosts By copying, we leave the /etc/hosts with original ownership/permissions/etc. Otherwise we create a new /etc/hosts, which is subject to new permissions and such. --- confluent_client/bin/confluent2hosts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/confluent2hosts b/confluent_client/bin/confluent2hosts index 5a212a33..6c0d0157 100644 --- a/confluent_client/bin/confluent2hosts +++ b/confluent_client/bin/confluent2hosts @@ -3,6 +3,7 @@ import argparse import os import re import signal +import shutil import sys try: signal.signal(signal.SIGPIPE, signal.SIG_DFL) @@ -205,7 +206,7 @@ def main(): merger.add_entry(ipbynode[node], namesbynode[node]) if os.path.exists('/etc/hosts'): merger.read_target('/etc/hosts') - os.rename('/etc/hosts', '/etc/hosts.confluentbkup') + shutil.copy2('/etc/hosts', '/etc/hosts.confluentbkup') merger.write_out('/etc/hosts')