* [PATCH] semanage bash completion: handle semanage module #246
@ 2020-05-25 19:47 Topi Miettinen
2020-05-29 13:57 ` Stephen Smalley
0 siblings, 1 reply; 2+ messages in thread
From: Topi Miettinen @ 2020-05-25 19:47 UTC (permalink / raw)
To: selinux; +Cc: Topi Miettinen
List modules for bash completion of `semanage module`.
Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
---
python/semanage/semanage-bash-completion.sh | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/python/semanage/semanage-bash-completion.sh b/python/semanage/semanage-bash-completion.sh
index 2d811c98..a3993c58 100644
--- a/python/semanage/semanage-bash-completion.sh
+++ b/python/semanage/semanage-bash-completion.sh
@@ -54,6 +54,9 @@ __get_all_roles () {
__get_all_stores () {
dir -1 -F /etc/selinux/ | grep '/' | cut -d'/' -f 1
}
+__get_all_modules () {
+ semodule -l
+}
__get_import_opts () { echo '$ALL_OPTS --f --input_file' ; }
__get_export_opts () { echo '$ALL_OPTS --f --output_file' ; }
__get_boolean_opts () { echo '$ALL_OPTS --on -off -1 -0' ; }
@@ -88,6 +91,14 @@ _semanage () {
if [ "$prev" = "-a" -a "$command" = "permissive" ]; then
COMPREPLY=( $(compgen -W "$( __get_all_domains ) " -- "$cur") )
return 0
+ elif [ "$command" = "module" ]; then
+ if [ "$prev" = "-a" ] || [ "$prev" = "--add" ] \
+ || [ "$prev" = "-d" ] || [ "$prev" = "--disable" ] \
+ || [ "$prev" = "-e" ] || [ "$prev" = "--enable" ] \
+ || [ "$prev" = "-r" ] || [ "$prev" = "--remove" ]; then
+ COMPREPLY=( $(compgen -W "$( __get_all_modules ) " -- "$cur") )
+ return 0
+ fi
fi
if [ "$verb" = "" -a "$prev" = "semanage" ]; then
comps="${VERBS[*]}"
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] semanage bash completion: handle semanage module #246
2020-05-25 19:47 [PATCH] semanage bash completion: handle semanage module #246 Topi Miettinen
@ 2020-05-29 13:57 ` Stephen Smalley
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2020-05-29 13:57 UTC (permalink / raw)
To: Topi Miettinen; +Cc: SElinux list
On Mon, May 25, 2020 at 5:50 PM Topi Miettinen <toiwoton@gmail.com> wrote:
>
> List modules for bash completion of `semanage module`.
>
> Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
> ---
> python/semanage/semanage-bash-completion.sh | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/python/semanage/semanage-bash-completion.sh b/python/semanage/semanage-bash-completion.sh
> index 2d811c98..a3993c58 100644
> --- a/python/semanage/semanage-bash-completion.sh
> +++ b/python/semanage/semanage-bash-completion.sh
> @@ -54,6 +54,9 @@ __get_all_roles () {
> __get_all_stores () {
> dir -1 -F /etc/selinux/ | grep '/' | cut -d'/' -f 1
> }
> +__get_all_modules () {
> + semodule -l
> +}
> __get_import_opts () { echo '$ALL_OPTS --f --input_file' ; }
> __get_export_opts () { echo '$ALL_OPTS --f --output_file' ; }
> __get_boolean_opts () { echo '$ALL_OPTS --on -off -1 -0' ; }
> @@ -88,6 +91,14 @@ _semanage () {
> if [ "$prev" = "-a" -a "$command" = "permissive" ]; then
> COMPREPLY=( $(compgen -W "$( __get_all_domains ) " -- "$cur") )
> return 0
> + elif [ "$command" = "module" ]; then
> + if [ "$prev" = "-a" ] || [ "$prev" = "--add" ] \
For -a we likely don't want this because the argument should be a
module file path not an already installed module name.
> + || [ "$prev" = "-d" ] || [ "$prev" = "--disable" ] \
> + || [ "$prev" = "-e" ] || [ "$prev" = "--enable" ] \
> + || [ "$prev" = "-r" ] || [ "$prev" = "--remove" ]; then
> + COMPREPLY=( $(compgen -W "$( __get_all_modules ) " -- "$cur") )
> + return 0
> + fi
> fi
> if [ "$verb" = "" -a "$prev" = "semanage" ]; then
> comps="${VERBS[*]}"
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-29 13:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 19:47 [PATCH] semanage bash completion: handle semanage module #246 Topi Miettinen
2020-05-29 13:57 ` Stephen Smalley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).