QubesOS / qubes-issues

The Qubes OS Project issue tracker
https://www.qubes-os.org/doc/issue-tracking/
526 stars 46 forks source link

Builder V2 fails to cache packages that have special chars for bash #9322

Closed ben-grande closed 11 hours ago

ben-grande commented 1 week ago

How to file a helpful issue

Qubes OS release

R4.2, Builder V2 commit bdd84da922fcd65ba3dc4df9a4161b67869374ea

Brief summary

I tried to escape the packages with

But each time it fails at a different stage. It is passed directly to the shell without special treatment. Each package name should be quoted to avoid shell syntax errors.

Steps to reproduce

Add the following file to cache.yml

Include the cache.yml:

include:
  - cache.yml

Try to init the cache:

./qb package init-cache

Expected behavior

Packages cached suffesfully.

Actual behavior

output: bash: -c: line 1: syntax error near unexpected token `('
output: bash: -c: line 1: `sed -i 's#@BUILDER_DIR@#/tmp/133920427104624f9794bb5/builder#g' /tmp/133920427104624f9 +794bb5/builder/plugins/chroot_rpm/mock/fedora-37-x86_64.cfg;sudo --preserve-env=DIST,PACKAGE_SET,USE_QUBES_REPO_VERSION /usr/libexec/mock/mock --root /tmp/133920427104624f9794bb5/builder/pl +ugins/chroot_rpm/mock/fedora-37-x86_64.cfg --disablerepo=builder-local --isolation=nspawn --verbose --init&&sudo --preserve-env=DIST,PACKAGE_SET,USE_QUBES_REPO_VERSION /usr/libexec/mock/moc +k --root /tmp/133920427104624f9794bb5/builder/plugins/chroot_rpm/mock/fedora-37-x86_64.cfg --disablerepo=builder-local --isolation=nspawn --verbose --install GraphicsMagick --install acpica +-tools --install asciidoc --install audit-libs-devel --install augeas --install autoconf --install automake --install bash --install bash-completion --install bc --install bison --install b +usybox --install bzip2-devel --install ccache --install checkpolicy --install clang --install clang-analyzer --install coreutils --install cppcheck --install cyrus-sasl-devel --install desk +top-backgrounds-basic --install desktop-file-utils --install dev86 --install device-mapper-devel --install dmidecode --install docbook-style-xsl --install dracut --install dwarves --install + e2fsprogs-devel --install ebtables --install edk2-ovmf --install elfutils-libelf-devel --install firewalld-filesystem --install flex --install freetype-devel --install fuse-devel --install + gawk --install gcc --install gcc-c++ --install gcc-plugin-devel --install gcc-x86_64-linux-gnu --install gdk-pixbuf2-devel --install genisoimage --install gettext --install gettext-devel - +-install git --install git-core --install glade-devel --install glib2-devel --install glib2-doc --install glusterfs-api-devel --install glusterfs-devel --install gnome-backgrounds --install + gnupg2 --install gnutls-devel --install gobject-introspection-devel --install google-roboto-fonts --install gsettings-desktop-schemas --install gtk-doc --install gtk3-devel --install gtk3- +devel-docs --install help2man --install inkscape --install intltool --install iptables --install iscsi-initiator-utils --install json-c-devel --install kernel-headers --install libGL-devel  +--install libGLU-devel --install libX11-devel --install libXScrnSaver-devel --install libXext-devel --install libXi-devel --install libXinerama-devel --install libXpm-devel --install libXra +ndr-devel --install libXt-devel --install libXxf86vm-devel --install libacl-devel --install libarchive-devel --install libasan --install libattr-devel --install libblkid-devel --install lib +cap-ng-devel --install libconfig-devel --install libcurl-devel --install libfdt-devel --install libftdi-devel --install libglade2-devel --install libgle-devel --install libgnomekbd-devel -- +install libidn-devel --install libiscsi-devel --install libjaylink-devel --install libjpeg-devel --install libnl3-devel --install libnotify-devel --install libpcap-devel --install libpciacc +ess-devel --install libpng-devel --install librados-devel --install librbd-devel --install libselinux-devel --install libssh-devel --install libssh2-devel --install libtasn1-devel --install + libtimezonemap-devel --install libtirpc-devel --install libtool --install libubsan --install libusb-compat-0.1-devel --install libusb-devel --install libusbx-devel --install libuuid-devel  +--install libvirt-devel --install libvirt-python3 --install libwsman-devel --install libxklavier-devel --install libxml2 --install libxml2-devel --install libxslt --install lsb-core-noarch  +--install lvm2 --install make --install meson --install mingw32-binutils --install mingw32-curl --install mingw32-dlfcn --install mingw32-filesystem --install mingw32-gcc --install mingw32- +gettext --install mingw32-glib2 --install mingw32-gnutls --install mingw32-libgcrypt --install mingw32-libgpg-error --install mingw32-libssh2 --install mingw32-libxml2 --install mingw32-por +tablexdr --install mingw64-binutils --install mingw64-curl --install mingw64-dlfcn --install mingw64-filesystem --install mingw64-gcc --install mingw64-gcc-c++ --install mingw64-gettext --i +nstall mingw64-glib2 --install mingw64-gnutls --install mingw64-libgcrypt --install mingw64-libgpg-error --install mingw64-libssh2 --install mingw64-libxml2 --install mingw64-portablexdr -- +install mingw64-winpthreads-static --install module-init-tools --install mono-core --install ncurses-devel --install netcf-devel --install netpbm-progs --install nfs-utils --install ninja-b +uild --install numactl-devel --install numad --install ocaml --install openssl --install openssl-devel --install pam-devel --install pandoc --install pango-devel --install parted-devel --in +stall pciutils-devel --install perl(Data::Dumper) --install perl(Pod::Man) --install perl(diagnostics) --install perl(strict) --install perl-generators --install perl-interpreter --install  +pesign --install pkgconfig --install pkgconfig(gdk-pixbuf-2.0) --install pkgconfig(gio-2.0) --install pkgconfig(gmodule-2.0) --install pkgconfig(gtk+-3.0) --install pkgconfig(libavcodec) -- +install pkgconfig(libavformat) --install pkgconfig(libavutil) --install pkgconfig(libcap) --install pkgconfig(libkmod) --install pkgconfig(libswresample) --install pkgconfig(libswscale) --i +nstall pkgconfig(libsystemd) --install pkgconfig(libxml-2.0) --install pkgconfig(x11) --install pkgconfig(x11-xcb) --install pkgconfig(xcb) --install pkgconfig(xcb-aux) --install pkgconfig( +xcb-shm) --install pkgconfig(xft) --install polkit --install pulseaudio-libs-devel --install pyproject-rpm-macros --install python-nautilus-common-files --install python-rpm-macros --instal +l python2-rpm-macros --install python2-setuptools --install python3 --install python3-PyQt5-devel --install python3-PyYAML --install python3-dbus --install python3-devel --install python3-d +ocutils --install python3-lxml --install python3-pytest --install python3-recommonmark --install python3-rpm-macros --install python3-setuptools --install python3-sphinx --install python3di +st(distro) --install python3dist(jinja2) --install python3dist(jmespath) --install python3dist(looseversion) --install python3dist(markupsafe) --install python3dist(packaging) --install pyt +hon3dist(pip) --install python3dist(psutil) --install python3dist(pycryptodomex) --install python3dist(pyyaml) --install python3dist(pyzmq) --install python3dist(requests) --install python3 +dist(setuptools) --install python3dist(sphinx) --install python3dist(wheel) --install qt5-devel --install qt5-linguist --install qt5-qtbase-devel --install readline-devel --install rpcgen - +-install rpm-devel --install rpm-libs --install rust-packaging --install s390utils-devel --install sanlock-devel --install scrub --install seabios-bin --install sed --install selinux-policy + --install selinux-policy-devel --install squashfs-tools --install svn --install systemd --install systemd-devel --install systemd-rpm-macros --install systemd-units --install systemtap-sdt +-devel --install texinfo --install transfig --install util-linux --install wine --install winetricks --install wireshark-devel --install xen-devel --install xorg-x11-proto-devel --install x +z-devel --install yajl-devel --install zlib-devel'
fepitre commented 1 week ago

Try that:

diff --git a/qubesbuilder/plugins/chroot_rpm/__init__.py b/qubesbuilder/plugins/chroot_rpm/__init__.py
index 5b7d31c..ed9b7af 100644
--- a/qubesbuilder/plugins/chroot_rpm/__init__.py
+++ b/qubesbuilder/plugins/chroot_rpm/__init__.py
@@ -145,7 +145,7 @@ class RPMChrootPlugin(RPMDistributionPlugin, ChrootPlugin):
                 )
             ]
             for package in additional_packages:
-                mock_cmd += ["--install", package]
+                mock_cmd += ["--install", f"'{package}'"]
             cmd.append(" ".join(mock_cmd))
             try:
                 executor.run(
ben-grande commented 1 week ago

Thank you, with that fix, it worked!