image-info: read content of /etc/resolv.conf
Read uncommented lined from /etc/resolv.conf and add them as a list to the image-info report. The list of lines is present in the report even if it is empty, so that the report is explicit about the file content and presence. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
299bd201e6
commit
ff2aa771fc
1 changed files with 32 additions and 0 deletions
|
|
@ -1919,6 +1919,34 @@ def read_authselect_conf(tree):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def read_resolv_conf(tree):
|
||||||
|
"""
|
||||||
|
Read /etc/resolv.conf.
|
||||||
|
|
||||||
|
Returns: a list of uncommented lines from the /etc/resolv.conf.
|
||||||
|
|
||||||
|
An example return value:
|
||||||
|
[
|
||||||
|
"search redhat.com",
|
||||||
|
"nameserver 192.168.1.1",
|
||||||
|
"nameserver 192.168.1.2"
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
result = []
|
||||||
|
|
||||||
|
with contextlib.suppress(FileNotFoundError):
|
||||||
|
with open(f"{tree}/resolv.conf") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
if line[0] == "#":
|
||||||
|
continue
|
||||||
|
result.append(line)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def append_filesystem(report, tree, *, is_ostree=False):
|
def append_filesystem(report, tree, *, is_ostree=False):
|
||||||
if os.path.exists(f"{tree}/etc/os-release"):
|
if os.path.exists(f"{tree}/etc/os-release"):
|
||||||
report["packages"] = rpm_packages(tree, is_ostree)
|
report["packages"] = rpm_packages(tree, is_ostree)
|
||||||
|
|
@ -2029,6 +2057,10 @@ def append_filesystem(report, tree, *, is_ostree=False):
|
||||||
if tuned_profile:
|
if tuned_profile:
|
||||||
report["tuned"] = tuned_profile
|
report["tuned"] = tuned_profile
|
||||||
|
|
||||||
|
resolv_conf = read_resolv_conf(tree)
|
||||||
|
# add even empty resolv_conf to the report to express that it is empty or non-existent
|
||||||
|
report["/etc/resolv.conf"] = resolv_conf
|
||||||
|
|
||||||
udev_rules = read_udev_rules(tree)
|
udev_rules = read_udev_rules(tree)
|
||||||
if udev_rules:
|
if udev_rules:
|
||||||
report["/etc/udev/rules.d"] = udev_rules
|
report["/etc/udev/rules.d"] = udev_rules
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue