使用 ORACLE PL/SQL 执行 Unix Sun Solaris 命令权限问题
我创建了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个语句中的第三个参数应该是文件或目录路径,例如
,或者您可以只授予 ORION JAVASYSPRIV 角色 相反,因为这几乎就是您正在做的事情。
无论哪种方式,向 ORION 授予最大权限都会使该帐户变得非常强大,并且您需要严格控制该帐户,尤其是在生产环境中。
The third parameter in the first statement should be a file or directory path, e.g.
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.