From 0a0964c71c19c9d434e4cc8dba047fd4677fb8f7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 30 May 2021 20:57:43 +0100 Subject: [PATCH] sshkeys: Provide MC::ThisConnAuthBy Signed-off-by: Ian Jackson --- daemon/cmdlistener.rs | 8 ++++++++ src/commands.rs | 8 ++++++++ src/mgmtchannel.rs | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index ce56b9f8..31c606ee 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -166,6 +166,14 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, } Fine }, + MC::ThisConnAuthBy => { + use MgmtThisConnAuthBy as MTCAB; + MR::ThisConnAuthBy(match &cs.authstate { + AuthState::None { .. } => MTCAB::Local, + AuthState::Superuser { .. } => MTCAB::Local, + AuthState::Ssh { key, .. } => MTCAB::Ssh { key: key.clone() }, + }) + } MC::SetRestrictedSshScope { key } => { let good_uid = Some(config().ssh_proxy_uid); let auth = cs.authorised_uid(good_uid, Some("SetRestrictedScope")) diff --git a/src/commands.rs b/src/commands.rs index e91ecc2c..04234759 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -62,6 +62,7 @@ pub enum MgmtCommand { SshListKeys, SshAddKey { akl: sshkeys::AuthkeysLine }, SshDeleteKey { index: usize, id: sshkeys::Id }, + ThisConnAuthBy, // -> Fine or SshKeySpec LoadFakeRng(Vec), } @@ -104,10 +105,17 @@ pub enum MgmtResponse { Bundle { bundle: bundles::Id }, SshKeys(Vec), SshKeyAdded { index: usize, id: sshkeys::Id }, + ThisConnAuthBy(MgmtThisConnAuthBy), } pub type MgmtBundleList = BTreeMap; +#[derive(Debug,Clone,Serialize,Deserialize)] +pub enum MgmtThisConnAuthBy { + Local, + Ssh { key: sshkeys::KeySpec }, +} + #[derive(Debug,Serialize,Deserialize)] pub enum MgmtGameInstruction { Noop, diff --git a/src/mgmtchannel.rs b/src/mgmtchannel.rs index a4a5692e..473fdde1 100644 --- a/src/mgmtchannel.rs +++ b/src/mgmtchannel.rs @@ -114,7 +114,7 @@ impl MgmtChannel { Progress(_) => panic!(), Fine | AccountsList{..} | GamesList{..} | Libraries(_) | LibraryItems(_) | Bundles{..} | Bundle{..} => { }, - SshKeys(..) | SshKeyAdded{..} => { }, + SshKeys(..) | SshKeyAdded{..} | ThisConnAuthBy{..} => { }, AlterGame { error: None, .. } => { }, Error { error } => { Err(error.clone()).context( -- 2.30.2