Skip to content

Commit

Permalink
feat: Implement boilerplate for f/setstat
Browse files Browse the repository at this point in the history
This removes the Status::OpUnsupported so scp does not fail when copying over files.
It can be properly implemented at a later point in time as it really does not seem critical.

If setting file permissions is crucial to the user, it should be rather done via Windows onboard
tools rather than relying on the minimal, unix-style feature that is provided via sftp.
  • Loading branch information
tuxuser committed Aug 18, 2024
1 parent 4158384 commit c73c902
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions crates/solstice_daemon/src/sftp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ impl SftpSession {
language_tag: "en-US".to_string(),
}
}

fn set_file_attributes(&self, path: &PathBuf, attrs: &FileAttributes) {
// TODO: Implement me
}
}

#[async_trait]
Expand Down Expand Up @@ -477,7 +481,11 @@ impl russh_sftp::server::Handler for SftpSession {
attrs: FileAttributes,
) -> Result<Status, Self::Error> {
debug!("setstat: {id} {path} {attrs:?}");
Err(self.unimplemented())
let path = unix_like_path_to_windows_path(&path)
.ok_or(StatusCode::NoSuchFile)?;

self.set_file_attributes(&path, &attrs);
Ok(self.success(id))
}

/// Called on SSH_FXP_FSETSTAT
Expand All @@ -488,7 +496,14 @@ impl russh_sftp::server::Handler for SftpSession {
attrs: FileAttributes,
) -> Result<Status, Self::Error> {
debug!("fsetstat: {id} {handle} {attrs:?}");
Err(self.unimplemented())
let path = &self
.handles
.get(&handle)
.ok_or(StatusCode::NoSuchFile)?
.path;

self.set_file_attributes(path, &attrs);
Ok(self.success(id))
}

/// Called on SSH_FXP_REMOVE.
Expand Down

0 comments on commit c73c902

Please sign in to comment.