agent: clear MsFlags if the option has clear flag set

'FLAGS' hash map has bool to indicate if the flag should be cleared or
not. But in parse_mount_flags_and_options() we set the flag even 'clear'
is true. This results in a 'rw' mount being mounted as 'MS_RDONLY'.

Fixes: #2262
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
This commit is contained in:
Eryu Guan 2021-07-19 11:36:26 +08:00
parent 594ff3a5bd
commit 35cbc93dee
2 changed files with 12 additions and 4 deletions

View File

@ -549,8 +549,12 @@ fn parse_mount_flags_and_options(options_vec: Vec<&str>) -> (MsFlags, String) {
if !opt.is_empty() {
match FLAGS.get(opt) {
Some(x) => {
let (_, f) = *x;
flags |= f;
let (clear, f) = *x;
if clear {
flags &= !f;
} else {
flags |= f;
}
}
None => {
if !options.is_empty() {

View File

@ -121,8 +121,12 @@ impl Namespace {
let mut flags = MsFlags::empty();
if let Some(x) = FLAGS.get("rbind") {
let (_, f) = *x;
flags |= f;
let (clear, f) = *x;
if clear {
flags &= !f;
} else {
flags |= f;
}
};
let bare_mount = BareMount::new(source, destination, "none", flags, "", &logger);