From: Hannes Laimer <h.laimer@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/5] api: add Sys.Modify on /system/disks as permission to endpoints handling removable datastores
Date: Tue, 26 Nov 2024 12:43:20 +0100 [thread overview]
Message-ID: <20241126114323.105838-3-h.laimer@proxmox.com> (raw)
In-Reply-To: <20241126114323.105838-1-h.laimer@proxmox.com>
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/api2/admin/datastore.rs | 12 +++++++++---
src/api2/config/datastore.rs | 12 +++++++++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 1c939bc20..cae7eb89c 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -45,7 +45,7 @@ use pbs_api_types::{
BACKUP_TYPE_SCHEMA, CATALOG_NAME, CLIENT_LOG_BLOB_NAME, DATASTORE_SCHEMA,
IGNORE_VERIFIED_BACKUPS_SCHEMA, MANIFEST_BLOB_NAME, MAX_NAMESPACE_DEPTH, NS_MAX_DEPTH_SCHEMA,
PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, PRIV_DATASTORE_PRUNE,
- PRIV_DATASTORE_READ, PRIV_DATASTORE_VERIFY, UPID, UPID_SCHEMA,
+ PRIV_DATASTORE_READ, PRIV_DATASTORE_VERIFY, PRIV_SYS_MODIFY, UPID, UPID_SCHEMA,
VERIFICATION_OUTDATED_AFTER_SCHEMA,
};
use pbs_client::pxar::{create_tar, create_zip};
@@ -2512,7 +2512,10 @@ pub fn do_mount_device(datastore: DataStoreConfig) -> Result<(), Error> {
schema: UPID_SCHEMA,
},
access: {
- permission: &Permission::Privilege(&["datastore", "{store}"], PRIV_DATASTORE_AUDIT, false),
+ permission: &Permission::And(&[
+ &Permission::Privilege(&["datastore", "{store}"], PRIV_DATASTORE_AUDIT, false),
+ &Permission::Privilege(&["system", "disks"], PRIV_SYS_MODIFY, false)
+ ]),
},
)]
/// Mount removable datastore.
@@ -2625,7 +2628,10 @@ fn do_unmount_device(
schema: UPID_SCHEMA,
},
access: {
- permission: &Permission::Privilege(&["datastore", "{store}"], PRIV_DATASTORE_MODIFY, true),
+ permission: &Permission::And(&[
+ &Permission::Privilege(&["datastore", "{store}"], PRIV_DATASTORE_MODIFY, true),
+ &Permission::Privilege(&["system", "disks"], PRIV_SYS_MODIFY, false)
+ ]),
}
)]
/// Unmount a removable device that is associated with the datastore
diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index 121222c40..359b676a5 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -14,7 +14,7 @@ use proxmox_uuid::Uuid;
use pbs_api_types::{
Authid, DataStoreConfig, DataStoreConfigUpdater, DatastoreNotify, DatastoreTuning, KeepOptions,
MaintenanceMode, PruneJobConfig, PruneJobOptions, SyncDirection, DATASTORE_SCHEMA,
- PRIV_DATASTORE_ALLOCATE, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_MODIFY,
+ PRIV_DATASTORE_ALLOCATE, PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_MODIFY, PRIV_SYS_MODIFY,
PROXMOX_CONFIG_DIGEST_SCHEMA, UPID_SCHEMA,
};
use pbs_config::BackupLockGuard;
@@ -173,7 +173,10 @@ pub(crate) fn do_create_datastore(
},
},
access: {
- permission: &Permission::Privilege(&["datastore"], PRIV_DATASTORE_ALLOCATE, false),
+ permission: &Permission::And(&[
+ &Permission::Privilege(&["datastore"], PRIV_DATASTORE_ALLOCATE, false),
+ &Permission::Privilege(&["system", "disks"], PRIV_SYS_MODIFY, false)
+ ]),
},
)]
/// Create new datastore config.
@@ -551,7 +554,10 @@ pub fn update_datastore(
},
},
access: {
- permission: &Permission::Privilege(&["datastore", "{name}"], PRIV_DATASTORE_ALLOCATE, false),
+ permission: &Permission::And(&[
+ &Permission::Privilege(&["datastore", "{name}"], PRIV_DATASTORE_ALLOCATE, false),
+ &Permission::Privilege(&["system", "disks"], PRIV_SYS_MODIFY, false)
+ ]),
},
returns: {
schema: UPID_SCHEMA,
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-11-26 11:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 11:43 [pbs-devel] [PATCH proxmox-backup 0/5] removable datastore follow-up Hannes Laimer
2024-11-26 11:43 ` [pbs-devel] [PATCH proxmox-backup 1/5] api: mainatenance: allow setting of maintenance mode if 'unmounting' Hannes Laimer
2024-11-26 11:43 ` Hannes Laimer [this message]
2024-11-26 12:07 ` [pbs-devel] [PATCH proxmox-backup 2/5] api: add Sys.Modify on /system/disks as permission to endpoints handling removable datastores Fabian Grünbichler
2024-11-26 12:26 ` Thomas Lamprecht
2024-11-26 13:53 ` Hannes Laimer
2024-11-26 14:14 ` Fabian Grünbichler
2024-11-26 11:43 ` [pbs-devel] [PATCH proxmox-backup 3/5] api: types: add 'mount_status' to schema Hannes Laimer
2024-11-26 11:43 ` [pbs-devel] [PATCH proxmox-backup 4/5] docs: add information for removable datastores Hannes Laimer
2024-11-26 11:43 ` [pbs-devel] [PATCH proxmox-backup 5/5] ui: allow resetting unmounting maintenance Hannes Laimer
2024-11-26 12:11 ` Fabian Grünbichler
2024-11-26 15:35 ` [pbs-devel] applied: " Thomas Lamprecht
2024-11-26 12:09 ` [pbs-devel] partially applied: [PATCH proxmox-backup 0/5] removable datastore follow-up Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241126114323.105838-3-h.laimer@proxmox.com \
--to=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox