Skip to content
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

Deprecate boot.cleanTmpDir? #96753

Open
primeos opened this issue Aug 31, 2020 · 7 comments
Open

Deprecate boot.cleanTmpDir? #96753

primeos opened this issue Aug 31, 2020 · 7 comments

Comments

@primeos
Copy link
Member

primeos commented Aug 31, 2020

Reason: We now install tmpfiles.d/tmp.conf from systemd with the following content:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# See tmpfiles.d(5) for details

# Clear tmp directories separately, to make them easier to override
q /tmp 1777 root root 10d
q /var/tmp 1777 root root 30d

Which is pretty similar to our implementation:

systemd.tmpfiles.rules = optional config.boot.cleanTmpDir "D! /tmp 1777 root root";

From man tmpfiles.d:

If multiple files specify the same path, the entry in the file with the lexicographically earliest name will be applied (note that lines suppressed due to the "!" are filtered before application, meaning that if an early line carries the exclamation mark and is suppressed because of that, a later line matching in path will be applied). All other conflicting entries will be logged as errors.

So this shouldn't cause any errors in the log but the effect of boot.cleanTmpDir = true; is only that we also delete files that are newer than 10 days on each boot. Therefore I am not sure if we still need the option. It might be useful for some special cases though.

But in any case we should IMO mention in the description of boot.cleanTmpDir = true; that the files will now be deleted after 10 days anyway. Current description:

Whether to delete all files in /tmp during boot.

@deliciouslytyped
Copy link
Contributor

deliciouslytyped commented Sep 21, 2020

Does systemd enable this clearing by default?

Given that cleanTmpDir currently defaults to false and that this setting destroys data, there should be a release note. There should then be a flag to disable it, and in the release notes give an example of how to disable it.

@primeos
Copy link
Member Author

primeos commented Sep 21, 2020

Does systemd enable this clearing by default?

Yes, systemd ships with tmpfiles.d/tmp.conf since 2011 (systemd/systemd@f08fce8) but IIRC most distributions don't install it. For NixOS we ship if since 3ef5115 (part of 20.03 but AFAIK we never mentioned the new behaviour in the release notes).

Disabling /tmp cleaning (tmpfiles.d/tmp.conf) currently requires a manual override (see #96766).

@stale
Copy link

stale bot commented Mar 20, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2021
@cx405
Copy link

cx405 commented Mar 11, 2023

@primeos
this file exists in nixos os by default in /etc/tmpfiles.d/tmp.conf, even if config.boot.cleanTmpDir is set.
it must be tested if this actually applies by creating random file and looking into it after 10 days.

if the file is gone, then "config.boot.cleanTmpDir" is indeed irrelevant.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 11, 2023
@MikaelFangel
Copy link
Contributor

@primeos this file exists in nixos os by default in /etc/tmpfiles.d/tmp.conf, even if config.boot.cleanTmpDir is set. it must be tested if this actually applies by creating random file and looking into it after 10 days.

if the file is gone, then "config.boot.cleanTmpDir" is indeed irrelevant.

@cx405
Any news on whether tests showed that the setting is irrelevant?

@MikaelFangel
Copy link
Contributor

I did a preliminary test of this by setting the following in my configuration:

  environment.etc."tmpfiles.d/tmp.conf".text = ''
  q /tmp 1777 root root 0d
  q /var/tmp 1777 root root 0d
  '';

I confirmed that it changed the .conf file, rebooted the system, and then checked if it had cleaned the tmp dir. Not only that, but I also tried setting the first parameter to q. In both cases it didn't look like the .conf file was respected.

Then, when I enabled boot.tmp.cleanOnBoot = true; again, it cleaned the tmp dir on boot as expected. (Note that I'm running 23.05)

@lolbinarycat
Copy link
Contributor

I can confirm that /etc/tmpfiles.d/tmp.conf is being ignored. the oldest file in my /tmp is from february 21, well over 30 days ago, let alone 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants