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

[JENKINS-41684] Ensure that PluginManager.dynamicLoad runs as SYSTEM #2732

Merged

Conversation

jglick
Copy link
Member

@jglick jglick commented Feb 2, 2017

JENKINS-41684

@reviewbybees

…YSTEM.

Test plugin source:
package test;
import hudson.Plugin;
import jenkins.model.Jenkins;
public class ThePlugin extends Plugin {
    @OverRide
    public void postInitialize() throws Exception {
        Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
    }
}
@jglick
Copy link
Member Author

jglick commented Feb 3, 2017

Test failures look unrelated.

@@ -819,6 +819,7 @@ public void dynamicLoad(File arc) throws IOException, InterruptedException, Rest
*/
@Restricted(NoExternalUse.class)
public void dynamicLoad(File arc, boolean removeExisting) throws IOException, InterruptedException, RestartRequiredException {
try (ACLContext context = ACL.as(ACL.SYSTEM)) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to not indent this entire block?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to create a minimal diff, since the intervening block is quite long.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it is reasonable to keep the entire method within the clause anyway. There are extension points like PluginStrategy#updateDependency(), which may also blow up in the case of the non-System user

Copy link
Member Author

Choose a reason for hiding this comment

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

Unlikely but conceivable.

Copy link
Member

Choose a reason for hiding this comment

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

I wanted to create a minimal diff, since the intervening block is quite long.

and max efforts to read logic later

Copy link
Member

Choose a reason for hiding this comment

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

Extract to private method should also provide short diff.

Copy link
Member

Choose a reason for hiding this comment

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

Would really prefer if something would be done here for readability.

@@ -819,6 +819,7 @@ public void dynamicLoad(File arc) throws IOException, InterruptedException, Rest
*/
@Restricted(NoExternalUse.class)
public void dynamicLoad(File arc, boolean removeExisting) throws IOException, InterruptedException, RestartRequiredException {
try (ACLContext context = ACL.as(ACL.SYSTEM)) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it is reasonable to keep the entire method within the clause anyway. There are extension points like PluginStrategy#updateDependency(), which may also blow up in the case of the non-System user

@jglick jglick added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Feb 7, 2017
@jglick
Copy link
Member Author

jglick commented Feb 9, 2017

@reviewbybees done

Copy link
Member

@KostyaSha KostyaSha left a comment

Choose a reason for hiding this comment

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

intend, i.e. private method

@jglick
Copy link
Member Author

jglick commented Feb 10, 2017

Reindented. I am going to be the one resolving the nasty merge conflicts here in the future so I think this was a bad idea, but I am sick of trying to explain to people how important minimal diffs are.

@@ -819,100 +819,102 @@ public void dynamicLoad(File arc) throws IOException, InterruptedException, Rest
*/
@Restricted(NoExternalUse.class)
public void dynamicLoad(File arc, boolean removeExisting) throws IOException, InterruptedException, RestartRequiredException {
LOGGER.info("Attempting to dynamic load "+arc);
Copy link
Member Author

Choose a reason for hiding this comment

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

Now you are going to have use this to understand what is going on.

@KostyaSha
Copy link
Member

I am sick of trying to explain to people how important minimal diffs are.

You can make private method and you will have small diff. Making code messed will definitely make you alone to such parts of code.

@daniel-beck
Copy link
Member

👍

@jglick
Copy link
Member Author

jglick commented Feb 10, 2017

You can make private method and you will have small diff.

Yes, but at a cost of added complexity worse than either the diff size or nonstandard indentation.

@oleg-nenashev oleg-nenashev merged commit 6fb9e91 into jenkinsci:master Feb 12, 2017
@jglick jglick deleted the require-system-during-load-JENKINS-41684 branch February 13, 2017 14:04
daniel-beck added a commit that referenced this pull request Feb 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants