diff --git a/0009-lvmdbusd-Correct-conditional-for-lvm-child-process-r.patch b/0009-lvmdbusd-Correct-conditional-for-lvm-child-process-r.patch new file mode 100644 index 0000000..e32528a --- /dev/null +++ b/0009-lvmdbusd-Correct-conditional-for-lvm-child-process-r.patch @@ -0,0 +1,30 @@ +From f7277061859740712b67ef6b229c2fc07482ef16 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 25 May 2022 15:51:14 -0500 +Subject: [PATCH 1/9] lvmdbusd: Correct conditional for lvm child process + running + +Poll returns None when process is running, else exit value. If poll returns +0 we will fail to exit the select loop. + +(cherry picked from commit 37733cd4eb5116db371ac1ae6e971e3c336c3ddb) +--- + daemons/lvmdbusd/lvm_shell_proxy.py.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in +index 7816daa8b..78fe1e422 100644 +--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in ++++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in +@@ -75,7 +75,7 @@ class LVMShellProxy(object): + stderr += read_decoded(self.lvm_shell.stderr) + + # Check to see if the lvm process died on us +- if self.lvm_shell.poll(): ++ if self.lvm_shell.poll() is not None: + raise Exception(self.lvm_shell.returncode, "%s" % stderr) + + if stdout.endswith(SHELL_PROMPT): +-- +2.37.1 + diff --git a/0010-lvmdbusd-Simplify-child-process-env.patch b/0010-lvmdbusd-Simplify-child-process-env.patch new file mode 100644 index 0000000..09ee5fd --- /dev/null +++ b/0010-lvmdbusd-Simplify-child-process-env.patch @@ -0,0 +1,30 @@ +From ece4c18a42af8fde41f55fd43e8cc0ca34ab2f7d Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 25 May 2022 15:52:20 -0500 +Subject: [PATCH 2/9] lvmdbusd: Simplify child process env + +We don't need to duplicate the entire env from the parent, supply only what +is needed. + +(cherry picked from commit 58c6c9e9aa8d6aa6d3be14a04ec0f4257b61495e) +--- + daemons/lvmdbusd/lvm_shell_proxy.py.in | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in +index 78fe1e422..10719c67e 100644 +--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in ++++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in +@@ -135,7 +135,8 @@ class LVMShellProxy(object): + self.report_stream = os.fdopen(self.report_fd, 'rb', 0) + + # Setup the environment for using our own socket for reporting +- local_env = copy.deepcopy(os.environ) ++ local_env = {} ++ local_env["LC_ALL"] = "C" + local_env["LVM_REPORT_FD"] = "32" + local_env["LVM_COMMAND_PROFILE"] = "lvmdbusd" + +-- +2.37.1 + diff --git a/0011-lvmdbusd-re-work-lvm-shell-main.patch b/0011-lvmdbusd-re-work-lvm-shell-main.patch new file mode 100644 index 0000000..ad1cc42 --- /dev/null +++ b/0011-lvmdbusd-re-work-lvm-shell-main.patch @@ -0,0 +1,73 @@ +From 6d0ad276260c902dba66df73beac1bafc3f4c254 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 25 May 2022 15:58:15 -0500 +Subject: [PATCH 3/9] lvmdbusd: re-work lvm shell main + +Add an optional single argument "bisect" to use with git bisect for +automation. Normal case is no arguments when running stand-alone. + +(cherry picked from commit b3407b16c1c7b5bff01e3bde4e0f62a2608682f8) +--- + daemons/lvmdbusd/lvm_shell_proxy.py.in | 46 ++++++++++++++++---------- + 1 file changed, 28 insertions(+), 18 deletions(-) + +diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in +index 10719c67e..40639442c 100644 +--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in ++++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in +@@ -238,24 +238,34 @@ class LVMShellProxy(object): + + + if __name__ == "__main__": +- shell = LVMShellProxy() +- in_line = "start" ++ print("USING LVM BINARY: %s " % LVM_CMD) ++ + try: +- while in_line: +- in_line = input("lvm> ") +- if in_line: +- start = time.time() +- ret, out, err = shell.call_lvm(in_line.split()) +- end = time.time() +- +- print(("RC: %d" % ret)) +- print(("OUT:\n%s" % out)) +- print(("ERR:\n%s" % err)) +- +- print("Command = %f seconds" % (end - start)) +- except KeyboardInterrupt: +- pass +- except EOFError: +- pass ++ if len(sys.argv) > 1 and sys.argv[1] == "bisect": ++ shell = LVMShellProxy() ++ shell.exit_shell() ++ else: ++ shell = LVMShellProxy() ++ in_line = "start" ++ try: ++ while in_line: ++ in_line = input("lvm> ") ++ if in_line: ++ start = time.time() ++ ret, out, err = shell.call_lvm(in_line.split()) ++ end = time.time() ++ ++ print(("RC: %d" % ret)) ++ print(("OUT:\n%s" % out)) ++ print(("ERR:\n%s" % err)) ++ ++ print("Command = %f seconds" % (end - start)) ++ except KeyboardInterrupt: ++ pass ++ except EOFError: ++ pass + except Exception: + traceback.print_exc(file=sys.stdout) ++ sys.exit(1) ++ ++ sys.exit(0) +-- +2.37.1 + diff --git a/0012-lvmdbusd-Add-debug-output-for-which-lvm-binary-is-us.patch b/0012-lvmdbusd-Add-debug-output-for-which-lvm-binary-is-us.patch new file mode 100644 index 0000000..ba9c433 --- /dev/null +++ b/0012-lvmdbusd-Add-debug-output-for-which-lvm-binary-is-us.patch @@ -0,0 +1,26 @@ +From a9ca83b880c19a72d6e00e13b6a638fb11630819 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 25 May 2022 15:59:11 -0500 +Subject: [PATCH 4/9] lvmdbusd: Add debug output for which lvm binary is used + +(cherry picked from commit 51d9b686c08d963c61898d407d15abf39f129d72) +--- + daemons/lvmdbusd/main.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py +index b0a82d492..1e717ef69 100644 +--- a/daemons/lvmdbusd/main.py ++++ b/daemons/lvmdbusd/main.py +@@ -127,6 +127,8 @@ def main(): + log_error("You cannot specify --lvmshell and --nojson") + sys.exit(1) + ++ log_debug("Using lvm binary: %s" % cfg.LVM_CMD) ++ + # We will dynamically add interfaces which support vdo if it + # exists. + cfg.vdo_support = supports_vdo() +-- +2.37.1 + diff --git a/0013-lvmdbusd-Change-unit-test-vdo-minimum-size.patch b/0013-lvmdbusd-Change-unit-test-vdo-minimum-size.patch new file mode 100644 index 0000000..5252f4e --- /dev/null +++ b/0013-lvmdbusd-Change-unit-test-vdo-minimum-size.patch @@ -0,0 +1,73 @@ +From aa5ec0804d151e5951c4516c3bc08d37e2494349 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 25 May 2022 16:03:27 -0500 +Subject: [PATCH 5/9] lvmdbusd: Change unit test vdo minimum size + +(cherry picked from commit 47c61907b4adbdead50f5bb5ac95c0f5d0fe263e) +--- + test/dbus/lvmdbustest.py | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py +index 6d692223f..3eef77fd7 100755 +--- a/test/dbus/lvmdbustest.py ++++ b/test/dbus/lvmdbustest.py +@@ -23,6 +23,9 @@ import os + + g_tmo = 0 + ++# Approx. min size ++VDO_MIN_SIZE = mib(8192) ++ + # Prefix on created objects to enable easier clean-up + g_prefix = os.getenv('PREFIX', '') + +@@ -1155,7 +1158,7 @@ class TestDbusService(unittest.TestCase): + return + + # This may not pass +- for i in [48, 64, 128]: ++ for i in [64, 128]: + yes = self._test_expired_timer(i) + if yes: + break +@@ -1907,8 +1910,8 @@ class TestDbusService(unittest.TestCase): + vdo_pool_object_path = self.handle_return( + vg_proxy.VgVdo.CreateVdoPoolandLv( + pool_name, lv_name, +- dbus.UInt64(mib(4096)), # Appears to be minimum size +- dbus.UInt64(mib(8192)), ++ dbus.UInt64(VDO_MIN_SIZE), ++ dbus.UInt64(VDO_MIN_SIZE * 2), + dbus.Int32(g_tmo), + EOD)) + +@@ -1950,7 +1953,7 @@ class TestDbusService(unittest.TestCase): + vg_proxy = self._vg_create(vg_prefix="vdo_conv_") + lv = self._test_lv_create( + vg_proxy.Vg.LvCreate, +- (dbus.String(pool_name), dbus.UInt64(mib(4096)), ++ (dbus.String(pool_name), dbus.UInt64(VDO_MIN_SIZE), + dbus.Array([], signature='(ott)'), dbus.Int32(g_tmo), + EOD), vg_proxy.Vg, LV_BASE_INT) + lv_obj_path = self._lookup("%s/%s" % (vg_proxy.Vg.Name, pool_name)) +@@ -1959,7 +1962,7 @@ class TestDbusService(unittest.TestCase): + vdo_pool_path = self.handle_return( + vg_proxy.VgVdo.CreateVdoPool( + dbus.ObjectPath(lv.object_path), lv_name, +- dbus.UInt64(mib(8192)), ++ dbus.UInt64(VDO_MIN_SIZE), + dbus.Int32(g_tmo), + EOD)) + +@@ -2083,6 +2086,7 @@ if __name__ == '__main__': + std_err_print('\n*** Testing only lvm shell mode ***\n') + + for g_tmo in [0, 15]: ++ std_err_print('Testing TMO=%d\n' % g_tmo) + if mode == 0: + if set_execution(False, r): + r.register_result(unittest.main(exit=False)) +-- +2.37.1 + diff --git a/0014-lvmdbusd-Fix-env-variable-LVM_DBUSD_TEST_MODE.patch b/0014-lvmdbusd-Fix-env-variable-LVM_DBUSD_TEST_MODE.patch new file mode 100644 index 0000000..7af9d4d --- /dev/null +++ b/0014-lvmdbusd-Fix-env-variable-LVM_DBUSD_TEST_MODE.patch @@ -0,0 +1,54 @@ +From d978fe593b3c75d4b5b66d743b4f5c3632861559 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 25 May 2022 16:21:14 -0500 +Subject: [PATCH 6/9] lvmdbusd: Fix env variable LVM_DBUSD_TEST_MODE + +Make it more logical. + +(cherry picked from commit b3d7aff6a3a8fd55790f61b9b0b33d599841030b) +--- + test/dbus/lvmdbustest.py | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py +index 3eef77fd7..d876a1748 100755 +--- a/test/dbus/lvmdbustest.py ++++ b/test/dbus/lvmdbustest.py +@@ -40,9 +40,10 @@ pv_device_list = os.getenv('LVM_DBUSD_PV_DEVICE_LIST', None) + + # Default is to test all modes + # 0 == Only test fork & exec mode +-# 1 == Test both fork & exec & lvm shell mode (default) ++# 1 == Only test lvm shell mode ++# 2 == Test both fork & exec & lvm shell mode (default) + # Other == Test just lvm shell mode +-test_shell = os.getenv('LVM_DBUSD_TEST_MODE', 1) ++test_shell = os.getenv('LVM_DBUSD_TEST_MODE', 2) + + # LVM binary to use + LVM_EXECUTABLE = os.getenv('LVM_BINARY', '/usr/sbin/lvm') +@@ -2081,16 +2082,19 @@ if __name__ == '__main__': + if mode == 0: + std_err_print('\n*** Testing only lvm fork & exec test mode ***\n') + elif mode == 1: ++ std_err_print('\n*** Testing only lvm shell mode ***\n') ++ elif mode == 2: + std_err_print('\n*** Testing fork & exec & lvm shell mode ***\n') + else: +- std_err_print('\n*** Testing only lvm shell mode ***\n') ++ std_err_print("Unsupported \"LVM_DBUSD_TEST_MODE\"=%d, [0-2] valid" % mode) ++ sys.exit(1) + + for g_tmo in [0, 15]: + std_err_print('Testing TMO=%d\n' % g_tmo) + if mode == 0: + if set_execution(False, r): + r.register_result(unittest.main(exit=False)) +- elif mode == 2: ++ elif mode == 1: + if set_execution(True, r): + r.register_result(unittest.main(exit=False)) + else: +-- +2.37.1 + diff --git a/0015-lvmdbusd-Remove-the-use-of-sub-shell-for-lvm-shell.patch b/0015-lvmdbusd-Remove-the-use-of-sub-shell-for-lvm-shell.patch new file mode 100644 index 0000000..1eb4144 --- /dev/null +++ b/0015-lvmdbusd-Remove-the-use-of-sub-shell-for-lvm-shell.patch @@ -0,0 +1,62 @@ +From 8e724393079784edbf779678df6937dd838c4149 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Thu, 26 May 2022 10:44:02 -0500 +Subject: [PATCH 7/9] lvmdbusd: Remove the use of sub shell for lvm shell + +This reduces the number of processes and improves security. + +(cherry picked from commit 7a2090655d3ab5abde83b981594ed527e2a7f1f7) +--- + daemons/lvmdbusd/lvm_shell_proxy.py.in | 24 +++++++++++------------- + 1 file changed, 11 insertions(+), 13 deletions(-) + +diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in +index 40639442c..1a5051a92 100644 +--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in ++++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in +@@ -129,31 +129,29 @@ class LVMShellProxy(object): + except FileExistsError: + pass + +- # We have to open non-blocking as the other side isn't open until +- # we actually fork the process. ++ # Open the fifo for use to read and for lvm child process to write to. + self.report_fd = os.open(tmp_file, os.O_NONBLOCK) + self.report_stream = os.fdopen(self.report_fd, 'rb', 0) ++ lvm_fd = os.open(tmp_file, os.O_WRONLY) + +- # Setup the environment for using our own socket for reporting +- local_env = {} +- local_env["LC_ALL"] = "C" +- local_env["LVM_REPORT_FD"] = "32" +- local_env["LVM_COMMAND_PROFILE"] = "lvmdbusd" +- +- # Disable the abort logic if lvm logs too much, which easily happens +- # when utilizing the lvm shell. +- local_env["LVM_LOG_FILE_MAX_LINES"] = "0" ++ # Set up the environment for using our own socket for reporting and disable the abort ++ # logic if lvm logs too much, which easily happens when utilizing the lvm shell. ++ local_env = {"LC_ALL": "C", "LVM_REPORT_FD": "%s" % lvm_fd, "LVM_COMMAND_PROFILE": "lvmdbusd", ++ "LVM_LOG_FILE_MAX_LINES": "0"} + + # run the lvm shell + self.lvm_shell = subprocess.Popen( +- [LVM_CMD + " 32>%s" % tmp_file], ++ [LVM_CMD], + stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=local_env, +- stderr=subprocess.PIPE, close_fds=True, shell=True) ++ stderr=subprocess.PIPE, close_fds=True, pass_fds=(lvm_fd,), shell=False) + + try: + make_non_block(self.lvm_shell.stdout) + make_non_block(self.lvm_shell.stderr) + ++ # Close our copy of the lvm_fd, child process is open in its process space ++ os.close(lvm_fd) ++ + # wait for the first prompt + errors = self._read_until_prompt(no_output=True)[2] + if errors and len(errors): +-- +2.37.1 + diff --git a/0016-lvmdbusd-Job-prop.-Get-GetAll-exec.-immediately.patch b/0016-lvmdbusd-Job-prop.-Get-GetAll-exec.-immediately.patch new file mode 100644 index 0000000..270d741 --- /dev/null +++ b/0016-lvmdbusd-Job-prop.-Get-GetAll-exec.-immediately.patch @@ -0,0 +1,42 @@ +From 70714b7fbe4d6f1ee943614cc26a990f20e35450 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Mon, 6 Jun 2022 09:51:54 -0500 +Subject: [PATCH 8/9] lvmdbusd: Job prop. Get/GetAll exec. immediately + +This allows API user the ability to check on the status of a long running +job without blocking in the request queue. + +(cherry picked from commit eee89a941eb4e63865356cfe9e513c24cfa8e0f9) +--- + daemons/lvmdbusd/job.py | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/daemons/lvmdbusd/job.py b/daemons/lvmdbusd/job.py +index 988b1147a..7629cafc7 100644 +--- a/daemons/lvmdbusd/job.py ++++ b/daemons/lvmdbusd/job.py +@@ -226,3 +226,21 @@ class Job(AutomatedProperties): + def Uuid(self): + import uuid + return uuid.uuid1() ++ ++ # Override the property "getters" implementation for the job interface, so a user can query a job while the queue ++ # is processing items. Originally all the property get methods were this way, but we changed this in ++ # e53454d6de07de56736303dd2157c3859f6fa848 ++ ++ # Properties ++ # noinspection PyUnusedLocal ++ @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, ++ in_signature='ss', out_signature='v') ++ def Get(self, interface_name, property_name): ++ # Note: If we get an exception in this handler we won't know about it, ++ # only the side effect of no returned value! ++ return AutomatedProperties._get_prop(self, interface_name, property_name) ++ ++ @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, ++ in_signature='s', out_signature='a{sv}') ++ def GetAll(self, interface_name): ++ return AutomatedProperties._get_all_prop(self, interface_name) +-- +2.37.1 + diff --git a/0017-lvmdbusd-Don-t-require-lvm-prompt-for-shell.patch b/0017-lvmdbusd-Don-t-require-lvm-prompt-for-shell.patch new file mode 100644 index 0000000..2429858 --- /dev/null +++ b/0017-lvmdbusd-Don-t-require-lvm-prompt-for-shell.patch @@ -0,0 +1,174 @@ +From a3c2dcc3726261d6463ea35102d86863d698021b Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Mon, 6 Jun 2022 09:56:32 -0500 +Subject: [PATCH 9/9] lvmdbusd: Don't require "lvm> " prompt for shell + +Depending on how lvm is compiled, it may not present the "lvm> " prompt +when using the lvm shell. Don't require it to be present. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2090391 +(cherry picked from commit 691494268502ddb20da2a14568984c0fa4f29f50) +--- + daemons/lvmdbusd/lvm_shell_proxy.py.in | 83 +++++++++++++------------- + 1 file changed, 43 insertions(+), 40 deletions(-) + +diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in +index 1a5051a92..e106ca36f 100644 +--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in ++++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in +@@ -19,7 +19,6 @@ import sys + import tempfile + import time + import select +-import copy + + try: + import simplejson as json +@@ -31,8 +30,6 @@ from lvmdbusd.cfg import LVM_CMD + from lvmdbusd.utils import log_debug, log_error, add_no_notify, make_non_block,\ + read_decoded + +-SHELL_PROMPT = "lvm> " +- + + def _quote_arg(arg): + if len(shlex.split(arg)) > 1: +@@ -43,10 +40,11 @@ def _quote_arg(arg): + + class LVMShellProxy(object): + +- # Read until we get prompt back and a result +- # @param: no_output Caller expects no output to report FD +- # Returns stdout, report, stderr (report is JSON!) +- def _read_until_prompt(self, no_output=False): ++ # Read REPORT FD until we have a complete and valid JSON record or give ++ # up trying to get one. ++ # ++ # Returns stdout, report (JSON), stderr ++ def _read_response(self): + stdout = "" + report = "" + stderr = "" +@@ -58,6 +56,7 @@ class LVMShellProxy(object): + # Try reading from all FDs to prevent one from filling up and causing + # a hang. Keep reading until we get the prompt back and the report + # FD does not contain valid JSON ++ + while keep_reading: + try: + rd_fd = [ +@@ -78,32 +77,33 @@ class LVMShellProxy(object): + if self.lvm_shell.poll() is not None: + raise Exception(self.lvm_shell.returncode, "%s" % stderr) + +- if stdout.endswith(SHELL_PROMPT): +- if no_output: +- keep_reading = False +- else: +- cur_report_len = len(report) +- if cur_report_len != 0: +- # Only bother to parse if we have more data +- if prev_report_len != cur_report_len: +- prev_report_len = cur_report_len +- # Parse the JSON if it's good we are done, +- # if not we will try to read some more. +- try: +- report_json = json.loads(report) +- keep_reading = False +- except ValueError: +- pass +- +- if keep_reading: +- extra_passes -= 1 +- if extra_passes <= 0: +- if len(report): +- raise ValueError("Invalid json: %s" % +- report) +- else: +- raise ValueError( +- "lvm returned no JSON output!") ++ cur_report_len = len(report) ++ if cur_report_len != 0: ++ # Only bother to parse if we have more data and the last 2 characters match expected ++ # complete JSON, prevents excessive JSON parsing attempts ++ if prev_report_len != cur_report_len and report[-2:] == "}\n": ++ prev_report_len = cur_report_len ++ ++ # Parse the JSON if it's good we are done, ++ # if not we will try to read some more. ++ try: ++ report_json = json.loads(report) ++ keep_reading = False ++ except ValueError: ++ pass ++ ++ # As long as lvm is spewing something on one of the FDs we will ++ # keep trying. If we get a few timeouts with no activity, and ++ # we don't have valid JSON, we will raise an error. ++ if len(ready) == 0 and keep_reading: ++ extra_passes -= 1 ++ if extra_passes <= 0: ++ if len(report): ++ raise ValueError("Invalid json: %s" % ++ report) ++ else: ++ raise ValueError( ++ "lvm returned no JSON output!") + + except IOError as ioe: + log_debug(str(ioe)) +@@ -118,7 +118,6 @@ class LVMShellProxy(object): + self.lvm_shell.stdin.flush() + + def __init__(self): +- + # Create a temp directory + tmp_dir = tempfile.mkdtemp(prefix="lvmdbus_") + tmp_file = "%s/lvmdbus_report" % (tmp_dir) +@@ -139,6 +138,11 @@ class LVMShellProxy(object): + local_env = {"LC_ALL": "C", "LVM_REPORT_FD": "%s" % lvm_fd, "LVM_COMMAND_PROFILE": "lvmdbusd", + "LVM_LOG_FILE_MAX_LINES": "0"} + ++ # If any env variables contain LVM we will propagate them too ++ for k, v in os.environ.items(): ++ if "LVM" in k: ++ local_env[k] = v ++ + # run the lvm shell + self.lvm_shell = subprocess.Popen( + [LVM_CMD], +@@ -152,10 +156,9 @@ class LVMShellProxy(object): + # Close our copy of the lvm_fd, child process is open in its process space + os.close(lvm_fd) + +- # wait for the first prompt +- errors = self._read_until_prompt(no_output=True)[2] +- if errors and len(errors): +- raise RuntimeError(errors) ++ # Assume we are ready as we may not get the lvm prompt message depending on ++ # if we are using readline or editline. ++ + except: + raise + finally: +@@ -169,7 +172,7 @@ class LVMShellProxy(object): + self._write_cmd('lastlog\n') + + # read everything from the STDOUT to the next prompt +- stdout, report_json, stderr = self._read_until_prompt() ++ stdout, report_json, stderr = self._read_response() + if 'log' in report_json: + error_msg = "" + # Walk the entire log array and build an error string +@@ -203,7 +206,7 @@ class LVMShellProxy(object): + self._write_cmd(cmd) + + # read everything from the STDOUT to the next prompt +- stdout, report_json, stderr = self._read_until_prompt() ++ stdout, report_json, stderr = self._read_response() + + # Parse the report to see what happened + if 'log' in report_json: +-- +2.37.1 + diff --git a/lvm2.spec b/lvm2.spec index 392c43d..491af12 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -81,6 +81,16 @@ Patch6: 0006-exit-with-error-when-devicesfile-name-doesn-t-exist.patch Patch7: 0007-make-generate.patch # BZ 2109351: Patch8: 0008-apply-multipath_component_detection-0-to-duplicate-P.patch +# BZ 2090391: +Patch9: 0009-lvmdbusd-Correct-conditional-for-lvm-child-process-r.patch +Patch10: 0010-lvmdbusd-Simplify-child-process-env.patch +Patch11: 0011-lvmdbusd-re-work-lvm-shell-main.patch +Patch12: 0012-lvmdbusd-Add-debug-output-for-which-lvm-binary-is-us.patch +Patch13: 0013-lvmdbusd-Change-unit-test-vdo-minimum-size.patch +Patch14: 0014-lvmdbusd-Fix-env-variable-LVM_DBUSD_TEST_MODE.patch +Patch15: 0015-lvmdbusd-Remove-the-use-of-sub-shell-for-lvm-shell.patch +Patch16: 0016-lvmdbusd-Job-prop.-Get-GetAll-exec.-immediately.patch +Patch17: 0017-lvmdbusd-Don-t-require-lvm-prompt-for-shell.patch BuildRequires: make BuildRequires: gcc @@ -149,6 +159,15 @@ or more physical volumes and creating one or more logical volumes %patch6 -p1 -b .backup6 %patch7 -p1 -b .backup7 %patch8 -p1 -b .backup8 +%patch9 -p1 -b .backup9 +%patch10 -p1 -b .backup10 +%patch11 -p1 -b .backup11 +%patch12 -p1 -b .backup12 +%patch13 -p1 -b .backup13 +%patch14 -p1 -b .backup14 +%patch15 -p1 -b .backup15 +%patch16 -p1 -b .backup16 +%patch17 -p1 -b .backup17 %build %global _default_pid_dir /run @@ -721,6 +740,7 @@ An extensive functional testsuite for LVM2. %changelog * Fri Jul 29 2022 Marian Csontos - 2.03.16-3 - Fix effect of setting multipath_component_detection to 0. +- Fix lvmdbusd using lvm shell with editline. * Thu Jul 14 2022 Marian Csontos - 2.03.16-2 - Exit with error when --devicesfile used does not exist.