diff --git a/src/main/scala/gitbucket/core/plugin/Plugin.scala b/src/main/scala/gitbucket/core/plugin/Plugin.scala index 6d2979d..1db553c 100644 --- a/src/main/scala/gitbucket/core/plugin/Plugin.scala +++ b/src/main/scala/gitbucket/core/plugin/Plugin.scala @@ -1,14 +1,15 @@ package gitbucket.core.plugin import javax.servlet.ServletContext - import gitbucket.core.controller.{Context, ControllerBase} import gitbucket.core.model.{Account, Issue} import gitbucket.core.service.RepositoryService.RepositoryInfo import gitbucket.core.service.SystemSettingsService.SystemSettings import io.github.gitbucket.solidbase.model.Version +import org.apache.sshd.server.channel.ChannelSession import org.apache.sshd.server.command.Command import play.twirl.api.Html + import scala.util.Using /** @@ -323,7 +324,7 @@ /** * Override to add ssh command providers. */ - val sshCommandProviders: Seq[PartialFunction[String, Command]] = Nil + val sshCommandProviders: Seq[PartialFunction[String, ChannelSession => Command]] = Nil /** * Override to add ssh command providers. @@ -332,7 +333,7 @@ registry: PluginRegistry, context: ServletContext, settings: SystemSettings - ): Seq[PartialFunction[String, Command]] = Nil + ): Seq[PartialFunction[String, ChannelSession => Command]] = Nil /** * This method is invoked in initialization of plugin system. diff --git a/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala b/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala index 217713d..4727b7a 100644 --- a/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala +++ b/src/main/scala/gitbucket/core/plugin/PluginRegistry.scala @@ -6,7 +6,6 @@ import java.util.Base64 import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.ConcurrentHashMap - import javax.servlet.ServletContext import com.github.zafarkhaja.semver.Version import gitbucket.core.controller.{Context, ControllerBase} @@ -21,6 +20,7 @@ import io.github.gitbucket.solidbase.manager.JDBCVersionManager import io.github.gitbucket.solidbase.model.Module import org.apache.commons.io.FileUtils +import org.apache.sshd.server.channel.ChannelSession import org.apache.sshd.server.command.Command import org.slf4j.LoggerFactory import play.twirl.api.Html @@ -58,7 +58,7 @@ private val suggestionProviders = new ConcurrentLinkedQueue[SuggestionProvider] suggestionProviders.add(new UserNameSuggestionProvider()) suggestionProviders.add(new IssueSuggestionProvider()) - private val sshCommandProviders = new ConcurrentLinkedQueue[PartialFunction[String, Command]]() + private val sshCommandProviders = new ConcurrentLinkedQueue[PartialFunction[String, ChannelSession => Command]]() def addPlugin(pluginInfo: PluginInfo): Unit = plugins.add(pluginInfo) @@ -177,10 +177,11 @@ def getSuggestionProviders: Seq[SuggestionProvider] = suggestionProviders.asScala.toSeq - def addSshCommandProvider(sshCommandProvider: PartialFunction[String, Command]): Unit = + def addSshCommandProvider(sshCommandProvider: PartialFunction[String, ChannelSession => Command]): Unit = sshCommandProviders.add(sshCommandProvider) - def getSshCommandProviders: Seq[PartialFunction[String, Command]] = sshCommandProviders.asScala.toSeq + def getSshCommandProviders: Seq[PartialFunction[String, ChannelSession => Command]] = + sshCommandProviders.asScala.toSeq } /** diff --git a/src/main/scala/gitbucket/core/ssh/GitCommand.scala b/src/main/scala/gitbucket/core/ssh/GitCommand.scala index 3e30d6d..9b73bb9 100644 --- a/src/main/scala/gitbucket/core/ssh/GitCommand.scala +++ b/src/main/scala/gitbucket/core/ssh/GitCommand.scala @@ -244,7 +244,7 @@ case f if f.isDefinedAt(command) => f(command) } - pluginCommand.getOrElse { + pluginCommand.map(_.apply(channel)).getOrElse { val (simpleRegex, defaultRegex) = if (sshAddress.isDefaultPort) { (SimpleCommandRegexPort22, DefaultCommandRegexPort22)