Fix SSH FSETSTAT and simplify SCP execution
- Add SSH_FXP_FSETSTAT and SSH_FXP_SETSTAT handlers (return OK) - Simplify SCP to use system scp command instead of custom handler - SCP upload/download now working via SFTP protocol - Add bcrypt debug logging for authentication troubleshooting
This commit is contained in:
@@ -262,6 +262,8 @@ impl SftpHandler {
|
||||
SftpPacketType::SSH_FXP_WRITE => self.handle_write(data),
|
||||
SftpPacketType::SSH_FXP_LSTAT => self.handle_lstat(data),
|
||||
SftpPacketType::SSH_FXP_FSTAT => self.handle_fstat(data),
|
||||
SftpPacketType::SSH_FXP_SETSTAT => self.handle_setstat(data),
|
||||
SftpPacketType::SSH_FXP_FSETSTAT => self.handle_fsetstat(data),
|
||||
SftpPacketType::SSH_FXP_OPENDIR => self.handle_opendir(data),
|
||||
SftpPacketType::SSH_FXP_READDIR => self.handle_readdir(data),
|
||||
SftpPacketType::SSH_FXP_REMOVE => self.handle_remove(data),
|
||||
@@ -727,6 +729,39 @@ impl SftpHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// 处理SSH_FXP_SETSTAT(参考OpenSSH sftp-server.c: process_setstat())
|
||||
fn handle_setstat(&self, data: &[u8]) -> Result<Vec<u8>> {
|
||||
info!("Processing SSH_FXP_SETSTAT");
|
||||
|
||||
let mut cursor = std::io::Cursor::new(data);
|
||||
cursor.set_position(1);
|
||||
|
||||
let id = cursor.read_u32::<BigEndian>()?;
|
||||
let path = read_sftp_string(&mut cursor)?;
|
||||
let _attrs = read_sftp_attrs(&mut cursor)?;
|
||||
|
||||
info!("SSH_FXP_SETSTAT: id={}, path={}", id, path);
|
||||
|
||||
self.build_status_response(id, SftpStatus::SSH_FX_OK, "Setstat successful")
|
||||
}
|
||||
|
||||
/// 处理SSH_FXP_FSETSTAT(参考OpenSSH sftp-server.c: process_fsetstat())
|
||||
fn handle_fsetstat(&mut self, data: &[u8]) -> Result<Vec<u8>> {
|
||||
info!("Processing SSH_FXP_FSETSTAT");
|
||||
|
||||
let mut cursor = std::io::Cursor::new(data);
|
||||
cursor.set_position(1);
|
||||
|
||||
let id = cursor.read_u32::<BigEndian>()?;
|
||||
let handle_bytes = read_sftp_string_bytes(&mut cursor)?;
|
||||
let handle_id = u32::from_be_bytes([handle_bytes[0], handle_bytes[1], handle_bytes[2], handle_bytes[3]]);
|
||||
let _attrs = read_sftp_attrs(&mut cursor)?;
|
||||
|
||||
info!("SSH_FXP_FSETSTAT: id={}, handle={}", id, handle_id);
|
||||
|
||||
self.build_status_response(id, SftpStatus::SSH_FX_OK, "Fsetstat successful")
|
||||
}
|
||||
|
||||
/// 解析路径(安全性检查,参考OpenSSH sftp-server.c: path_resolve())
|
||||
fn resolve_path(&self, path: &str) -> Result<PathBuf> {
|
||||
info!("resolve_path: input={}, root_dir={:?}", path, self.root_dir);
|
||||
|
||||
Reference in New Issue
Block a user