diff --git a/src/create.rs b/src/create.rs index b9f7678b..837a11b2 100644 --- a/src/create.rs +++ b/src/create.rs @@ -68,6 +68,7 @@ pub fn create_container( let mut file = OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(spec_path_backup) .expect("Unable to write spec to backup file!"); file.write_all(serde_json::to_string(&container).unwrap().as_bytes()) @@ -345,6 +346,7 @@ pub fn create_container( .read(true) .write(true) .create(true) + .truncate(true) .open(state_location) .expect("Could not create state-file in container dir!"); write!(state_file, "{pid}").expect("Could not write pid to state-file!"); diff --git a/src/devices.rs b/src/devices.rs index 21debde6..5819bd53 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -227,6 +227,7 @@ fn mount_device(rootfs: &Path, destination_rel: &Path, major: u64, minor: u64) { let _ = OpenOptions::new() .mode(0o755) .create(true) + .truncate(true) .write(true) .open(&destination) .unwrap_or_else(|_| { diff --git a/src/init.rs b/src/init.rs index d774ecf3..cdf7ec9a 100644 --- a/src/init.rs +++ b/src/init.rs @@ -477,6 +477,7 @@ fn init_stage_child(args: SetupArgs) -> ! { let mut sysctl_file = OpenOptions::new() .mode(0o644) .create(true) + .truncate(true) .write(true) .open(&full_path) .unwrap_or_else(|_| panic!("Could not create sysctl entry at {:?}", full_path)); diff --git a/src/logging.rs b/src/logging.rs index 4514532f..f93a613b 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -169,6 +169,7 @@ pub fn init( Some( OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(project_dir.join(format!( "log-{}.json", diff --git a/src/mounts.rs b/src/mounts.rs index 5c4e5601..70c9385f 100644 --- a/src/mounts.rs +++ b/src/mounts.rs @@ -34,6 +34,7 @@ pub fn mount_console(slave_path: &Path) { let _ = OpenOptions::new() .mode(0o666) .create(true) + .truncate(true) .write(true) .read(true) .open("/dev/console") @@ -119,6 +120,7 @@ pub fn configure_mounts( let _ = OpenOptions::new() .mode(0o755) .create(true) + .truncate(true) .write(true) .open(&destination_resolved) .unwrap_or_else(|_| {