Janis Danisevskis | 2ded9cb | 2021-10-20 08:39:30 -0700 | [diff] [blame^] | 1 | // Copyright 2021, The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | //! This crate provides convenience wrappers for the SELinux permission |
| 16 | //! defined in the diced SELinux access class. |
| 17 | |
| 18 | use keystore2_selinux as selinux; |
| 19 | use selinux::{implement_class, ClassPermission}; |
| 20 | |
| 21 | implement_class!( |
| 22 | /// Permission provides a convenient abstraction from the SELinux class `diced`. |
| 23 | #[selinux(class_name = diced)] |
| 24 | #[derive(Clone, Copy, Debug, PartialEq)] |
| 25 | pub enum Permission { |
| 26 | /// Checked when a client attempts to call seal or unseal. |
| 27 | #[selinux(name = use_seal)] |
| 28 | UseSeal, |
| 29 | /// Checked when a client attempts to call IDiceNode::sign. |
| 30 | #[selinux(name = use_sign)] |
| 31 | UseSign, |
| 32 | /// Checked when a client attempts to call IDiceNode::getAttestationChain. |
| 33 | #[selinux(name = get_attestation_chain)] |
| 34 | GetAttestationChain, |
| 35 | /// Checked when a client attempts to call IDiceNode::derive. |
| 36 | #[selinux(name = derive)] |
| 37 | Derive, |
| 38 | /// Checked when a client wants to demote itself by calling IDiceNode::demote. |
| 39 | #[selinux(name = demote)] |
| 40 | Demote, |
| 41 | /// Checked when a client calls IDiceMaintenance::demote in an attempt to |
| 42 | /// demote this dice node. |
| 43 | #[selinux(name = demote_self)] |
| 44 | DemoteSelf, |
| 45 | } |
| 46 | ); |