使用 ORACLE PL/SQL 执行 Unix Sun Solaris 命令权限问题

发布于 2024-11-28 09:53:47 字数 1348 浏览 1 评论 0原文

我创建了 2 个程序和一个 java 源

一个程序正在调用 java 类 TestHostCommand

 PROCEDURE TEST2
  (p_command IN Varchar2)
   AS LANGUAGE JAVA
    NAME 'TestHostCommand.executeCommand(java.lang.String)';

Java 源是:

import java.io.*;

public class TestHostCommand
{

public void executeCommand(String command)
 {
Runtime rt = Runtime.getRuntime();
Process p = null;
try
{
  p = rt.exec("ls > /Orion/list/list.txt");
  return;
} catch ( IOException ioe)
  {
    System.out.println("Error executing file");
  }
}

}

另一个程序是授予权限,但生成不正确:

     PROCEDURE GRANT_PERMISSION
      (grantee            IN  VARCHAR2,
       permission_type    IN  VARCHAR2,
       permission_name    IN  VARCHAR2,
       permission_action  IN  VARCHAR2)


        IS
        BEGIN
         DBMS_JAVA.grant_permission ('ORION', 'java.io.FilePermission',
                                   '<>', 'read ,write, execute, delete');

         DBMS_JAVA.grant_permission ('ORION', 'SYS:java.lang.RuntimePermission',
                                               'writeFileDescriptor', '');

          DBMS_JAVA.grant_permission ('Orion', 'SYS:java.lang.RuntimePermission',
                                                 'readFileDescriptor', '');

           END; 

错误是无效对象。

谢谢

I have created 2 procedure and a java source

One procedure is calling java class TestHostCommand

 PROCEDURE TEST2
  (p_command IN Varchar2)
   AS LANGUAGE JAVA
    NAME 'TestHostCommand.executeCommand(java.lang.String)';

Java Source is:

import java.io.*;

public class TestHostCommand
{

public void executeCommand(String command)
 {
Runtime rt = Runtime.getRuntime();
Process p = null;
try
{
  p = rt.exec("ls > /Orion/list/list.txt");
  return;
} catch ( IOException ioe)
  {
    System.out.println("Error executing file");
  }
}

}

And the other Procedure is to grant permissions but it is generated incorrectly:

     PROCEDURE GRANT_PERMISSION
      (grantee            IN  VARCHAR2,
       permission_type    IN  VARCHAR2,
       permission_name    IN  VARCHAR2,
       permission_action  IN  VARCHAR2)


        IS
        BEGIN
         DBMS_JAVA.grant_permission ('ORION', 'java.io.FilePermission',
                                   '<>', 'read ,write, execute, delete');

         DBMS_JAVA.grant_permission ('ORION', 'SYS:java.lang.RuntimePermission',
                                               'writeFileDescriptor', '');

          DBMS_JAVA.grant_permission ('Orion', 'SYS:java.lang.RuntimePermission',
                                                 'readFileDescriptor', '');

           END; 

Error is invalid object.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无法言说的痛 2024-12-05 09:53:47

第一个语句中的第三个参数应该是文件或目录路径,例如

     DBMS_JAVA.grant_permission ('ORION', 'java.io.FilePermission',
                               '/home/orion/*', 'read ,write, execute, delete');

,或者您可以只授予 ORION JAVASYSPRIV 角色 相反,因为这几乎就是您正在做的事情。

无论哪种方式,向 ORION 授予最大权限都会使该帐户变得非常强大,并且您需要严格控制该帐户,尤其是在生产环境中。

The third parameter in the first statement should be a file or directory path, e.g.

     DBMS_JAVA.grant_permission ('ORION', 'java.io.FilePermission',
                               '/home/orion/*', 'read ,write, execute, delete');

Alternatively you could just grant ORION the JAVASYSPRIV role instead, as it's pretty much what you're doing anyway.

Either way, granting maximal privileges to ORION makes the account very poweful, and one which you will need to control tightly, especially in production environments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文