#!/usr/bin/ksh # set -xv # program: smenu_db_role.sh # author : Bernard Polarski # 18 Jun 2009 # # this script regroup all role/grants utilities HOST=`hostname` HOST=`echo $HOST | awk '{ printf ("%-+15.15s",$1) }'` # ------------------------------------------------------------------------------------- function do_execute { $SETXV sqlplus -s "$CONNECT_STRING" <] : role/user distribution [ restricted to ] rol -r [] : user/role distribution [ restricted to ] Object grants: rol -o [] : object / user:role object grants -------------- System grants: rol -s [] : user / system Privileges ------------- Grants: rol -g : Grants for role ------- rol -t : Grants hierarchy for user Misc: rol -sp : Display users with the SYSDBA or SYSOPR privilge ----- rol -smap : List system privilege map Generated Scripts: ------------------ rol -cr : user grants script rol -gr : role grants script EOF exit } # ------------------------------------------------------------------------------------- # Main # ------------------------------------------------------------------------------------- if [ -z "$1" ];then help fi typeset -u fuser typeset -u frole typeset -u fentity while [ -n "$1" ] do case "$1" in -cr ) CHOICE=SCRIPT ; fuser=$2; shift ;; -g ) CHOICE=LIST_ROLE_GRANT ; frole=$2 ; shift ;; -gr ) CHOICE=ROB_CR ; frole=$2 ; shift ;; -l ) CHOICE=LIST_ROLE ;; -o ) CHOICE=OBJECT_GRANT ; fentity=$2; shift ;; -r ) CHOICE=ROLE_USER ; EXECUTE=YES if [ -n "$2" -a ! "$2" = "-v" ];then frole=$2 ; shift ; fi ;; -s ) CHOICE=SYSTEM_GRANT_TO_USER if [ -n "$2" -a ! "$2" = "-v" -a ! "$2" = "-u" ];then fuser=$2 ; shift ; fi ;; -smap ) CHOICE=MAP ; EXECUTE=YES ;; -sp ) CHOICE=PF ;; -t ) CHOICE=TREE ; fuser=$2 ; shift ;; -x ) EXECUTE=YES;; -v ) SETXV="set -xv";; -u ) if [ -n "$2" -a ! "$2" = "-v" ];then fuser=$2 ; shift fi if [ -z "$ACTION" ];then CHOICE=USER_ROLE ; EXECUTE=YES fi;; -h ) help ;; * ) echo "Unknown parameter : $1" ; exit ;; esac shift done # ...................................... # # ...................................... $SETXV # ...................................... # generate script to create role # ...................................... if [ "$CHOICE" = "ROB_CR" ];then . $SBIN/scripts/passwd.env . ${GET_PASSWD} $S_USER $ORACLE_SID if [ "x-$CONNECT_STRING" = "x-" ];then echo "could no get a the password of $S_USER" exit 0 fi sqlplus -s "$CONNECT_STRING" <