From 101cb5346c1fc85f7a7d07f481c9edfcac1a6ac5 Mon Sep 17 00:00:00 2001 From: grey Date: Mon, 13 May 2024 21:28:39 +0200 Subject: [PATCH 1/2] adding "/proc/sys/kernel/hostname" to the paths in _parse_hostname_string --- dissect/target/plugins/os/unix/_os.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dissect/target/plugins/os/unix/_os.py b/dissect/target/plugins/os/unix/_os.py index 81710ecc5..11c183556 100644 --- a/dissect/target/plugins/os/unix/_os.py +++ b/dissect/target/plugins/os/unix/_os.py @@ -149,7 +149,7 @@ def _parse_hostname_string(self, paths: Optional[list[str]] = None) -> Optional[ paths (list): list of paths """ redhat_legacy_path = "/etc/sysconfig/network" - paths = paths or ["/etc/hostname", "/etc/HOSTNAME", redhat_legacy_path] + paths = paths or ["/etc/hostname", "/etc/HOSTNAME", "/proc/sys/kernel/hostname", redhat_legacy_path] hostname_dict = {"hostname": None, "domain": None} for path in paths: From 6e5428a38bc1136180f3b5fad8d32593ab688e9c Mon Sep 17 00:00:00 2001 From: Stefan de Reuver <9864602+Horofic@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:14:08 +0100 Subject: [PATCH 2/2] Add test case --- tests/plugins/os/unix/test__os.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/plugins/os/unix/test__os.py b/tests/plugins/os/unix/test__os.py index 4093c5d9b..ffb3c917e 100644 --- a/tests/plugins/os/unix/test__os.py +++ b/tests/plugins/os/unix/test__os.py @@ -112,6 +112,7 @@ def test_mount_volume_name_regression(fs_unix: VirtualFilesystem) -> None: ("/not_a_valid_hostname_path", None, None, ""), ("/etc/hostname", None, None, ""), ("/etc/sysconfig/network", None, None, ""), + ("/proc/sys/kernel/hostname", "myhost", None, "myhost"), ], ) def test_parse_hostname_string(