Debian Codegraph @

bash-completion/setpriv

raw
1 _setpriv_module()
2 {
3 local cur prev OPTS
4 COMPREPLY=()
5 cur="${COMP_WORDS[COMP_CWORD]}"
6 prev="${COMP_WORDS[COMP_CWORD-1]}"
7 case $prev in
8 '--ambient-caps'|'--inh-caps'|'--bounding-set')
9 local prefix realcur INHERIT_ALL INHERIT
10 realcur="${cur##*,}"
11 prefix="${cur%$realcur}"
12 INHERIT_ALL=$($1 --list-caps| command awk '{print $1, "-" $1}')
13 for WORD in $INHERIT_ALL; do
14 if ! [[ $prefix == *"$WORD"* ]]; then
15 INHERIT="$WORD ${INHERIT:-""}"
16 fi
17 done
18 compopt -o nospace
19 COMPREPLY=( $(compgen -P "$prefix" -W "$INHERIT" -S ',' -- $realcur) )
20 return 0
21 ;;
22 '--ruid'|'--euid'|'--reuid')
23 local UIDS
24 UIDS=$(command getent passwd | command awk -F: '{print $1}')
25 COMPREPLY=( $(compgen -W "$UIDS" -- $cur) )
26 return 0
27 ;;
28 '--rgid'|'--egid'|'--regid')
29 local GIDS
30 GIDS=$(command getent group | command awk -F: '{print $1}')
31 COMPREPLY=( $(compgen -W "$GIDS" -- $cur) )
32 return 0
33 ;;
34 '--groups')
35 local prefix realcur GIDS_ALL GIDS
36 realcur="${cur##*,}"
37 prefix="${cur%$realcur}"
38 GIDS_ALL=$(command getent group | command awk -F: '{print $3}')
39 for WORD in $GIDS_ALL; do
40 if ! [[ $prefix == *"$WORD"* ]]; then
41 GIDS="$WORD ${GIDS:-""}"
42 fi
43 done
44 compopt -o nospace
45 COMPREPLY=( $(compgen -P "$prefix" -W "$GIDS" -S ',' -- $realcur) )
46 return 0
47 ;;
48 '--securebits')
49 local prefix realcur SBITS_ALL SBITS WORD
50 realcur="${cur##*,}"
51 prefix="${cur%$realcur}"
52 SBITS_ALL="
53 {+,-}keep_caps_locked
54 {+,-}noroot
55 {+,-}noroot_locked
56 {+,-}no_setuid_fixup
57 {+,-}no_setuid_fixup_locked
58 "
59 for WORD in $SBITS_ALL; do
60 if ! [[ $prefix == *"$WORD"* ]]; then
61 SBITS="$WORD ${SBITS:-""}"
62 fi
63 done
64 compopt -o nospace
65 COMPREPLY=( $(compgen -P "$prefix" -W "$SBITS" -S ',' -- $realcur) )
66 return 0
67 ;;
68 '--pdeathsig')
69 local i signals
70 for i in $(kill -l); do
71 case $i in
72 SIG*)
73 signals+="$i "
74 ;;
75 esac
76 done
77 COMPREPLY=( $(compgen -W "keep clear $signals" -- $cur) )
78 return 0
79 ;;
80 '--selinux-label')
81 # FIXME: how to list selinux labels?
82 COMPREPLY=( $(compgen -W "label" -- $cur) )
83 return 0
84 ;;
85 '--apparmor-profile')
86 # FIXME: how to list apparmor profiles?
87 COMPREPLY=( $(compgen -W "profile" -- $cur) )
88 return 0
89 ;;
90 '--landlock-access')
91 # FIXME: how to list landlock accesses?
92 COMPREPLY=( $(compgen -W "access" -- $cur) )
93 return 0
94 ;;
95 '--landlock-rule')
96 # FIXME: how to list landlock rules?
97 COMPREPLY=( $(compgen -W "rule" -- $cur) )
98 return 0
99 ;;
100 '--seccomp-filter')
101 COMPREPLY=( $(compgen -f -- $cur) )
102 return 0
103 ;;
104 '-h'|'--help'|'-V'|'--version')
105 return 0
106 ;;
107 esac
108 case $cur in
109 -*)
110 OPTS="--dump
111 --no-new-privs
112 --ambient-caps
113 --inh-caps
114 --bounding-set
115 --ruid
116 --euid
117 --rgid
118 --egid
119 --reuid
120 --regid
121 --clear-groups
122 --keep-groups
123 --groups
124 --securebits
125 --pdeathsig
126 --reset-env
127 --init-groups
128 --nnp
129 --ptracer
130 --selinux-label
131 --apparmor-profile
132 --landlock-access
133 --landlock-rule
134 --seccomp-filter
135 --help
136 --version"
137 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
138 return 0
139 ;;
140 esac
141 compopt -o bashdefault
142 COMPREPLY=( $(compgen -c -- $cur) )
143 return 0
144 }
145 complete -F _setpriv_module setpriv