mirror of
https://github.com/Noratrieb/cluelessh.git
synced 2026-01-14 16:35:06 +01:00
misc improvements
This commit is contained in:
parent
ca4213ba81
commit
26cdcd0524
7 changed files with 39 additions and 31 deletions
|
|
@ -43,7 +43,7 @@ impl InteractiveShell {
|
|||
127 => {
|
||||
// Backspace, space, backspace.
|
||||
// We literally erase it.
|
||||
if self.line_buf.len() > 0 {
|
||||
if !self.line_buf.is_empty() {
|
||||
self.write(&[8, 32, 8]);
|
||||
self.line_buf.truncate(self.line_buf.len() - 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ impl UserPublicKey {
|
|||
|
||||
let file = tokio::fs::read_to_string(sshd_dir)
|
||||
.await
|
||||
.map_err(|err| AuthError::NoAuthorizedKeys(err))?;
|
||||
.map_err(AuthError::NoAuthorizedKeys)?;
|
||||
|
||||
let authorized_keys = AuthorizedKeys::parse(&file)?;
|
||||
|
||||
if let Some(key) = authorized_keys.contains(&provided_key) {
|
||||
if let Some(key) = authorized_keys.contains(provided_key) {
|
||||
Ok(Self(key.clone()))
|
||||
} else {
|
||||
Err(AuthError::UnauthorizedPublicKey)
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ async fn handle_connection(
|
|||
}
|
||||
},
|
||||
},
|
||||
result = futures::future::try_join_all(&mut channel_tasks), if channel_tasks.len() > 0 => {
|
||||
result = futures::future::try_join_all(&mut channel_tasks), if !channel_tasks.is_empty() => {
|
||||
match result {
|
||||
Ok(_) => channel_tasks.clear(),
|
||||
Err(err) => return Err((err as eyre::Report).wrap_err("channel task failed")),
|
||||
|
|
@ -259,20 +259,17 @@ async fn handle_session_channel(user: String, channel: Channel) -> Result<()> {
|
|||
}
|
||||
}
|
||||
exit = state.process_exit_recv.recv() => {
|
||||
match exit {
|
||||
Some(exit) => {
|
||||
let exit = exit?;
|
||||
state.channel.send(ChannelOperationKind::Eof).await?;
|
||||
// TODO: also handle exit-signal
|
||||
state.channel
|
||||
.send(ChannelOperationKind::Request(ChannelRequest::ExitStatus {
|
||||
status: exit.code().unwrap_or(0) as u32,
|
||||
}))
|
||||
.await?;
|
||||
state.channel.send(ChannelOperationKind::Close).await?;
|
||||
return Ok(());
|
||||
}
|
||||
None => {}
|
||||
if let Some(exit) = exit {
|
||||
let exit = exit?;
|
||||
state.channel.send(ChannelOperationKind::Eof).await?;
|
||||
// TODO: also handle exit-signal
|
||||
state.channel
|
||||
.send(ChannelOperationKind::Request(ChannelRequest::ExitStatus {
|
||||
status: exit.code().unwrap_or(0) as u32,
|
||||
}))
|
||||
.await?;
|
||||
state.channel.send(ChannelOperationKind::Close).await?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
read = read => {
|
||||
|
|
@ -346,12 +343,11 @@ impl SessionState {
|
|||
};
|
||||
}
|
||||
ChannelUpdateKind::OpenFailed { .. } => todo!(),
|
||||
ChannelUpdateKind::Data { data } => match &mut self.writer {
|
||||
Some(pty) => {
|
||||
pty.write_all(&data).await?;
|
||||
ChannelUpdateKind::Data { data } => {
|
||||
if let Some(writer) = &mut self.writer {
|
||||
writer.write_all(&data).await?;
|
||||
}
|
||||
None => {}
|
||||
},
|
||||
}
|
||||
ChannelUpdateKind::Open(_)
|
||||
| ChannelUpdateKind::Closed
|
||||
| ChannelUpdateKind::ExtendedData { .. }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue