From da50e3817ae5ac1022ee396cfa81c64d11208198 Mon Sep 17 00:00:00 2001 From: "rongfu.leng" Date: Wed, 29 May 2024 15:58:49 +0800 Subject: [PATCH] add uid/gid mappings to mount Signed-off-by: rongfu.leng --- src/runtime/miscellaneous.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/runtime/miscellaneous.rs b/src/runtime/miscellaneous.rs index 73a9a7f399..f020661501 100644 --- a/src/runtime/miscellaneous.rs +++ b/src/runtime/miscellaneous.rs @@ -1,4 +1,5 @@ use crate::error::OciSpecError; +use crate::runtime::LinuxIdMapping; use derive_builder::Builder; use getset::{CopyGetters, Getters, MutGetters, Setters}; use serde::{Deserialize, Serialize}; @@ -76,6 +77,14 @@ pub struct Mount { #[serde(default, skip_serializing_if = "Option::is_none")] /// Options are fstab style mount options. options: Option>, + + #[serde(default, skip_serializing_if = "Option::is_none")] + /// UID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping. + uid_mappings: Option>, + + #[serde(default, skip_serializing_if = "Option::is_none")] + /// GID mappings used for changing file owners w/o calling chown, fs should support it. Every mount point could have its own mapping. + gid_mappings: Option>, } /// utility function to generate default config for mounts. @@ -86,6 +95,8 @@ pub fn get_default_mounts() -> Vec { typ: "proc".to_string().into(), source: PathBuf::from("proc").into(), options: None, + uid_mappings: None, + gid_mappings: None, }, Mount { destination: PathBuf::from("/dev"), @@ -98,6 +109,8 @@ pub fn get_default_mounts() -> Vec { "size=65536k".into(), ] .into(), + uid_mappings: None, + gid_mappings: None, }, Mount { destination: PathBuf::from("/dev/pts"), @@ -112,6 +125,8 @@ pub fn get_default_mounts() -> Vec { "gid=5".into(), ] .into(), + uid_mappings: None, + gid_mappings: None, }, Mount { destination: PathBuf::from("/dev/shm"), @@ -125,12 +140,16 @@ pub fn get_default_mounts() -> Vec { "size=65536k".into(), ] .into(), + uid_mappings: None, + gid_mappings: None, }, Mount { destination: PathBuf::from("/dev/mqueue"), typ: "mqueue".to_string().into(), source: PathBuf::from("mqueue").into(), options: vec!["nosuid".into(), "noexec".into(), "nodev".into()].into(), + uid_mappings: None, + gid_mappings: None, }, Mount { destination: PathBuf::from("/sys"), @@ -143,6 +162,8 @@ pub fn get_default_mounts() -> Vec { "ro".into(), ] .into(), + uid_mappings: None, + gid_mappings: None, }, Mount { destination: PathBuf::from("/sys/fs/cgroup"), @@ -156,6 +177,8 @@ pub fn get_default_mounts() -> Vec { "ro".into(), ] .into(), + uid_mappings: None, + gid_mappings: None, }, ] }