Skip to content
Merged
2 changes: 1 addition & 1 deletion client/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl CommandContext for Cli {
fn session_stopped(&mut self, session_id: &SessionId) -> Result<(), CommandError> {
let mut session_guard = self.session.lock().unwrap();
if let Some(session) = session_guard.as_ref()
&& session.session_id() == session_id
&& session.session_id() == *session_id
{
let _ = session_guard.take();
}
Expand Down
22 changes: 9 additions & 13 deletions client/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ async fn session(
.await?
.into_inner();
if let Some(session_id) = session_id
&& *session.session_id() != session_id
&& session.session_id() != session_id
{
return Err(CommandError::MissingSession);
}
Expand All @@ -781,7 +781,7 @@ async fn session(
let session = if let Some(session_id) = session_id {
Session::new(session_id)
} else {
Session::new(SessionId::new())
Session::new(SessionId::random())
};
with_login(ctx, client, async || {
client
Expand Down Expand Up @@ -809,7 +809,7 @@ async fn session(
with_login(ctx, client, async || {
client
.session_allow_attach()
.session_id(session_id.clone())
.session_id(session_id)
.key_id(key_id.clone())
.access(access)
.send()
Expand All @@ -827,7 +827,7 @@ async fn session(
with_login(ctx, client, async || {
client
.session_deny_attach()
.session_id(session_id.clone())
.session_id(session_id)
.key_id(key_id.clone())
.send()
.await
Expand All @@ -843,11 +843,7 @@ async fn session(
return Err(CommandError::MissingSession);
};
with_login(ctx, client, async || {
client
.session_stop()
.session_id(session_id.clone())
.send()
.await
client.session_stop().session_id(*session_id).send().await
})
.await?;
ctx.session_stopped(session_id)?;
Expand Down Expand Up @@ -920,7 +916,7 @@ async fn job(
{
Ok(resp) => resp.into_inner(),
Err(CommandError::NotFound) => {
let session = Session::new(SessionId::new());
let session = Session::new(SessionId::random());
with_login(ctx, client, async || {
client
.session_start()
Expand Down Expand Up @@ -1136,7 +1132,7 @@ async fn job_start(
match with_login_via(ctx, client, Some(&target), async || {
client
.job_output()
.job_id(&job_id)
.job_id(job_id)
.target(target.to_string())
.stream(stream)
.send()
Expand Down Expand Up @@ -1242,7 +1238,7 @@ async fn job_output(
// Fetch job status for output length and hash.
let status = job_status_try_from_json_map(
with_login_via(ctx, client, Some(target), async || {
client.job_status().job_id(&job_id).send().await
client.job_status().job_id(job_id).send().await
})
.await?
.into_inner(),
Expand Down Expand Up @@ -1348,7 +1344,7 @@ async fn job_output(
async || {
client
.job_output()
.job_id(&job_id)
.job_id(job_id)
.target(target.to_string())
.stream(stream)
.send()
Expand Down
11 changes: 4 additions & 7 deletions client/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl IdentityError {

#[cfg(test)]
mod test {
use sush_common::codephrases::{PHRASE_WORDS_ID, WORD_SEPARATOR, generate_id};
use sush_common::codephrases::Codephrase;
use tempfile::TempDir;
use tokio::process::Command;

Expand Down Expand Up @@ -214,12 +214,9 @@ mod test {

let mut agent = SshAgentConnection::connect(&sock).await.unwrap();
for key in agent.list_identities().await.unwrap() {
let key_id = key.key_id().unwrap();
assert_eq!(key_id.split(WORD_SEPARATOR).count(), PHRASE_WORDS_ID);

let nonce = generate_id();
let signature = agent.sign_with(&key, nonce.as_bytes()).await.unwrap();
key.verify(nonce.as_bytes(), &signature).unwrap();
let nonce = Codephrase::random();
let signature = agent.sign_with(&key, &nonce.to_be_bytes()).await.unwrap();
key.verify(&nonce.to_be_bytes(), &signature).unwrap();
}

agent_process
Expand Down
Loading