CC: | kris.lemaire [...] kbc.be |
Subject: | patch for SYS[BACKUKP|KM|DG] on DBD::Oracle 1.66 |
Originally sent to dbi-dev by Kris Lemaire - his email was:
==========
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)
==========
Martin
--
Martin J. Evans
Wetherby, UK
Subject: | DBD-Oracle-1.66.withSYSBACKUP.patch |
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