Skip to content

Commit 75ca6fa

Browse files
committed
_comp_selinux_users: new, use to complete user{add,mod} --selinux-user/-Z arg
1 parent e05885e commit 75ca6fa

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

bash_completion

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,13 @@ _allowed_groups()
14431443
fi
14441444
}
14451445

1446+
_comp_selinux_users()
1447+
{
1448+
COMPREPLY+=($(compgen -W '$(
1449+
semanage user -nl 2>/dev/null | awk "{ print \$1 }"
1450+
)' -- "$cur"))
1451+
}
1452+
14461453
# This function completes on valid shells
14471454
#
14481455
# @param $1 chroot to search from

completions/useradd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _useradd()
1919

2020
case $prev in
2121
--comment | --help | --expiredate | --inactive | --key | --password | \
22-
--uid | --selinux-user | -!(-*)[chefKpuZ])
22+
--uid | -!(-*)[chefKpu])
2323
return
2424
;;
2525
--base-dir | --home-dir | --skel | --root | -!(-*)[bdkR])
@@ -35,6 +35,10 @@ _useradd()
3535
_comp_delimited , -g
3636
return
3737
;;
38+
--selinux-user | -!(-*)Z)
39+
_comp_selinux_users
40+
return
41+
;;
3842
--shell | -!(-*)s)
3943
_shells "${chroot-}"
4044
return

completions/usermod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _usermod()
1919

2020
case $prev in
2121
--comment | --home | --expiredate | --inactive | --help | --login | \
22-
--password | --uid | --selinux-user | -!(-*)[cdefhlpuZ])
22+
--password | --uid | -!(-*)[cdefhlpu])
2323
return
2424
;;
2525
--gid | -!(-*)g)
@@ -35,6 +35,10 @@ _usermod()
3535
_filedir -d
3636
return
3737
;;
38+
--selinux-user | -!(-*)Z)
39+
_comp_selinux_users
40+
return
41+
;;
3842
--shell | -!(-*)s)
3943
_shells "${chroot-}"
4044
return

0 commit comments

Comments
 (0)