semanage bash completion: handle semanage module
PATCH v2 1/1 semanage bash completion: handle semanage module
List modules for bash completion of semanage module.
Signed-off-by Topi Miettinen <[email protected]>
--
v2: removed -a or --add as they expect a file, not existing module
--- python/semanage/semanage-bash-completion.sh | 10 ++++++++++ 1 file changed, 10 insertions(+)
python/semanage/semanage-bash-completion.sh +10 -0
@@ -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,13 @@ _semanage () { if [ "$prev" = "-a" -a "$command" = "permissive" ]; then COMPREPLY=( $(compgen -W "$( __get_all_domains ) " -- "$cur") ) return 0 + elif [ "$command" = "module" ]; then + if [ "$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[*]}"
Signature · 1 line
2.26.2
Quoted 4 lines · Topi Miettinen
List modules for bash completion of
semanage module.Signed-off-by Topi Miettinen <[email protected]>
Acked-by Stephen Smalley <[email protected]>
Only caveat is that this can only work if running as root, e.g. sudo semanage module -d <TAB> will produce an error message from the shell but I guess that is true in general.
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Topi Miettinen
List modules for bash completion of
semanage module.
Quoted 7 lines
Quoted 1 line
Signed-off-by Topi Miettinen <[email protected]>Acked-by Stephen Smalley <[email protected]>Only caveat is that this can only work if running as root, e.g. sudo semanage module -d <TAB> will produce an error message from the shell but I guess that is true in general.
Applied.