-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SSHD-525] Server side implementation of [email protected]
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
|
||
## Minor code helpers | ||
|
||
* [SSHD-525](https://issues.apache.org/jira/browse/SSHD-525) Added support for SFTP **client-side** ["[email protected]" | ||
* [SSHD-525](https://issues.apache.org/jira/browse/SSHD-525) Added support for SFTP `[email protected]` | ||
extension](http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL?rev=1.28&content-type=text/x-cvsweb-markup) - see section 3.3 | ||
* [SSHD-1083](https://issues.apache.org/jira/browse/SSHD-1083) Relaxed required `Nio2Connector/Acceptor` required constructor arguments | ||
* [SSHD-1085](https://issues.apache.org/jira/browse/SSHD-1085) Added `CliLogger` + more verbosity on `SshClientMain` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ | |
import org.apache.sshd.sftp.common.extensions.openssh.FsyncExtensionParser; | ||
import org.apache.sshd.sftp.common.extensions.openssh.HardLinkExtensionParser; | ||
import org.apache.sshd.sftp.common.extensions.openssh.LSetStatExtensionParser; | ||
import org.apache.sshd.sftp.common.extensions.openssh.PosixRenameExtensionParser; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Apache MINA SSHD Project</a> | ||
|
@@ -130,7 +131,8 @@ NavigableMapBuilder.<String, OptionalFeature> builder() | |
Arrays.asList( | ||
new OpenSSHExtension(FsyncExtensionParser.NAME, "1"), | ||
new OpenSSHExtension(HardLinkExtensionParser.NAME, "1"), | ||
new OpenSSHExtension(LSetStatExtensionParser.NAME, "1"))); | ||
new OpenSSHExtension(LSetStatExtensionParser.NAME, "1"), | ||
new OpenSSHExtension(PosixRenameExtensionParser.NAME, "1"))); | ||
|
||
public static final List<String> DEFAULT_OPEN_SSH_EXTENSIONS_NAMES = Collections.unmodifiableList( | ||
NamedResource.getNameList(DEFAULT_OPEN_SSH_EXTENSIONS)); | ||
|
@@ -1226,6 +1228,23 @@ protected void doRename(int id, String oldPath, String newPath, Collection<CopyO | |
listener.moved(session, o, n, opts, null); | ||
} | ||
|
||
// see https://github.com/openssh/openssh-portable/blob/master/PROTOCOL section 3.3 | ||
protected void doPosixRename(Buffer buffer, int id) throws IOException { | ||
String oldPath = buffer.getString(); | ||
String newPath = buffer.getString(); | ||
try { | ||
int flags = SftpConstants.SSH_FXP_RENAME_ATOMIC | SftpConstants.SSH_FXP_RENAME_OVERWRITE; | ||
doRename(id, oldPath, newPath, flags); | ||
} catch (IOException | RuntimeException e) { | ||
sendStatus(prepareReply(buffer), id, e, | ||
SftpConstants.SSH_FXP_EXTENDED, SftpConstants.SSH_FXP_RENAME, | ||
oldPath, newPath); | ||
return; | ||
} | ||
|
||
sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, ""); | ||
} | ||
|
||
// see https://tools.ietf.org/html/draft-ietf-secsh-filexfer-extensions-00#section-7 | ||
protected void doCopyData(Buffer buffer, int id) throws IOException { | ||
String readHandle = buffer.getString(); | ||
|
@@ -1740,6 +1759,9 @@ protected void executeExtendedCommand(Buffer buffer, int id, String extension) t | |
case LSetStatExtensionParser.NAME: | ||
doSetStat(buffer, id, extension, -1, Boolean.FALSE); | ||
break; | ||
case PosixRenameExtensionParser.NAME: | ||
doPosixRename(buffer, id); | ||
break; | ||
default: | ||
doUnsupportedExtension(buffer, id, extension); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters