File and operating system interaction with SQL and PLSQL


Package file_security

Helper package for granting java file permissions. Can be used instead of DBMS_JAVA calls.


Field Summary
 pls_integerEXEC
           EXECUTE permission for a filesystem resource (file or folder)
 pls_integerREAD
           READ permission for a filesystem resource (file or folder)
 pls_integerWRITE
           WRITE permission for a filesystem resource (file or folder)

Method Summary
 varchar2get_script_grant_java_privs(p_directory varchar2, p_grantee varchar2)
           generates a SQL scripts with DBMS_JAVA.GRANT_PERMISSION calls according to the privileges granted on the directory object.
 grant_permission(p_file_path varchar2, p_grantee varchar2, p_permission pls_integer)
           Grants permissions on a file.
 grant_stdin_stdout(p_grantee varchar2)
           grants "file descriptor" read and write permissions - these are needed to access STDIN and STDOUT when working with OS_COMMAND.
 restrict_permission(p_file_path varchar2, p_grantee varchar2, p_permission pls_integer)
           restricts permissions on a file.
 revoke_permission(p_file_path varchar2, p_grantee varchar2, p_permission pls_integer)
           revokes permissions on a file.

Field Detail

READ

  public pls_integer READ
READ permission for a filesystem resource (file or folder)

WRITE

  public pls_integer WRITE
WRITE permission for a filesystem resource (file or folder)

EXEC

  public pls_integer EXEC
EXECUTE permission for a filesystem resource (file or folder)

Method Detail

grant_permission

public  grant_permission(p_file_path varchar2, 
p_grantee varchar2,
p_permission pls_integer)
Grants permissions on a file.
file_security.grant_permission(
p_file_path  => '/home/oracle/*,
p_grantee    => 'SCOTT',
p_permission => FILE_SECURITY.READ + FILE_SECURITY.WRITE
);
Parameters:
p_file_path - absolute path to the filesystem resource (file or folder). A star includes all files in a folder without the subfolders - a dash (-) includes all files in the folder and all subfolders recursively.
p_grantee - database user to which to grant the privileges
p_permission - permissions to grant - use the package constants READ, WRITE and EXECUTE


revoke_permission

public  revoke_permission(p_file_path varchar2, 
p_grantee varchar2,
p_permission pls_integer)
revokes permissions on a file.
file_security.revoke_permission(
p_file_path  => '/home/oracle/*,
p_grantee    => 'SCOTT',
p_permission => FILE_SECURITY.READ + FILE_SECURITY.WRITE
);
Parameters:
p_file_path - absolute path to the filesystem resource (file or folder). A star includes all files in a folder without the subfolders - a dash (-) includes all files in the folder and all subfolders recursively.
p_grantee - database user to which to grant the privileges
p_permission - permissions to grant - use the package constants READ, WRITE and EXECUTE


restrict_permission

public  restrict_permission(p_file_path varchar2, 
p_grantee varchar2,
p_permission pls_integer)
restricts permissions on a file. This is a function to work with "negative" privileges. An example might be to use GRANT_PERMISSION to grant access to a folder and the use RESTRICT_PERMISSION to exempt particular files.
file_security.restrict_permission(
p_file_path  => '/home/oracle/*,
p_grantee    => 'SCOTT',
p_permission => FILE_SECURITY.READ + FILE_SECURITY.WRITE
);
Parameters:
p_file_path - absolute path to the filesystem resource (file or folder). A star includes all files in a folder without the subfolders - a dash (-) includes all files in the folder and all subfolders recursively.
p_grantee - database user to which to grant the privileges
p_permission - permissions to grant - use the package constants READ, WRITE and EXECUTE


grant_stdin_stdout

public  grant_stdin_stdout(p_grantee varchar2)
grants "file descriptor" read and write permissions - these are needed to access STDIN and STDOUT when working with OS_COMMAND.
Parameters:
p_grantee - database user to which to grant the privileges


get_script_grant_java_privs

public varchar2 get_script_grant_java_privs(p_directory varchar2, 
p_grantee varchar2)
generates a SQL scripts with DBMS_JAVA.GRANT_PERMISSION calls according to the privileges granted on the directory object.
Parameters:
p_directory - name of the directory object
p_grantee - grantee to generate grants for. If none is given, grants are being generated for all grantees
Returns:
SQL script containing DBMS_JAVA.GRANT_PERMISSION calls for the given directory object


File and operating system interaction with SQL and PLSQL