Permission Denied for "find" command; No idea why

Jeremy Chadwick koitsu at FreeBSD.org
Wed Nov 12 21:29:01 PST 2008


On Thu, Nov 13, 2008 at 12:16:24AM -0500, APseudoUtopia wrote:
> Hey. I've been writing a set of sh backup scripts over the past few
> days. I'm having some trouble with the final thing with them.
> 
> This is the command that is being run by the "www" user via cron:
> /usr/bin/find /usr/local/backups/ -ctime +7d -type f -not -name
> "*daily_backup*" -ls
> 
> (Eventually, I'm going to change the "-ls" to "-delete")
> 
> This is the "ls -al" of /usr/local/backups:
> drwxrwx---   2 www   wheel        512 Nov 13 04:29 .
> drwxr-xr-x  15 root  wheel        512 Nov 12 20:24 ..
> -rw-------   1 www   wheel   22250785 Nov 13 04:18 2008-11-13.mysql-main.sql
> -rw-------   1 www   wheel     124781 Nov 13 04:18 2008-11-13.mysql-staffwiki.sql
> -rw-------   1 www   wheel     674306 Nov 13 04:18 2008-11-13.mysql-wiki.sql
> -rw-------   1 www   wheel  111845376 Nov 13 04:18 2008-11-13.www.tar
> -r-xrw----   1 www   wheel       8109 Nov 13 04:16 daily_backup.sh
> 
> For some reason, the "find" command above is getting a "permission denied."
> And, again, the "find" command is being run by the "www" user, who
> owns the files and dir.
> The exact message is: "find: .: Permission denied"
> 
> The "find" permissions:
> -r-xr-xr-x  1 root  wheel  36800 Oct 23 01:17 /usr/bin/find
> 
> Also, all dirs above /usr/local/backups (/usr and /usr/local) are +x
> for the "other" user, so the www should be able to enter them:
> drwxr-xr-x  17 root  wheel      512 Nov 12 20:38 usr
> drwxr-xr-x  15 root  wheel      512 Nov 12 20:24 local
> 
> Does anyone have any idea what's causing this permission denied error?
> Obviously it's some sort of permissions problem, but I have no idea
> where or what exactly it is. It's driving me crazy.

"find: .: Permission denied" would only be returned, AFAIK, if you were
doing "find . <someflags>", which your "find" example above does not
show.

Example:

$ id
uid=1000(jdc) gid=1000(users) groups=1000(users),0(wheel),20(staff),1002(wwwsite),1501(storage)

$ ls -ld /var/heimdal
drwx------    2 root      wheel     512 14 Oct 13:21 /var/heimdal/

$ find /var/heimdal -print
/var/heimdal
find: /var/heimdal: Permission denied
$

$ find /var/db -type d -print 1> /dev/null
find: /var/db/entropy: Permission denied
find: /var/db/ipf: Permission denied
find: /var/db/postfix: Permission denied

$ ls -ld /var/db/entropy /var/db/ipf /var/db/postfix
drwx------    2 operator  operator  512 12 Nov 21:22 /var/db/entropy/
drwx------    2 root      wheel     512 14 Oct 13:21 /var/db/ipf/
drwx------    2 postfix   wheel     512  6 Nov 04:16 /var/db/postfix/

-- 
| Jeremy Chadwick                                jdc at parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |



More information about the freebsd-questions mailing list