我一直回到完美的基于Web的权限,我已经做了几个方法。 这篇文章没有那么复杂,我想提供一些样本。
我搜查了很多,但我想知道是否有一个事实上的标准。 感谢您的时间。
问:任何人都可以根据下面的基本权限目标,告诉我最好的方法吗?
0777模式 www-data是粘性的 myself默认用户是棒(如果可能,我不认为setfacl中存在默认) Ubuntu 16.04和16.10 (当下的桌面版本) 我已经设置了这个之前,我不知道为什么这突出了我的文件橙色,它关系到我 。 目标是将当前和新文件保存为www-data 。
sudo chgrp -R www-data /var/www sudo chmod -R g+rws /var/www # <-- s or S?
以上的作品大部分,但我已经读了它不好用 ,为什么? 所以我尝试了setfacl 。
在这里我setfacl ,问题是,它会使所有的当前文件+x的用户,我不希望这一点。
# For Current Files | User/Group sudo setfacl -Rm u:myself:rwx /var/www sudo setfacl -Rm g:ww-data:rwx /var/www # For Future Files | User/Group sudo setfacl -Rmd u:myself:rwx /var/www sudo setfacl -Rm g:www-data:rwx /var/www
所以我有一个疯狂的想法是做一个.bashrc函数这还不完全正确,但你明白了。
function facl_file() { echo "(+) Set ACL for $USER:www-data rw [Files Only, Persist]" # Files cannot have defaults -d permissions while IFS= read -r -d $'\0' file; do echo " Setting $file" # Default Mode: RW mode="rw" # If Executable, Add RWX if [[ -x "$file" ]]; then mode="rwx" fi sudo setfacl -mu:$USER:$mode $file sudo setfacl -mg:www-data:$mode $file done < <(find $CREATE -type f -print0) echo "(+) Done with Files" } function facl_dir() { echo "(+) Set ACL for $USER:www-data rwx [Directories Only, Persist]" while IFS= read -r -d $'\0' dir; do echo " Setting $dir" sudo setfacl -mu:$USER:rwx $dir sudo setfacl -dm u:$USER:rwx $dir sudo setfacl -mg:www-data:rwx $dir sudo setfacl -dm g:www-data:rwx $dir done < <(find $CREATE -type d -print0) echo "(+) Done with Directories" }
上面的目标是防止Directories丢失+x ,并防止不是+x文件成为它。
任何意见,将不胜感激,如果我走错了这一点。 我似乎无法find一个好的“粘性标准”。