-
-
Notifications
You must be signed in to change notification settings - Fork 68
enhance tmpfiles implementation #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
troglobit
requested changes
Jan 18, 2026
Collaborator
troglobit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good, love the separation of the commits which makes it very easy to review!
Only a minor code duplication comment.
4fb8859 to
d84f1d9
Compare
troglobit
approved these changes
Jan 18, 2026
Rename the command-line flag variables to be more descriptive: c_flag -> create_flag r_flag -> remove_flag This improves code readability.
Add support for the --clean (-C) flag to remove files and directories
older than the age specified in tmpfiles.d configuration entries.
The age field (6th column) in tmpfiles.d entries can now be used with
'd', 'D', and 'e' type entries to clean up old files. Supported time
suffixes are: s (seconds), m (minutes), h (hours), d (days), w (weeks).
Example configuration:
d /tmp/cache 0755 root root 10d
When run with --clean, files in /tmp/cache older than 10 days will be
removed. The directory itself is preserved.
Uses a conservative cleanup approach matching systemd-tmpfiles:
- Files: kept if ANY of atime, ctime, mtime is recent
- Directories: kept if ANY of atime, mtime is recent (ctime excluded
because cleanup itself updates directory ctime)
A value of "-" or "0" for age disables cleanup for that entry.
Note: x/X exclusion patterns are recognized but not yet implemented.
Allow specifying one or more configuration files as command line
arguments instead of always processing all files in the standard
tmpfiles.d directories.
This enables targeted operations on specific config files:
tmpfiles --create /etc/tmpfiles.d/myapp.conf
tmpfiles --clean /tmp/test.conf /tmp/other.conf
When no config files are specified, the existing behavior of
processing all *.conf files in the standard directories is preserved.
Also refactors file processing into a helper function to reduce
code duplication.
The L+ type should replace existing entries with a symlink. Previously, rmrf() was always called which is only appropriate for directories. Now we check if the path is a directory first, and use erase() for files and symlinks.
Add parse_uid() and parse_gid() helper functions that support both numeric IDs and name lookups. Update the d/D directory creation handlers to use these new functions. This allows config files to specify ownership using numeric UIDs and GIDs instead of only usernames and group names, matching systemd-tmpfiles behavior.
According to tmpfiles.d(5), the 'e' type adjusts the mode and ownership of existing paths but should not create them. Previously, mksubsys() was used which could create directories. Now we explicitly check if the path is an existing directory before adjusting its permissions.
When f or F types write content to a file, the mode and ownership specified in the config should be applied. Previously, ownership was only applied when create() was used (i.e., when no argument was specified). Now we explicitly apply mode and ownership after writing content to the file.
Contributor
Author
|
i have loaded this onto my system and ran a few basic tests... all good from my end 👍 thanks! |
Collaborator
|
Thank you, another awesome contribution! 🥇 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
i created some tests...