tmpreaper, --protect and a non-root user
Posted
by
nsg
on Server Fault
See other posts from Server Fault
or by nsg
Published on 2011-03-19T20:50:57Z
Indexed on
2011/03/20
19:23 UTC
Read the original article
Hit count: 266
Hi, I'm a little confused. I have a download directory that I want to remove all files older then 30 days with tmpreaper. Just one problem, the directory in question is a separate partition with a lost+found directory, of course I need to keep it so I added --protect 'lost+found'
, the problem is that tmpreaper outputs:
error: chdir() to directory 'lost+found' (inode 11) failed: Permission denied
(PID 30604) Back from recursing down `lost+found'.
Entry matching `--protect' pattern skipped. `lost+found'
I have tried with other pattern like lost* and so on... I'm running tmpreaper as a non-root user because there is no reason for superuser privileges because I own all files (except lost+found).
Are I'm forced to run tmpreaper as root? Or are my shell-skills not as good as I thought? I guess the problem is:
tmpreaper will chdir(2) into each of the directories you've
specified for cleanup, and check for files matching the
<shell_pattern> there. It then builds a list of them, and
uses that to protect them from removal.
Any thought and/or advice?
Edit:
The command I'm trying to run is something like
$ /usr/sbin/tmpreaper -t --protect 'lost+found' 30d /mydir 1> /dev/null
error: chdir() to directory `lost+found' (inode 11) failed: Permission denied
Edit 2:
I read the source code for tmpreaper-1.6.13 and found this
if (safe_chdir (dirname))
exit(1);
and
if (chdir (dirname)) {
message (LOG_ERROR,
"chdir() to directory `%s' (inode %lu) failed: %s\n",
dirname, (u_long) sb1.st_ino, strerror (errno));
return 1;
}
So it seems tmpreaper needs to be able to chdir in to all directories, ignored or not. I see two options left
- Run tmpreaper as root
- Move the download directory
- Find a alternative tool (tmpwatch?)
I will give it some more research before i make a choice.
© Server Fault or respective owner