Package org.apache.sshd.server.shell
Class ProcessShellFactory
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.server.shell.ProcessShellFactory
-
- All Implemented Interfaces:
ShellFactory
- Direct Known Subclasses:
InteractiveProcessShellFactory
public class ProcessShellFactory extends AbstractLoggingBean implements ShellFactory
AFactoryofCommandthat will create a new process executing the given command in an OS shell.Caveat: Apache MINA SSHD does not provide privilege separation, and SSH users are by default not tied to OS users. The OS shell will run as the same OS user the process using Apache MINA SSHD runs. The shell will have the same access rights as the Apache MINA SSHD server process itself.
It is in general not recommended to use this class as is in a production server.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringcommandprivate java.util.List<java.lang.String>elements-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ProcessShellFactory()ProcessShellFactory(java.lang.String command, java.lang.String... elements)ProcessShellFactory(java.lang.String command, java.util.List<java.lang.String> elements)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InvertedShellcreateInvertedShell(ChannelSession channel)CommandcreateShell(ChannelSession channel)java.lang.StringgetCommand()java.util.List<java.lang.String>getElements()protected java.util.List<java.lang.String>resolveEffectiveCommand(ChannelSession channel, java.lang.String rawCommand, java.util.List<java.lang.String> parsedElements)Determines the shell command to run.voidsetCommand(java.lang.String command, java.lang.String... elements)voidsetCommand(java.lang.String command, java.util.List<java.lang.String> elements)
-
-
-
Method Detail
-
getCommand
public java.lang.String getCommand()
- Returns:
- The original unparsed raw command
-
getElements
public java.util.List<java.lang.String> getElements()
- Returns:
- The parsed command elements
-
setCommand
public void setCommand(java.lang.String command, java.lang.String... elements)
-
setCommand
public void setCommand(java.lang.String command, java.util.List<java.lang.String> elements)
-
createShell
public Command createShell(ChannelSession channel)
- Specified by:
createShellin interfaceShellFactory- Parameters:
channel- TheChannelSessionthrough which the command has been received- Returns:
- The
Commandrepresenting the shell to be executed
-
createInvertedShell
protected InvertedShell createInvertedShell(ChannelSession channel)
-
resolveEffectiveCommand
protected java.util.List<java.lang.String> resolveEffectiveCommand(ChannelSession channel, java.lang.String rawCommand, java.util.List<java.lang.String> parsedElements)
Determines the shell command to run. On Windowscmd.exe /Cis used; on other systems/bin/sh -c.- Parameters:
channel-ChannelSessionthe shell will be executed inrawCommand- the shell command passedparsedElements- legacy; unused- Returns:
- a list containing the full command to run to execute the given
rawCommand
-
-