Tmpfiles.d configuration - files in /etc/tmpfiles.d

The TmpfilesD class parser provides a ‘rules’ list, as well as a find_file method to find rules for a particular tmp file.

class insights.parsers.tmpfilesd.TmpFilesD(context)[source]

Bases: Parser

Parse files in /etc/tmpfiles.d, /usr/lib/tmpfiles.d/, and /run/tmpfiles.d.

This parser reads the files and records the filename in each line.

files

A list of the files that tmpfiles.d is managing.

Type:

list

rules

A list of dictionaries with the values of each rule.

Type:

list

Sample input:

# /usr/lib/tmpfiles.d/dnf.conf
r! /var/cache/dnf/*/*/download_lock.pid
e  /var/cache/dnf/ - - - 30d

Examples

>>> tmpfiles = shared[TmpFilesd][0] # List is per filename
>>> len(tmpfiles.rules)
2
>>> tmpfiles.files
['/var/cache/dnf/*/*/download_lock.pid', '/var/cache/dnf/']
>>> tmpfiles.rules[1]
{'path': '/var/cache/dnf/', 'type': 'e', 'mode': '-', 'age': '30d',
 'gid': '-', 'uid': '-', 'argument': None}
>>> tmpfiles.find_file('download_lock.pid')
[{'path': '/var/cache/dnf/*/*/download_lock.pid', 'type': 'r!',
  'mode': None, 'age': None, 'gid': None, 'uid': None, 'argument': None}]
find_file(filename)[source]

Find any rules containing the file being searched.

This method returns a list of dictionaries where the the managed file is found.

parse_content(content)[source]

This method must be implemented by classes based on this class.