Bug 234596 - --test does not resemble reality
--test does not resemble reality
Product: Fedora
Classification: Fedora
Component: tmpwatch (Show other bugs)
All Linux
medium Severity low
: ---
: ---
Assigned To: Miloslav Trmač
Ben Levenson
Depends On:
  Show dependency treegraph
Reported: 2007-03-30 09:54 EDT by Konstantin Ryabitsev
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version: 2.9.11-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-03-31 08:37:25 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Konstantin Ryabitsev 2007-03-30 09:54:42 EDT
Check this out:

root@gdb:[/home/test7]# ls -al muhc/files
total 8
drwxr-xr-x  2 wcg  wcg  4096 Mar 14 20:49 ./
drwxr-xr-x  3 wcg  wcg  4096 Mar 14 20:49 ../
lrwxrwxrwx  1 root root   18 Mar 14 20:49 global -> /home/files-global/

root@gdb:[/home/test7]# tmpwatch --test --nosymlinks -m 168 muhc
removing directory muhc/files
root@gdb:[/home/test7]# tmpwatch --nosymlinks -m 168 muhc
root@gdb:[/home/test7]# tmpwatch --test --nosymlinks -m 168 muhc
removing directory muhc/files

Hence, even though "--test" will claim that muhc/files will be removed, it
actually won't since it's contains a symlink.
Comment 1 Miloslav Trmač 2007-03-30 14:40:22 EDT
Thanks for your report.

tmpwatch always uses rmdir() and ignores its failure if the directory is
non-empty, thus the message should probably be "attempting to remove directory %
if not empty".

tmpwatch could keep track of the directory contents and skip the rmdir () if the
directory were known to be non-empty, but this is racy - the only way to
atomically remove a directory if it is non-empty is to actually use rmdir ().

Would keeping track of the directory contents be useful to you (are you e. g.
somehow processing the --test output), or is fixing the incorrect message
Comment 2 Konstantin Ryabitsev 2007-03-30 21:43:47 EDT
I think that changing the message to say "removing if not empty" is sufficient.
The purpose of --test is to see what precisely is going to get removed, and my
concern upon seeing the message was that the files directory would get deleted
(very bad for me). I think I would have been a lot less worried if I knew that
it wouldn't actually delete the directory if it wasn't empty.
Comment 3 Miloslav Trmač 2007-03-31 08:37:25 EDT
Thanks, message changed in rawhide tmpwatch-2.9.11-1.

Note You need to log in before you can comment on or make changes to this bug.