]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/setpriv
rev: be careful with close()
[thirdparty/util-linux.git] / bash-completion / setpriv
CommitLineData
c6f8c3f5
SK
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
37a6cc7a 8 '--ambient-caps'|'--inh-caps'|'--bounding-set')
b5b80e5a
BE
9 local prefix realcur INHERIT_ALL INHERIT
10 realcur="${cur##*,}"
11 prefix="${cur%$realcur}"
12 INHERIT_ALL=$($1 --list-caps| awk '{print $1, "-" $1}')
13 for WORD in $INHERIT_ALL; do
14 if ! [[ $prefix == *"$WORD"* ]]; then
37a6cc7a 15 INHERIT="$WORD ${INHERIT:-""}"
b5b80e5a
BE
16 fi
17 done
c6f8c3f5 18 compopt -o nospace
b5b80e5a 19 COMPREPLY=( $(compgen -P "$prefix" -W "$INHERIT" -S ',' -- $realcur) )
c6f8c3f5
SK
20 return 0
21 ;;
22 '--ruid'|'--euid'|'--reuid')
23 local UIDS
5feae697 24 UIDS=$(getent passwd | awk -F: '{print $1}')
c6f8c3f5
SK
25 COMPREPLY=( $(compgen -W "$UIDS" -- $cur) )
26 return 0
27 ;;
28 '--rgid'|'--egid'|'--regid')
29 local GIDS
5feae697 30 GIDS=$(getent group | awk -F: '{print $1}')
c6f8c3f5
SK
31 COMPREPLY=( $(compgen -W "$GIDS" -- $cur) )
32 return 0
33 ;;
34 '--groups')
b5b80e5a
BE
35 local prefix realcur GIDS_ALL GIDS
36 realcur="${cur##*,}"
37 prefix="${cur%$realcur}"
38 GIDS_ALL=$(getent group | awk -F: '{print $3}')
39 for WORD in $GIDS_ALL; do
40 if ! [[ $prefix == *"$WORD"* ]]; then
c6f0bdfe 41 GIDS="$WORD ${GIDS:-""}"
b5b80e5a
BE
42 fi
43 done
c6f8c3f5 44 compopt -o nospace
b5b80e5a 45 COMPREPLY=( $(compgen -P "$prefix" -W "$GIDS" -S ',' -- $realcur) )
c6f8c3f5
SK
46 return 0
47 ;;
48 '--securebits')
ecfb5b26
SK
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) )
c6f8c3f5
SK
66 return 0
67 ;;
5feae697
SK
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 ;;
c6f8c3f5
SK
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 ;;
d4f9b8d7
VS
90 '-h'|'--help'|'-V'|'--version')
91 return 0
92 ;;
c6f8c3f5
SK
93 esac
94 case $cur in
95 -*)
0d5b9b8a
VS
96 OPTS="--dump
97 --no-new-privs
37a6cc7a 98 --ambient-caps
c6f8c3f5
SK
99 --inh-caps
100 --bounding-set
101 --ruid
102 --euid
103 --rgid
104 --egid
105 --reuid
106 --regid
107 --clear-groupsclear
108 --keep-groupskeep
109 --groups
110 --securebits
5feae697
SK
111 --pdeathsig
112 --reset-env
c6f8c3f5
SK
113 --selinux-label
114 --apparmor-profile
0d5b9b8a
VS
115 --help
116 --version"
c6f8c3f5
SK
117 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
118 return 0
119 ;;
120 esac
121 compopt -o bashdefault
122 COMPREPLY=( $(compgen -c -- $cur) )
123 return 0
124}
125complete -F _setpriv_module setpriv