use shared libs, enabling openssl in init

This commit is contained in:
Mikaël Cluseau
2025-07-21 03:25:48 +02:00
parent e484802284
commit 0d9d087afd
5 changed files with 551 additions and 89 deletions

View File

@ -1,4 +1,4 @@
use eyre::{Result, format_err};
use eyre::{format_err, Result};
use log::{error, info, warn};
use std::collections::BTreeSet as Set;
use std::os::unix::fs::symlink;
@ -220,6 +220,8 @@ async fn extract_cpio_entry<R: std::io::Read>(
fs::create_dir_all(parent).await?;
}
let _ = fs::remove_file(path).await;
let mode = entry.mode();
let uid = entry.uid();
let gid = entry.gid();
@ -259,30 +261,26 @@ async fn mount(src: Option<&str>, dst: &str, fstype: &str, opts: Option<&str>) {
error!("failed to create dir {dst}: {e}");
}
let mut is_file = false;
retry_or_ignore(async || {
let mut is_file = false;
if let Some(src) = src {
retry_or_ignore(async || {
if let Some(src) = src {
is_file = (fs::metadata(src).await)
.map_err(|e| format_err!("stat {src} failed: {e}"))?
.is_file();
Ok(())
})
.await;
match fstype {
"ext4" => {
exec("fsck.ext4", &["-p", src]).await;
match fstype {
"ext4" => {
exec("fsck.ext4", &["-p", src]).await;
}
_ => {}
}
_ => {}
}
}
let mut args = vec![src.unwrap_or("none"), dst, "-t", fstype];
if let Some(opts) = opts {
args.extend(["-o", opts]);
}
let mut args = vec![src.unwrap_or("none"), dst, "-t", fstype];
if let Some(opts) = opts {
args.extend(["-o", opts]);
}
retry_or_ignore(async || {
// if it's a file, we need to use a loopdev
if is_file {
// loopdev crate has annoying dependencies, just use the normal mount program
@ -392,9 +390,9 @@ fn cmd_str(prog: &str, args: &[&str]) -> (String, Command) {
#[allow(unused)]
async fn child_reaper() {
use nix::sys::wait::{WaitPidFlag, waitpid};
use nix::sys::wait::{waitpid, WaitPidFlag};
use nix::unistd::Pid;
use tokio::signal::unix::{SignalKind, signal};
use tokio::signal::unix::{signal, SignalKind};
let Ok(mut sigs) =
signal(SignalKind::child()).inspect_err(|e| warn!("failed to setup SIGCHLD handler: {e}"))
@ -418,7 +416,7 @@ async fn switch_root(root: &str) -> Result<()> {
info!("killing all processes and switching root");
dklog::LOG.close().await;
use nix::sys::signal::{SIGKILL, kill};
use nix::sys::signal::{kill, SIGKILL};
use nix::unistd::Pid;
if let Err(e) = kill(Pid::from_raw(-1), SIGKILL) {