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 f9969d3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/runtime/miscellaneous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use derive_builder::Builder;
use getset::{CopyGetters, Getters, MutGetters, Setters};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use crate::runtime::LinuxIdMapping;

#[derive(
Builder, Clone, CopyGetters, Debug, Deserialize, Eq, Getters, Setters, PartialEq, Serialize,
Expand Down Expand Up @@ -76,6 +77,15 @@ 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 +96,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 +110,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 +126,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 +141,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 +163,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 +178,8 @@ pub fn get_default_mounts() -> Vec<Mount> {
"ro".into(),
]
.into(),
uid_mappings: None,
gid_mappings: None,
},
]
}
Expand Down

0 comments on commit f9969d3

Please sign in to comment.