chiark / gitweb /
for revert: invent ServerOperatorPrivilege
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 Aug 2020 18:34:58 +0000 (19:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 Aug 2020 18:34:58 +0000 (19:34 +0100)
gold plating

src/cmdlistener.rs

index 9db49c2bec78ceaa95b548799cb17a2217997012..e9bb38d6822ca6b9053d70c2c5703fb49efdd9f3 100644 (file)
@@ -109,22 +109,29 @@ fn authorise_scope(cs: &CommandStream, wanted: &ManagementScope)
     .map_err(|e| cs.map_auth_err(e))?
 }
 
+struct ServerOperatorPrivilege;
+#[throws(AuthorisationError)]
+fn do_authorise_server(cs: &CommandStream)
+                       -> AuthorisedSatisfactory<ServerOperatorPrivilege {
+  type AS<T> = (T, ManagementScope);
+  let y : AS<
+      Authorised<(Passwd,uid_t)>,
+    > = {
+    let ok = cs.authorised_uid(None,None)?;
+    (ok, ServerOperatorPrivilege)
+    )
+  };
+  return y.into()
+}
+
 #[throws(AuthorisationError)]
 fn do_authorise_scope(cs: &CommandStream, wanted: &ManagementScope)
                    -> AuthorisedSatisfactory {
   type AS<T> = (T, ManagementScope);
 
   match &wanted {
-
     ManagementScope::Server => {
-      let y : AS<
-        Authorised<(Passwd,uid_t)>,
-      > = {
-        let ok = cs.authorised_uid(None,None)?;
-        (ok,
-         ManagementScope::Server)
-      };
-      return y.into()
+      do_authorise_server(cs,wanted) ManagementScope::Server
     },
 
     ManagementScope::Unix { user: wanted } => {