patch for SYS[BACKUKP|KM|DG] on DBD::Oracle 1.66

[email protected]
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <14507_1382594645_r9O645rj017763_OFD740939C.F7756040-ONC1257C0E.001C4185-C1257C0E.002154C3@servers.kbc.be>
Hi,

I needed the new Oracle 12c feature to connect to the database with 
SYSBACKUP.
So I patched the latest DBD::Oracle.



This patch supports ORA_SYSBACKUP, ORA_SYSDG and ORA_SYSKM.
The OCI parameter are OCI_SYSBKP, OCI_SYSDGD and OCI_SYSKMT
but since DBD::Oracle will be used by users who are used to use '/ as 
sysbackup' 
I decided to use ORA_SYSBACKUP over ORA_SYSBKP.

My test results : 

Extract from my $OH/rdbms/lib/config.c
#define SS_DBA_GRP "dba"
#define SS_OPER_GRP "dba"
#define SS_ASM_GRP ""
#define SS_BKP_GRP "bkpdba"
#define SS_DGD_GRP "dgddba"
#define SS_KMT_GRP "kmtdba"

My os users : 
grep dba /etc/passwd
bkpdba:x:4102:15001::/home/bkpdba:/bin/bash
dgddba:x:4103:15002::/home/dgddba:/bin/bash
kmtdba:x:4104:15003::/home/kmtdba:/bin/bash

My os grps :
grep dba /etc/group
dba:x:15000:
bkpdba:x:15001:oracle
dgddba:x:15002:oracle
kmtdba:x:15003:oracle

Test script (quick and dirty) :
#!/usr/local/bin/perl
use DBI;
use DBD::Oracle qw(:ora_session_modes);
use Data::Dumper;
my @session_modes = (ORA_SYSDBA, ORA_SYSBACKUP, ORA_SYSKM, ORA_SYSDG);

print "Execution user is :\n";
system("id");

foreach $session_mode ( @session_modes ) {
  printf( "Session mode is %x\n", $session_mode);

  $dbh = DBI->connect("dbi:Oracle:", "/", "", {PrintError=>0, 
ora_session_mode=>$session_mode});
  if (defined $dbh) {
    $ary_ref  = $dbh->selectall_arrayref("SELECT username FROM 
user_users");
    print $ary_ref->[0]->[0]."\n";
    $dbh->disconnect;
  } else {
    print $DBI::errstr . "\n";
  }

  print "\n";
}


Execution user is :
uid=80000649(oracle) gid=15000(dba) 
groups=15000(dba),15001(bkpdba),15002(dgddba),15003(kmtdba) 
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Session mode is 2
SYS

Session mode is 20000
SYSBACKUP

Session mode is 80000
SYSKM

Session mode is 40000
SYSDG


Execution user is :
uid=4102(bkpdba) gid=15001(bkpdba) groups=15001(bkpdba) 
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Session mode is 2
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)

Session mode is 20000
SYSBACKUP

Session mode is 80000
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)

Session mode is 40000
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)


Execution user is :
uid=4103(dgddba) gid=15002(dgddba) groups=15002(dgddba) 
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Session mode is 2
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)

Session mode is 20000
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)

Session mode is 80000
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)

Session mode is 40000
SYSDG


Execution user is :
uid=4104(kmtdba) gid=15003(kmtdba) groups=15003(kmtdba) 
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Session mode is 2
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)

Session mode is 20000
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)

Session mode is 80000
SYSKM

Session mode is 40000
ORA-01017: invalid username/password; logon denied (DBD ERROR: 
OCISessionBegin)



Met vriendelijke groeten,
Yours truly,
Kris Lemaire, Oracle DBA
Tel. + 32 15 35 93 38 - fax + 015 35 20 18 - [email protected]
Application Hosting Product Factory 1 - Server Frameworks - Databases 
KBC Global Services NV, COX (MECPark4 - COR+2 - CMS Infrastructuur - 
Databanken)
E. Walschaertsstraat 3, 2800 Mechelen, België

For additional information on our private cloud services we recommend the 
HPC portal (available internal KBC only)
Be green – keep it on the screen. Please think before you print this 
e-mail. 
KBC Global NV, Havenlaan 2, 1080 Brussels, Belgium, VAT BE 0465.746.488, 
RLP Brussels
A division of the KBC-group

This e-mail and any attached files are confidential and may be legally privileged. If you are not the addressee, any disclosure, reproduction, copying, distribution, or other dissemination or use of this communication is strictly prohibited. If you have received this transmission in error please notify KBC immediately and then delete this e-mail.
KBC does not accept liability for the correct and complete transmission of the information, nor for any delay or interruption of the transmission, nor for damages arising from the use of or reliance on the information.
All e-mail messages addressed to, received or sent by KBC or KBC employees are deemed to be professional in nature. Accordingly, the sender or recipient of these messages agrees that they may be read by other KBC employees than the official recipient or sender in order to ensure the continuity of work-related activities and allow supervision thereof.
(unnamed) (image/png, 9.4 KB) - not displayed
DBD-Oracle-1.66.withSYSBACKUP.patch (application/octet-stream, 1.9 KB)
diff -r -u DBD-Oracle-1.66/lib/DBD/Oracle.pm DBD-Oracle-1.66.withSYSBACKUP/lib/DBD/Oracle.pm
--- DBD-Oracle-1.66/lib/DBD/Oracle.pm	2013-08-23 18:59:32.000000000 +0200
+++ DBD-Oracle-1.66.withSYSBACKUP/lib/DBD/Oracle.pm	2013-10-24 06:56:21.034115585 +0200
@@ -35,7 +35,7 @@
 	    ORA_CLOB ORA_BLOB ORA_RSET ORA_VARCHAR2_TABLE ORA_NUMBER_TABLE
 	    SQLT_INT SQLT_FLT ORA_OCI SQLT_CHR SQLT_BIN
 	) ],
-        ora_session_modes => [ qw( ORA_SYSDBA ORA_SYSOPER ORA_SYSASM) ],
+        ora_session_modes => [ qw( ORA_SYSDBA ORA_SYSOPER ORA_SYSASM ORA_SYSBACKUP ORA_SYSDG ORA_SYSKM) ],
         ora_fetch_orient  => [ qw( OCI_FETCH_NEXT OCI_FETCH_CURRENT OCI_FETCH_FIRST
         			   OCI_FETCH_LAST OCI_FETCH_PRIOR OCI_FETCH_ABSOLUTE
         			   OCI_FETCH_RELATIVE)],
@@ -1186,7 +1186,7 @@
 
 =item :ora_session_modes
 
-ORA_SYSDBA ORA_SYSOPER ORA_SYSASM
+ORA_SYSDBA ORA_SYSOPER ORA_SYSASM ORA_SYSBACKUP ORA_SYSDG ORA_SYSKM
 
 =item :ora_types
 
@@ -1577,8 +1577,9 @@
 =head4 ora_session_mode
 
 The ora_session_mode attribute can be used to connect with SYSDBA,
-SYSOPER and ORA_SYSASM authorization.
-The ORA_SYSDBA, ORA_SYSOPER and ORA_SYSASM constants can be imported using
+SYSOPER, ORA_SYSASM, ORA_SYSBACKUP, ORA_SYSKM and ORA_SYSDG authorization.
+The ORA_SYSDBA, ORA_SYSOPER, ORA_SYSASM, ORA_SYSBACKUP, ORA_SYSKM 
+and ORA_SYSDG constants can be imported using
 
   use DBD::Oracle qw(:ora_session_modes);
 
diff -r -u DBD-Oracle-1.66/Oracle.xs DBD-Oracle-1.66.withSYSBACKUP/Oracle.xs
--- DBD-Oracle-1.66/Oracle.xs	2013-08-23 18:59:32.000000000 +0200
+++ DBD-Oracle-1.66.withSYSBACKUP/Oracle.xs	2013-10-24 07:01:51.157341144 +0200
@@ -30,6 +30,9 @@
 	ORA_SYSDBA	 		= 0x0002
 	ORA_SYSOPER	 		= 0x0004
 	ORA_SYSASM	 		= 0x8000
+	ORA_SYSBACKUP	 		= 0x00020000
+	ORA_SYSDG	 		= 0x00040000
+	ORA_SYSKM	 		= 0x00080000
 	SQLCS_IMPLICIT 		= SQLCS_IMPLICIT
 	SQLCS_NCHAR			= SQLCS_NCHAR
 	SQLT_INT	 		= SQLT_INT
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.