image-info: read tmpfiles.d config files from multiple paths
Extend image-info to read tmpfiles.d configuration files from multiple paths: - /etc/tmpfiles.d/*.conf - /usr/lib/tmpfiles.d/*.conf Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
70e1b30347
commit
7c9ecf8a53
1 changed files with 52 additions and 28 deletions
|
|
@ -1502,39 +1502,63 @@ def read_systemd_service_dropins(tree):
|
||||||
return _read_glob_paths_with_parser(tree, checked_globs, read_systemd_service_dropin)
|
return _read_glob_paths_with_parser(tree, checked_globs, read_systemd_service_dropin)
|
||||||
|
|
||||||
|
|
||||||
def read_tmpfilesd(tree):
|
def read_tmpfilesd_config(config_path):
|
||||||
"""
|
"""
|
||||||
Read all configuration files from /etc/tmpfiles.d.
|
Read tmpfiles.d configuration files.
|
||||||
|
|
||||||
Returns: dictionary with the keys representing names of configuration files
|
Returns: list of strings representing uncommented lines read from the
|
||||||
from /etc/tmpfiles.d. Value of each key is a list of strings representing
|
configuration file.
|
||||||
uncommented lines read from the configuration file.
|
|
||||||
|
An example return value:
|
||||||
|
[
|
||||||
|
"x /tmp/.sap*",
|
||||||
|
"x /tmp/.hdb*lock",
|
||||||
|
"x /tmp/.trex*lock"
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
file_lines = []
|
||||||
|
|
||||||
|
with open(config_path) as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
if line[0] == "#":
|
||||||
|
continue
|
||||||
|
file_lines.append(line)
|
||||||
|
|
||||||
|
return file_lines
|
||||||
|
|
||||||
|
|
||||||
|
def read_tmpfilesd_configs(tree):
|
||||||
|
"""
|
||||||
|
Read all tmpfiles.d *.conf files from a predefined list of paths and parse
|
||||||
|
them.
|
||||||
|
|
||||||
|
The searched paths are:
|
||||||
|
- "/etc/tmpfiles.d/*.conf"
|
||||||
|
- "/usr/lib/tmpfiles.d/*.conf"
|
||||||
|
|
||||||
|
Returns: dictionary as returned by '_read_glob_paths_with_parser()' with
|
||||||
|
configuration representation as returned by 'read_tmpfilesd_config()'.
|
||||||
|
|
||||||
An example return value:
|
An example return value:
|
||||||
{
|
{
|
||||||
"sap.conf": [
|
"/etc/tmpfiles.d": {
|
||||||
"x /tmp/.sap*",
|
"sap.conf": [
|
||||||
"x /tmp/.hdb*lock",
|
"x /tmp/.sap*",
|
||||||
"x /tmp/.trex*lock"
|
"x /tmp/.hdb*lock",
|
||||||
]
|
"x /tmp/.trex*lock"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
result = {}
|
checked_globs = [
|
||||||
|
"/etc/tmpfiles.d/*.conf",
|
||||||
|
"/usr/lib/tmpfiles.d/*.conf"
|
||||||
|
]
|
||||||
|
|
||||||
for file in glob.glob(f"{tree}/etc/tmpfiles.d/*.conf"):
|
return _read_glob_paths_with_parser(tree, checked_globs, read_tmpfilesd_config)
|
||||||
with open(file) as f:
|
|
||||||
file_lines = []
|
|
||||||
for line in f:
|
|
||||||
line = line.strip()
|
|
||||||
if not line:
|
|
||||||
continue
|
|
||||||
if line[0] == "#":
|
|
||||||
continue
|
|
||||||
file_lines.append(line)
|
|
||||||
if file_lines:
|
|
||||||
result[os.path.basename(file)] = file_lines
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def read_tuned_profile(tree):
|
def read_tuned_profile(tree):
|
||||||
|
|
@ -1917,9 +1941,9 @@ def append_filesystem(report, tree, *, is_ostree=False):
|
||||||
if modprobe_configs:
|
if modprobe_configs:
|
||||||
report["modprobe"] = modprobe_configs
|
report["modprobe"] = modprobe_configs
|
||||||
|
|
||||||
tmpfilesd_config = read_tmpfilesd(tree)
|
tmpfilesd_configs = read_tmpfilesd_configs(tree)
|
||||||
if tmpfilesd_config:
|
if tmpfilesd_configs:
|
||||||
report["/etc/tmpfiles.d"] = tmpfilesd_config
|
report["tmpfiles.d"] = tmpfilesd_configs
|
||||||
|
|
||||||
rhsm = read_rhsm(tree)
|
rhsm = read_rhsm(tree)
|
||||||
if rhsm:
|
if rhsm:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue