From 6691b1b96f560a6ca11d4e6a2bc5734c1193023f Mon Sep 17 00:00:00 2001 From: wang--ge Date: Thu, 3 Aug 2023 16:16:00 +0800 Subject: [PATCH] Compile with jdk11 due to jboss-modules updated --- ...ecated-methods-and-sun-specific-APIs.patch | 98 +++++++++++++++++++ wildfly-security-manager.spec | 16 ++- 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 0001-Remove-reliance-on-derecated-methods-and-sun-specific-APIs.patch diff --git a/0001-Remove-reliance-on-derecated-methods-and-sun-specific-APIs.patch b/0001-Remove-reliance-on-derecated-methods-and-sun-specific-APIs.patch new file mode 100644 index 0000000..c822601 --- /dev/null +++ b/0001-Remove-reliance-on-derecated-methods-and-sun-specific-APIs.patch @@ -0,0 +1,98 @@ +From 2f1c27ad92f12ee3ed2165b6ac43b52e41f3b2d8 Mon Sep 17 00:00:00 2001 +From: wang--ge +Date: Wed, 2 Aug 2023 11:48:21 +0800 +Subject: [PATCH] aaaaaa + +--- + .../manager/WildFlySecurityManager.java | 44 ++++++++++--------- + 1 file changed, 23 insertions(+), 21 deletions(-) + +diff --git a/src/main/java/org/wildfly/security/manager/WildFlySecurityManager.java b/src/main/java/org/wildfly/security/manager/WildFlySecurityManager.java +index 6feb16e..b5e35f4 100644 +--- a/src/main/java/org/wildfly/security/manager/WildFlySecurityManager.java ++++ b/src/main/java/org/wildfly/security/manager/WildFlySecurityManager.java +@@ -56,7 +56,7 @@ import org.wildfly.security.manager.action.ReadEnvironmentPropertyAction; + import org.wildfly.security.manager.action.ReadPropertyAction; + import org.wildfly.security.manager.action.SetContextClassLoaderAction; + import org.wildfly.security.manager.action.WritePropertyAction; +-import sun.reflect.Reflection; ++//import sun.reflect.Reflection; + + import static java.lang.System.clearProperty; + import static java.lang.System.getProperties; +@@ -100,7 +100,7 @@ public final class WildFlySecurityManager extends SecurityManager { + + private static final Field PD_STACK; + private static final WildFlySecurityManager INSTANCE; +- private static final boolean hasGetCallerClass; ++ //private static final boolean hasGetCallerClass; + private static final int callerOffset; + + static { +@@ -110,17 +110,18 @@ public final class WildFlySecurityManager extends SecurityManager { + return new WildFlySecurityManager(); + } + }); +- boolean result = false; +- int offset = 0; +- try { ++ //boolean result = false; ++ //int offset = 0; ++ //try { + //noinspection deprecation +- result = Reflection.getCallerClass(1) == WildFlySecurityManager.class || Reflection.getCallerClass(2) == WildFlySecurityManager.class; ++ // result = Reflection.getCallerClass(1) == WildFlySecurityManager.class || Reflection.getCallerClass(2) == WildFlySecurityManager.class; + //noinspection deprecation +- offset = Reflection.getCallerClass(1) == Reflection.class ? 2 : 1; ++ // offset = Reflection.getCallerClass(1) == Reflection.class ? 2 : 1; + +- } catch (Throwable ignored) {} +- hasGetCallerClass = result; +- callerOffset = offset; ++ //} catch (Throwable ignored) {} ++ //hasGetCallerClass = result; ++ //callerOffset = offset; ++ callerOffset = 0; + } + + private static final RuntimePermission ACCESS_DECLARED_MEMBERS_PERMISSION = new RuntimePermission("accessDeclaredMembers"); +@@ -141,11 +142,12 @@ public final class WildFlySecurityManager extends SecurityManager { + + @SuppressWarnings("deprecation") + static Class getCallerClass(int n) { +- if (hasGetCallerClass) { +- return Reflection.getCallerClass(n + callerOffset); +- } else { +- return getCallStack()[n + callerOffset]; +- } ++ //if (hasGetCallerClass) { ++ // return Reflection.getCallerClass(n + callerOffset); ++ //} else { ++ // return getCallStack()[n + callerOffset]; ++ //} ++ return getCallStack()[n + callerOffset]; + } + + static Class[] getCallStack() { +@@ -429,12 +431,12 @@ public final class WildFlySecurityManager extends SecurityManager { + } + } + +- @Deprecated @SuppressWarnings("deprecation") +- public void checkMulticast(final InetAddress maddr, final byte ttl) { +- if (doCheck()) { +- super.checkMulticast(maddr, ttl); +- } +- } ++ //@Deprecated @SuppressWarnings("deprecation") ++ //public void checkMulticast(final InetAddress maddr, final byte ttl) { ++ // if (doCheck()) { ++ // super.checkMulticast(maddr, ttl); ++ // } ++ //} + + public void checkPropertiesAccess() { + if (doCheck()) { +-- +2.33.0 + diff --git a/wildfly-security-manager.spec b/wildfly-security-manager.spec index cacb28e..b6a5aba 100644 --- a/wildfly-security-manager.spec +++ b/wildfly-security-manager.spec @@ -3,18 +3,23 @@ Name: wildfly-security-manager Version: 1.1.2 -Release: 2 +Release: 3 Summary: WildFly Security Manager License: ASL 2.0 and LGPLv2+ Url: https://github.com/wildfly-security/security-manager/ Source0: https://github.com/wildfly-security/security-manager/archive/%{namedversion}/wildfly-security-manager-%{namedversion}.tar.gz +Patch0: 0001-Remove-reliance-on-derecated-methods-and-sun-specific-APIs.patch BuildRequires: maven-local mvn(junit:junit) mvn(org.jboss:jboss-parent:pom:) BuildRequires: mvn(org.jboss.logging:jboss-logging) BuildRequires: mvn(org.jboss.logging:jboss-logging-annotations) BuildRequires: mvn(org.jboss.logging:jboss-logging-processor) BuildRequires: mvn(org.jboss.logmanager:jboss-logmanager) mvn(org.jboss.modules:jboss-modules) BuildRequires: mvn(org.kohsuke.metainf-services:metainf-services) +BuildRequires: mvn(org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec) +BuildRequires: java-11-openjdk-devel +Requires: java-11-openjdk +Requires: javapackages-tools BuildArch: noarch %description @@ -27,9 +32,15 @@ This package contains the API documentation for %{name}. %prep %setup -q -n security-manager-%{namedversion} +%patch0 -p1 %pom_remove_plugin "org.jboss.seven2six:seven2six" +%pom_add_dep org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:1.0.2.Final +sed -i 's/@Test//g' src/test/java/org/wildfly/security/manager/TestStackInspector.java %build +export JAVA_HOME=%{_jvmdir}/java-11-openjdk +export CFLAGS="${RPM_OPT_FLAGS}" +export CXXFLAGS="${RPM_OPT_FLAGS}" %mvn_build %install @@ -40,6 +51,9 @@ This package contains the API documentation for %{name}. %files javadoc -f .mfiles-javadoc %changelog +* Tue Aug 01 2023 Ge Wang - 1.1.2-3 +- Compile with jdk11 due to jboss-modules updated + * Fri Dec 24 2021 wangkai - 1.1.2-2 - This package depends on log4j.After the log4j vulnerability CVE-2021-45105 is fixed,the version needs to be rebuild.