2012-03-28 102 views
1

我想设置一些默认的继承权限,将一个目录传播到它将包含的所有新文件和文件夹。设置新文件的默认权限 - CentOS 6.0

到目前为止,我的尝试一直在使用setfacl,但是当我将新文件触摸到目录中时,它似乎将文件的执行权限去掉,考虑到这将是一个脚本文件夹。

我可能会采取这种完全错误的方式,但任何帮助将不胜感激。基本上我试图实现的是,脚本将被rsync化,从中央位置scp到(但不是此位置)主机上的某个位置,默认情况下,它们在创建时具有执行权限

$ mkdir /tmp/scripts 
$ cd /tmp/scripts 
$ setfacl -Rm d:u::rwx,d:g::rwx,d:o:rx /tmp/scripts 
$ getfacl /tmp/scripts/ 
getfacl: Removing leading '/' from absolute path names 
# file: tmp/scripts/ 
# owner: chris 
# group: chris 
user::rwx 
group::rwx 
other::r-x 
default:user::rwx 
default:group::rwx 
default:other::r-x 

$ setfacl -Rm d:u:chris:rwx,d:g:chris:rwx,d:o:rx /tmp/scripts 
$ getfacl /tmp/scripts/ 
getfacl: Removing leading '/' from absolute path names 
# file: tmp/scripts/ 
# owner: chris 
# group: chris 
user::rwx 
group::rwx 
other::r-x 
default:user::rwx 
default:user:chris:rwx 
default:group::rwx 
default:group:chris:rwx 
default:mask::rwx 
default:other::r-x 

$ setfacl -k /tmp/scripts 
$ setfacl -nRm d:u:chris:rwx,d:g:chris:rwx,d:o:rx /tmp/scripts 
$ getfacl /tmp/scripts/ 
getfacl: Removing leading '/' from absolute path names 
# file: tmp/scripts/ 
# owner: chris 
# group: chris 
user::rwx 
group::rwx 
other::r-x 
default:user::rwx 
default:user:chris:rwx 
default:group::rwx 
default:group:chris:rwx 
default:mask::rwx 
default:other::r-x 

$ touch this.py 
$ getfacl this.py 
# file: this.py 
# owner: chris 
# group: chris 
user::rw- 
user:chris:rwx     #effective:rw- 
group::rwx      #effective:rw- 
group:chris:rwx    #effective:rw- 
mask::rw- 
other::r-- 

$ ls -la 
total 20 
drwxrwxr-x+ 2 chris chris 4096 Mar 28 12:00 . 
drwxrwxrwt. 18 root root 4096 Mar 28 11:56 .. 
-rw-rw-r--+ 1 chris chris 0 Mar 28 11:58 test.py 
-rw-rw-r--+ 1 chris chris 0 Mar 28 12:00 this.py 
$ 

回答

2

IIRC基本的unix权限位也构成了文件可用权限的限制。

即可用的权限总是受基本权限的限制。基本权限可能受限于同步过程的umask,或受源文件的原始权限限制,因此您应该检查它们。

或者,您应该在完成同步后更正基本权限。

+0

是的,我有一种感觉,它会降低本地运行的东西来纠正权限。感谢道格拉斯 – azipheral 2012-03-28 12:04:32