Blame SOURCES/bz1328386-3-oracle-monprofile-container-databases.patch

937446
From 3860fd89726e74946c9de660c885f60cacc1fda6 Mon Sep 17 00:00:00 2001
937446
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
937446
Date: Mon, 29 Aug 2016 17:33:01 +0200
937446
Subject: [PATCH] oracle: add quotes for monuser and monpassword and inform
937446
 user to start monuser with C## if it's a container database
937446
937446
---
937446
 heartbeat/oracle | 17 ++++++++++-------
937446
 1 file changed, 10 insertions(+), 7 deletions(-)
937446
937446
diff --git a/heartbeat/oracle b/heartbeat/oracle
937446
index da322a7..6fad5bc 100755
937446
--- a/heartbeat/oracle
937446
+++ b/heartbeat/oracle
937446
@@ -291,7 +291,7 @@ dbasql() {
937446
 	runsql "connect / as sysdba" $*
937446
 }
937446
 monsql() {
937446
-	runsql "connect $MONUSR/\"$MONPWD\"" $*
937446
+	runsql "connect \"$MONUSR\"/\"$MONPWD\"" $*
937446
 }
937446
 # use dbasql_one if the query should result in a single line output
937446
 # at times people stuff commands in oracle .profile
937446
@@ -379,19 +379,19 @@ show_mon_user() {
937446
 }
937446
 mk_mon_user() {
937446
 	cat<
937446
-create user $MONUSR identified by "$MONPWD" profile "$MONPROFILE";
937446
-grant create session to $MONUSR;
937446
-grant select on v_\$instance to $MONUSR;
937446
+create user "$MONUSR" identified by "$MONPWD" profile "$MONPROFILE";
937446
+grant create session to "$MONUSR";
937446
+grant select on v_\$instance to "$MONUSR";
937446
 EOF
937446
 }
937446
 show_mon_user_profile() {
937446
 	echo "select PROFILE from dba_users where USERNAME='$MONUSR';"
937446
 }
937446
 set_mon_user_profile() {
937446
-	echo "alter user $MONUSR profile '$MONPROFILE';"
937446
+	echo "alter user "$MONUSR" profile '$MONPROFILE';"
937446
 }
937446
 reset_mon_user_password() {
937446
-	echo "alter user $MONUSR identified by $MONPWD;"
937446
+	echo "alter user "$MONUSR" identified by "$MONPWD";"
937446
 }
937446
 check_mon_profile() {
937446
 	local output
937446
@@ -437,6 +437,9 @@ check_mon_user() {
937446
 	output=`dbasql mk_mon_user show_mon_user`
937446
 	if echo "$output" | grep -iw "^$MONUSR" >/dev/null; then
937446
 		return 0
937446
+	elif echo "$output" | grep ORA-65096 >/dev/null 2>&1; then
937446
+		ocf_exit_reason "monuser must start with C## for container databases"
937446
+		return $OCF_ERR_CONFIGURED
937446
 	else
937446
 		ocf_exit_reason "could not create $MONUSR oracle user"
937446
 		ocf_log err "sqlplus output: $output"
937446
@@ -757,7 +760,7 @@ MONUSR=${OCF_RESKEY_monuser:-$OCF_RESKEY_monuser_default}
937446
 MONPWD=${OCF_RESKEY_monpassword:-$OCF_RESKEY_monpassword_default}
937446
 MONPROFILE=${OCF_RESKEY_monprofile:-$OCF_RESKEY_monprofile_default}
937446
 
937446
-MONUSR=$(echo $MONUSR | awk '{print toupper($0)}')
937446
+MONUSR=$(echo "$MONUSR" | awk '{print toupper($0)}')
937446
 MONPROFILE=$(echo "$MONPROFILE" | awk '{print toupper($0)}')
937446
 OCF_REQUIRED_PARAMS="sid"
937446
 OCF_REQUIRED_BINARIES="sqlplus"