Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Furisto committed Jul 5, 2021
1 parent 9be94d9 commit 1643dd2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ pub fn drop_privileges(cs: &LinuxCapabilities, syscall: &impl Syscall) -> Result
#[cfg(test)]
mod tests {
use super::*;
use crate::command::test::TestHelperCommand;
use crate::command::test::TestHelperSyscall;

#[test]
fn test_reset_effective() {
let test_command = TestHelperCommand::default();
let test_command = TestHelperSyscall::default();
assert!(reset_effective(&test_command).is_ok());
let set_capability_args: Vec<_> = test_command
.get_set_capability_args()
Expand Down
6 changes: 3 additions & 3 deletions src/command/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ use crate::capabilities;

/// Empty structure to implement Command trait for
#[derive(Clone)]
pub struct LinuxCommand;
pub struct LinuxSyscall;

impl LinuxCommand {
impl LinuxSyscall {
unsafe fn from_raw_buf<'a, T>(p: *const c_char) -> T
where
T: From<&'a OsStr>,
Expand All @@ -46,7 +46,7 @@ impl LinuxCommand {
}
}

impl Syscall for LinuxCommand {
impl Syscall for LinuxSyscall {
/// To enable dynamic typing,
/// see https://doc.rust-lang.org/std/any/index.html for more information
fn as_any(&self) -> &dyn Any {
Expand Down
6 changes: 3 additions & 3 deletions src/command/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use nix::{

use oci_spec::LinuxRlimit;

use crate::command::{linux::LinuxCommand, test::TestHelperCommand};
use crate::command::{linux::LinuxSyscall, test::TestHelperSyscall};

/// This specifies various kernel/other functionalities required for
/// container management
Expand All @@ -30,8 +30,8 @@ pub trait Syscall {

pub fn create_syscall() -> Box<dyn Syscall> {
if cfg!(test) {
Box::new(TestHelperCommand::default())
Box::new(TestHelperSyscall::default())
} else {
Box::new(LinuxCommand)
Box::new(LinuxSyscall)
}
}
10 changes: 5 additions & 5 deletions src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ use oci_spec::LinuxRlimit;
use super::Syscall;

#[derive(Clone)]
pub struct TestHelperCommand {
pub struct TestHelperSyscall {
set_ns_args: RefCell<Vec<(i32, CloneFlags)>>,
unshare_args: RefCell<Vec<CloneFlags>>,
set_capability_args: RefCell<Vec<(CapSet, CapsHashSet)>>,
}

impl Default for TestHelperCommand {
impl Default for TestHelperSyscall {
fn default() -> Self {
TestHelperCommand {
TestHelperSyscall {
set_ns_args: RefCell::new(vec![]),
unshare_args: RefCell::new(vec![]),
set_capability_args: RefCell::new(vec![]),
}
}
}

impl Syscall for TestHelperCommand {
impl Syscall for TestHelperSyscall {
fn as_any(&self) -> &dyn Any {
self
}
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Syscall for TestHelperCommand {
}
}

impl TestHelperCommand {
impl TestHelperSyscall {
pub fn get_setns_args(&self) -> Vec<(i32, CloneFlags)> {
self.set_ns_args.borrow_mut().clone()
}
Expand Down
6 changes: 3 additions & 3 deletions src/container/builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::command::linux::LinuxCommand;
use crate::command::linux::LinuxSyscall;
use std::path::PathBuf;

use super::{init_builder::InitContainerBuilder, tenant_builder::TenantContainerBuilder};
Expand All @@ -7,7 +7,7 @@ pub struct ContainerBuilder {

pub(super) root_path: PathBuf,

pub(super) syscall: LinuxCommand,
pub(super) syscall: LinuxSyscall,

pub(super) pid_file: Option<PathBuf>,

Expand Down Expand Up @@ -46,7 +46,7 @@ impl ContainerBuilder {
Self {
container_id,
root_path,
syscall: LinuxCommand,
syscall: LinuxSyscall,
pid_file: None,
console_socket: None,
}
Expand Down
4 changes: 2 additions & 2 deletions src/container/builder_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use oci_spec::Spec;

use crate::{
cgroups,
command::{linux::LinuxCommand, Syscall},
command::{linux::LinuxSyscall, Syscall},
namespaces::Namespaces,
notify_socket::NotifyListener,
process::{fork, setup_init_process, Process},
Expand All @@ -22,7 +22,7 @@ use super::{Container, ContainerStatus};

pub(super) struct ContainerBuilderImpl {
pub init: bool,
pub syscall: LinuxCommand,
pub syscall: LinuxSyscall,
pub use_systemd: bool,
pub container_id: String,
pub root_path: PathBuf,
Expand Down
6 changes: 3 additions & 3 deletions src/namespaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod tests {
use oci_spec::LinuxNamespaceType;

use super::*;
use crate::command::test::TestHelperCommand;
use crate::command::test::TestHelperSyscall;

fn gen_sample_linux_namespaces() -> Vec<LinuxNamespace> {
vec![
Expand Down Expand Up @@ -112,7 +112,7 @@ mod tests {
fn test_namespaces_set_ns() {
let sample_linux_namespaces = gen_sample_linux_namespaces();
let namespaces: Namespaces = sample_linux_namespaces.into();
let test_command: &TestHelperCommand = namespaces.command.as_any().downcast_ref().unwrap();
let test_command: &TestHelperSyscall = namespaces.command.as_any().downcast_ref().unwrap();
assert!(namespaces.apply_setns().is_ok());

let mut setns_args: Vec<_> = test_command
Expand All @@ -132,7 +132,7 @@ mod tests {
let namespaces: Namespaces = sample_linux_namespaces.into();
assert!(namespaces.apply_unshare(CloneFlags::CLONE_NEWIPC).is_ok());

let test_command: &TestHelperCommand = namespaces.command.as_any().downcast_ref().unwrap();
let test_command: &TestHelperSyscall = namespaces.command.as_any().downcast_ref().unwrap();
let mut unshare_args = test_command.get_unshare_args();
unshare_args.sort();
let mut expect = vec![CloneFlags::CLONE_NEWUSER | CloneFlags::CLONE_NEWPID];
Expand Down

0 comments on commit 1643dd2

Please sign in to comment.