2012-03-28 100 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