Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing SecurityManager in prep of JEP411 #7562

Closed
wants to merge 31 commits into from

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Feb 10, 2022

Removing the usages of deprecated (and slated for removal) methods and classes defined in JEP-411.

joakime and others added 30 commits January 21, 2022 09:36
+ Introduce new top levels
  /build/
  /jetty-core/
  /jetty-integrations/
  /jetty-ee9/
+ Ensure `mvn validate` is happy

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
+ Change artifactIds in /jetty-ee9/ to
  include jetty-ee9 prefix
+ Ensure 'mvn validate' is sane

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
+ Moving /demos/ to /jetty-ee9/jetty-ee9-demos/
+ Moving more /tests/ projects to /jetty-ee9/
+ Isolating ee9 dependencies properties to /jetty-ee9/
+ Establishing jetty-ee9-bom
+ Removing IO classes that were deleted in jetty-12.0.x

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are SecurityManager direct usages that it's ok to remove; fine with that.

There are doPrivileged() calls that I think were only used to "hide" operations that required permissions (e.g. load the logging properties) and that is ok to remove; fine with that.

There are doPrivileged() calls that were done to "cut" the AccessControlContext that was captured, which otherwise was retaining ClassLoader instances; I don't think it's ok to remove those, but I may be wrong.
If it's not ok, then perhaps try reflection?

@janbartel?

@janbartel
Copy link
Contributor

@sbordet @joakime see my comment over here #6184 (comment).

The java.security classes were essential in fixing the implementation of the Thread' constructor pinning of the classloader.

@sbordet
Copy link
Contributor

sbordet commented Feb 14, 2022

@janbartel I agree, Thread pinning the ClassLoader is category 3 of my comment above and I think it should remain, so that people using Java 17 will get the right effect, and those using a Java version without SecurityManager will have a modified Thread class that does not pin the ClassLoader, hopefully.

@sbordet
Copy link
Contributor

sbordet commented Feb 14, 2022

@janbartel looking at this in more details, I am dubious about the fix for the ClassLoader pinning.

See how Executors.privilegedThreadFactory() is doing things differently from our PrivilegedThreadFactory, in particular it does not replace the AccessControlContext, which pins a ProtectionDomain which pins the ClassLoader.

@janbartel
Copy link
Contributor

@sbordet Executors.privilegedThreadFactory will pin the AccessControlContext, thus the ProtectionDomain and the ClassLoader to be the same as the calling Thread. Thus, depending on when jetty called Executors.privilegedThreadFactory, we could be just pinning the server class loader, which would be fine. However, if it was called by code that was already in a context, then it would pin the context's classloader.

Our solution executes in a privileged block, which means that the AccessControlContext is effectively not inherited, thus the ProtectionDomain and attendant ClassLoader cannot be pinned.

@joakime
Copy link
Contributor Author

joakime commented Mar 1, 2022

@janbartel the AccessController is one of the classes deprecated by JEP-411, it's role in JDK-17 is a mere shell now, it barely does anything anymore as you cannot have a SecurityManager (most of the remaining methods now do nothing because of this, compared to previous JDKs).
A future JDK will just delete/remove AccessController entirely.

@gregw gregw force-pushed the jetty-12.0.x branch 3 times, most recently from fdbae02 to 0a32147 Compare May 3, 2022 13:56
@joakime
Copy link
Contributor Author

joakime commented Jun 28, 2022

Way out of date.
Will redo if there is a desire for it.
Closing.

@joakime joakime closed this Jun 28, 2022
Jetty 12.0.ALPHA1 automation moved this from In progress to Done Jun 28, 2022
@joakime joakime deleted the jetty-12.0.x-remove-security-manager branch June 28, 2022 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants