Executing Unix Sun Solaris Commands Using ORACLE PL/SQL trouble with permissions
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");
retu开发者_运维问答rn;
} 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
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.
精彩评论