drcp_privileged.phpt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --TEST--
  2. DRCP: privileged connect
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. require(__DIR__."/connect.inc");
  8. if (!$test_drcp) die("skip requires DRCP connection");
  9. // Looked for :pooled in EZ connect string
  10. if (strpos($dbase, "/") !== false && stripos($dbase, ":pooled") === false)
  11. die('skip DRCP test requires a DRCP pooled server connection');
  12. if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
  13. ob_start();
  14. phpinfo(INFO_MODULES);
  15. $phpinfo = ob_get_clean();
  16. if (preg_match('/Compile-time ORACLE_HOME/', $phpinfo) !== 1) {
  17. // Assume building PHP with an ORACLE_HOME means the tested DB is on the same machine as PHP
  18. die("skip this test is unlikely to work with a remote database - unless an Oracle password file has been created");
  19. }
  20. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv);
  21. // This test in Oracle 12c needs a non-CDB or the root container
  22. if (isset($matches_sv[0]) && $matches_sv[1] >= 12) {
  23. $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual");
  24. $r = @oci_execute($s);
  25. if (!$r)
  26. die('skip could not identify container type');
  27. $r = oci_fetch_array($s);
  28. if ($r['DBTYPE'] !== 'CDB$ROOT')
  29. die('skip cannot run test using a PDB');
  30. }
  31. ?>
  32. --INI--
  33. oci8.privileged_connect=1
  34. --FILE--
  35. <?php
  36. // Connecting as SYSDBA or SYSOPER through DRCP will give ORA-1031
  37. require __DIR__."/details.inc";
  38. var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSDBA));
  39. var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSOPER));
  40. var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSDBA));
  41. var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSOPER));
  42. var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA));
  43. var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSOPER));
  44. echo "Done\n";
  45. ?>
  46. --EXPECTF--
  47. Warning: oci_connect(): ORA-01031: %s in %s on line %d
  48. bool(false)
  49. Warning: oci_connect(): ORA-01031: %s in %s on line %d
  50. bool(false)
  51. Warning: oci_new_connect(): ORA-01031: %s in %s on line %d
  52. bool(false)
  53. Warning: oci_new_connect(): ORA-01031: %s in %s on line %d
  54. bool(false)
  55. Warning: oci_pconnect(): ORA-01031: %s in %s on line %d
  56. bool(false)
  57. Warning: oci_pconnect(): ORA-01031: %s in %s on line %d
  58. bool(false)
  59. Done