tape: finish api permission checks

This commit is contained in:
Dietmar Maurer
2021-03-05 11:40:52 +01:00
parent ee33795b72
commit b4975d3102
4 changed files with 151 additions and 4 deletions

View File

@ -29,6 +29,8 @@ use crate::{
cached_user_info::CachedUserInfo,
acl::{
PRIV_TAPE_AUDIT,
PRIV_TAPE_READ,
PRIV_TAPE_WRITE,
},
},
api2::{
@ -143,6 +145,9 @@ where
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Load media with specified label
///
@ -182,6 +187,9 @@ pub fn load_media(
},
},
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Load media from the specified slot
///
@ -215,6 +223,9 @@ pub async fn load_slot(drive: String, source_slot: u64) -> Result<(), Error> {
type: u64,
minimum: 1,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Export media with specified label
pub async fn export_media(drive: String, label_text: String) -> Result<u64, Error> {
@ -252,6 +263,9 @@ pub async fn export_media(drive: String, label_text: String) -> Result<u64, Erro
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Unload media via changer
pub fn unload(
@ -297,6 +311,9 @@ pub fn unload(
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_WRITE, false),
},
)]
/// Erase media. Check for label-text if given (cancels if wrong media).
pub fn erase_media(
@ -381,6 +398,9 @@ pub fn erase_media(
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Rewind tape
pub fn rewind(
@ -413,6 +433,9 @@ pub fn rewind(
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Eject/Unload drive media
pub fn eject_media(
@ -456,6 +479,9 @@ pub fn eject_media(
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_WRITE, false),
},
)]
/// Label media
///
@ -588,6 +614,9 @@ fn write_media_label(
},
},
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Try to restore a tape encryption key
pub async fn restore_key(
@ -631,6 +660,9 @@ pub async fn restore_key(
returns: {
type: MediaIdFlat,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Read media label (optionally inventorize media)
pub async fn read_label(
@ -706,6 +738,9 @@ pub async fn read_label(
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Clean drive
pub fn clean_drive(
@ -748,6 +783,9 @@ pub fn clean_drive(
type: LabelUuidMap,
},
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// List known media labels (Changer Inventory)
///
@ -817,6 +855,9 @@ pub async fn inventory(
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Update inventory
///
@ -911,6 +952,9 @@ pub fn update_inventory(
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_WRITE, false),
},
)]
/// Label media with barcodes from changer device
pub fn barcode_label_media(
@ -1020,6 +1064,9 @@ fn barcode_label_media_worker(
type: MamAttribute,
},
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_AUDIT, false),
},
)]
/// Read Cartridge Memory (Medium auxiliary memory attributes)
pub async fn cartridge_memory(drive: String) -> Result<Vec<MamAttribute>, Error> {
@ -1047,6 +1094,9 @@ pub async fn cartridge_memory(drive: String) -> Result<Vec<MamAttribute>, Error>
returns: {
type: Lp17VolumeStatistics,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_AUDIT, false),
},
)]
/// Read Volume Statistics (SCSI log page 17h)
pub async fn volume_statistics(drive: String) -> Result<Lp17VolumeStatistics, Error> {
@ -1074,6 +1124,9 @@ pub async fn volume_statistics(drive: String) -> Result<Lp17VolumeStatistics, Er
returns: {
type: LinuxDriveAndMediaStatus,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_AUDIT, false),
},
)]
/// Get drive/media status
pub async fn status(drive: String) -> Result<LinuxDriveAndMediaStatus, Error> {
@ -1115,6 +1168,9 @@ pub async fn status(drive: String) -> Result<LinuxDriveAndMediaStatus, Error> {
returns: {
schema: UPID_SCHEMA,
},
access: {
permission: &Permission::Privilege(&["tape", "device", "{drive}"], PRIV_TAPE_READ, false),
},
)]
/// Scan media and record content
pub fn catalog_media(