Permalink
Browse files

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

  • Loading branch information...
jglick authored and olivergondza committed Jun 10, 2013
1 parent 76163e2 commit b358d71ce0f0f8232bab211680f54eefd8ea973f
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;
@@ -81,6 +82,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;
@@ -446,8 +449,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;
@@ -472,8 +481,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 b358d71

Please sign in to comment.