chiark / gitweb /
sshkeys: Provide MC::ThisConnAuthBy
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 May 2021 19:57:43 +0000 (20:57 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 May 2021 19:57:43 +0000 (20:57 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs
src/commands.rs
src/mgmtchannel.rs

index ce56b9f80715fa273566924be64137e37f9764b0..31c606eedead4b9296ed5b82e398f348d61611eb 100644 (file)
@@ -166,6 +166,14 @@ fn execute_and_respond<W>(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"))
index e91ecc2c8d6391674129ba9683f9f0f826fdaaf5..04234759d0f1b38ee39de99915571e791baf81d9 100644 (file)
@@ -62,6 +62,7 @@ pub enum MgmtCommand {
   SshListKeys,
   SshAddKey { akl: sshkeys::AuthkeysLine },
   SshDeleteKey { index: usize, id: sshkeys::Id },
+  ThisConnAuthBy, // -> Fine or SshKeySpec
 
   LoadFakeRng(Vec<String>),
 }
@@ -104,10 +105,17 @@ pub enum MgmtResponse {
   Bundle { bundle: bundles::Id },
   SshKeys(Vec<sshkeys::MgmtKeyReport>),
   SshKeyAdded { index: usize, id: sshkeys::Id },
+  ThisConnAuthBy(MgmtThisConnAuthBy),
 }
 
 pub type MgmtBundleList = BTreeMap<bundles::Id, bundles::State>;
 
+#[derive(Debug,Clone,Serialize,Deserialize)]
+pub enum MgmtThisConnAuthBy {
+  Local,
+  Ssh { key: sshkeys::KeySpec },
+}
+
 #[derive(Debug,Serialize,Deserialize)]
 pub enum MgmtGameInstruction {
   Noop,
index a4a5692e149c46a5c58e858db7d25915032dcc20..473fdde1e6baadb8d4ac850ccbfcaf0b49b731eb 100644 (file)
@@ -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(