Skip to content
Permalink
Browse files

[JENKINS-18274] ComputerListener methods should be called as ACL.SYSTEM.

  • Loading branch information
jglick committed Jun 10, 2013
1 parent e50f0f5 commit ca5304307607a9bddfb472cf6dc014ed5c0f8f83
Showing with 19 additions and 4 deletions.
  1. +19 −4 core/src/main/java/hudson/slaves/SlaveComputer.java
@@ -39,6 +39,7 @@
import hudson.Util;
import hudson.AbortException;
import hudson.remoting.Launcher;
import hudson.security.ACL;
import static hudson.slaves.SlaveComputer.LogHolder.SLAVE_LOG_HANDLER;
import hudson.slaves.OfflineCause.ChannelTermination;
import hudson.util.Secret;
@@ -80,6 +81,8 @@
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponseWrapper;
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.kohsuke.stapler.ResponseImpl;
import org.kohsuke.stapler.WebMethod;
import org.kohsuke.stapler.compression.FilterServletOutputStream;
@@ -460,8 +463,14 @@ public void onClosed(Channel c, IOException cause) {
channel.pinClassLoader(getClass().getClassLoader());

channel.call(new SlaveInitializer());
for (ComputerListener cl : ComputerListener.all())
cl.preOnline(this,channel,root,taskListener);
SecurityContext old = ACL.impersonate(ACL.SYSTEM);
try {
for (ComputerListener cl : ComputerListener.all()) {
cl.preOnline(this,channel,root,taskListener);
}
} finally {
SecurityContextHolder.setContext(old);
}

offlineCause = null;

@@ -486,8 +495,14 @@ public void onClosed(Channel c, IOException cause) {
statusChangeLock.notifyAll();
}
}
for (ComputerListener cl : ComputerListener.all())
cl.onOnline(this,taskListener);
old = ACL.impersonate(ACL.SYSTEM);
try {
for (ComputerListener cl : ComputerListener.all()) {
cl.onOnline(this,taskListener);
}
} finally {
SecurityContextHolder.setContext(old);
}
log.println("Slave successfully connected and online");
Jenkins.getInstance().getQueue().scheduleMaintenance();
}

0 comments on commit ca53043

Please sign in to comment.
You can’t perform that action at this time.