You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
systemd-tmpfiles deletes quota files and lost+found directory #181
The default cleanup rules in /usr/lib/tmpfiles.d/tmp.conf will remove all files and directories, excluding systemd-private in /tmp and /var/tmp.
If /tmp or /var/tmp are on a separate partition, those directories can contain a lost+found folder from a previous fsck run. More inportantly, they might contain quota configuration files. Those should not be removed by systemd-tmpfiles.
In Debian, we had the following exceptions when cleaning up /tmp and /var/tmp in our old sysvinit setup:
For systemd, we should at least ignore the lost+found directory and the quota.{user,group} files.
I first intended to create a pull request, which adds those to tmp.conf and marks them as x, but @martinpitt mentioned, that it might be preferable to always ignore those paths when using "D" or "d" and add those ignore list to the source code instead.
I'm therefor looking for feedback first, which approach would be preferred.
I indeed missed, that we alreay ignore aquota.user and aquote.group.
But as @keszybz said, we should apply the uid check to aquota.user and aquota.group as well.
We should also skip the quota.group and quota.user file and the lost+found directory.
As for the latter, I think we should ignore lost+found completely
@poettering any idea, why the uid check is only applied to ".journal"? Is that deliberate or an oversight/bug? I.e. shouldn't it rather be s.st_uid == 0 && (foo || bar || baz)
Well, we do already ignore lost+found. The check is just in the other branch of the same if, the one that applies to directories. You added it back in 2010 ;). I now checked, and on my system, lost+found is ignored in /tmp. So it seems that the original reporter messed something up: maybe he created the directory as non-root?
I don't get it why you both think that we should ignore contents of lost+found. If my machine is reset, and something lands in lost+found, it most likely is some garbage temporary file. I certainly wouldn't mind if it was deleted like any other file in /var/tmp or /tmp after a while, they are probably less useful than other files in /tmp or /var/tmp.
@keszybz well, we really have no idea what ends up in lost+found. It could be super important data that just ended up there because the machine crashed while the user edited it. Automatic time-based clean-up is something we should only do if we know that the data is only temporary data that is OK to trash, and when the app developer acknowledged that things are cleaned up that way, by placing it in /tmp or /var/tmp. This is very different for lost-found where we really have no clue what it is, the file system forgot the context about it could be both the most irrelevant or most important of files.
So yes, lost+found should not be cleaned up. It's not safe to do things.
Or to turn this around: lost+found is for files that where recovered from a corrupted file systems. It's great that they were recovered, and we shouldn't then go ahead and delete them again, possibly even very quickly since the original mtime was recovered too and is very old.
Also, the directory doesn't really exist on modern file systems anyway, and we shouldn't design around design weirdness of older file systems...
But that lost+found we are looking at must be underneath the directory we are cleaning up... Realistically that would only be /var/tmp/lost+found or /tmp/lost+found. In either case the only files which could end up there should be from the temporary filesystem anyway. But I'm fine with leaving things as they are.
I'm pretty sure that the original reported misunderstood something. I'd just push patch 1/2 and close this issue.
@poettering, @keszybz: nod, please push patch 1, since it looks correct in any case. As for lost+found, I'll doublecheck if I can reproduce the issue myself and if not, ask the bug reporter for futher info.
Activity
grawity commentedon Jun 12, 2015
Hmm,
src/tmpfiles/tmpfiles.c:498already has:On the other hand, there is no conf syntax for "/aquota.user at the root of any mountpoint".
keszybz commentedon Jun 13, 2015
On Fri, Jun 12, 2015 at 04:36:54PM -0700, Mantas Mikulėnas wrote:
It seems that the uid check should apply to all of them, no?
Also, without looking at the code it's hard to tell, but I think
we should recurse into lost+found, and just ignore the directory
itself.
mbiebl commentedon Jun 13, 2015
I indeed missed, that we alreay ignore aquota.user and aquote.group.
But as @keszybz said, we should apply the uid check to aquota.user and aquota.group as well.
We should also skip the quota.group and quota.user file and the lost+found directory.
As for the latter, I think we should ignore lost+found completely
poettering commentedon Jun 13, 2015
Yeah i agree, we should ignore the whole of lost+found and not descend into it.
mbiebl commentedon Jun 13, 2015
@poettering any idea, why the uid check is only applied to ".journal"? Is that deliberate or an oversight/bug? I.e. shouldn't it rather be s.st_uid == 0 && (foo || bar || baz)
keszybz commentedon Jun 13, 2015
Well, we do already ignore lost+found. The check is just in the other branch of the same if, the one that applies to directories. You added it back in 2010 ;). I now checked, and on my system, lost+found is ignored in /tmp. So it seems that the original reporter messed something up: maybe he created the directory as non-root?
I don't get it why you both think that we should ignore contents of lost+found. If my machine is reset, and something lands in lost+found, it most likely is some garbage temporary file. I certainly wouldn't mind if it was deleted like any other file in /var/tmp or /tmp after a while, they are probably less useful than other files in /tmp or /var/tmp.
For your consideration: #188.
poettering commentedon Jun 14, 2015
@keszybz well, we really have no idea what ends up in lost+found. It could be super important data that just ended up there because the machine crashed while the user edited it. Automatic time-based clean-up is something we should only do if we know that the data is only temporary data that is OK to trash, and when the app developer acknowledged that things are cleaned up that way, by placing it in /tmp or /var/tmp. This is very different for lost-found where we really have no clue what it is, the file system forgot the context about it could be both the most irrelevant or most important of files.
So yes, lost+found should not be cleaned up. It's not safe to do things.
Or to turn this around: lost+found is for files that where recovered from a corrupted file systems. It's great that they were recovered, and we shouldn't then go ahead and delete them again, possibly even very quickly since the original mtime was recovered too and is very old.
Also, the directory doesn't really exist on modern file systems anyway, and we shouldn't design around design weirdness of older file systems...
Really, we should stay away from it.
poettering commentedon Jun 17, 2015
I am not sure what this bug is about now. If we add the uid check to tmpfiles, then nothing about the original issue will change.
@mbiebl any idea why the checks we already have in place don't work?
Can you provide a reproducer or an strace or so?
keszybz commentedon Jun 17, 2015
But that lost+found we are looking at must be underneath the directory we are cleaning up... Realistically that would only be /var/tmp/lost+found or /tmp/lost+found. In either case the only files which could end up there should be from the temporary filesystem anyway. But I'm fine with leaving things as they are.
I'm pretty sure that the original reported misunderstood something. I'd just push patch 1/2 and close this issue.
mbiebl commentedon Jun 17, 2015
@poettering, @keszybz: nod, please push patch 1, since it looks correct in any case. As for lost+found, I'll doublecheck if I can reproduce the issue myself and if not, ask the bug reporter for futher info.
poettering commentedon Jun 17, 2015
@keszybz ok, pushed patch 1 now.
poettering commentedon Jul 11, 2015
Closing this issue now. Should there be something more to fix, please reopen.