From ec42a2aad8ab9f5e7c72eddce63c8f793124a27f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 14 Aug 2020 07:16:04 -0400 Subject: [PATCH] Fix confluentdbrestore in non-root environments --- confluent_server/bin/confluentdbutil | 8 ++++++++ confluent_server/confluent/config/configmanager.py | 1 + 2 files changed, 9 insertions(+) diff --git a/confluent_server/bin/confluentdbutil b/confluent_server/bin/confluentdbutil index 2bdfa5b2..884a1b8f 100755 --- a/confluent_server/bin/confluentdbutil +++ b/confluent_server/bin/confluentdbutil @@ -62,11 +62,19 @@ if args[0] == 'restore': if pid is not None: print("Confluent is running, must shut down to restore db") sys.exit(1) + stinf = os.stat('/etc/confluent') + owner = stinf.st_uid + group = stinf.st_gid password = options.password if options.interactivepassword: password = getpass.getpass('Enter password to restore backup: ') try: cfm.restore_db_from_directory(dumpdir, password) + if owner != 0: + for targdir in os.walk('/etc/confluent'): + os.chown(targdir[0], owner, group) + for f in targdir[2]: + os.chown(os.patht.join(targdir[0], f), owner, group) except Exception as e: print(str(e)) sys.exit(1) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 9a9ae4e5..495c242a 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -2674,6 +2674,7 @@ def restore_db_from_directory(location, password): with open(os.path.join(location, 'main.json'), 'r') as cfgfile: cfgdata = cfgfile.read() ConfigManager(tenant=None)._load_from_json(cfgdata) + ConfigManager.wait_for_sync(True) def dump_db_to_directory(location, password, redact=None, skipkeys=False):