diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 5d7ce69e0..36d8ab9ad 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -112,7 +112,7 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None): path_variable = '%s:/bin' % path_variable # Install grub - utils.execute('chroot %(path)s /bin/bash -c ' + utils.execute('chroot %(path)s /bin/sh -c ' '"/usr/sbin/%(bin)s-install %(dev)s"' % {'path': path, 'bin': binary_name, 'dev': device}, shell=True, env_variables={'PATH': path_variable}) @@ -125,13 +125,13 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None): # the default file to be copied, destination file name, and # prevents NVRAM from being updated. if efi_partition: - utils.execute('chroot %(path)s /bin/bash -c ' + utils.execute('chroot %(path)s /bin/sh -c ' '"/usr/sbin/%(bin)s-install %(dev)s --removable"' % {'path': path, 'bin': binary_name, 'dev': device}, shell=True, env_variables={'PATH': path_variable}) # Generate the grub configuration file - utils.execute('chroot %(path)s /bin/bash -c ' + utils.execute('chroot %(path)s /bin/sh -c ' '"/usr/sbin/%(bin)s-mkconfig -o ' '/boot/%(bin)s/grub.cfg"' % {'path': path, 'bin': binary_name}, shell=True, diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py index 5591d7699..7e7fa59b3 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -86,11 +86,11 @@ class TestImageExtension(test_base.BaseTestCase): self.fake_dir + '/proc'), mock.call('mount', '-t', 'sysfs', 'none', self.fake_dir + '/sys'), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-install %s"' % (self.fake_dir, self.fake_dev)), shell=True, env_variables={'PATH': '/sbin:/bin'}), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-mkconfig -o ' '/boot/grub/grub.cfg"' % self.fake_dir), shell=True, @@ -131,15 +131,15 @@ class TestImageExtension(test_base.BaseTestCase): self.fake_dir + '/sys'), mock.call('mount', self.fake_efi_system_part, self.fake_dir + '/boot/efi'), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-install %s"' % (self.fake_dir, self.fake_dev)), shell=True, env_variables={'PATH': '/sbin:/bin'}), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-install %s --removable"' % (self.fake_dir, self.fake_dev)), shell=True, env_variables={'PATH': '/sbin:/bin'}), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-mkconfig -o ' '/boot/grub/grub.cfg"' % self.fake_dir), shell=True, @@ -191,15 +191,15 @@ class TestImageExtension(test_base.BaseTestCase): self.fake_dir + '/sys'), mock.call('mount', self.fake_efi_system_part, self.fake_dir + '/boot/efi'), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-install %s"' % (self.fake_dir, self.fake_dev)), shell=True, env_variables={'PATH': '/sbin:/bin'}), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-install %s --removable"' % (self.fake_dir, self.fake_dev)), shell=True, env_variables={'PATH': '/sbin:/bin'}), - mock.call(('chroot %s /bin/bash -c ' + mock.call(('chroot %s /bin/sh -c ' '"/usr/sbin/grub-mkconfig -o ' '/boot/grub/grub.cfg"' % self.fake_dir), shell=True, diff --git a/releasenotes/notes/no-bash-for-grub-c38369af8cc7cf26.yaml b/releasenotes/notes/no-bash-for-grub-c38369af8cc7cf26.yaml new file mode 100644 index 000000000..7855b6e03 --- /dev/null +++ b/releasenotes/notes/no-bash-for-grub-c38369af8cc7cf26.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Ironic Python Agent no longer requires 'bash' to be present in the user + image when preparing the partition image for local boot, + and uses default 'sh' interpreter to run 'grub'-related commands instead.