Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 96f801e27d | |||
| 3f7cd80a96 | |||
| 41c3f9badd |
845
Cargo.lock
generated
845
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "init"
|
||||
version = "2.5.1"
|
||||
version = "2.5.2"
|
||||
edition = "2024"
|
||||
|
||||
[profile.release]
|
||||
|
||||
12
Dockerfile
12
Dockerfile
@ -1,4 +1,4 @@
|
||||
from rust:1.91.0-alpine as rust
|
||||
from rust:1.93.0-alpine as rust
|
||||
|
||||
run apk add --no-cache git musl-dev libudev-zero-dev openssl-dev cryptsetup-dev lvm2-dev clang-libs clang-dev
|
||||
|
||||
@ -14,13 +14,15 @@ run apk add zstd lz4
|
||||
|
||||
workdir /system
|
||||
|
||||
env VERSION=3.23.2
|
||||
|
||||
run . /etc/os-release \
|
||||
&& wget -O- https://dl-cdn.alpinelinux.org/alpine/v${VERSION_ID%.*}/releases/x86_64/alpine-minirootfs-${VERSION_ID}-x86_64.tar.gz |tar zxv
|
||||
&& wget -O- https://dl-cdn.alpinelinux.org/alpine/v${VERSION%.*}/releases/x86_64/alpine-minirootfs-${VERSION}-x86_64.tar.gz |tar zxv
|
||||
|
||||
run apk add --no-cache --update -p . musl libgcc coreutils \
|
||||
lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup \
|
||||
iproute2 lvm2 lvm2-extra lvm2-dmeventd udev cryptsetup \
|
||||
e2fsprogs lsblk openssl openssh-server wireguard-tools-wg-quick \
|
||||
&& rm -rf usr/share/apk var/cache/apk etc/motd
|
||||
&& rm -rf usr/share/apk var/cache/apk etc/motd dev/*
|
||||
|
||||
copy etc/sshd_config etc/ssh/sshd_config
|
||||
|
||||
@ -34,6 +36,6 @@ run chroot . init-version
|
||||
run find * |cpio -H newc -oF /initrd
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
from alpine:3.22.2
|
||||
from alpine:3.23.0
|
||||
copy --from=initrd /initrd /
|
||||
entrypoint ["base64","/initrd"]
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
use eyre::{format_err, Result};
|
||||
use log::{error, info, warn};
|
||||
use std::collections::BTreeSet as Set;
|
||||
use std::convert::Infallible;
|
||||
use std::os::unix::fs::symlink;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::{fs, process::Command};
|
||||
@ -323,13 +324,7 @@ async fn child_reaper() {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! cstr {
|
||||
($s:expr) => {
|
||||
std::ffi::CString::new($s)?.as_c_str()
|
||||
};
|
||||
}
|
||||
|
||||
async fn switch_root(root: &str) -> Result<()> {
|
||||
async fn switch_root(root: &str) -> Result<Infallible> {
|
||||
info!("killing all processes and switching root");
|
||||
dklog::LOG.close().await;
|
||||
|
||||
@ -340,7 +335,13 @@ async fn switch_root(root: &str) -> Result<()> {
|
||||
eprintln!("failed to kill processes: {e}");
|
||||
}
|
||||
|
||||
nix::unistd::execv(
|
||||
macro_rules! cstr {
|
||||
($s:expr) => {
|
||||
std::ffi::CString::new($s)?.as_c_str()
|
||||
};
|
||||
}
|
||||
|
||||
Ok(nix::unistd::execv(
|
||||
cstr!("/sbin/switch_root"),
|
||||
&[
|
||||
cstr!("switch_root"),
|
||||
@ -349,8 +350,5 @@ async fn switch_root(root: &str) -> Result<()> {
|
||||
cstr!(root),
|
||||
cstr!("/sbin/init"),
|
||||
],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
unreachable!();
|
||||
)?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user