Skip to content

Commit e1f8f32

Browse files
committed
more cleanup
1 parent a36d9a8 commit e1f8f32

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ edition = "2018"
77
[dependencies]
88
rand = "0.8.3"
99
serde = { version = "1.0.123", features = ["derive"] }
10-
serde_json = "1.0.62"
1110
backtrace = "0.3.56"
1211
thiserror = "1.0.23"
1312
anyhow = "1.0.38"
1413
once_cell = "1.5.2"
1514
futures-util = "0.3.12"
16-
tokio = { version = "1.2.0", features = ["net"] }
1715
tracing = "0.1.23"
1816

1917
[target.'cfg(target_os="linux")'.dependencies]

minion-tests/src/master.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ fn get_filter(matches: &clap::ArgMatches) -> Box<dyn Fn(&'static dyn TestCase) -
152152
}
153153

154154
fn check_static() {
155+
if cfg!(not(target_os = "linux")) {
156+
return;
157+
}
155158
let ldd_output = std::process::Command::new("ldd")
156159
.arg(std::env::current_exe().unwrap())
157160
.output()

src/windows/isolate.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use winapi::{
2020
pub(crate) struct Profile {
2121
/// Pointer to the Security Identifier (SID) of this container
2222
sid: PSID,
23+
/// Profile name (used in destructor)
24+
profile_name: Vec<u16>,
2325
}
2426

2527
unsafe impl Send for Profile {}
@@ -33,7 +35,6 @@ impl Profile {
3335
let profile_name = OsString::from(format!("minion-sandbox-appcontainer-{}", sandbox_id));
3436
let mut profile_name: Vec<u16> = profile_name.encode_wide().collect();
3537
profile_name.push(0);
36-
let profile_name = profile_name.as_ptr();
3738
let mut sid = std::ptr::null_mut();
3839
unsafe {
3940
let mut sid_string_repr = std::ptr::null_mut();
@@ -51,15 +52,15 @@ impl Profile {
5152
}
5253
unsafe {
5354
Cvt::hresult(CreateAppContainerProfile(
54-
profile_name,
55-
profile_name,
56-
profile_name,
55+
profile_name.as_ptr(),
56+
profile_name.as_ptr(),
57+
profile_name.as_ptr(),
5758
std::ptr::null_mut(),
5859
0,
5960
&mut sid,
6061
))?;
6162
}
62-
Ok(Profile { sid })
63+
Ok(Profile { sid, profile_name })
6364
}
6465
/// Returns `SECURITY_CAPABILITIES` representing this container.
6566
#[instrument(skip(self))]
@@ -75,6 +76,9 @@ impl Drop for Profile {
7576
fn drop(&mut self) {
7677
unsafe {
7778
FreeSid(self.sid);
79+
if let Err(e) = Cvt::hresult(DeleteAppContainerProfile(self.profile_name.as_ptr())) {
80+
tracing::warn!(error = %e, "Ignoring resource cleanup error");
81+
}
7882
}
7983
}
8084
}

src/windows/spawn.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ use winapi::{
2121
handleapi::INVALID_HANDLE_VALUE,
2222
minwinbase::SECURITY_ATTRIBUTES,
2323
processthreadsapi::{
24-
CreateProcessW, DeleteProcThreadAttributeList, GetCurrentProcess,
24+
CreateProcessW, DeleteProcThreadAttributeList,
2525
InitializeProcThreadAttributeList, UpdateProcThreadAttribute, PROCESS_INFORMATION,
2626
PROC_THREAD_ATTRIBUTE_LIST,
2727
},
28-
userenv::{CreateAppContainerProfile, DeleteAppContainerProfile},
2928
winbase::{
3029
CreateFileMappingA, CREATE_UNICODE_ENVIRONMENT, EXTENDED_STARTUPINFO_PRESENT,
3130
STARTF_USESTDHANDLES, STARTUPINFOEXW,

0 commit comments

Comments
 (0)