From 8ef91c16c07968b7bd4839045278f1c4298cd663 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 5 Apr 2022 09:35:05 -0400 Subject: [PATCH] Do not let an existing /var/lib/confluent block the requisite chown --- confluent_server/bin/osdeploy | 8 ++------ confluent_server/confluent/util.py | 8 ++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/confluent_server/bin/osdeploy b/confluent_server/bin/osdeploy index 97281f94..d3f68647 100644 --- a/confluent_server/bin/osdeploy +++ b/confluent_server/bin/osdeploy @@ -255,12 +255,8 @@ def initialize(cmdset): sys.exit(1) if cmdset.t or cmdset.s or cmdset.a or cmdset.u: neededuid = os.stat('/etc/confluent').st_uid - try: - os.makedirs('/var/lib/confluent') - os.chown('/var/lib/confluent', neededuid, -1) - except OSError as e: - if e.errno != 17: - raise + util.mkdirp('/var/lib/confluent') + os.chown('/var/lib/confluent', neededuid, -1) if cmdset.u: didsomething = True if not glob.glob('/root/.ssh/*.pub'): diff --git a/confluent_server/confluent/util.py b/confluent_server/confluent/util.py index e3f5bfb3..52726302 100644 --- a/confluent_server/confluent/util.py +++ b/confluent_server/confluent/util.py @@ -29,6 +29,14 @@ import struct import eventlet.green.subprocess as subprocess +def mkdirp(path): + try: + os.makedirs(path) + except OSError as e: + if e.errno != 17: + raise + + def run(cmd): process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate()