Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
target
Cargo.lock
railcar
.wercker
412 changes: 412 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ authors = ["Vishvananda Ishaya Abrams <[email protected]>"]
build = "build.rs"

[dependencies]
caps = "0.2.0"
clap = "2.24.1"
error-chain = "0.10.0"
lazy_static = "^1.1.0"
libc = "0.2.21"
log = {version = "0.4.3", features = ["release_max_level_info"] }
caps = "0.2"
clap = "2.24"
error-chain = "0.12"
lazy_static = "1"
libc = "0.2"
log = {version = "0.4", features = ["release_max_level_info"] }
nix = "0.11.0"
num-traits = "^0.2.5"
oci = { path = "oci" }
prctl = "1.0.0"
prctl = "1"
scopeguard = "^0.3.3"
seccomp-sys = "0.1.2"
seccomp-sys = "^0.1.2"

[features]
nightly = []
Expand Down
2 changes: 1 addition & 1 deletion libseccomp
Submodule libseccomp updated 124 files
2 changes: 1 addition & 1 deletion oci/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Error for SerializeError {
}
}

fn cause(&self) -> Option<&Error> {
fn cause(&self) -> Option<&dyn Error> {
match *self {
SerializeError::Io(ref err) => Some(err),
SerializeError::Json(ref err) => Some(err),
Expand Down
4 changes: 2 additions & 2 deletions src/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ fn to_set(caps: &[LinuxCapabilityType]) -> CapsHashSet {
capabilities
}

pub fn reset_effective() -> ::Result<()> {
pub fn reset_effective() -> crate::Result<()> {
set(None, CapSet::Effective, ::caps::all())?;
Ok(())
}

pub fn drop_privileges(cs: &LinuxCapabilities) -> ::Result<()> {
pub fn drop_privileges(cs: &LinuxCapabilities) -> crate::Result<()> {
let all = ::caps::all();
debug!("dropping bounding capabilities to {:?}", cs.bounding);
// drop excluded caps from the bounding set
Expand Down
2 changes: 1 addition & 1 deletion src/cgroups.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use errors::*;
use crate::errors::*;
use lazy_static::initialize;
use nix::unistd::Pid;
use num_traits::identities::Zero;
Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![recursion_limit = "1024"]
#![cfg_attr(feature = "nightly", feature(start))]
#![cfg_attr(feature = "nightly", feature(alloc_system))]
#![cfg_attr(feature = "nightly", feature(ord_max_min))]
#[cfg(feature = "nightly")]
extern crate alloc_system;

Expand Down Expand Up @@ -35,7 +36,7 @@ mod signals;
mod sync;

use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use errors::*;
use crate::errors::*;
use lazy_static::initialize;
use nix::errno::Errno;
use nix::fcntl::{open, OFlag};
Expand All @@ -51,7 +52,7 @@ use nix::sys::wait::{waitpid, WaitStatus};
use nix::unistd::{chdir, execvp, getpid, sethostname, setresgid, setresuid};
use nix::unistd::{close, dup2, fork, pipe2, read, setsid, write, ForkResult};
use nix::unistd::{Gid, Pid, Uid};
use nix_ext::{clearenv, putenv, setgroups, setrlimit};
use crate::nix_ext::{clearenv, putenv, setgroups, setrlimit};
use oci::{Linux, LinuxIDMapping, LinuxRlimit, Spec};
use oci::{LinuxDevice, LinuxDeviceType};
use std::collections::HashMap;
Expand All @@ -61,7 +62,7 @@ use std::io::{Read, Write};
use std::os::unix::fs::symlink;
use std::os::unix::io::{FromRawFd, RawFd};
use std::result::Result as StdResult;
use sync::Cond;
use crate::sync::Cond;

lazy_static! {
static ref DEFAULT_DEVICES: Vec<LinuxDevice> = {
Expand Down
8 changes: 4 additions & 4 deletions src/mounts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cgroups;
use errors::*;
use crate::cgroups;
use crate::errors::*;
use nix::errno::Errno;
use nix::fcntl::{open, OFlag};
use nix::mount::MsFlags;
Expand All @@ -9,9 +9,9 @@ use nix::sys::stat::{Mode, SFlag};
use nix::unistd::{chdir, chown, close, getcwd, pivot_root};
use nix::unistd::{Gid, Uid};
use nix::NixPath;
use nix_ext::fchdir;
use crate::nix_ext::fchdir;
use oci::{LinuxDevice, LinuxDeviceType, Mount, Spec};
use selinux::setfilecon;
use crate::selinux::setfilecon;
use std::collections::HashMap;
use std::fs::OpenOptions;
use std::fs::{canonicalize, create_dir_all, remove_file};
Expand Down
8 changes: 4 additions & 4 deletions src/seccomp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use errors::*;
use crate::errors::*;
use oci::{Arch, LinuxSeccomp, LinuxSeccompOperator};
use seccomp_sys::*;

Expand All @@ -10,7 +10,7 @@ fn to_cmp(cmp: LinuxSeccompOperator) -> scmp_compare {
unsafe { ::std::mem::transmute(cmp) }
}

fn syscall_resolve_name(name: &str) -> ::Result<i32> {
fn syscall_resolve_name(name: &str) -> crate::Result<i32> {
let s = ::std::ffi::CString::new(name)?;
let id = unsafe { seccomp_syscall_resolve_name(s.as_ptr()) };
if id == __NR_SCMP_ERROR {
Expand All @@ -31,7 +31,7 @@ fn init(act: u32) -> Result<*mut scmp_filter_ctx> {
}
}

fn arch_add(ctx: *mut scmp_filter_ctx, arch: scmp_arch) -> ::Result<i32> {
fn arch_add(ctx: *mut scmp_filter_ctx, arch: scmp_arch) -> crate::Result<i32> {
let id = unsafe { seccomp_arch_add(ctx, arch as u32) };
if id == __NR_SCMP_ERROR {
let msg = format!("could not add arch {:?}", arch);
Expand Down Expand Up @@ -87,7 +87,7 @@ fn load(ctx: *mut scmp_filter_ctx) -> Result<()> {
}
}

pub fn initialize_seccomp(seccomp: &LinuxSeccomp) -> ::Result<()> {
pub fn initialize_seccomp(seccomp: &LinuxSeccomp) -> crate::Result<()> {
let ctx = init(seccomp.default_action as u32)?;
// set control NoNewPrivs to false, as we deal with it separately
attr_set(ctx, scmp_filter_attr::SCMP_FLTATR_CTL_NNP, false as u32)?;
Expand Down
4 changes: 2 additions & 2 deletions src/selinux.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use errors::*;
use crate::errors::*;
use nix::fcntl::{open, OFlag};
use nix::sys::stat::Mode;
use nix::unistd::{close, write};
use nix_ext::lsetxattr;
use crate::nix_ext::lsetxattr;
use std::ffi::CString;

const EXEC_PATH: &'static str = "/proc/self/attr/exec";
Expand Down
2 changes: 1 addition & 1 deletion src/signals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use errors::*;
use crate::errors::*;
use libc::c_int;
use nix::sys::signal::{kill, raise, sigaction};
use nix::sys::signal::{SaFlags, SigAction, SigHandler, SigSet, Signal};
Expand Down