-
Notifications
You must be signed in to change notification settings - Fork 392
Support for setfacl #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Support for setfacl #639
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,92 @@ | ||||||||||||||||||||
# setfacl(1) completion -*- shell-script -*- | ||||||||||||||||||||
|
||||||||||||||||||||
_setfacl() | ||||||||||||||||||||
{ | ||||||||||||||||||||
local cur prev words cword split | ||||||||||||||||||||
# Don't treat user:group as separate words. | ||||||||||||||||||||
_init_completion -s -n : || return | ||||||||||||||||||||
|
||||||||||||||||||||
if [[ $cword -ge 2 ]]; then | ||||||||||||||||||||
Roy-Orbison marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
local word | ||||||||||||||||||||
for word in "${words[@]:1:$(( cword - 1 ))}"; do | ||||||||||||||||||||
Roy-Orbison marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
if [[ "$word" == '--' ]]; then | ||||||||||||||||||||
_filedir | ||||||||||||||||||||
return 0 | ||||||||||||||||||||
fi | ||||||||||||||||||||
done | ||||||||||||||||||||
fi | ||||||||||||||||||||
|
||||||||||||||||||||
case "$prev" in | ||||||||||||||||||||
--restore) | ||||||||||||||||||||
_filedir | ||||||||||||||||||||
return 0 | ||||||||||||||||||||
;; | ||||||||||||||||||||
|
||||||||||||||||||||
-m|--modify|-x|--remove|--set) | ||||||||||||||||||||
local other_rules prefix_default mycur | ||||||||||||||||||||
other_rules="${cur%"${cur##*,}"}" | ||||||||||||||||||||
cur="${cur##*,}" | ||||||||||||||||||||
if [[ $cur = d:* || $cur = default:* ]]; then | ||||||||||||||||||||
prefix_default=${cur%%"${cur#*:}"} | ||||||||||||||||||||
cur="${cur#*:}" | ||||||||||||||||||||
else | ||||||||||||||||||||
prefix_default= | ||||||||||||||||||||
fi | ||||||||||||||||||||
mycur="${cur##*:}" | ||||||||||||||||||||
if [[ $cur == *:*:*:* ]]; then | ||||||||||||||||||||
return | ||||||||||||||||||||
elif [[ $cur == *:*:* || $cur == [mo]*:* ]]; then | ||||||||||||||||||||
local opts | ||||||||||||||||||||
opts='- r w x X rw rx rX wx wX rwx rwX' | ||||||||||||||||||||
COMPREPLY=( $( compgen -S ',' -W "$opts" -- "$mycur" ) ) | ||||||||||||||||||||
elif [[ $cur == u*:* ]]; then | ||||||||||||||||||||
local IFS | ||||||||||||||||||||
IFS=$'\n' | ||||||||||||||||||||
COMPREPLY=( $( compgen -u -S ':' -- "$mycur" ) ) | ||||||||||||||||||||
elif [[ $cur == g*:* ]]; then | ||||||||||||||||||||
local IFS | ||||||||||||||||||||
IFS=$'\n' | ||||||||||||||||||||
COMPREPLY=( $( compgen -g -S ':' -- "$mycur" ) ) | ||||||||||||||||||||
else | ||||||||||||||||||||
local prefixes | ||||||||||||||||||||
prefixes='user: group: mask: other:' | ||||||||||||||||||||
if [[ -z $prefix_default ]]; then | ||||||||||||||||||||
prefixes+=' default:' | ||||||||||||||||||||
fi | ||||||||||||||||||||
COMPREPLY=( $( compgen -W "$prefixes" -- "$mycur" ) ) | ||||||||||||||||||||
fi | ||||||||||||||||||||
if [[ $cur != *:* && -z $prefix_default && "$other_rules" && ${#COMPREPLY[@]} -eq 1 ]]; then | ||||||||||||||||||||
COMPREPLY=("${other_rules##*:}${COMPREPLY[0]}") | ||||||||||||||||||||
fi | ||||||||||||||||||||
Comment on lines
+58
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't checked the actual behavior, but I guess this has the same problem as #913 (comment) when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably wouldn't have been picked up by the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no robust way to make the displayed list compact. You'll need to always prefix the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re #913:
My understanding was that omitting the prefix when there are multiple candidates makes the list more concise, thus easier to visually scan & less likely to cause pagination. It also provides the ability to create richer results, as demonstrated in this article. Without your suggestion the behaviour is like this: roy@RoyBook:~$ setfacl --set user:w
whoopsie: www-data:
roy@RoyBook:~$ setfacl --set user:whoopsie:rw
rw, rwx, rwX,
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:a
adm: audio: avahi: avahi-autoipd:
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:adm:
-, r, rw, rwx, rwX, rx, rX, w, wx, wX, x, X,
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:adm:rw,
default: group: mask: other: user:
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:adm:rw,other:
-, r, rw, rwx, rwX, rx, rX, w, wx, wX, x, X,
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:adm:rw,other:r With it, the previous definition's mode is prepended to the next definition, which is a drop in readability: roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,
rwX,default: rwX,group: rwX,mask: rwX,other: rwX,user:
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:a
adm: audio: avahi: avahi-autoipd:
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:adm:
-, r, rw, rwx, rwX, rx, rX, w, wx, wX, x, X,
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:adm:rw,
rw,default: rw,group: rw,mask: rw,other: rw,user: I tried to replicate the prefix loss per the last snippet of your comment, but it did not seem to occur. Perhaps this function is not affected due to the slightly different behviour around colons? roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:avahi
avahi: avahi-autoipd:
roy@RoyBook:~$ setfacl --set user:whoopsie:rwX,group:av<TAB> |
||||||||||||||||||||
[[ $COMPREPLY == *[:,] ]] && compopt -o nospace | ||||||||||||||||||||
return 0 | ||||||||||||||||||||
;; | ||||||||||||||||||||
|
||||||||||||||||||||
-M|--modify-file|-X|--remove-file|--set-file) | ||||||||||||||||||||
_filedir | ||||||||||||||||||||
return 0 | ||||||||||||||||||||
;; | ||||||||||||||||||||
|
||||||||||||||||||||
esac | ||||||||||||||||||||
|
||||||||||||||||||||
$split && return 0 | ||||||||||||||||||||
|
||||||||||||||||||||
if [[ "$cur" == -* || $cword -eq 1 ]]; then | ||||||||||||||||||||
local opts | ||||||||||||||||||||
opts='--modify-file= --modify --remove-file= --remove --set-file= --set | ||||||||||||||||||||
--remove-all --remove-default --no-mask --mask --default --test | ||||||||||||||||||||
--recursive --logical --physical --' | ||||||||||||||||||||
if [[ ${#words[@]} -eq 2 ]]; then | ||||||||||||||||||||
opts+=' --version --help --restore=' | ||||||||||||||||||||
elif [[ ${#words[@]} -eq 3 && "$prev" == --test ]]; then | ||||||||||||||||||||
opts+=' --restore=' | ||||||||||||||||||||
fi | ||||||||||||||||||||
COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) | ||||||||||||||||||||
[[ $COMPREPLY == *= ]] && compopt -o nospace | ||||||||||||||||||||
else | ||||||||||||||||||||
_filedir | ||||||||||||||||||||
fi | ||||||||||||||||||||
} && | ||||||||||||||||||||
complete -F _setfacl setfacl | ||||||||||||||||||||
Roy-Orbison marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||
|
||||||||||||||||||||
# ex: ts=4 sw=4 et filetype=sh |
Uh oh!
There was an error while loading. Please reload this page.