Bug in "du", needing current directory
John F Meinel Jr <[email protected]> Thu, 22 May 2003 15:02:41 -0500
| Newsgroups | gmane.comp.gnu.fileutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
I found an odd bug in using du Specifically, why does du need to read the current directory if you are wanting the disk usage of a different directory. I ran into this problem because I have a cron job that switches to another user, and then runs du in order to do some monitoring. Whenever I ran this job as root manually, it worked fine, but when I ran it as cron I got the error: du: cannot open current directory: Permission denied I eventually figured out that cron was running the process in '/root' , which didn't have read permissions set for the user that the process was switching to. It is simple to reproduce this. Create a directory as root and then chmod it 700. Switch to that directory and then su to another use (therefore you don't have permission to read the current directory) type du /etc (or some other directory you normally can access), and you should get this error. My workaround was to give read permissions to /root, but that really isn't a preferred method. # du --version du (fileutils) 4.1.9 Written by Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert.