[PATCH 5/5] adding completion to seadmin feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Leonidas Da Silva Barbosa <leosilva@xxxxxxxxxxxxxxxxxx>
---
 policycoreutils/sepolicy/sepolicy-bash-completion.sh | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/policycoreutils/sepolicy/sepolicy-bash-completion.sh b/policycoreutils/sepolicy/sepolicy-bash-completion.sh
index 779fd75..2b85ad9 100644
--- a/policycoreutils/sepolicy/sepolicy-bash-completion.sh
+++ b/policycoreutils/sepolicy/sepolicy-bash-completion.sh
@@ -60,6 +60,9 @@ __get_all_domain_types () {
 __get_all_domains () {
     seinfo -adomain -x 2>/dev/null | sed 's/_t$//g'
 }
+__get_all_roles () {
+    seinfo -r 2>/dev/null | tail -n +3
+}
 _sepolicy () {
         local command=${COMP_WORDS[1]}
         local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
@@ -74,6 +77,7 @@ _sepolicy () {
                [MANPAGE]='manpage'
                [NETWORK]='network'
                [TRANSITION]='transition'
+               [ADMIN]='admin'
         )
 
         COMMONOPTS='-P --policy -h --help'
@@ -86,6 +90,7 @@ _sepolicy () {
                [manpage]='-h --help -p --path -a -all -o --os -d --domain -w --web -r --root'
                [network]='-h --help -d --domain -l --list -p --port -t --type '
                [transition]='-h --help -s --source -t --target'
+               [admin]='-h --help -a --add -u --user -r --role -l --login -m --modify -d --delete -e --extend'
         )
 
         for ((i=0; $i <= $COMP_CWORD; i++)); do
@@ -189,7 +194,18 @@ _sepolicy () {
             fi
             COMPREPLY=( $(compgen -W '${OPTS[$verb]}' -- "$cur") )
             return 0
-        fi
+        elif [ "$verb" = "admin" ]; then
+            if [ "$prev" = "-u" -o "$prev" = "--user" ]; then
+                COMPREPLY=( $(compgen -W "$( __get_all_users ) " -- "$cur") )  
+                return 0
+            fi
+            if [ "$prev" = "-r" -o "$prev" = "--role" ]; then
+                COMPREPLY=( $(compgen -W "$( __get_all_roles ) " -- "$cur") )
+                return 0
+            fi
+            COMPREPLY=( $(compgen -W '${OPTS[$verb]}' -- "$cur") )
+            return 0
+        fi  
         COMPREPLY=( $(compgen -W "$comps" -- "$cur") )
         return 0
 }
-- 
1.8.3.1

--
selinux mailing list
selinux@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/selinux





[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux