为什么chmod在recursion运行时会给出“No such file or directory”?

我可以直接更改文件的权限

# chmod --changes --recursive ug+rwX /var/www/shared/tmp/cache/assets/BA0/280/sprockets%2F286302903364106648b609d708884f78 

我也可以更改包含该文件的目录的权限:

 # chmod --changes --recursive ug+rwX /var/www/shared/tmp/cache/assets/BA0/280 

当我尝试更改包含该目录的目录的权限时,recursion地,我得到一个关于以前的目录不被发现的错误:

 # chmod --changes --recursive ug+rwX /var/www/shared/tmp/cache/assets/BA0 chmod: getting new attributes of `280': No such file or directory 

目前的权限,即使我不这样做可以有任何影响,看起来像这样:

 # ls -alR /var/www/shared/tmp/cache/assets/BA0 /var/www/shared/tmp/cache/assets/BA0: total 20 drwxrwsr-x 3 rails rails 4096 Jun 4 09:54 . drwxrwsr-x 569 rails rails 12288 Jun 4 09:54 .. drwxrwsr-x 2 rails rails 4096 Jun 4 09:54 280 /var/www/shared/tmp/cache/assets/BA0/280: total 12 drwxrwsr-x 2 rails rails 4096 Jun 4 09:54 . drwxrwsr-x 3 rails rails 4096 Jun 4 09:54 .. -rw-rw-r-- 1 rails rails 481 Jun 4 09:54 sprockets%2F286302903364106648b609d708884f78 

我以root身份运行这些命令。 任何ides?

这个错误看起来相关:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=706097

我可以使用coreutils 8.13-3.5在debian 7中重现它。

我认为不使用“–changes”或“–verbose”可以解决问题。

当我使用--verbose时,我在这周发生了这种事。 最初是困惑,但认为我已经缩小了。 只有当SETGID位被设置时才会发生这种情况。

testing设置:

 $ mkdir --parent foo/bar 

没有SetGID,没有错误:

 $ chmod --recursive --changes o-rwx foo mode of 'foo' changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---) mode of 'foo/bar' changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---) 

用SETGID,错误:

 $ chmod --recursive g+s foo $ chmod --recursive --changes o-rwx foo mode of 'foo' changed from 2775 (rwxrwsr-x) to 2770 (rwxrws---) chmod: getting new attributes of 'bar': No such file or directory 

作为解决方法,使用find

 $ find foo | xargs chmod --changes o-rwx mode of 'foo' changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---) mode of 'foo/bar' changed from 0775 (rwxrwxr-x) to 0770 (rwxrwx---) 

希望这可以帮助!