-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(libcontainer) no_pivot args is not used (#2923)
* Support setting no_pivot_root for create and run command Signed-off-by: Vanient <[email protected]> * fix: mount move before choot Move the rootfs to the root of the host filesystem before chrooting, this is equivalent to pivot_root, if don't move mount first, we will not see the new rootfs when exec into the container Signed-off-by: xujihui1985 <[email protected]> * fix(chroot): ensure mount occurs before chroot to mimic pivot_root behavior Move the mount operation to occur before calling chroot to better simulate the effect of pivot_root. Add a check to confirm if the current process is running inside an isolated mount namespace, ensuring proper mount handling. Signed-off-by: xujihui1985 <[email protected]> * implement intergration test for no-pivot Signed-off-by: xujihui1985 <[email protected]> * fix: add comments to no-pivot related code Signed-off-by: xujihui1985 <[email protected]> * fix(lint): fix format Signed-off-by: xujihui1985 <[email protected]> --------- Signed-off-by: Vanient <[email protected]> Signed-off-by: xujihui1985 <[email protected]> Co-authored-by: Vanient <[email protected]>
- Loading branch information
1 parent
6cee446
commit d071596
Showing
16 changed files
with
304 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use anyhow::{Context, Result}; | ||
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
use crate::utils::test_utils::test_inside_container_with_no_pivot; | ||
|
||
fn create_spec() -> Result<Spec> { | ||
SpecBuilder::default() | ||
.process( | ||
ProcessBuilder::default() | ||
.args(vec!["runtimetest".to_string(), "no_pivot".to_string()]) | ||
.build()?, | ||
) | ||
.build() | ||
.context("failed to create spec") | ||
} | ||
|
||
fn no_pivot_test() -> TestResult { | ||
let spec = test_result!(create_spec()); | ||
test_inside_container_with_no_pivot(spec, &|_| Ok(())) | ||
} | ||
|
||
pub fn get_no_pivot_test() -> TestGroup { | ||
let mut test_group = TestGroup::new("no_pivot"); | ||
let no_pivot_test = Test::new("no_pivot_test", Box::new(no_pivot_test)); | ||
test_group.add(vec![Box::new(no_pivot_test)]); | ||
|
||
test_group | ||
} |
Oops, something went wrong.