1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-28 07:57:38 +00:00

[PR #11240/8d51c5f6 backport][stable-12] btrfs module utils: pass command as list to run_command() (#11248)

btrfs module utils: pass command as list to `run_command()` (#11240)

* btrfs module utils: pass command as list to run_command()

* add changelog frag

(cherry picked from commit 8d51c5f666)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2025-12-02 21:17:59 +01:00 committed by GitHub
parent 5cb24c2599
commit 469ba26c8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- btrfs module utils - make execution of external commands safer by passing arguments as list (https://github.com/ansible-collections/community.general/pull/11240).

View file

@ -37,7 +37,7 @@ class BtrfsCommands:
self.__btrfs: str = self.__module.get_bin_path("btrfs", required=True)
def filesystem_show(self) -> list[dict[str, t.Any]]:
command = f"{self.__btrfs} filesystem show -d"
command = [self.__btrfs, "filesystem", "show", "-d"]
result = self.__module.run_command(command, check_rc=True)
stdout = [x.strip() for x in result[1].splitlines()]
filesystems = []
@ -69,7 +69,7 @@ class BtrfsCommands:
return re.sub(r"^.*path\s", "", line)
def subvolumes_list(self, filesystem_path: str) -> list[dict[str, t.Any]]:
command = f"{self.__btrfs} subvolume list -tap {filesystem_path}"
command = [self.__btrfs, "subvolume", "list", "-tap", to_bytes(filesystem_path)]
result = self.__module.run_command(command, check_rc=True)
stdout = [x.split("\t") for x in result[1].splitlines()]
subvolumes: list[dict[str, t.Any]] = [{"id": 5, "parent": None, "path": "/"}]
@ -148,7 +148,7 @@ class BtrfsInfoProvider:
return [m for m in mountpoints if (m["device"] in devices)]
def __find_mountpoints(self) -> list[dict[str, t.Any]]:
command = f"{self.__findmnt_path} -t btrfs -nvP"
command = [self.__findmnt_path, "-t", "btrfs", "-nvP"]
result = self.__module.run_command(command)
mountpoints = []
if result[0] == 0: