Skip to content

Commit

Permalink
add uid/gid mappings to mount
Browse files Browse the repository at this point in the history
Signed-off-by: rongfu.leng <[email protected]>
  • Loading branch information
lengrongfu committed May 29, 2024
1 parent d338cf8 commit da50e38
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/runtime/miscellaneous.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -76,6 +77,14 @@ pub struct Mount {
#[serde(default, skip_serializing_if = "Option::is_none")]
/// Options are fstab style mount options.
options: Option<Vec<String>>,

#[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<Vec<LinuxIdMapping>>,

#[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<Vec<LinuxIdMapping>>,
}

/// utility function to generate default config for mounts.
Expand All @@ -86,6 +95,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
typ: "proc".to_string().into(),
source: PathBuf::from("proc").into(),
options: None,
uid_mappings: None,
gid_mappings: None,
},
Mount {
destination: PathBuf::from("/dev"),
Expand All @@ -98,6 +109,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
"size=65536k".into(),
]
.into(),
uid_mappings: None,
gid_mappings: None,
},
Mount {
destination: PathBuf::from("/dev/pts"),
Expand All @@ -112,6 +125,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
"gid=5".into(),
]
.into(),
uid_mappings: None,
gid_mappings: None,
},
Mount {
destination: PathBuf::from("/dev/shm"),
Expand All @@ -125,12 +140,16 @@ pub fn get_default_mounts() -> Vec<Mount> {
"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"),
Expand All @@ -143,6 +162,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
"ro".into(),
]
.into(),
uid_mappings: None,
gid_mappings: None,
},
Mount {
destination: PathBuf::from("/sys/fs/cgroup"),
Expand All @@ -156,6 +177,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
"ro".into(),
]
.into(),
uid_mappings: None,
gid_mappings: None,
},
]
}
Expand Down

0 comments on commit da50e38

Please sign in to comment.