-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
refuse systemd-tmpfiles --purge invocation without config file specified on cmdline #33349
Comments
So an option that is literally documented as saying "all files and directories created by a tmpfiles.d/ entry will be deleted", that you knew nothing about, sounded like a "good idea"? Did you even go and look what tmpfiles.d entries you had beforehand? Maybe don't just run random commands that you know nothing about, while ignoring what the documentation tells you? Just a thought eh |
Technically speaking, systemd-tmpfiles simply makes use of tmpfiles.d/ definitions to perform purge operations, so the tool itself is nothing wrong. Yet I understand that people would think sd-tmpfiles as a tool that only manages temporary files, which hasn't been the case for a pretty long time. Our documentation also still states that it's a tool to
which is definitely something we should improve. |
I know systemd-tmpfiles is (at least) used to clean temp files, I think it's not unreasonable to assume the config entries have to do with explaining which files should be considered "temp" and which ones are not (well, turns out they do, but they also do other things). Especially because the first line of the DESCRIPTION section told me that they indeed are, so I didn't feel the need to check tmpfiles.d(5). Why would I? I wasn't configuring anything, I just wanted to delete temp files.
No need to be aggressive. I think the documentation simply depends too much on the knowledge of the subsystem, for users who just want to do something with it. If I read the apt(8) manpage, it doesn't rely on knowledge of how dpkg and Debian packaging works, it just tells me - this installs packages, this removes packages, this removes packages and cleans the configuration. Which is all I need to know. Sure, have in depth explanations on what it does, they are great if you decide to write your own config or you want to contribute to the project, but let people who just need to use it have understandable explanations on why it does that.
Yeah, as I said, I realize this is not a bug. It's just a feature that's not well explained. I did use the bug label because I do think it's a bug in the documentation, and it fits the template best.
Yes, at this point I'm still not sure why |
While #33350 does address point 2, somewhat, it does not address point 1. I would still like to see a explanation why the options do what they do (in other words, what they are supposed to be used for). I also would emphasize the "Keep in mind" or replace it with emphasized "Warning:" (which I think sounds more direct) but oh well. The way it is now definitely would have stopped me from using it. |
I think we should fail --purge if no config file is specified on the command line. I see no world where an invocation without one would make sense, and it would have caught the problem here. |
The actual integration does not specify config files, as they are all gone by the time it is called, instead it passes input via stdin (ie, |
@bluca I would kindly ask you to reconsider this attitude. For instance, I happily went on to read the the documentation on
actually does. And the man pages has this to say:
Now, it takes a lot of patience, re-reading and understanding (of a number o concepts!) to go from this to the real effects of the commands. At least to me, that was quite far from intuitive. I urge you to consider how the current behaviour may affect thousands of ordinary Linux users and admins, and improve the behaviour so that it is harder to shoot oneself -- by default. |
We need to rethink how (For example, please consider how systemd-repart behaves. You need to specify Apart from how the command is invoked, I think the current design needs some rethinking. The command is advertised as "remove files and directories that tmpfiles creates", but the operation is asymmetrical. Tmpfiles does not manage As is, this is a footgun that we shouldn't provide to our users. I'll file a simple PR to hide the feature for now. We can re-enable it when other details have been figured out. In particular, the documentation needs to be updated in the style of hdparm(8) quoted above, and the option must be changed to be much harder to invoke unintentionally. |
This effectively reverts 81a1838. Note that the actual implementation was retained, but there is no way to invoke it once the commandline switch is removed. I expect that the switch will be restored in a slightly different form, so it doesn't make sense to create churn by removing all the code. As discussed in systemd#33349, --purge provides a footgun for users by allowing them to easily remove contents of /home. At least one user has done this, which is one too many. Let's disable the command before this hits stable distributions and more users have a chance to destroy their data. Closes systemd#33349.
#33353 is intended as a patch to apply and backport to stable while we rethink how this should work. |
Historically, systemd-tmpfiles was designed to manager temporary files, but nowadays it has become a generic tool for managing all kinds of files. To avoid user confusion, let's remove "temporary" from the tool's description. As discussed in systemd#33349
This effectively reverts 81a1838. Note that the actual implementation was retained, but there is no way to invoke it once the commandline switch is removed. I expect that the switch will be restored in a slightly different form, so it doesn't make sense to create churn by removing all the code. As discussed in systemd#33349, --purge provides a footgun for users by allowing them to easily remove contents of /home. At least one user has done this, which is one too many. Let's disable the command before this hits stable distributions and more users have a chance to destroy their data. Closes systemd#33349.
Historically, systemd-tmpfiles was designed to manager temporary files, but nowadays it has become a generic tool for managing all kinds of files. To avoid user confusion, let's remove "temporary" from the tool's description. As discussed in systemd#33349
Historically, systemd-tmpfiles was designed to manager temporary files, but nowadays it has become a generic tool for managing all kinds of files. To avoid user confusion, let's remove "temporary" from the tool's description. As discussed in #33349
There's been a discussion around the tempfiles name in #12447 (comment), back then it was decided it's too much churn. Glad the "temporary" now at least is gone since #33354 :-) |
That's not really true. We do not "convert" anything (we can't do that, dirs cannot be convetred into subvols in btrfs). The file exists for environments where we boot up with an empty / (i.e. only /usr mounted in), and /home should hence be created on first boot. |
I know that. That's why I put "convert" in quotes. From the users POV, without our configuration in place, they get |
At least on the Debian side of things, /home is shipped in base-files, so you really have to modify an image manually to be able to trigger the subvolume-on-first-boot logic, which means it really has to be intentional. base-files is the first thing (well, one of the couple of) that is installed, so you won't get an image without /home unless you are really trying to. |
mkosi images with only a usr partition are a thing. The package manager is only used for prepping the original image, but it is then booted up with only /usr/ populated, anything outside of it is not even part of the golden image, |
Yeah, building such an image with mkosi is one of the things I meant when I said "really trying to" - home.conf is doing what it's supposed to in that case I think |
I may have some misunderstandings as English is only my first language, but I believe the definition of "temp files" are files that:
Having a function that declares irreplaceable files - such as the contents of a home directory - to be temporary files that can be easily purged, is at best poor user interfacing design and at worst a severe design flaw. |
…n --purge Also, extend the man page explanation substantially, matching more closely what --create says. Fixes: systemd#33349
I don't thinkt he usecase for --purge is really primarily factory reset. Instead it's about package removal: a systematic way how files created by some RPM/DEB xyz via tmpfiles.d/ can be removed when xyz is removed again. That usecase has nothing to do with factory reset.
I'd be entirely fine with dropping --purge from tab completion btw. similar the other destructive factory reset options. |
There is not, and there never was, tab completion for --purge |
This comment was marked as off-topic.
This comment was marked as off-topic.
This seems to be turning into MS Recall drama. RIP devs inboxes. As re the issue itself, Either rename |
…n --purge Also, extend the man page explanation substantially, matching more closely what --create says. Fixes: systemd#33349 (cherry picked from commit 41064a3)
v256.1 has been released with the belt and braces and updated docs |
systemd version the issue has been seen with
256
Used distribution
Debian Unstable
Linux kernel version used
6.8.12-amd64
CPU architectures issue was seen on
x86_64
Component
systemd-tmpfiles
Expected behaviour you didn't see
I noticed my
/var/tmp
directory grew quite a bit and wanted to manually clean it. Since I was about to log off for the day, I skimmed through the manual for systemd-tmpfiles(8).Not knowing much about the systemd-tmpfiles architecture, other than that it's being used to clean up temp files,
--purge
seemed like a good idea. So, I ransudo systemd-tmpfiles --purge
, expecting it to clean my temp files.Unexpected behaviour you saw
A lot of warning messages started appearing, which included paths in
/home
(it couldn't restore modification times...?). What's a temp-cleaning tool doing in my home directory? That's no good. My heart started beating faster and I hit Ctrl-C as fast as I could.Turns out, a good portion of my home directory got deleted. Thankfully, it seems like it started from the config files and not the actual data, though I am still not sure if I lost anything important. I turned off the machine to recover the data later with
extundelete
(it didn't work btw, it instantly crashes for some reason; I do have backups, but they are a bit outdated, I'm filling drives way too fast).I talked about this on #debian-next, and seems that this is not a bug, but a feature, as systemd-tmpfiles also handles autocreating data directories such as
/home
, and the--purge
flag is meant to wipe them clean. I am unsure what's the utility of that, but I assume there is a good reason.What I do have an issue with is the documentation. It does explain what the options do, technically speaking (well, I assume so - I don't know a lot about the architecture here), but it doesn't explain why they do what they do. As someone just browsing the documentation, the three options seem to do the same thing - cleaning temp files, though
--purge
seems "more throughout" as it does mention it removes all files (including user data).This kinda wraps back to the "Expected behaviour you didn't see" section, but sometimes the rigid form of the issue templates doesn't fit everything - so, what I would want to see is:
An explanation of why a given option does something, for example:
As a user, I don't know what those are actually intended to be used for, but as the developers, you probably do, and can describe them better than I did ;) I don't think this is specific to systemd-tmpfiles, it probably should be used as a guideline on how to write manuals project-wide (and honestly, industry-wide).
A huge warning next to
--purge
. This option is dangerous, so it should be made clear that it's dangerous. hdparm(8) is a great example:For me, this would be sufficient, as I check the options I'm using in the manual. Not sure if it should have a confirmation or anything, I don't think it's necessary, even if you do have a confirmation, some people will blindly confirm anyways. Having a confirmation would also be API breakage I assume.
Steps to reproduce the problem
systemd-tmpfiles --dry-run --purge
(due to--dry-run
this is safe to run).--dry-run
it would remove all your data.Additional program output to the terminal or log subsystem illustrating the issue
No response
The text was updated successfully, but these errors were encountered: