mirror of
https://github.com/michael-yuji/xc.git
synced 2026-03-23 01:05:22 +01:00
fixed a jail image convertion bug, and docker, I hate you to allow empty string as working dir
This commit is contained in:
@@ -250,7 +250,13 @@ impl ProcessRunner {
|
||||
.jail(&jail);
|
||||
|
||||
if let Some(work_dir) = &exec.work_dir {
|
||||
cmd.jwork_dir(work_dir);
|
||||
// god damn it Docker
|
||||
if !work_dir.is_empty() {
|
||||
let path = std::path::Path::new(&work_dir);
|
||||
if path.is_absolute() {
|
||||
cmd.jwork_dir(work_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
let devnull = std::path::PathBuf::from("/dev/null");
|
||||
let spawn_info_result = match &exec.output_mode {
|
||||
@@ -569,7 +575,7 @@ impl ProcessRunner {
|
||||
self.container.main_started_notify.notify_waiters();
|
||||
}
|
||||
}
|
||||
Err(error) => error!("cannot spawn {id}: {error:#?}"),
|
||||
Err(error) => error!("cannot spawn {id}: {process:#?} {error:#?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,13 +308,20 @@ impl JailConfig {
|
||||
}
|
||||
|
||||
pub fn from_json(value: serde_json::Value) -> Option<JailImage> {
|
||||
serde_json::from_value::<JailImage>(value.clone())
|
||||
.ok()
|
||||
.or_else(|| {
|
||||
serde_json::from_value::<OciConfig>(value)
|
||||
.ok()
|
||||
.and_then(Self::from_oci)
|
||||
})
|
||||
let maybe_converted = serde_json::from_value::<JailImage>(value.clone()).ok()?;
|
||||
// .expect(&format!("unknown format: {value}"));
|
||||
if maybe_converted
|
||||
.clone()
|
||||
.oci_config
|
||||
.config
|
||||
.and_then(|c| c.xc_extension)
|
||||
.is_none()
|
||||
{
|
||||
let ociconfig = serde_json::from_value::<OciConfig>(value).ok()?;
|
||||
Self::from_oci(ociconfig)
|
||||
} else {
|
||||
Some(maybe_converted)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_oci(config: OciConfig) -> Option<JailImage> {
|
||||
|
||||
@@ -200,6 +200,9 @@ pub async fn pull_image(
|
||||
});
|
||||
|
||||
let jail_image = JailConfig::from_json(config).ok_or(PullImageError::ConfigConvertFail)?;
|
||||
|
||||
eprintln!("jail_image: {jail_image:#?}");
|
||||
|
||||
_ = emitter.use_try(|state| {
|
||||
state.jail_image = Some(jail_image.clone());
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user