Skip to content

Commit

Permalink
Add parsing hostname from /proc/sys/kernel/hostname in Unix OSPlugin (#…
Browse files Browse the repository at this point in the history
…704)

Co-authored-by: Stefan de Reuver <[email protected]>
  • Loading branch information
CinisSec and Horofic authored Dec 6, 2024
1 parent 79aa5dd commit 63e52e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dissect/target/plugins/os/unix/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _parse_hostname_string(self, paths: list[str] | None = None) -> dict[str, st
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:
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/os/unix/test__os.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 63e52e1

Please sign in to comment.