diff options
Diffstat (limited to 'debian/patches')
4 files changed, 140 insertions, 0 deletions
diff --git a/debian/patches/0001-fix-libvirt-connection-plugin-warning.patch b/debian/patches/0001-fix-libvirt-connection-plugin-warning.patch new file mode 100644 index 000000000..d3daee66b --- /dev/null +++ b/debian/patches/0001-fix-libvirt-connection-plugin-warning.patch @@ -0,0 +1,22 @@ +Description: Fix libvirt connection plugin warning +Origin: upstream, https://github.com/ansible-collections/community.libvirt/pull/147 +Forwarded: not-needed +Reviewed-by: Lee Garrett <debian@rocketjump.eu> +Last-Update: 2023-07-22 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- /dev/null ++++ b/ansible_collections/community/libvirt/changelogs/fragments/147_fix_qemu_remote_target_warning.yml +@@ -0,0 +1,2 @@ ++bugfixes: ++ - libvirt_qemu - connection plugin threw a warning about an improperly configured remote target. Fix adds `inventory_hostname` to `options.remote_addr.vars` (https://github.com/ansible-collections/community.libvirt/pull/147). +--- a/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py ++++ b/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py +@@ -29,6 +29,7 @@ + default: inventory_hostname + vars: + - name: ansible_host ++ - name: inventory_hostname + executable: + description: + - Shell to use for execution inside container. diff --git a/debian/patches/0002-fix-libvirt-encoding-errors-on-windows-guests.patch b/debian/patches/0002-fix-libvirt-encoding-errors-on-windows-guests.patch new file mode 100644 index 000000000..4c8e2926c --- /dev/null +++ b/debian/patches/0002-fix-libvirt-encoding-errors-on-windows-guests.patch @@ -0,0 +1,35 @@ +From fb6123b5419dee8de0bd739383ee1c67ad596216 Mon Sep 17 00:00:00 2001 +From: Lee Garrett <lgarrett@rocketjump.eu> +Date: Fri, 1 Sep 2023 14:35:15 +0200 +Subject: [PATCH 1/2] Fix encoding errors on Windows guests (fixes: #156) + +On Windows guests the default encoding will be set to whatever +default legacy encoding, not utf-8. This issue isn't apparent on English locale +Windows guests, as there the encodings (ISO-8859-1, utf-8) happen to coincide. + +However, on e.g. German Windows guests this will cause an encoding error when +reading any output from there. + +This patch ensures that the proper encoding is set on every command. +--- + plugins/connection/libvirt_qemu.py | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py ++++ b/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py +@@ -161,6 +161,10 @@ + # prompt that will not occur + sudoable = False + ++ # Make sure our first command is to set the console encoding to ++ # utf-8, this must be done via chcp to get utf-8 (65001) ++ cmd = ' '.join(["chcp.com", "65001", self._shell._SHELL_REDIRECT_ALLNULL, self._shell._SHELL_AND, cmd]) ++ + # Generate powershell commands + cmd_args_list = self._shell._encode_script(cmd, as_list=True, strict_mode=False, preserve_rc=False) + +--- /dev/null ++++ b/ansible_collections/community/libvirt/changelogs/fragments/156_fix_windows_encoding.yml +@@ -0,0 +1,2 @@ ++bugfixes: ++ - libvirt_qemu - fix encoding errors on Windows guests for non-ASCII return values (https://github.com/ansible-collections/community.libvirt/pull/157) diff --git a/debian/patches/0003-fix-libvirt-path-resolution.patch b/debian/patches/0003-fix-libvirt-path-resolution.patch new file mode 100644 index 000000000..3153b6fd3 --- /dev/null +++ b/debian/patches/0003-fix-libvirt-path-resolution.patch @@ -0,0 +1,80 @@ +Description: Fix issue with ansible.builtin.copy when using libvirt connection plugin + The libvirt connection plugin is unable to resolve "~", leading to files copied + to literal /~/ansible-tmp/, and thus many modules failing. +Author: antonc42 +Origin: upstream, https://github.com/ansible-collections/community.libvirt/pull/162 +Bug: https://github.com/ansible-collections/community.libvirt/issues/161 +Applied-Upstream: not yet +Reviewed-by: Lee Garrett <debian@rocketjump.eu> +Last-Update: 2023-10-20 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- /dev/null ++++ b/ansible_collections/community/libvirt/changelogs/fragments/161_fix_resolve_tilde.yml +@@ -0,0 +1,2 @@ ++bugfixes: ++ - libvirt_qemu - fix path resolution of tilde (~) used to represent remote user's homedir +--- a/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py ++++ b/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py +@@ -46,6 +46,7 @@ + + import base64 + import json ++import re + import shlex + import time + import traceback +@@ -99,6 +100,7 @@ + super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs) + + self._host = self._play_context.remote_addr ++ self._user_homedir = None + + # Windows operates differently from a POSIX connection/shell plugin, + # we need to set various properties to ensure SSH on Windows continues +@@ -147,6 +149,21 @@ + display.vvv(u"ESTABLISH {0} CONNECTION".format(self.transport), host=self._host) + self._connected = True + ++ @property ++ def user_homedir(self): ++ """ the resolved user homedir on the remote """ ++ if self._user_homedir: ++ return self._user_homedir ++ exitcode, stdout, stderr = self.exec_command("/bin/sh -c 'getent passwd $(id -un) | cut -d: -f6'") ++ self._user_homedir = to_text(stdout).strip() ++ return self._user_homedir ++ ++ def _resolve_tilde(self, string): ++ """ resolve file paths or commands that begin with '~/' to the remote user's homedir """ ++ if re.search(r"~\/", string): ++ return re.sub(r"~\/", self.user_homedir + r"/", string) ++ return string ++ + def exec_command(self, cmd, in_data=None, sudoable=True): + """ execute a command on the virtual machine host """ + super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) +@@ -154,6 +171,7 @@ + self._display.vvv(u"EXEC {0}".format(cmd), host=self._host) + + cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict')) ++ cmd_args_list = list(map(self._resolve_tilde, cmd_args_list)) + + if getattr(self._shell, "_IS_WINDOWS", False): + # Become method 'runas' is done in the wrapper that is executed, +@@ -242,6 +260,7 @@ + def put_file(self, in_path, out_path): + ''' transfer a file from local to domain ''' + super(Connection, self).put_file(in_path, out_path) ++ out_path = self._resolve_tilde(out_path) + display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._host) + + if not exists(to_bytes(in_path, errors='surrogate_or_strict')): +@@ -304,6 +323,7 @@ + def fetch_file(self, in_path, out_path): + ''' fetch a file from domain to local ''' + super(Connection, self).fetch_file(in_path, out_path) ++ in_path = self._resolve_tilde(in_path) + display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._host) + + request_handle = { diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 000000000..593fcdb88 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,3 @@ +0001-fix-libvirt-connection-plugin-warning.patch +0002-fix-libvirt-encoding-errors-on-windows-guests.patch +0003-fix-libvirt-path-resolution.patch |