Plugins: Fix bug in stopping a ClientApp plugin with $parameters in the args

This commit is contained in:
zzz
2014-11-12 14:38:13 +00:00
parent fd7e549915
commit f19ec4bd44
3 changed files with 18 additions and 3 deletions

View File

@ -672,8 +672,20 @@ public class PluginStarter implements Runnable {
// If the client is a running ClientApp that we want to stop,
// bypass all the logic below.
if (action.equals("stop")) {
ClientApp ca = ctx.routerAppManager().getClientApp(app.className, LoadClientAppsJob.parseArgs(app.args));
if (ca != null && ca.getState() == ClientAppState.RUNNING) {
String[] argVal = LoadClientAppsJob.parseArgs(app.args);
// We must do all the substitution just as when started, so the
// argument array comparison in getClientApp() works.
// Do this after parsing so we don't need to worry about quoting
for (int i = 0; i < argVal.length; i++) {
if (argVal[i].indexOf("$") >= 0) {
argVal[i] = argVal[i].replace("$I2P", ctx.getBaseDir().getAbsolutePath());
argVal[i] = argVal[i].replace("$CONFIG", ctx.getConfigDir().getAbsolutePath());
argVal[i] = argVal[i].replace("$PLUGIN", pluginDir.getAbsolutePath());
}
}
ClientApp ca = ctx.routerAppManager().getClientApp(app.className, argVal);
if (ca != null) {
// even if (ca.getState() != ClientAppState.RUNNING), we do this, we don't want to fall thru
try {
ca.shutdown(LoadClientAppsJob.parseArgs(app.stopargs));
} catch (Throwable t) {