-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Description
Hi,
After upgrading to pljava 1.6.1 I'm seeing this error:
[local] user@database=> CREATE FUNCTION pljava_test(VARCHAR)
[more] - > RETURNS VARCHAR
[more] - > AS 'java.lang.System.getProperty'
[more] - > LANGUAGE java;
ERROR: must be superuser or a member of pg_read_all_settings to examine "pljava.policy_urls"
Is there any workaround to avoid granting pg_read_all_settings?
And after granting that role I can create the function but the policy kicks in. Is there any way of going back to the previous behaviour?, this change will break our applications until the third party providers change their side
[local] user@database=> select pljava_test('user.home');
ERROR: java.sql.SQLSyntaxErrorException: access denied ("java.util.PropertyPermission" "user.home" "read")
[local] user@database=> select name, setting from pg_settings where name like 'pljava%';
name | setting
-------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------
pljava.debug | off
pljava.enable | on
pljava.implementors | postgresql
pljava.java_thread_pg_entry | error
pljava.libjvm_location | /home/pgsqladm/openjdk/lib/server/libjvm.so
pljava.module_path | /pgsqladm/postgresql-server-11.10_el7_x86_64/share/pljava/pljava-1.6.1.jar:/pgsqladm/postgresql-server-11.10_el7_x86_64/share/pljava/pljava-api-1.6.1.jar
pljava.policy_urls | "file:${org.postgresql.sysconfdir}/pljava.policy","="
pljava.release_lingering_savepoints | off
pljava.statement_cache_size | 100
pljava.vmoptions | -Xms32M -Xmx128M -XX:ParallelGCThreads=2 -Xss2m
(10 rows)
pljava.policy
//
// Security policy for PL/Java. These grants are intended to add to those
// contained in the java.policy file of the standard Java installation.
//
//
// This grant is unconditional. It adds these properties to the standard Java
// list of system properties that any code may read.
//
grant {
// "standard" properties that can be read by anyone, by analogy to the
// ones so treated in Java itself.
//
permission java.util.PropertyPermission
"org.postgresql.version", "read";
permission java.util.PropertyPermission
"org.postgresql.pljava.version", "read";
permission java.util.PropertyPermission
"org.postgresql.pljava.native.version", "read";
permission java.util.PropertyPermission
"org.postgresql.pljava.udt.byteorder.*", "read";
permission java.util.PropertyPermission
"org.postgresql.server.encoding", "read";
// PostgreSQL allows SELECT current_database() or SHOW cluster_name anyway.
//
permission java.util.PropertyPermission
"org.postgresql.database", "read";
permission java.util.PropertyPermission
"org.postgresql.cluster", "read";
// SQL/JRT specifies this property.
//
permission java.util.PropertyPermission
"sqlj.defaultconnection", "read";
// This property is read in the innards of Java 9 and 10, but they forgot
// to add a permission for it. Not needed for Java 11 and later.
//
permission java.util.PropertyPermission
"jdk.lang.ref.disableClearBeforeEnqueue", "read";
};
//
// This grant is specific to the internal implementation of PL/Java itself,
// which needs these permissions for its own operations.
//
// Historically, PL/Java has been able to read any file on the server filesystem
// when a file: URL is passed to sqlj.install_jar or sqlj.replace_jar. Such a
// broad grant is not necessary, and can be narrowed below if desired.
//
grant codebase "${org.postgresql.pljava.codesource}" {
permission java.lang.RuntimePermission
"charsetProvider";
permission java.lang.RuntimePermission
"createClassLoader";
permission java.net.NetPermission
"specifyStreamHandler";
permission java.util.logging.LoggingPermission
"control";
permission java.security.SecurityPermission
"createAccessControlContext";
// This gives the PL/Java implementation code permission to read
// any file, which it only exercises on behalf of sqlj.install_jar()
// or sqlj.replace_jar() when called with a file: URL.
//
// There would be nothing wrong with restricting this permission to
// a specific directory, if all jar files to be loaded will be found there,
// or replacing it with a URLPermission if they will be hosted on a remote
// server, etc.
//
permission java.io.FilePermission
"<<ALL FILES>>", "read";
};
//
// This grant defines the mapping onto Java of PostgreSQL's "trusted language"
// category. When PL/Java executes a function whose SQL declaration names
// a language that was declared WITH the TRUSTED keyword, it will have these
// permissions, if any (in addition to whatever others might be granted to all
// code, or to its specific jar, etc.).
//
grant principal org.postgresql.pljava.PLPrincipal$Sandboxed * {
};
//
// This grant defines the mapping onto Java of PostgreSQL's "untrusted language"
// category. When PL/Java executes a function whose SQL declaration names
// a language that was declared WITHOUT the TRUSTED keyword, it will have these
// permissions (in addition to whatever others might be granted to all code, or
// to its specific jar, etc.).
//
grant principal org.postgresql.pljava.PLPrincipal$Unsandboxed * {
// Java does not circumvent operating system access controls; this grant
// will still be limited to what the OS allows a PostgreSQL backend process
// to do.
permission java.io.FilePermission
"<<ALL FILES>>", "read,readlink,write,delete";
};
//
// This grant applies to a specific PL/Java sandboxed language named java_tzset
// (if such a language exists) and grants functions created in that language
// permission to adjust the time zone. There is an example method in the
// org.postgresql.pljava.example.annotation.PreJSR310 class, which needs to
// temporarily adjust the time zone for a test. That example also uses
// sqlj.alias_java_language to create the java_tzset "language" when deployed,
// and DROP LANGUAGE to remove it when undeployed.
//
grant principal org.postgresql.pljava.PLPrincipal$Sandboxed "java_tzset" {
permission java.util.PropertyPermission "user.timezone", "write";
};
Metadata
Metadata
Assignees
Labels
No labels