Align signed time audience and add bounded native Chrony source
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
Generated
+13
@@ -2388,6 +2388,19 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rmm-time-source-linux"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hex",
|
||||
"libc",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.10.9",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rmm-updater"
|
||||
version = "0.1.0"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
exclude = ["crates/oidc-auth"]
|
||||
members = ["crates/domain", "crates/protocol", "crates/persistence", "crates/server", "crates/agent-linux", "crates/agent-core", "crates/agent-windows", "crates/agent", "crates/privileged-helper", "crates/updater", "crates/updater-handoff", "crates/updater-linux", "crates/updater-worker", "crates/time-attestation"]
|
||||
members = ["crates/domain", "crates/protocol", "crates/persistence", "crates/server", "crates/agent-linux", "crates/agent-core", "crates/agent-windows", "crates/agent", "crates/privileged-helper", "crates/updater", "crates/updater-handoff", "crates/updater-linux", "crates/updater-worker", "crates/time-attestation", "crates/time-source-linux"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -8,7 +8,7 @@ use sha2::{Digest, Sha256};
|
||||
use std::collections::BTreeMap;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub const ENDPOINT: &str = "https://discovery.ease-technologies.de/api/agent/v1/time-attestation";
|
||||
pub const ENDPOINT: &str = "https://discovery.ease-technologies.de/agent/v1/time-attestation";
|
||||
pub const MAX_RTT_NS: u64 = 1_000_000_000;
|
||||
pub const MAX_RECEIVED_AGE_NS: u64 = 100_000_000;
|
||||
pub const MAX_CAPTURE_ERROR_NS: u64 = 50_000_000;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "rmm-time-source-linux"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
libc = "0.2"
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
sha2.workspace = true
|
||||
hex.workspace = true
|
||||
uuid.workspace = true
|
||||
@@ -0,0 +1,58 @@
|
||||
//! Native, read-only Chrony + Linux kernel quality observation.
|
||||
//! This is a source sample, never a job grant or a clock-setting interface.
|
||||
#[cfg(target_os = "linux")]
|
||||
mod native;
|
||||
#[cfg(any(target_os = "linux", test))]
|
||||
mod tracking;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use native::NativeTimeSource;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Constructible only by the native authenticated observation. Consumers must
|
||||
/// account for all further elapsed time before signing a response; no holdover.
|
||||
#[derive(Debug)]
|
||||
pub struct QualifiedSample {
|
||||
captured_utc_ns: i64,
|
||||
server_error_ns: u64,
|
||||
source_sync_age_ns: u64,
|
||||
server_boot_id: Uuid,
|
||||
captured_monotonic_ns: u64,
|
||||
sampled_boottime_ns: u64,
|
||||
kernel_state: i32,
|
||||
}
|
||||
impl QualifiedSample {
|
||||
pub fn captured_utc_ns(&self) -> i64 {
|
||||
self.captured_utc_ns
|
||||
}
|
||||
pub fn server_error_ns(&self) -> u64 {
|
||||
self.server_error_ns
|
||||
}
|
||||
pub fn source_sync_age_ns(&self) -> u64 {
|
||||
self.source_sync_age_ns
|
||||
}
|
||||
pub fn server_boot_id(&self) -> Uuid {
|
||||
self.server_boot_id
|
||||
}
|
||||
pub fn captured_monotonic_ns(&self) -> u64 {
|
||||
self.captured_monotonic_ns
|
||||
}
|
||||
pub fn sampled_boottime_ns(&self) -> u64 {
|
||||
self.sampled_boottime_ns
|
||||
}
|
||||
pub fn kernel_state(&self) -> i32 {
|
||||
self.kernel_state
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
pub struct NativeTimeSource;
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
impl NativeTimeSource {
|
||||
pub fn open() -> anyhow::Result<Self> {
|
||||
anyhow::bail!("TIME_SOURCE_LINUX_REQUIRED")
|
||||
}
|
||||
pub fn sample(&mut self) -> anyhow::Result<QualifiedSample> {
|
||||
anyhow::bail!("TIME_SOURCE_LINUX_REQUIRED")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,868 @@
|
||||
use crate::{QualifiedSample, tracking};
|
||||
use anyhow::{Context, Result, ensure};
|
||||
use serde::Deserialize;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::ffi::CString;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::mem::{self, size_of, size_of_val};
|
||||
use std::os::fd::{AsRawFd, FromRawFd, OwnedFd, RawFd};
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use uuid::Uuid;
|
||||
|
||||
const PIN: &str = "/etc/rmm-time-source/chrony-pin.json";
|
||||
const DAEMON: &str = "/usr/sbin/chronyd";
|
||||
const SERVER_DIR: &str = "/run/chrony";
|
||||
const SERVER: &str = "/run/chrony/chronyd.sock";
|
||||
const CLIENT_DIR: &str = "/run/rmm-time-source/clients";
|
||||
const QUERY_NS: u64 = 100_000_000;
|
||||
const CAPTURE_NS: u64 = 10_000_000;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Pin {
|
||||
schema_version: u32,
|
||||
daemon_pid: i32,
|
||||
daemon_birth_ticks: u64,
|
||||
daemon_uid: u32,
|
||||
daemon_gid: u32,
|
||||
daemon_image_sha256: String,
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
struct Identity {
|
||||
dev: u64,
|
||||
ino: u64,
|
||||
uid: u32,
|
||||
gid: u32,
|
||||
mode: u32,
|
||||
links: u64,
|
||||
}
|
||||
fn identity(fd: RawFd) -> Result<Identity> {
|
||||
let mut st = mem::MaybeUninit::<libc::stat>::uninit();
|
||||
// SAFETY: fstat initializes the supplied stat on success.
|
||||
ensure!(
|
||||
unsafe { libc::fstat(fd, st.as_mut_ptr()) } == 0,
|
||||
"TIME_FSTAT"
|
||||
);
|
||||
let st = unsafe { st.assume_init() };
|
||||
Ok(Identity {
|
||||
dev: st.st_dev,
|
||||
ino: st.st_ino,
|
||||
uid: st.st_uid,
|
||||
gid: st.st_gid,
|
||||
mode: st.st_mode,
|
||||
links: st.st_nlink,
|
||||
})
|
||||
}
|
||||
fn cstr(value: &str) -> Result<CString> {
|
||||
Ok(CString::new(value)?)
|
||||
}
|
||||
fn fd_result(value: i32) -> Result<OwnedFd> {
|
||||
if value < 0 {
|
||||
return Err(std::io::Error::last_os_error().into());
|
||||
}
|
||||
// SAFETY: every caller passes a newly allocated descriptor.
|
||||
Ok(unsafe { OwnedFd::from_raw_fd(value) })
|
||||
}
|
||||
fn openat(dir: RawFd, name: &str, flags: i32) -> Result<OwnedFd> {
|
||||
let name = cstr(name)?;
|
||||
// SAFETY: name is NUL terminated, dir remains held by the caller.
|
||||
fd_result(unsafe {
|
||||
libc::openat(
|
||||
dir,
|
||||
name.as_ptr(),
|
||||
flags | libc::O_CLOEXEC | libc::O_NOFOLLOW,
|
||||
)
|
||||
})
|
||||
}
|
||||
fn open_dir(path: &str, chrony: Option<(u32, u32)>) -> Result<OwnedFd> {
|
||||
ensure!(
|
||||
path.starts_with('/') && !path.contains(".."),
|
||||
"TIME_FIXED_DIRECTORY"
|
||||
);
|
||||
let slash = cstr("/")?;
|
||||
let mut fd = fd_result(unsafe {
|
||||
libc::open(
|
||||
slash.as_ptr(),
|
||||
libc::O_RDONLY | libc::O_DIRECTORY | libc::O_CLOEXEC | libc::O_NOFOLLOW,
|
||||
)
|
||||
})?;
|
||||
let root = identity(fd.as_raw_fd())?;
|
||||
ensure!(
|
||||
root.uid == 0 && root.mode & libc::S_IFMT == libc::S_IFDIR && root.mode & 0o022 == 0,
|
||||
"TIME_ROOT_DIRECTORY"
|
||||
);
|
||||
let parts: Vec<_> = path.split('/').filter(|v| !v.is_empty()).collect();
|
||||
for (index, part) in parts.iter().enumerate() {
|
||||
fd = openat(fd.as_raw_fd(), part, libc::O_RDONLY | libc::O_DIRECTORY)?;
|
||||
let m = identity(fd.as_raw_fd())?;
|
||||
// The daemon-owned /run/chrony leaf is the sole permitted non-root owner.
|
||||
let daemon_leaf = path == SERVER_DIR
|
||||
&& index + 1 == parts.len()
|
||||
&& chrony.is_some_and(|(uid, gid)| m.uid == uid && m.gid == gid);
|
||||
ensure!(
|
||||
m.mode & libc::S_IFMT == libc::S_IFDIR
|
||||
&& (m.uid == 0 || daemon_leaf)
|
||||
&& m.mode & 0o022 == 0,
|
||||
"TIME_PROTECTED_DIRECTORY"
|
||||
);
|
||||
}
|
||||
Ok(fd)
|
||||
}
|
||||
fn bound_dir(path: &str, held: &OwnedFd, chrony: Option<(u32, u32)>) -> Result<()> {
|
||||
let current = open_dir(path, chrony)?;
|
||||
ensure!(
|
||||
identity(current.as_raw_fd())? == identity(held.as_raw_fd())?,
|
||||
"TIME_DIRECTORY_REPLACED"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
fn read_bounded(fd: OwnedFd, limit: usize) -> Result<Vec<u8>> {
|
||||
let mut raw = Vec::new();
|
||||
File::from(fd)
|
||||
.take((limit + 1) as u64)
|
||||
.read_to_end(&mut raw)?;
|
||||
ensure!(raw.len() <= limit, "TIME_READ_BOUND");
|
||||
Ok(raw)
|
||||
}
|
||||
fn pin() -> Result<Pin> {
|
||||
let dir = open_dir("/etc/rmm-time-source", None)?;
|
||||
let fd = openat(dir.as_raw_fd(), "chrony-pin.json", libc::O_RDONLY)?;
|
||||
let m = identity(fd.as_raw_fd())?;
|
||||
ensure!(
|
||||
m.uid == 0
|
||||
&& m.mode & libc::S_IFMT == libc::S_IFREG
|
||||
&& m.mode & 0o7777 == 0o600
|
||||
&& m.links == 1,
|
||||
"TIME_PIN_PROTECTION"
|
||||
);
|
||||
let before = File::from(fd.try_clone()?).metadata()?;
|
||||
let raw = read_bounded(fd.try_clone()?, 4096)?;
|
||||
let after = File::from(fd.try_clone()?).metadata()?;
|
||||
ensure!(
|
||||
before.dev() == after.dev()
|
||||
&& before.ino() == after.ino()
|
||||
&& before.len() == after.len()
|
||||
&& before.mtime_nsec() == after.mtime_nsec()
|
||||
&& before.mtime() == after.mtime()
|
||||
&& before.ctime_nsec() == after.ctime_nsec()
|
||||
&& before.ctime() == after.ctime(),
|
||||
"TIME_PIN_CHANGED"
|
||||
);
|
||||
let p: Pin = serde_json::from_slice(&raw)?;
|
||||
ensure!(
|
||||
p.schema_version == 1
|
||||
&& p.daemon_pid > 1
|
||||
&& p.daemon_birth_ticks > 0
|
||||
&& p.daemon_image_sha256.len() == 64
|
||||
&& p.daemon_image_sha256
|
||||
.bytes()
|
||||
.all(|b| b.is_ascii_digit() || (b'a'..=b'f').contains(&b)),
|
||||
"TIME_PIN_SCHEMA"
|
||||
);
|
||||
bound_dir("/etc/rmm-time-source", &dir, None)?;
|
||||
let current = openat(dir.as_raw_fd(), "chrony-pin.json", libc::O_RDONLY)?;
|
||||
ensure!(
|
||||
identity(fd.as_raw_fd())? == identity(current.as_raw_fd())?,
|
||||
"TIME_PIN_REPLACED"
|
||||
);
|
||||
Ok(p)
|
||||
}
|
||||
fn digest(fd: &OwnedFd) -> Result<String> {
|
||||
let before = File::from(fd.try_clone()?).metadata()?;
|
||||
ensure!(
|
||||
before.is_file()
|
||||
&& before.uid() == 0
|
||||
&& before.mode() & 0o022 == 0
|
||||
&& before.nlink() == 1
|
||||
&& before.len() <= 16 * 1024 * 1024,
|
||||
"TIME_DAEMON_IMAGE_PROTECTED"
|
||||
);
|
||||
let mut hasher = Sha256::new();
|
||||
let mut total = 0;
|
||||
let mut buf = [0u8; 16384];
|
||||
// pread avoids shared seek offsets in retained descriptors.
|
||||
loop {
|
||||
let got = unsafe { libc::pread(fd.as_raw_fd(), buf.as_mut_ptr().cast(), buf.len(), total) };
|
||||
ensure!(got >= 0, "TIME_IMAGE_READ");
|
||||
if got == 0 {
|
||||
break;
|
||||
}
|
||||
total += i64::try_from(got)?;
|
||||
ensure!(total <= 16 * 1024 * 1024, "TIME_IMAGE_BOUND");
|
||||
hasher.update(&buf[..got as usize]);
|
||||
}
|
||||
let after = File::from(fd.try_clone()?).metadata()?;
|
||||
ensure!(
|
||||
before.len() == total as u64
|
||||
&& before.len() == after.len()
|
||||
&& before.dev() == after.dev()
|
||||
&& before.ino() == after.ino()
|
||||
&& before.mtime() == after.mtime()
|
||||
&& before.mtime_nsec() == after.mtime_nsec()
|
||||
&& before.ctime() == after.ctime()
|
||||
&& before.ctime_nsec() == after.ctime_nsec(),
|
||||
"TIME_IMAGE_CHANGED"
|
||||
);
|
||||
Ok(hex::encode(hasher.finalize()))
|
||||
}
|
||||
struct Daemon {
|
||||
pin: Pin,
|
||||
proc: OwnedFd,
|
||||
image: OwnedFd,
|
||||
pidfd: OwnedFd,
|
||||
image_id: Identity,
|
||||
}
|
||||
impl Daemon {
|
||||
fn open(pin: Pin) -> Result<Self> {
|
||||
let proc = openat(
|
||||
libc::AT_FDCWD,
|
||||
&format!("/proc/{}", pin.daemon_pid),
|
||||
libc::O_RDONLY | libc::O_DIRECTORY,
|
||||
)?;
|
||||
let pidfd =
|
||||
fd_result(unsafe { libc::syscall(libc::SYS_pidfd_open, pin.daemon_pid, 0) } as i32)?;
|
||||
let dir = open_dir("/usr/sbin", None)?;
|
||||
let image = openat(dir.as_raw_fd(), "chronyd", libc::O_RDONLY)?;
|
||||
let image_id = identity(image.as_raw_fd())?;
|
||||
let value = Self {
|
||||
pin,
|
||||
proc,
|
||||
image,
|
||||
pidfd,
|
||||
image_id,
|
||||
};
|
||||
value.verify()?;
|
||||
Ok(value)
|
||||
}
|
||||
fn exe(&self) -> Result<OwnedFd> {
|
||||
let name = cstr("exe")?;
|
||||
// /proc/PID/exe is intentionally a kernel symlink; procdir is retained.
|
||||
fd_result(unsafe {
|
||||
libc::openat(
|
||||
self.proc.as_raw_fd(),
|
||||
name.as_ptr(),
|
||||
libc::O_RDONLY | libc::O_CLOEXEC,
|
||||
)
|
||||
})
|
||||
}
|
||||
fn verify(&self) -> Result<()> {
|
||||
let mut poll = libc::pollfd {
|
||||
fd: self.pidfd.as_raw_fd(),
|
||||
events: libc::POLLIN,
|
||||
revents: 0,
|
||||
};
|
||||
ensure!(
|
||||
unsafe { libc::poll(&mut poll, 1, 0) } == 0 && poll.revents == 0,
|
||||
"TIME_DAEMON_EXITED"
|
||||
);
|
||||
let first = self.exe()?;
|
||||
ensure!(
|
||||
identity(first.as_raw_fd())? == self.image_id,
|
||||
"TIME_DAEMON_EXEC_CHANGED"
|
||||
);
|
||||
let stat = String::from_utf8(read_bounded(
|
||||
openat(self.proc.as_raw_fd(), "stat", libc::O_RDONLY)?,
|
||||
8192,
|
||||
)?)?;
|
||||
let rest = stat.rsplit_once(") ").context("TIME_PROC_STAT")?.1;
|
||||
ensure!(
|
||||
rest.split_whitespace()
|
||||
.nth(19)
|
||||
.context("TIME_PROC_BIRTH")?
|
||||
.parse::<u64>()?
|
||||
== self.pin.daemon_birth_ticks,
|
||||
"TIME_DAEMON_BIRTH"
|
||||
);
|
||||
let status = String::from_utf8(read_bounded(
|
||||
openat(self.proc.as_raw_fd(), "status", libc::O_RDONLY)?,
|
||||
16384,
|
||||
)?)?;
|
||||
for (label, expected) in [("Uid:", self.pin.daemon_uid), ("Gid:", self.pin.daemon_gid)] {
|
||||
let line = status
|
||||
.lines()
|
||||
.find(|v| v.starts_with(label))
|
||||
.context("TIME_PROC_CREDENTIALS")?;
|
||||
let ids: Vec<u32> = line
|
||||
.split_whitespace()
|
||||
.skip(1)
|
||||
.map(str::parse)
|
||||
.collect::<std::result::Result<_, _>>()?;
|
||||
ensure!(ids == [expected; 4], "TIME_DAEMON_ACCOUNT");
|
||||
}
|
||||
ensure!(
|
||||
digest(&self.image)? == self.pin.daemon_image_sha256
|
||||
&& digest(&first)? == self.pin.daemon_image_sha256,
|
||||
"TIME_DAEMON_IMAGE"
|
||||
);
|
||||
let fixed = openat(libc::AT_FDCWD, DAEMON, libc::O_RDONLY)?;
|
||||
ensure!(
|
||||
identity(fixed.as_raw_fd())? == self.image_id
|
||||
&& identity(self.exe()?.as_raw_fd())? == self.image_id,
|
||||
"TIME_DAEMON_IMAGE_REPLACED"
|
||||
);
|
||||
ensure!(
|
||||
unsafe { libc::poll(&mut poll, 1, 0) } == 0 && poll.revents == 0,
|
||||
"TIME_DAEMON_EXITED"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct Capture {
|
||||
mono: u64,
|
||||
end: u64,
|
||||
boot: u64,
|
||||
utc: i64,
|
||||
}
|
||||
fn clock(id: libc::clockid_t) -> Result<i128> {
|
||||
let mut ts = mem::MaybeUninit::<libc::timespec>::uninit();
|
||||
ensure!(
|
||||
unsafe { libc::clock_gettime(id, ts.as_mut_ptr()) } == 0,
|
||||
"TIME_CLOCK_GETTIME"
|
||||
);
|
||||
let ts = unsafe { ts.assume_init() };
|
||||
ensure!(
|
||||
ts.tv_sec >= 0 && (0..1_000_000_000).contains(&ts.tv_nsec),
|
||||
"TIME_CLOCK_RANGE"
|
||||
);
|
||||
Ok(i128::from(ts.tv_sec) * 1_000_000_000 + i128::from(ts.tv_nsec))
|
||||
}
|
||||
fn capture() -> Result<Capture> {
|
||||
let mono = u64::try_from(clock(libc::CLOCK_MONOTONIC)?)?;
|
||||
let boot = u64::try_from(clock(libc::CLOCK_BOOTTIME)?)?;
|
||||
let utc = i64::try_from(clock(libc::CLOCK_REALTIME)?)?;
|
||||
let end = u64::try_from(clock(libc::CLOCK_MONOTONIC)?)?;
|
||||
ensure!(
|
||||
end >= mono && end - mono <= CAPTURE_NS && utc > 0,
|
||||
"TIME_CAPTURE_BOUND"
|
||||
);
|
||||
Ok(Capture {
|
||||
mono,
|
||||
end,
|
||||
boot,
|
||||
utc,
|
||||
})
|
||||
}
|
||||
#[derive(Clone, Copy)]
|
||||
struct Kernel {
|
||||
state: i32,
|
||||
maxerror_ns: u64,
|
||||
}
|
||||
fn kernel() -> Result<Kernel> {
|
||||
let mut tx: libc::timex = unsafe { mem::zeroed() }; // modes=0: query only, never set time.
|
||||
let state = unsafe { libc::adjtimex(&mut tx) };
|
||||
ensure!(
|
||||
(0..=4).contains(&state)
|
||||
&& tx.status & (libc::STA_UNSYNC | libc::STA_CLOCKERR) == 0
|
||||
&& (0..=500_000).contains(&tx.maxerror),
|
||||
"TIME_KERNEL_UNQUALIFIED"
|
||||
);
|
||||
Ok(Kernel {
|
||||
state,
|
||||
maxerror_ns: u64::try_from(tx.maxerror)?
|
||||
.checked_mul(1000)
|
||||
.context("TIME_KERNEL_OVERFLOW")?,
|
||||
})
|
||||
}
|
||||
fn elapsed(before: Capture, after: Capture) -> Result<u64> {
|
||||
ensure!(
|
||||
after.mono >= before.end && after.boot >= before.boot && after.utc >= before.utc,
|
||||
"TIME_CLOCK_BACKWARD"
|
||||
);
|
||||
let span = after
|
||||
.end
|
||||
.checked_sub(before.mono)
|
||||
.context("TIME_MONOTONIC_OVERFLOW")?;
|
||||
ensure!(span <= QUERY_NS, "TIME_SOURCE_TOTAL_TIMEOUT");
|
||||
let mono = after.mono - before.mono;
|
||||
let boot = after.boot - before.boot;
|
||||
let wall = u64::try_from(after.utc - before.utc)?;
|
||||
let tolerance = (before.end - before.mono) + (after.end - after.mono);
|
||||
ensure!(
|
||||
mono.abs_diff(boot) <= tolerance && mono.abs_diff(wall) <= tolerance,
|
||||
"TIME_SOURCE_DISCONTINUITY"
|
||||
);
|
||||
Ok(span)
|
||||
}
|
||||
fn boot_id() -> Result<Uuid> {
|
||||
let raw = std::fs::read_to_string("/proc/sys/kernel/random/boot_id")?;
|
||||
let id = Uuid::parse_str(raw.trim())?;
|
||||
ensure!(!id.is_nil(), "TIME_BOOT_ID");
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
fn socket_identity(dir: RawFd, name: &str) -> Result<Identity> {
|
||||
let name = cstr(name)?;
|
||||
let mut st = mem::MaybeUninit::<libc::stat>::uninit();
|
||||
ensure!(
|
||||
unsafe {
|
||||
libc::fstatat(
|
||||
dir,
|
||||
name.as_ptr(),
|
||||
st.as_mut_ptr(),
|
||||
libc::AT_SYMLINK_NOFOLLOW,
|
||||
)
|
||||
} == 0,
|
||||
"TIME_SOCKET_STAT"
|
||||
);
|
||||
let st = unsafe { st.assume_init() };
|
||||
Ok(Identity {
|
||||
dev: st.st_dev,
|
||||
ino: st.st_ino,
|
||||
uid: st.st_uid,
|
||||
gid: st.st_gid,
|
||||
mode: st.st_mode,
|
||||
links: st.st_nlink,
|
||||
})
|
||||
}
|
||||
fn address(path: &str) -> Result<(libc::sockaddr_un, libc::socklen_t)> {
|
||||
let mut addr: libc::sockaddr_un = unsafe { mem::zeroed() };
|
||||
addr.sun_family = libc::AF_UNIX as _;
|
||||
ensure!(path.len() < addr.sun_path.len(), "TIME_SOCKET_PATH_BOUND");
|
||||
for (dst, src) in addr.sun_path.iter_mut().zip(path.bytes()) {
|
||||
*dst = src as _;
|
||||
}
|
||||
Ok((
|
||||
addr,
|
||||
(mem::offset_of!(libc::sockaddr_un, sun_path) + path.len() + 1) as _,
|
||||
))
|
||||
}
|
||||
struct Client {
|
||||
fd: OwnedFd,
|
||||
dir: OwnedFd,
|
||||
name: String,
|
||||
own: Option<Identity>,
|
||||
}
|
||||
impl Client {
|
||||
fn open(gid: u32) -> Result<Self> {
|
||||
let dir = open_dir(CLIENT_DIR, None)?;
|
||||
let d = identity(dir.as_raw_fd())?;
|
||||
ensure!(
|
||||
d.uid == 0 && d.gid == gid && d.mode & 0o7777 == 0o710,
|
||||
"TIME_CLIENT_DIRECTORY_PROFILE"
|
||||
);
|
||||
ensure!(
|
||||
unsafe { libc::flock(dir.as_raw_fd(), libc::LOCK_EX | libc::LOCK_NB) } == 0,
|
||||
"TIME_CLIENT_SINGLE_OWNER"
|
||||
);
|
||||
// A leftover from an unknown cleanup blocks all future instances. Only
|
||||
// an operator may investigate it; no automatic deletion or new UUID loop.
|
||||
let mut entries = std::fs::read_dir(format!("/proc/self/fd/{}", dir.as_raw_fd()))?;
|
||||
ensure!(entries.next().is_none(), "TIME_CLIENT_DIRECTORY_NOT_EMPTY");
|
||||
let fd = fd_result(unsafe {
|
||||
libc::socket(
|
||||
libc::AF_UNIX,
|
||||
libc::SOCK_DGRAM | libc::SOCK_CLOEXEC | libc::SOCK_NONBLOCK,
|
||||
0,
|
||||
)
|
||||
})?;
|
||||
let name = format!("tracking-{}.sock", Uuid::new_v4().simple());
|
||||
let mut value = Self {
|
||||
fd,
|
||||
dir,
|
||||
name,
|
||||
own: None,
|
||||
};
|
||||
let (addr, len) = address(&format!("{CLIENT_DIR}/{}", value.name))?;
|
||||
bound_dir(CLIENT_DIR, &value.dir, None)?;
|
||||
ensure!(
|
||||
unsafe {
|
||||
libc::bind(
|
||||
value.fd.as_raw_fd(),
|
||||
(&addr as *const libc::sockaddr_un).cast(),
|
||||
len,
|
||||
)
|
||||
} == 0,
|
||||
"TIME_CLIENT_BIND_ONCE"
|
||||
);
|
||||
let mut own = socket_identity(value.dir.as_raw_fd(), &value.name)?;
|
||||
ensure!(
|
||||
own.uid == 0 && own.mode & libc::S_IFMT == libc::S_IFSOCK && own.links == 1,
|
||||
"TIME_CLIENT_INITIAL_IDENTITY"
|
||||
);
|
||||
value.own = Some(own);
|
||||
let name = cstr(&value.name)?;
|
||||
ensure!(
|
||||
unsafe {
|
||||
libc::fchownat(
|
||||
value.dir.as_raw_fd(),
|
||||
name.as_ptr(),
|
||||
0,
|
||||
gid,
|
||||
libc::AT_SYMLINK_NOFOLLOW,
|
||||
)
|
||||
} == 0,
|
||||
"TIME_CLIENT_GROUP"
|
||||
);
|
||||
// Parent is root-write-only: no daemon or unprivileged process can swap
|
||||
// the leaf between this identity capture and chmod.
|
||||
ensure!(
|
||||
unsafe { libc::fchmodat(value.dir.as_raw_fd(), name.as_ptr(), 0o660, 0) } == 0,
|
||||
"TIME_CLIENT_MODE"
|
||||
);
|
||||
let next = socket_identity(value.dir.as_raw_fd(), &value.name)?;
|
||||
ensure!(
|
||||
next.dev == own.dev
|
||||
&& next.ino == own.ino
|
||||
&& next.uid == 0
|
||||
&& next.gid == gid
|
||||
&& next.mode & 0o7777 == 0o660
|
||||
&& next.links == 1,
|
||||
"TIME_CLIENT_READY_IDENTITY"
|
||||
);
|
||||
own = next;
|
||||
value.own = Some(own);
|
||||
value.verify()?;
|
||||
let yes: libc::c_int = 1;
|
||||
ensure!(
|
||||
unsafe {
|
||||
libc::setsockopt(
|
||||
value.fd.as_raw_fd(),
|
||||
libc::SOL_SOCKET,
|
||||
libc::SO_PASSCRED,
|
||||
(&yes as *const libc::c_int).cast(),
|
||||
size_of::<libc::c_int>() as _,
|
||||
)
|
||||
} == 0,
|
||||
"TIME_PASSCRED_REQUIRED"
|
||||
);
|
||||
let (server, len) = address(SERVER)?;
|
||||
ensure!(
|
||||
unsafe {
|
||||
libc::connect(
|
||||
value.fd.as_raw_fd(),
|
||||
(&server as *const libc::sockaddr_un).cast(),
|
||||
len,
|
||||
)
|
||||
} == 0,
|
||||
"TIME_CHRONY_CONNECT"
|
||||
);
|
||||
Ok(value)
|
||||
}
|
||||
fn verify(&self) -> Result<()> {
|
||||
bound_dir(CLIENT_DIR, &self.dir, None)?;
|
||||
ensure!(
|
||||
Some(socket_identity(self.dir.as_raw_fd(), &self.name)?) == self.own,
|
||||
"TIME_CLIENT_REPLACED"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
fn cleanup(&mut self) -> Result<()> {
|
||||
// Consume cleanup authority before any fallible work. Unknown cleanup
|
||||
// never retries from Drop and never adopts a newly observed leaf.
|
||||
let expected = self
|
||||
.own
|
||||
.take()
|
||||
.context("TIME_CLIENT_CLEANUP_ALREADY_ATTEMPTED")?;
|
||||
bound_dir(CLIENT_DIR, &self.dir, None)?;
|
||||
unlink_owned(self.dir.as_raw_fd(), &self.name, expected)
|
||||
}
|
||||
fn exchange(&self, sequence: u32, daemon: &Pin, start: Capture) -> Result<tracking::Tracking> {
|
||||
let request = tracking::request(sequence);
|
||||
ensure!(
|
||||
unsafe {
|
||||
libc::send(
|
||||
self.fd.as_raw_fd(),
|
||||
request.as_ptr().cast(),
|
||||
request.len(),
|
||||
libc::MSG_DONTWAIT | libc::MSG_NOSIGNAL,
|
||||
)
|
||||
} == request.len() as isize,
|
||||
"TIME_CHRONY_SEND_ONCE"
|
||||
);
|
||||
let now = u64::try_from(clock(libc::CLOCK_MONOTONIC)?)?;
|
||||
let left = QUERY_NS
|
||||
.checked_sub(now.checked_sub(start.mono).context("TIME_QUERY_CLOCK")?)
|
||||
.context("TIME_QUERY_TIMEOUT")?;
|
||||
let timeout = libc::timespec {
|
||||
tv_sec: 0,
|
||||
tv_nsec: left as _,
|
||||
};
|
||||
let mut poll = libc::pollfd {
|
||||
fd: self.fd.as_raw_fd(),
|
||||
events: libc::POLLIN,
|
||||
revents: 0,
|
||||
};
|
||||
ensure!(
|
||||
unsafe { libc::ppoll(&mut poll, 1, &timeout, std::ptr::null()) } == 1
|
||||
&& poll.revents == libc::POLLIN,
|
||||
"TIME_CHRONY_TIMEOUT"
|
||||
);
|
||||
let mut packet = [0u8; tracking::PACKET_BYTES];
|
||||
let mut iov = libc::iovec {
|
||||
iov_base: packet.as_mut_ptr().cast(),
|
||||
iov_len: packet.len(),
|
||||
};
|
||||
let mut control = [0usize; 16];
|
||||
let mut msg: libc::msghdr = unsafe { mem::zeroed() };
|
||||
msg.msg_iov = &mut iov;
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = control.as_mut_ptr().cast();
|
||||
msg.msg_controllen = size_of_val(&control);
|
||||
let got = unsafe { libc::recvmsg(self.fd.as_raw_fd(), &mut msg, libc::MSG_DONTWAIT) };
|
||||
ensure!(
|
||||
got == tracking::PACKET_BYTES as isize
|
||||
&& msg.msg_flags & (libc::MSG_TRUNC | libc::MSG_CTRUNC) == 0,
|
||||
"TIME_CHRONY_TRUNCATED"
|
||||
);
|
||||
ensure!(
|
||||
msg.msg_controllen <= size_of_val(&control),
|
||||
"TIME_CREDENTIALS_CONTROL_BOUND"
|
||||
);
|
||||
let control_start = msg.msg_control as usize;
|
||||
let control_end = control_start
|
||||
.checked_add(msg.msg_controllen)
|
||||
.context("TIME_CREDENTIALS_CONTROL_OVERFLOW")?;
|
||||
let mut count = 0;
|
||||
let mut header = unsafe { libc::CMSG_FIRSTHDR(&msg) };
|
||||
while !header.is_null() {
|
||||
let position = header as usize;
|
||||
ensure!(
|
||||
position >= control_start
|
||||
&& position
|
||||
.checked_add(size_of::<libc::cmsghdr>())
|
||||
.is_some_and(|n| n <= control_end),
|
||||
"TIME_CREDENTIALS_HEADER_BOUND"
|
||||
);
|
||||
let h = unsafe { &*header };
|
||||
ensure!(
|
||||
h.cmsg_len >= unsafe { libc::CMSG_LEN(0) } as usize
|
||||
&& h.cmsg_len <= control_end - position,
|
||||
"TIME_CREDENTIALS_LENGTH_BOUND"
|
||||
);
|
||||
ensure!(
|
||||
h.cmsg_level == libc::SOL_SOCKET
|
||||
&& h.cmsg_type == libc::SCM_CREDENTIALS
|
||||
&& h.cmsg_len
|
||||
== unsafe { libc::CMSG_LEN(size_of::<libc::ucred>() as _) } as usize,
|
||||
"TIME_CREDENTIALS_FORMAT"
|
||||
);
|
||||
let credentials =
|
||||
unsafe { std::ptr::read_unaligned(libc::CMSG_DATA(header).cast::<libc::ucred>()) };
|
||||
ensure!(
|
||||
credentials.pid == daemon.daemon_pid
|
||||
&& credentials.uid == daemon.daemon_uid
|
||||
&& credentials.gid == daemon.daemon_gid,
|
||||
"TIME_CREDENTIALS_MISMATCH"
|
||||
);
|
||||
count += 1;
|
||||
header = unsafe { libc::CMSG_NXTHDR(&msg, header) };
|
||||
}
|
||||
ensure!(count == 1, "TIME_CREDENTIALS_REQUIRED");
|
||||
tracking::reply(&packet, sequence)
|
||||
}
|
||||
}
|
||||
fn unlink_owned(dir: RawFd, name: &str, expected: Identity) -> Result<()> {
|
||||
ensure!(
|
||||
socket_identity(dir, name)? == expected,
|
||||
"TIME_CLIENT_CLEANUP_IDENTITY"
|
||||
);
|
||||
let name = cstr(name)?;
|
||||
ensure!(
|
||||
unsafe { libc::unlinkat(dir, name.as_ptr(), 0) } == 0,
|
||||
"TIME_CLIENT_UNLINK"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
impl Drop for Client {
|
||||
fn drop(&mut self) {
|
||||
// Lost identity is intentionally retained, never recursively removed.
|
||||
if self.own.is_some() {
|
||||
let _ = self.cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Root-only source broker primitive. No daemon discovery, adoption, commands,
|
||||
/// configurable endpoint, retry, IP transport or time-setting entrypoint.
|
||||
pub struct NativeTimeSource {
|
||||
daemon: Daemon,
|
||||
server_dir: OwnedFd,
|
||||
server_identity: Identity,
|
||||
boot: Uuid,
|
||||
poisoned: bool,
|
||||
}
|
||||
impl NativeTimeSource {
|
||||
pub fn open() -> Result<Self> {
|
||||
ensure!(
|
||||
unsafe { libc::geteuid() } == 0,
|
||||
"TIME_SOURCE_ROOT_BROKER_REQUIRED"
|
||||
);
|
||||
let pin = pin().with_context(|| format!("TIME_PROTECTED_PIN {PIN}"))?;
|
||||
let daemon = Daemon::open(pin)?;
|
||||
let server_dir = open_dir(
|
||||
SERVER_DIR,
|
||||
Some((daemon.pin.daemon_uid, daemon.pin.daemon_gid)),
|
||||
)?;
|
||||
let server_identity = socket_identity(server_dir.as_raw_fd(), "chronyd.sock")?;
|
||||
ensure!(
|
||||
server_identity.mode & libc::S_IFMT == libc::S_IFSOCK
|
||||
&& server_identity.links == 1
|
||||
&& server_identity.uid == daemon.pin.daemon_uid
|
||||
&& server_identity.gid == daemon.pin.daemon_gid
|
||||
&& server_identity.mode & 0o007 == 0,
|
||||
"TIME_CHRONY_SOCKET_PROTECTION"
|
||||
);
|
||||
Ok(Self {
|
||||
daemon,
|
||||
server_dir,
|
||||
server_identity,
|
||||
boot: boot_id()?,
|
||||
poisoned: false,
|
||||
})
|
||||
}
|
||||
fn verify(&self) -> Result<()> {
|
||||
self.daemon.verify()?;
|
||||
bound_dir(
|
||||
SERVER_DIR,
|
||||
&self.server_dir,
|
||||
Some((self.daemon.pin.daemon_uid, self.daemon.pin.daemon_gid)),
|
||||
)?;
|
||||
ensure!(
|
||||
socket_identity(self.server_dir.as_raw_fd(), "chronyd.sock")? == self.server_identity
|
||||
&& boot_id()? == self.boot,
|
||||
"TIME_SOURCE_GENERATION_CHANGED"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
pub fn sample(&mut self) -> Result<QualifiedSample> {
|
||||
ensure!(!self.poisoned, "TIME_SOURCE_CLEANUP_UNCERTAIN");
|
||||
let before = capture()?;
|
||||
let first = kernel()?;
|
||||
self.verify()?;
|
||||
self.poisoned = true;
|
||||
let mut client = Client::open(self.daemon.pin.daemon_gid)?;
|
||||
let random = Uuid::new_v4();
|
||||
let sequence = u32::from_ne_bytes(random.as_bytes()[..4].try_into()?);
|
||||
let report = client.exchange(sequence, &self.daemon.pin, before)?;
|
||||
client.verify()?;
|
||||
self.verify()?;
|
||||
let last = kernel()?;
|
||||
let after = capture()?;
|
||||
let span = elapsed(before, after)?;
|
||||
let error = report
|
||||
.error_ns
|
||||
.checked_add(first.maxerror_ns.max(last.maxerror_ns))
|
||||
.and_then(|v| v.checked_add(span))
|
||||
.context("TIME_SOURCE_ERROR_OVERFLOW")?;
|
||||
ensure!(error <= tracking::MAX_ERROR_NS, "TIME_SOURCE_ERROR_LIMIT");
|
||||
ensure!(
|
||||
report.reference_utc_ns <= after.utc,
|
||||
"TIME_SOURCE_FUTURE_REFERENCE"
|
||||
);
|
||||
let age = u64::try_from(after.utc - report.reference_utc_ns)?
|
||||
.checked_add(error)
|
||||
.context("TIME_SOURCE_AGE_OVERFLOW")?;
|
||||
ensure!(age <= tracking::MAX_AGE_NS, "TIME_SOURCE_STALE_REFERENCE");
|
||||
// Cleanup is explicit and part of successful observation, not an ignored
|
||||
// Drop error. The returned sample is already aged by this final work.
|
||||
client.cleanup()?;
|
||||
self.poisoned = false;
|
||||
let final_capture = capture()?;
|
||||
let total = elapsed(before, final_capture)?;
|
||||
let post = total.checked_sub(span).context("TIME_SOURCE_FINAL_CLOCK")?;
|
||||
let error = error.checked_add(post).context("TIME_SOURCE_FINAL_ERROR")?;
|
||||
let age = age.checked_add(post).context("TIME_SOURCE_FINAL_AGE")?;
|
||||
ensure!(
|
||||
error <= tracking::MAX_ERROR_NS && age <= tracking::MAX_AGE_NS,
|
||||
"TIME_SOURCE_FINAL_QUALITY"
|
||||
);
|
||||
Ok(QualifiedSample {
|
||||
captured_utc_ns: after.utc,
|
||||
server_error_ns: error,
|
||||
source_sync_age_ns: age,
|
||||
server_boot_id: self.boot,
|
||||
captured_monotonic_ns: after.mono,
|
||||
sampled_boottime_ns: after.boot,
|
||||
kernel_state: last.state,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn clock_brackets_reject_suspend_step_backwards_and_total_timeout() {
|
||||
let a = Capture {
|
||||
mono: 1_000_000,
|
||||
end: 1_000_100,
|
||||
boot: 2_000_000,
|
||||
utc: 1_800_000_000_000_000_000,
|
||||
};
|
||||
let b = Capture {
|
||||
mono: 2_000_000,
|
||||
end: 2_000_100,
|
||||
boot: 3_000_000,
|
||||
utc: a.utc + 1_000_000,
|
||||
};
|
||||
assert!(elapsed(a, b).is_ok());
|
||||
assert!(
|
||||
elapsed(
|
||||
a,
|
||||
Capture {
|
||||
boot: b.boot + 1_000_000,
|
||||
..b
|
||||
}
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
elapsed(
|
||||
a,
|
||||
Capture {
|
||||
utc: b.utc + 1_000_000,
|
||||
..b
|
||||
}
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
elapsed(
|
||||
a,
|
||||
Capture {
|
||||
utc: a.utc - 1,
|
||||
..b
|
||||
}
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
elapsed(
|
||||
a,
|
||||
Capture {
|
||||
end: a.mono + QUERY_NS + 1,
|
||||
..b
|
||||
}
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn socket_cleanup_preserves_replaced_name_and_removes_only_exact_own_inode() {
|
||||
use std::os::unix::{fs::PermissionsExt, net::UnixDatagram};
|
||||
let path = std::env::temp_dir().join(format!("rmm-time-source-unit-{}", Uuid::new_v4()));
|
||||
std::fs::create_dir(&path).unwrap();
|
||||
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o700)).unwrap();
|
||||
let dir = openat(
|
||||
libc::AT_FDCWD,
|
||||
path.to_str().unwrap(),
|
||||
libc::O_RDONLY | libc::O_DIRECTORY,
|
||||
)
|
||||
.unwrap();
|
||||
let old = UnixDatagram::bind(path.join("own.sock")).unwrap();
|
||||
let expected = socket_identity(dir.as_raw_fd(), "own.sock").unwrap();
|
||||
std::fs::rename(path.join("own.sock"), path.join("held.sock")).unwrap();
|
||||
let new = UnixDatagram::bind(path.join("own.sock")).unwrap();
|
||||
assert!(unlink_owned(dir.as_raw_fd(), "own.sock", expected).is_err());
|
||||
assert!(path.join("own.sock").exists());
|
||||
let current = socket_identity(dir.as_raw_fd(), "own.sock").unwrap();
|
||||
unlink_owned(dir.as_raw_fd(), "own.sock", current).unwrap();
|
||||
assert!(!path.join("own.sock").exists());
|
||||
unlink_owned(dir.as_raw_fd(), "held.sock", expected).unwrap();
|
||||
drop((old, new));
|
||||
std::fs::remove_dir(&path).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
use anyhow::{Result, ensure};
|
||||
pub(crate) const PACKET_BYTES: usize = 104;
|
||||
pub(crate) const MAX_ERROR_NS: u64 = 500_000_000;
|
||||
pub(crate) const MAX_AGE_NS: u64 = 3_600_000_000_000;
|
||||
|
||||
pub(crate) fn request(sequence: u32) -> [u8; PACKET_BYTES] {
|
||||
let mut out = [0; PACKET_BYTES];
|
||||
out[0] = 6;
|
||||
out[1] = 1;
|
||||
out[4..6].copy_from_slice(&33u16.to_be_bytes());
|
||||
out[8..12].copy_from_slice(&sequence.to_be_bytes());
|
||||
out
|
||||
}
|
||||
fn u16_at(raw: &[u8], n: usize) -> u16 {
|
||||
u16::from_be_bytes(raw[n..n + 2].try_into().expect("checked packet size"))
|
||||
}
|
||||
fn u32_at(raw: &[u8], n: usize) -> u32 {
|
||||
u32::from_be_bytes(raw[n..n + 4].try_into().expect("checked packet size"))
|
||||
}
|
||||
|
||||
/// Chrony's wire Float is signed7 exponent + signed25 coefficient, value
|
||||
/// coefficient * 2^(exponent-25). Convert its magnitude to ns, rounding upward
|
||||
/// using integer arithmetic; no IEEE conversion or underflow-to-zero.
|
||||
fn float_ns(raw: u32, allow_negative: bool) -> Result<u64> {
|
||||
let mut exponent = (raw >> 25) as i32;
|
||||
if exponent >= 64 {
|
||||
exponent -= 128;
|
||||
}
|
||||
let mut coefficient = (raw & 0x01ff_ffff) as i32;
|
||||
if coefficient >= 0x0100_0000 {
|
||||
coefficient -= 0x0200_0000;
|
||||
}
|
||||
ensure!(allow_negative || coefficient >= 0, "CHRONY_NEGATIVE_ERROR");
|
||||
let numerator = u128::from(coefficient.unsigned_abs()) * 1_000_000_000;
|
||||
let shift = exponent - 25;
|
||||
let rounded = if shift >= 0 {
|
||||
numerator
|
||||
.checked_shl(shift as u32)
|
||||
.ok_or_else(|| anyhow::anyhow!("CHRONY_FLOAT_OVERFLOW"))?
|
||||
} else {
|
||||
let denominator = 1u128
|
||||
.checked_shl((-shift) as u32)
|
||||
.ok_or_else(|| anyhow::anyhow!("CHRONY_FLOAT_OVERFLOW"))?;
|
||||
numerator.div_ceil(denominator)
|
||||
};
|
||||
u64::try_from(rounded).map_err(Into::into)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Tracking {
|
||||
pub reference_utc_ns: i64,
|
||||
pub error_ns: u64,
|
||||
}
|
||||
pub(crate) fn reply(raw: &[u8], sequence: u32) -> Result<Tracking> {
|
||||
ensure!(raw.len() == PACKET_BYTES, "CHRONY_PACKET_LENGTH");
|
||||
ensure!(
|
||||
raw[0] == 6
|
||||
&& raw[1] == 2
|
||||
&& raw[2..4] == [0, 0]
|
||||
&& u16_at(raw, 4) == 33
|
||||
&& u16_at(raw, 6) == 5
|
||||
&& u16_at(raw, 8) == 0
|
||||
&& raw[10..16] == [0; 6]
|
||||
&& raw[20..28] == [0; 8]
|
||||
&& u32_at(raw, 16) == sequence,
|
||||
"CHRONY_REPLY_BINDING"
|
||||
);
|
||||
let reference = u32_at(raw, 28);
|
||||
let family = u16_at(raw, 48);
|
||||
// Network peers only. Local/reference-clock fallback is deliberately outside
|
||||
// this profile; family UNSPEC/ID and loopback identities cannot qualify.
|
||||
ensure!(
|
||||
reference != 0
|
||||
&& reference != 0x4c4f_434c
|
||||
&& reference >> 24 != 127
|
||||
&& (family == 1 || family == 2)
|
||||
&& raw[50..52] == [0, 0],
|
||||
"CHRONY_REFERENCE_SOURCE"
|
||||
);
|
||||
if family == 1 {
|
||||
ensure!(
|
||||
raw[32] != 127 && raw[32..36] != [0; 4] && raw[36..48] == [0; 12],
|
||||
"CHRONY_LOCAL_IPV4"
|
||||
);
|
||||
} else {
|
||||
let address = &raw[32..48];
|
||||
let mapped = address[..10] == [0; 10] && address[10..12] == [0xff, 0xff];
|
||||
let compatible = address[..12] == [0; 12];
|
||||
ensure!(
|
||||
!((mapped || compatible) && (address[12] == 127 || address[12..16] == [0; 4])),
|
||||
"CHRONY_LOCAL_EMBEDDED_IPV4"
|
||||
);
|
||||
ensure!(
|
||||
raw[32..48] != [0; 16]
|
||||
&& raw[32..48] != [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
|
||||
"CHRONY_LOCAL_IPV6"
|
||||
);
|
||||
}
|
||||
ensure!(
|
||||
(1..=15).contains(&u16_at(raw, 52)) && u16_at(raw, 54) <= 2,
|
||||
"CHRONY_UNSYNCHRONIZED"
|
||||
);
|
||||
let high = u32_at(raw, 56);
|
||||
let seconds = if high == 0x7fff_ffff {
|
||||
u64::from(u32_at(raw, 60))
|
||||
} else {
|
||||
(u64::from(high) << 32) | u64::from(u32_at(raw, 60))
|
||||
};
|
||||
let nanos = u32_at(raw, 64);
|
||||
ensure!(
|
||||
seconds > 0 && nanos < 1_000_000_000,
|
||||
"CHRONY_REFERENCE_TIME"
|
||||
);
|
||||
let reference_utc_ns = i64::try_from(u128::from(seconds) * 1_000_000_000 + u128::from(nanos))?;
|
||||
let correction = float_ns(u32_at(raw, 68), true)?;
|
||||
let delay = float_ns(u32_at(raw, 92), false)?;
|
||||
let dispersion = float_ns(u32_at(raw, 96), false)?;
|
||||
let error_ns = correction
|
||||
.checked_add(delay.div_ceil(2))
|
||||
.and_then(|v| v.checked_add(dispersion))
|
||||
.ok_or_else(|| anyhow::anyhow!("CHRONY_ERROR_OVERFLOW"))?;
|
||||
ensure!(error_ns <= MAX_ERROR_NS, "CHRONY_ERROR_LIMIT");
|
||||
Ok(Tracking {
|
||||
reference_utc_ns,
|
||||
error_ns,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
fn good() -> [u8; PACKET_BYTES] {
|
||||
let mut b = [0; PACKET_BYTES];
|
||||
b[0] = 6;
|
||||
b[1] = 2;
|
||||
b[4..6].copy_from_slice(&33u16.to_be_bytes());
|
||||
b[6..8].copy_from_slice(&5u16.to_be_bytes());
|
||||
b[16..20].copy_from_slice(&7u32.to_be_bytes());
|
||||
b[28..32].copy_from_slice(&0xc0000201u32.to_be_bytes());
|
||||
b[32..36].copy_from_slice(&[192, 0, 2, 1]);
|
||||
b[48..50].copy_from_slice(&1u16.to_be_bytes());
|
||||
b[52..54].copy_from_slice(&2u16.to_be_bytes());
|
||||
b[60..64].copy_from_slice(&1_800_000_000u32.to_be_bytes());
|
||||
b
|
||||
}
|
||||
#[test]
|
||||
fn exact_packet_sequence_and_network_source() {
|
||||
let b = good();
|
||||
let t = reply(&b, 7).unwrap();
|
||||
assert_eq!(t.reference_utc_ns, 1_800_000_000_000_000_000);
|
||||
assert_eq!(t.error_ns, 0);
|
||||
assert!(reply(&b, 8).is_err());
|
||||
assert!(reply(&b[..103], 7).is_err());
|
||||
for offset in [0, 1, 4, 6, 8, 10, 20, 48, 54] {
|
||||
let mut bad = b;
|
||||
bad[offset] ^= 0x40;
|
||||
assert!(reply(&bad, 7).is_err(), "offset {offset}");
|
||||
}
|
||||
let mut bad = b;
|
||||
bad[48..50].fill(0);
|
||||
assert!(reply(&bad, 7).is_err());
|
||||
// IPv4 loopback/unspecified cannot hide inside mapped or compatible
|
||||
// IPv6. Ordinary IPv6 and mapped network peers remain accepted.
|
||||
for (mapped, ipv4) in [
|
||||
(true, [127, 0, 0, 1]),
|
||||
(true, [0, 0, 0, 0]),
|
||||
(false, [127, 0, 0, 1]),
|
||||
(false, [0, 0, 0, 0]),
|
||||
] {
|
||||
let mut bad = b;
|
||||
bad[48..50].copy_from_slice(&2u16.to_be_bytes());
|
||||
bad[32..48].fill(0);
|
||||
if mapped {
|
||||
bad[42..44].fill(0xff);
|
||||
}
|
||||
bad[44..48].copy_from_slice(&ipv4);
|
||||
assert!(reply(&bad, 7).is_err());
|
||||
}
|
||||
let mut ipv6 = b;
|
||||
ipv6[48..50].copy_from_slice(&2u16.to_be_bytes());
|
||||
ipv6[32..48].fill(0);
|
||||
ipv6[32..36].copy_from_slice(&[0x20, 0x01, 0x0d, 0xb8]);
|
||||
ipv6[47] = 1;
|
||||
assert!(reply(&ipv6, 7).is_ok());
|
||||
ipv6[32..48].fill(0);
|
||||
ipv6[42..44].fill(0xff);
|
||||
ipv6[44..48].copy_from_slice(&[192, 0, 2, 1]);
|
||||
assert!(reply(&ipv6, 7).is_ok());
|
||||
assert_eq!(request(7).len(), 104);
|
||||
assert_eq!(&request(7)[8..12], &7u32.to_be_bytes());
|
||||
}
|
||||
#[test]
|
||||
fn signed_float_ceil_and_overflow_are_conservative() {
|
||||
// exp=-6, coeff=2^24 -> 1/128 sec, exactly 7_812_500ns.
|
||||
let positive = (122u32 << 25) | 0x0100_0000; // coeff -2^24
|
||||
assert_eq!(float_ns(positive, true).unwrap(), 7_812_500);
|
||||
assert!(float_ns(positive, false).is_err());
|
||||
assert_eq!(float_ns(64u32 << 25 | 1, true).unwrap(), 1);
|
||||
assert!(float_ns(63u32 << 25 | 0x00ff_ffff, true).is_err());
|
||||
let mut b = good();
|
||||
b[96..100].copy_from_slice(&(63u32 << 25 | 0x00ff_ffff).to_be_bytes());
|
||||
assert!(reply(&b, 7).is_err());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Frozen four Linux time-contract units only; no updater service or Apply.
|
||||
|
||||
Prepare copies the independently reviewed snapshot locally. Execute is one
|
||||
root-only Cloud-VM fixture run. After any lost reply read the original case;
|
||||
never execute it again or substitute another binary/source generation.
|
||||
"""
|
||||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import inspect
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import stat
|
||||
import uuid
|
||||
|
||||
import windows_msi_runtime_acceptance as support
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ACCESS_ROOT = ROOT.parent / 'rust-discovery'
|
||||
QUALIFICATION = ROOT / 'devstate/time-attestation-qualification/61dd70ca-3952-435e-9de2-dc2f40fedac7'
|
||||
STATE = ROOT / 'devstate/time-attestation-uri-linux'
|
||||
PROFILE = 'rmm.time-attestation.four-uri-contract-units.v1'
|
||||
RECEIPT_SHA = 'b708000c9ca9ba8da2128003683ed26382d4349833c322663bdd393dd60ad751'
|
||||
INPUTS_SHA = '989bcd56c96747ce8f2c4020423360ce4a8c9d8057f7c3deccba4e44fbc30c9a'
|
||||
BINARY_SHA = '4dc10170500912c703f815f8c13f9ac28715afe919ad94020fe713ade8fbafdb'
|
||||
BINARY_BYTES = 1515168
|
||||
TESTS = sorted(['tests::foreign_reply_cannot_reenable_an_older_own_challenge', 'tests::signed_roundtrip_uses_entire_rtt_and_strict_deadline_interval', 'tests::discontinuity_invalidates_outstanding_and_requires_new_challenge', 'tests::tampering_wrong_role_nonce_key_and_delays_never_open'])
|
||||
AGENT_SHA = '0a7ad6eefaefda79ee80b6a41b2df904e9e7f50ae6ebeed01b98c25b6ce5c06f'
|
||||
HELPER_SHA = '79442727c3ba31cda02a8bc0e67481f14db9f39fc07520a880a90b64f10f1eaf'
|
||||
|
||||
|
||||
def sha(raw):
|
||||
return hashlib.sha256(raw).hexdigest()
|
||||
|
||||
|
||||
def save_local(path, value):
|
||||
support.save(path, value)
|
||||
fd = os.open(path.parent, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
|
||||
try:
|
||||
os.fsync(fd)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
def copy_exact(source, destination, digest, size):
|
||||
metadata = source.lstat()
|
||||
support.require(stat.S_ISREG(metadata.st_mode) and metadata.st_nlink == 1
|
||||
and metadata.st_uid in (0, os.getuid()) and not metadata.st_mode & 0o002
|
||||
and metadata.st_size == size and size <= 2 * 1024 * 1024, 'bounded regular frozen input')
|
||||
raw = source.read_bytes()
|
||||
support.require(sha(raw) == digest, 'frozen snapshot input hash')
|
||||
destination.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
support.private(destination.parent, True)
|
||||
fd = os.open(destination, os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW | os.O_WRONLY, 0o600)
|
||||
with os.fdopen(fd, 'wb') as stream:
|
||||
stream.write(raw); stream.flush(); os.fsync(stream.fileno())
|
||||
fd = os.open(destination.parent, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
|
||||
try:
|
||||
os.fsync(fd)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
|
||||
def verify_case(folder):
|
||||
value = support.load(folder / 'manifest.json')
|
||||
support.require(value['profile'] == PROFILE and value['tests'] == TESTS
|
||||
and value['runner_sha256'] == sha(Path(__file__).read_bytes())
|
||||
and value['receipt_sha256'] == RECEIPT_SHA and value['binary_sha256'] == BINARY_SHA
|
||||
and value['binary_bytes'] == BINARY_BYTES, 'same original reviewed manifest')
|
||||
support.require(sha((folder / 'receipt.json').read_bytes()) == RECEIPT_SHA
|
||||
and sha((folder / 'inputs.json').read_bytes()) == INPUTS_SHA, 'original qualification provenance')
|
||||
source = support.load(folder / 'inputs.json')
|
||||
support.require(len(source) == 4 and source == value['source_files'], 'exact frozen four codec inputs')
|
||||
for item in source:
|
||||
path = Path(item['path'])
|
||||
support.require(not path.is_absolute() and '..' not in path.parts, 'fixed snapshot relative path')
|
||||
file = folder / 'source' / path
|
||||
support.private(file)
|
||||
support.require(file.stat().st_size == item['bytes'] and sha(file.read_bytes()) == item['sha256'], 'retained source freeze')
|
||||
binary = folder / 'time-contract-tests'; support.private(binary)
|
||||
support.require(binary.stat().st_size == BINARY_BYTES and sha(binary.read_bytes()) == BINARY_SHA, 'original qualified test bytes')
|
||||
for path, digest in value['transport_sources'].items():
|
||||
support.require(sha((ROOT / path).read_bytes()) == digest, 'original strict transport source')
|
||||
return value
|
||||
|
||||
|
||||
def remote(p):
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import selectors
|
||||
import signal
|
||||
import stat
|
||||
import subprocess
|
||||
import time
|
||||
import uuid
|
||||
|
||||
def require(ok, message):
|
||||
if not ok:
|
||||
raise RuntimeError(message)
|
||||
|
||||
def enc(value):
|
||||
return json.dumps(value, sort_keys=True, separators=(',', ':')).encode()
|
||||
|
||||
def create(path, raw, mode=0o600):
|
||||
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, mode)
|
||||
with os.fdopen(fd, 'wb') as stream:
|
||||
stream.write(raw); stream.flush(); os.fsync(stream.fileno())
|
||||
fd = os.open(path.parent, os.O_DIRECTORY | os.O_RDONLY | os.O_NOFOLLOW)
|
||||
try:
|
||||
os.fsync(fd)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
def run(args, timeout=20):
|
||||
# Keep the owned group leader unreaped until its entire group has been
|
||||
# cleaned up. Its PID therefore cannot be recycled before killpg.
|
||||
child = subprocess.Popen(args, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, start_new_session=True,
|
||||
env={'PATH': '/usr/bin:/bin', 'LC_ALL': 'C', 'HOME': '/nonexistent'})
|
||||
selector = selectors.DefaultSelector()
|
||||
buffers = {'stdout': bytearray(), 'stderr': bytearray()}
|
||||
deadline = time.monotonic() + timeout
|
||||
try:
|
||||
for stream, name in ((child.stdout, 'stdout'), (child.stderr, 'stderr')):
|
||||
os.set_blocking(stream.fileno(), False); selector.register(stream, selectors.EVENT_READ, name)
|
||||
while True:
|
||||
require(time.monotonic() < deadline, 'owned native command timeout; read original case only')
|
||||
for key, _ in selector.select(0.02):
|
||||
raw = os.read(key.fileobj.fileno(), 4096)
|
||||
if raw:
|
||||
buffers[key.data].extend(raw)
|
||||
require(len(buffers[key.data]) <= 65536, 'bounded native output')
|
||||
else:
|
||||
selector.unregister(key.fileobj)
|
||||
ended = os.waitid(os.P_PID, child.pid, os.WEXITED | os.WNOHANG | os.WNOWAIT)
|
||||
if ended is not None:
|
||||
# Child remains a zombie until finally: no PID/group reuse.
|
||||
os.killpg(child.pid, signal.SIGKILL)
|
||||
for key in list(selector.get_map().values()):
|
||||
while True:
|
||||
try:
|
||||
raw = os.read(key.fileobj.fileno(), 4096)
|
||||
except BlockingIOError:
|
||||
break
|
||||
if not raw:
|
||||
break
|
||||
buffers[key.data].extend(raw)
|
||||
require(len(buffers[key.data]) <= 65536, 'bounded native output')
|
||||
code = ended.si_status if ended.si_code == os.CLD_EXITED else -ended.si_status
|
||||
return code, bytes(buffers['stdout']), bytes(buffers['stderr'])
|
||||
finally:
|
||||
os.killpg(child.pid, signal.SIGKILL)
|
||||
child.wait()
|
||||
selector.close(); child.stdout.close(); child.stderr.close()
|
||||
|
||||
def metadata_identity(value):
|
||||
return (value.st_dev, value.st_ino, value.st_uid, value.st_gid, value.st_mode,
|
||||
value.st_nlink, value.st_size, value.st_mtime_ns, value.st_ctime_ns)
|
||||
|
||||
def hashed(path, maximum, process_image=False):
|
||||
fd = os.open(path, os.O_RDONLY | os.O_CLOEXEC | (0 if process_image else os.O_NOFOLLOW))
|
||||
with os.fdopen(fd, 'rb') as stream:
|
||||
before = os.fstat(stream.fileno()); require(stat.S_ISREG(before.st_mode) and before.st_size <= maximum, 'bounded witness file')
|
||||
digest = hashlib.sha256(); total = 0
|
||||
while True:
|
||||
raw = stream.read(32768)
|
||||
if not raw:
|
||||
break
|
||||
total += len(raw); require(total <= maximum, 'bounded witness hash'); digest.update(raw)
|
||||
after = os.fstat(stream.fileno())
|
||||
require(metadata_identity(before) == metadata_identity(after) and total == before.st_size, 'stable witness hash')
|
||||
return before, digest.hexdigest()
|
||||
|
||||
def witness():
|
||||
out = {'boot_id': Path('/proc/sys/kernel/random/boot_id').read_text().strip(), 'services': {}, 'files': {}}
|
||||
release = dict(line.split('=', 1) for line in Path('/etc/os-release').read_text().splitlines() if '=' in line)
|
||||
require(release.get('ID', '').strip('"') == 'ubuntu' and release.get('VERSION_ID', '').strip('"') == '24.04', 'fixed native Ubuntu24.04')
|
||||
out['os'] = {'id': 'ubuntu', 'version': '24.04', 'machine': os.uname().machine, 'kernel': os.uname().release}
|
||||
for name, uid, binary in (
|
||||
('rmm-agent-remote.service', 993, p['agent_sha256']),
|
||||
('rmm-helper-cloud.service', 0, p['helper_sha256']),
|
||||
('rmm-full-maintenance-helper.service', 0, p['helper_sha256'])):
|
||||
code, stdout, _ = run(['/usr/bin/systemctl', 'show', name, '-p', 'ActiveState', '-p', 'MainPID', '-p', 'UnitFileState', '-p', 'InvocationID'])
|
||||
require(code == 0, 'existing service read')
|
||||
service = dict(line.split('=', 1) for line in stdout.decode().splitlines())
|
||||
pid = int(service['MainPID']); require(service['ActiveState'] == 'active' and pid > 1, 'three existing services active')
|
||||
proc = Path('/proc', str(pid)); birth = (proc / 'stat').read_text().rsplit(') ', 1)[1].split()[19]
|
||||
ids = {line.split(':')[0]: line.split()[1:] for line in (proc / 'status').read_text().splitlines() if line.startswith(('Uid:', 'Gid:'))}
|
||||
metadata, image = hashed(proc / 'exe', 256 * 1024 * 1024, process_image=True)
|
||||
current = (proc / 'exe').stat()
|
||||
require(ids['Uid'] == [str(uid)] * 4 and ids['Gid'] == ['984'] * 4 and image == binary
|
||||
and (metadata.st_dev, metadata.st_ino) == (current.st_dev, current.st_ino)
|
||||
and (proc / 'stat').read_text().rsplit(') ', 1)[1].split()[19] == birth, 'current generation/account/image')
|
||||
out['services'][name] = dict(service, birth=birth, image=image, ids=ids)
|
||||
code, stdout, _ = run(['/usr/bin/systemctl', 'show', 'rmm-apt-helper.service', '-p', 'ActiveState', '-p', 'UnitFileState'])
|
||||
apt = dict(line.split('=', 1) for line in stdout.decode().splitlines())
|
||||
require(code == 0 and apt == {'ActiveState': 'inactive', 'UnitFileState': 'disabled'}, 'APT remains closed')
|
||||
out['apt'] = apt
|
||||
for name in ('/etc/rmm-remote/helper-general.json', '/etc/rmm-remote/helper-full-maintenance.json',
|
||||
'/etc/rmm-remote/full-maintenance-helper-proof.json', '/etc/systemd/system/rmm-full-maintenance-helper.service'):
|
||||
path = Path(name); metadata = path.lstat()
|
||||
require(not path.is_symlink() and stat.S_ISREG(metadata.st_mode) and metadata.st_uid == 0
|
||||
and not metadata.st_mode & 0o022 and metadata.st_nlink == 1, 'protected known control')
|
||||
current, digest = hashed(path, 65536)
|
||||
require(metadata_identity(current) == metadata_identity(metadata), 'same known control file')
|
||||
out['files'][name] = [metadata.st_dev, metadata.st_ino, metadata.st_uid, metadata.st_gid, metadata.st_mode,
|
||||
metadata.st_size, metadata.st_mtime_ns, metadata.st_ctime_ns, digest]
|
||||
for name in ('/var/lib/rmm-helper/consumption.sqlite', '/var/lib/rmm-helper/executor.lock',
|
||||
'/var/lib/rmm-agent-remote/journal.sqlite', '/var/lib/rmm-agent-remote/consumption.sqlite'):
|
||||
path = Path(name); metadata = path.lstat()
|
||||
require(not path.is_symlink() and stat.S_ISREG(metadata.st_mode) and metadata.st_nlink == 1, 'existing state identity')
|
||||
out['files'][name] = [metadata.st_dev, metadata.st_ino, metadata.st_uid, metadata.st_gid, metadata.st_mode]
|
||||
return out
|
||||
|
||||
require(os.geteuid() == 0 and os.uname().machine == 'x86_64', 'fixed Cloud Linux root contract fixtures')
|
||||
ident = str(uuid.UUID(p['id'])); require(ident == p['id'], 'canonical original case')
|
||||
folder = Path('/var/tmp') / ('rmm-time-attestation-uri-tests-' + ident)
|
||||
if p['action'] == 'read':
|
||||
metadata = folder.lstat()
|
||||
require(stat.S_ISDIR(metadata.st_mode) and not folder.is_symlink() and metadata.st_uid == 0
|
||||
and stat.S_IMODE(metadata.st_mode) == 0o700, 'own original case only')
|
||||
result = folder / 'result.json'
|
||||
return {'read_only': True, 'id': ident, 'entered': (folder / 'entered.json').exists(),
|
||||
'result': json.loads(result.read_bytes()) if result.exists() else None, 'current_witness': witness()}
|
||||
require(p['action'] == 'execute', 'one fixed time contract action')
|
||||
os.umask(0o077); folder.mkdir(mode=0o700)
|
||||
create(folder / 'intent.json', enc({key: value for key, value in p.items() if key != 'binary_b64'}))
|
||||
require(len(p['binary_b64']) == 2020224, 'bounded binary transfer')
|
||||
raw = base64.b64decode(p['binary_b64'], validate=True)
|
||||
require(len(raw) == 1515168 and hashlib.sha256(raw).hexdigest() == p['binary_sha256'], 'fixed four-unit binary')
|
||||
binary = folder / 'time-contract-tests'; create(binary, raw, 0o700)
|
||||
before = witness(); create(folder / 'before.json', enc(before))
|
||||
command = ['/usr/bin/setpriv', '--reuid=0', '--regid=0', '--clear-groups', '--no-new-privs', str(binary)]
|
||||
code, stdout, stderr = run(command + ['--list', '--format', 'terse'])
|
||||
create(folder / 'list.stdout', stdout); create(folder / 'list.stderr', stderr)
|
||||
require(code == 0 and stderr == b'', 'native list succeeded')
|
||||
lines = stdout.decode().splitlines()
|
||||
require(len(lines) == 4 and sorted(line[:-6] for line in lines if line.endswith(': test')) == p['tests'], 'exact four tests before any run')
|
||||
create(folder / 'entered.json', enc({'id': ident, 'run_once': True, 'time_ns': time.time_ns()}))
|
||||
code, stdout, stderr = run(command + ['--test-threads=1', '--nocapture'])
|
||||
create(folder / 'run.stdout', stdout); create(folder / 'run.stderr', stderr)
|
||||
after = witness(); create(folder / 'after.json', enc(after))
|
||||
require(before == after and code == 0 and stderr == b''
|
||||
and b'4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out' in stdout
|
||||
and all((b'test ' + name.encode() + b' ... ok') in stdout for name in p['tests']), 'four native units and retained target state')
|
||||
receipt = dict(id=ident, profile=p['profile'], passed=4, ignored=0, filtered=0, execution_uid=0, tests=p['tests'],
|
||||
before=before, after=after, binary_sha256=p['binary_sha256'], source_receipt_sha256=p['receipt_sha256'],
|
||||
source_manifest_sha256=p['manifest_sha256'], stdout_sha256=hashlib.sha256(stdout).hexdigest(),
|
||||
no_rmm_jobs=True, no_apply=True, no_service_control=True)
|
||||
create(folder / 'result.json', enc(receipt)); return receipt
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('action', choices=('prepare', 'execute', 'read')); parser.add_argument('--case')
|
||||
args = parser.parse_args(); os.umask(0o077)
|
||||
STATE.mkdir(mode=0o700, parents=True, exist_ok=True); support.private(STATE, True)
|
||||
if args.action == 'prepare':
|
||||
support.require(args.case is None, 'prepare one new local case')
|
||||
receipt_path = QUALIFICATION / 'receipt.json'; support.private(receipt_path)
|
||||
support.require(sha(receipt_path.read_bytes()) == RECEIPT_SHA, 'independently reviewed source receipt')
|
||||
receipt = support.load(receipt_path); original = support.load(QUALIFICATION / 'inputs.json')
|
||||
support.require(sha((QUALIFICATION / 'inputs.json').read_bytes()) == INPUTS_SHA
|
||||
and receipt['inputs_sha256'] == INPUTS_SHA and len(original) == 4
|
||||
and receipt['result'] == 'LOCAL_TIME4_URI_PASS_RELEASE' and receipt['tests'] == 4
|
||||
and receipt['skips'] == 0 and receipt['filters'] == 0, 'reviewed four-test qualification')
|
||||
ident = str(uuid.uuid4()); folder = STATE / ident; folder.mkdir(mode=0o700)
|
||||
copy_exact(receipt_path, folder / 'receipt.json', RECEIPT_SHA, receipt_path.stat().st_size)
|
||||
copy_exact(QUALIFICATION / 'inputs.json', folder / 'inputs.json', INPUTS_SHA, (QUALIFICATION / 'inputs.json').stat().st_size)
|
||||
paths = set()
|
||||
for item in original:
|
||||
path = Path(item['path'])
|
||||
support.require(not path.is_absolute() and '..' not in path.parts and str(path) not in paths, 'unique fixed frozen input')
|
||||
paths.add(str(path)); copy_exact(QUALIFICATION / 'source' / path, folder / 'source' / path, item['sha256'], item['bytes'])
|
||||
binary = QUALIFICATION / 'qualified-time-tests'
|
||||
support.require(receipt['artifacts'][0] == dict(path='qualified-time-tests', bytes=BINARY_BYTES, sha256=BINARY_SHA), 'fixed original linked artifact')
|
||||
copy_exact(binary, folder / 'time-contract-tests', BINARY_SHA, BINARY_BYTES)
|
||||
transports = {path: sha((ROOT / path).read_bytes()) for path in ('deploy/windows_msi_runtime_acceptance.py', 'deploy/vm_access_check.py')}
|
||||
save_local(folder / 'manifest.json', dict(id=ident, profile=PROFILE, runner_sha256=sha(Path(__file__).read_bytes()),
|
||||
receipt_sha256=RECEIPT_SHA, binary_sha256=BINARY_SHA, binary_bytes=BINARY_BYTES,
|
||||
source_files=original, tests=TESTS, transport_sources=transports))
|
||||
verify_case(folder)
|
||||
print(json.dumps({'id': ident, 'prepared_locally': True})); return
|
||||
support.require(args.case is not None, 'original --case required')
|
||||
ident = str(uuid.UUID(args.case)); support.require(ident == args.case, 'same canonical original case')
|
||||
folder = STATE / ident; support.private(folder, True); verify_case(folder)
|
||||
payload = dict(id=ident, action=args.action, profile=PROFILE, tests=TESTS, binary_sha256=BINARY_SHA,
|
||||
receipt_sha256=RECEIPT_SHA, manifest_sha256=sha((folder / 'manifest.json').read_bytes()),
|
||||
agent_sha256=AGENT_SHA, helper_sha256=HELPER_SHA)
|
||||
if args.action == 'execute':
|
||||
save_local(folder / 'execute-entered.json', {'once': True, 'no_retry': True})
|
||||
payload['binary_b64'] = base64.b64encode((folder / 'time-contract-tests').read_bytes()).decode()
|
||||
code = 'import json\n' + inspect.getsource(remote) + '\nprint(json.dumps(remote(' + repr(payload) + ')))\n'
|
||||
response = support.transport(support.access_settings(ACCESS_ROOT, 'linux'), 'python3 -', code.encode(), folder)
|
||||
save_local(folder / (args.action + '-' + str(uuid.uuid4()) + '.json'), response)
|
||||
if args.action == 'read' and response['result'] is not None:
|
||||
support.require(response['result']['source_manifest_sha256'] == sha((folder / 'manifest.json').read_bytes())
|
||||
and response['current_witness'] == response['result']['after'], 'same-case retained native result')
|
||||
print(json.dumps({'id': ident, 'action': args.action, 'passed': response.get('passed'),
|
||||
'complete': response.get('result') is not None if args.action == 'read' else True, 'read_only': args.action == 'read'}))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
+17
-1
@@ -1,6 +1,6 @@
|
||||
# Linux-first-Entwicklung und reale VM-Abnahme
|
||||
|
||||
Stand: 2026-11-14 · Spezifikation 1.21. Das begrenzte Linux-MVP ist inzwischen
|
||||
Stand: 2026-11-14 · Spezifikation 1.22. Das begrenzte Linux-MVP ist inzwischen
|
||||
dokumentiert abgenommen; aktuelle Nachweise stehen in [handover.md](handover.md).
|
||||
Die getrennte Windows-SYSTEM-Grenze ist in Spezifikation0.1 und
|
||||
[windows-system-policy.md](windows-system-policy.md) präzisiert; Quellen-/Build-
|
||||
@@ -17,6 +17,22 @@ Deploymentnachweise: [server-deployment.md](server-deployment.md).
|
||||
Die folgenden PC-Server-/Reverse-Tunnel-Abläufe und Nachweise sind historisch.
|
||||
TLS/mTLS, Credentialschutz, Linux-first und WebUI-Plangenehmigung gelten weiter.
|
||||
|
||||
## Unabhängiger signierter Windows-Zeitvergleich (Version1.22)
|
||||
|
||||
Der User erlaubt ausdrücklich den signierten Onlinevergleich mit dem festen
|
||||
Server. [Angenommener Vertrag](windows-clock-attestation-proposal.md) und
|
||||
SpezifikationKapitel0 ersetzen den früheren Ausschluss dieser Trustsource.
|
||||
Agent und SYSTEM-Helper halten eigene Challenges, Beobachtungen und geschützte
|
||||
Zeitpins. W32Time-Rohstatus bleibt separat; kein Clocksetter oder impliziter
|
||||
manueller Resync. Fehlende native Server-/Windowsqualität sperrt weiter Jobs.
|
||||
Ein signierter Zeitbeleg ersetzt weder SignedSync noch Startgrant oder WebUI.
|
||||
|
||||
Zuerst reale Cloud-Linux-Prüfungen des gemeinsamen Vertrags und der Serverquelle,
|
||||
danach Windows getrennt je tatsächlicher Identität. Isolierte Codecunits belegen
|
||||
keine reale Zeitqualität. Caller dürfen die gesamte frische UTCspanne nicht auf
|
||||
einen ungesicherten Mittelpunkt reduzieren; Start- und Syncablauffristen müssen
|
||||
konservativ eingehalten werden. Notebook bleibt nur Entwicklung.
|
||||
|
||||
## Enger paralleler Agentupdater (Version1.21)
|
||||
|
||||
Der User hat signiertes Agent-Selbstupdate parallel vorgezogen. Es bleibt ein
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# Übergabe — Linux-MVP abgeschlossen, Windows wird fortgesetzt
|
||||
|
||||
**Aktueller Zeitcodec-Endpunkt nativ geprüft:** Die Audiencekorrektur auf
|
||||
/agent/v1/time-attestation hat einen eigenen Linuxfall a22de8d2 mit4/4 und
|
||||
separatem vollständigem Readback; Originalfall2b282376 unverändert.
|
||||
[Belege](signed-time-contract-results.md#nachfolgender-quellenstand-tatsächlicher-agent-endpunkt).
|
||||
Linux-Providerquelle lokal4/4 plus unabhängiger Review bestanden; noch kein
|
||||
nativer Chrony-/Kernelprovider. Ein getrennter lesender Serverkernelbefund
|
||||
meldet state0/flags0/maxerror55.773ms; keine gemeinsame Qualitätsabnahme oder
|
||||
Clockgateöffnung. [Grenzen](server-time-source.md).
|
||||
|
||||
|
||||
**Signierter Zeitvergleich, erster tatsächlicher Linuxbeleg:** Gemeinsamer
|
||||
Codec/Verifier nach Nonce-Replayfix im Originalfall2b282376 nativ4/4 bestanden,
|
||||
separater Readback abgeschlossen, bekannte Runtimezeugen erhalten.
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
# Nativer Linux-Zeitprovider: Quellencheckpoint
|
||||
|
||||
Der neue Quellpfad `crates/time-source-linux` beobachtet eine fest provisionierte
|
||||
Chrony-Instanz und den Linux-Kernel lesend. Er ist weder eine Zeitstellung noch
|
||||
ein Jobgrant. Dieser Stand ist implementierter, lokal geprüfter, noch nicht nativ
|
||||
qualifizierter Quellcode. Es wurde durch diesen Implementierungsauftrag keine tatsächliche
|
||||
Chrony-Abfrage, Provisionierung, Dienstaktion oder VM-Änderung ausgeführt.
|
||||
Die tatsächlichen lokalen Dockerprüfungen sind unten getrennt dokumentiert.
|
||||
Der Codec-Nachweis ersetzt diesen Providernachweis nicht.
|
||||
|
||||
`NativeTimeSource::open()` benötigt einen engen Root-Brokerprozess. Der
|
||||
unprivilegierte Anwendungsserver wird dadurch nicht zu Root. Die Runtime-
|
||||
Brokerintegration und die getrennte Zeit-Signierschlüsselprovisionierung sind
|
||||
separate Arbeitspakete. `sample()` liefert ausschließlich nach erfolgreicher
|
||||
authentisierter Beobachtung einen privat konstruierten `QualifiedSample`.
|
||||
UTC, Fehlerobergrenze, tatsächliches Referenzalter, Boot-ID sowie Monoton-/
|
||||
Boottime-Erfassungszeiten sind lesbar; Caller können keine Qualifikation per
|
||||
Boolean oder eigenem Konstruktor erzeugen. Der Broker muss Zeit bis zum
|
||||
Signieren konservativ ergänzen, Frische und Boot erneut prüfen und den
|
||||
Sourcezustand ohne Holdover verwenden. Dieser Typ allein autorisiert keinen
|
||||
HTTP-Aufrufer und keine Agentaktion.
|
||||
|
||||
## Festes Provisionierungsprofil
|
||||
|
||||
Die folgende Konfiguration beschreibt Voraussetzungen, keinen ausgeführten
|
||||
Bootstrap. `/etc/rmm-time-source/chrony-pin.json` muss eine reguläre,
|
||||
root-eigene Datei mit Modus0600 und genau einem Link unter geschützter
|
||||
root-eigener Verzeichniskette sein. Striktes JSON-Schema1, keine Zusatzfelder:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": 1,
|
||||
"daemon_pid": 1234,
|
||||
"daemon_birth_ticks": 123456,
|
||||
"daemon_uid": 999,
|
||||
"daemon_gid": 999,
|
||||
"daemon_image_sha256": "<64 kleingeschriebene Hexzeichen>"
|
||||
}
|
||||
```
|
||||
|
||||
Die Zahlen sind ausschließlich Platzhalter. Ein Operator muss die tatsächlichen
|
||||
Werte unabhängig aus der vorgesehenen Instanz prüfen. Der Imagepfad ist fest
|
||||
`/usr/sbin/chronyd`. PID-Startzeit, alle vier UID-/GID-Werte, lebendes pidfd,
|
||||
gehaltenes und aktuelles `/proc/PID/exe`, aktueller fester Imagepfad und SHA256
|
||||
müssen übereinstimmen. Die geschützte Binärdatei wird vor und nach der Abfrage
|
||||
geprüft. Neustart, Konto-/Imagewechsel oder unklarer Zustand bleiben deny;
|
||||
keine automatische PID- oder Pinübernahme. Root muss einen neuen vertrauens-
|
||||
würdigen Pin separat provisionieren und die Providerinstanz neu eröffnen.
|
||||
|
||||
Ziel ist ausschließlich `/run/chrony/chronyd.sock`. Seine Identität und
|
||||
Verzeichniskette werden vor und nach der Abfrage geprüft. Nicht-root-eigene
|
||||
Verzeichnisse müssen dem gepinnten Chrony-Konto gehören; kein Gruppen- oder
|
||||
Fremdschreibrecht. Der Socket muss dem gepinnten Daemonkonto gehören und darf
|
||||
keine Rechte für Fremde haben. Andere Images oder Layouts bleiben vorerst
|
||||
nicht unterstützt, ohne permissiven Fallback.
|
||||
|
||||
Der vom Rootoperator separat anzulegende Clientbereich ist
|
||||
`/run/rmm-time-source/clients`, root:ChronyGID0710 unter geschützter root-eigener
|
||||
Kette. Eine einzelne Zufallsadresse `tracking-<UUID>.sock` wird einmalig dort
|
||||
gebunden, root:ChronyGID0660 gesetzt und mit Device/Inode/Name/Konto/Modus
|
||||
gehalten. Chrony erhält nur Traversierungsrecht am Verzeichnis und Socket-
|
||||
zugriff; es kann dort keine Namen ändern. Vor jedem Namespacezugriff werden
|
||||
gehaltener Verzeichnis-FD und aktueller Pfad verglichen. Cleanup konsumiert
|
||||
seine einmalige Autorität vor der Prüfung und verwendet ausschließlich
|
||||
`unlinkat` für die exakt eigene Identität. Unklarer Cleanup bleibt liegen;
|
||||
kein Retry, rekursives Entfernen oder Übernehmen fremder Dateien. Vor Beginn
|
||||
wird das Clientverzeichnis exklusiv per nonblocking flock am gehaltenen
|
||||
Verzeichnis-FD gesperrt und muss leer sein. Ein unbekannter Rest blockiert
|
||||
auch neue Instanzen. Die laufende Providerinstanz bleibt nach einem unklaren
|
||||
Clientpfad sticky gesperrt; keine neue UUID-Schleife.
|
||||
|
||||
## Drahtvertrag und Qualität
|
||||
|
||||
Primärquellen: Chrony [candm.h](https://github.com/mlichvar/chrony/blob/master/candm.h),
|
||||
[pktlength.c](https://github.com/mlichvar/chrony/blob/master/pktlength.c),
|
||||
[addressing.h](https://github.com/mlichvar/chrony/blob/master/addressing.h) und
|
||||
[util.c](https://github.com/mlichvar/chrony/blob/master/util.c).
|
||||
|
||||
Ein einzelner Unix-Datagrammaufruf verwendet Version6, Tracking-Befehl33,
|
||||
Antworttyp5 und eine zufällige32-Bit-Sequenz. Request und erfolgreiche Antwort
|
||||
sind jeweils104Bytes; das Requestpadding gehört dazu. Kein Retry, Shellaufruf,
|
||||
CLI, UDP-/IP-Fallback, frei wählbarer Befehl oder Zeitsetter. `SO_PASSCRED` und
|
||||
`recvmsg` verlangen genau eine unveränderte Kernel-Credential mit gepinnter
|
||||
PID/UID/GID. Fremde Sequenz, fehlerhafte Status-/Headerfelder, abgeschnittene
|
||||
Nutz- oder Kontrolldaten und fehlende Credentials verweigern.
|
||||
|
||||
Die ursprünglich vorgesehene abstrakte Linux-Autobindadresse wird nicht
|
||||
verwendet. Die Chrony-[Socketimplementierung](https://github.com/mlichvar/chrony/blob/master/socket.c)
|
||||
behandelt Unix-Rückadressen als C-Strings und rekonstruiert sie mit `strlen`;
|
||||
eine mit NUL beginnende abstrakte Clientadresse verliert dadurch ihren Namen.
|
||||
Dieser reine Quellenbefund wurde auch in4.6.1 geprüft, nicht als reales
|
||||
fehlgeschlagenes Runtimeexperiment ausgegeben. Die technische Entscheidung
|
||||
des Hauptagenten erlaubt stattdessen den engen sichtbaren Clientbereich oben.
|
||||
|
||||
Das Trackingalter wird aus Chronys tatsächlicher Referenzzeit berechnet,
|
||||
nicht aus Abfragezeit oder Pollintervall. Unsynchronisiert, lokale Referenz/
|
||||
Refclock, Nullreferenz, Nicht-Netzwerkquelle, Loopback, ungültiger Stratum,
|
||||
Leapstatus, Zukunftszeit oder ein Alter über1h verweigern. Die spezialisierte
|
||||
Draht-Floatdarstellung wird als exakte ganzzahlige rationale Größe mit
|
||||
Aufrundung nach Nanosekunden dekodiert, einschließlich negativer Korrektur;
|
||||
negative Verzögerung/Dispersion oder Overflow verweigern.
|
||||
|
||||
Vor und nach der Abfrage wird `adjtimex` ausschließlich mit modes0 abgefragt:
|
||||
Status0–4, weder `STA_UNSYNC` noch `STA_CLOCKERR`, gültiger `maxerror`.
|
||||
REALTIME, MONOTONIC und BOOTTIME werden zeitlich eingegrenzt beobachtet;
|
||||
Bootwechsel, Rücksprung, Suspendabweichung, unpassende Wanduhrdifferenz und
|
||||
überschrittenes Gesamtbudget verweigern. Eine Erfassung darf höchstens10ms,
|
||||
das ist ausschließlich das gemessene Erfassungsfenster, keine Zusage
|
||||
physikalischer Timerqualität oder Kalibrierung. Die gesamte Abfrage
|
||||
einschließlich Auth-/Nachprüfung und Cleanup darf höchstens
|
||||
100ms dauern. Fehlerobergrenze ist konservativ aufgerundet:
|
||||
Betrag der Chrony-Korrektur + Rootdispersion + halbe Rootverzögerung + größter
|
||||
Kernel-maxerror + vollständige verstrichene Abfrage-/Nachprüfzeit. Über500ms
|
||||
verweigert. Nachlauf bis Signierung ist zusätzliche Brokerpflicht; es gibt
|
||||
keine erfundene Timerkalibrierung und keinen Offline-Lease.
|
||||
|
||||
## Tatsächlich lokal ausgeführt
|
||||
|
||||
Im unveränderten Offline-Buildimage
|
||||
`sha256:9a76ad3744ebfdddae96ca10001ce8291c1b332fb54c8df5eea0e8e999ac6fc6`,
|
||||
Quellmount read-only, UID1000, eigenes `devstate/provider-target`:
|
||||
|
||||
- `cargo test --locked --offline -p rmm-time-source-linux --all-targets`:
|
||||
4bestanden,0fehlgeschlagen,0ignoriert,0gefiltert. Parserbindung und signed-Float-
|
||||
Grenzen; synthetische Zeitbracket-Fehler; ausschließlich eigener temporärer
|
||||
Socket mit echter Namenersetzung und genauem Inodecleanup.
|
||||
- `cargo clippy --locked --offline -p rmm-time-source-linux --all-targets -- -D warnings`:
|
||||
bestanden ohne Warnungsunterdrückung.
|
||||
- Gezieltes `rustfmt --edition2024 --check --config skip_children=true` der
|
||||
drei eigenen Rustdateien: bestanden.
|
||||
|
||||
Der erste Compilerlauf meldete den konkreten `pread`-Offsettypkonflikt
|
||||
`i64/isize`; er wurde explizit konvertiert und danach bestanden alle obigen
|
||||
Prüfungen. Die Tests rufen weder den echten Chrony-Provider noch `adjtimex`
|
||||
auf. Kein Rootlauf, keine Dienstinstallation, keine Server-/Clientwirkung.
|
||||
|
||||
## Verbleibende reale Gates
|
||||
|
||||
Unabhängiger Quellenreview,
|
||||
Linux-first-Nachweis mit tatsächlichem Chrony-/Kernelzustand, geschützte
|
||||
Provisionierung, Broker- und mTLS-HTTP-Anschluss sowie unabhängige Agent-/
|
||||
SYSTEM-Verifikation bleiben getrennt. Fehlende Plattformqualität bleibt deny.
|
||||
WebUI-Genehmigung und sämtliche ursprünglichen Clock-/Jobgrenzen bleiben
|
||||
bestehen. Auf dem Notebook wird kein RMM-Dienst oder Agent installiert.
|
||||
|
||||
|
||||
## Unabhängiger Quellenreview und gezielter Parserfix
|
||||
|
||||
Die enge unabhängige Prüfung korrigierte ausschließlich konkrete Fehlerpfade:
|
||||
Chrony-Ownerausnahme nur am letzten `/run/chrony`-Verzeichnisteil, gebundene
|
||||
Ancillary-Grenzen vor Credentiallesen sowie sticky Cleanupfence und exklusiver
|
||||
Verzeichnislock/Leerverzeichnisprüfung. Keine unbekannten Namen automatisch
|
||||
entfernen oder bei unklarem Cleanup neue UUID-Dateien anhäufen.
|
||||
|
||||
Danach wurden zusätzlich IPv4-mapped und IPv4-compatible Loopback-/
|
||||
Unspecified-Adressen im IPv6-Feld verweigert. Der bestehende Parserfall prüft
|
||||
vier Gegenfälle und zwei erlaubte Netzwerkdarstellungen; Testzahl bleibt4.
|
||||
Neuer ReceiptSHA256
|
||||
`275e6661ad1342cf63df573cab4309ca49d1f7a1066ee2d03fdf686ac58370a6`;
|
||||
lokale4/4,Clippy,Fmt und Release-Link bestanden. Originale4041333 bleibt
|
||||
historisch unverändert. Kein nativer Provider-/Kernelquery durch diese Tests.
|
||||
Der Quellenreview ist abgeschlossen; tatsächliche Providerqualität bleibt offen.
|
||||
|
||||
## Getrennter tatsächlicher Kernelbefund auf dem Server
|
||||
|
||||
Im nur lesenden Originalfall `09f56716-6175-41f6-8217-5de46854aaf1` wurde auf
|
||||
dem festgelegten ARM64-Server genau eine Kernelabfrage mit modes0 ausgeführt.
|
||||
Gemeldet: state0/flags0, kein STA_UNSYNC/STA_CLOCKERR,
|
||||
maxerror55773us,esterror544us. Eigenes monotones Erfassungsfenster128082ns.
|
||||
ResultatSHA256
|
||||
`5422ab7182fd7ff7896f56ce61ea3fe96e9b3a9ef236c39f74a6add8a538a61b`.
|
||||
Keine Zeitstellung, kein Resync, keine Dienst-/Anwendungsänderung.
|
||||
|
||||
Das ist ein einmaliger ABI-begrenzter LP64-Diagnosebefund. Er bildet mit dem
|
||||
älteren separaten Chrony-CLI-Beleg keine neue gemeinsame native Qualitätsprobe.
|
||||
Kein signierter Beleg oder freigegebenes Clockgate daraus. Der neue native
|
||||
Provider muss diese Kernel- und Chronyprüfung selbst frisch zusammen ausführen.
|
||||
@@ -72,10 +72,45 @@ Zeitqualität oder komplette Runtime. Geschützte Pinprovisionierung, tatsächli
|
||||
Chrony-/Kernelquelle samt lokalem Signierbroker, mTLS-/SQL-Kontextprüfung,
|
||||
unabhängiger Windows-Agent/SYSTEM-Timerbeleg und Jobintegration bleiben offen.
|
||||
Der erste Codec bindet noch den provisorischen Audiencepfad
|
||||
`/api/agent/v1/time-attestation`; vor Transportintegration muss er an den
|
||||
bestehenden `/agent/v1/...`-Vertrag angeglichen und als neuer Quellenstand
|
||||
geprüft werden. Keine zusätzliche öffentliche API-Wildcard vorsehen und den
|
||||
`/api/agent/v1/time-attestation`; die nachfolgende Korrektur an den
|
||||
bestehenden `/agent/v1/...`-Vertrag ist unten mit eigenem Beleg dokumentiert. Keine zusätzliche öffentliche API-Wildcard vorsehen und den
|
||||
ursprünglichen nativen Beleg dabei nicht nachträglich umetikettieren.
|
||||
|
||||
Die unverbundene Windows-Slice-/Providerentwicklung parallel dazu eröffnet
|
||||
keine Capability. Das Windows-MVP und der Selbstupdater sind nicht abgeschlossen.
|
||||
|
||||
|
||||
## Nachfolgender Quellenstand: tatsächlicher Agent-Endpunkt
|
||||
|
||||
Der feste Audiencepfad ist jetzt `/agent/v1/time-attestation`, passend zum
|
||||
bestehenden Agentvertrag. Genau eine Codec-Konstante geändert; keine neue
|
||||
öffentliche API-Wildcard oder geänderte Verifikationsregel. Der erste
|
||||
Originalfall2b282376 bleibt unverändert und qualifiziert weiterhin seine alten
|
||||
Bytes, nicht diese nachfolgende Generation.
|
||||
|
||||
Neuer unabhängiger Runnerreview und eingefrorene lokale Release4/4, Clippy und
|
||||
Fmt bestanden. ReceiptSHA256
|
||||
`b708000c9ca9ba8da2128003683ed26382d4349833c322663bdd393dd60ad751`,
|
||||
InputmanifestSHA256
|
||||
`989bcd56c96747ce8f2c4020423360ce4a8c9d8057f7c3deccba4e44fbc30c9a`.
|
||||
Neue Releaseexe1515168Byte/SHA256
|
||||
`4dc10170500912c703f815f8c13f9ac28715afe919ad94020fe713ade8fbafdb`.
|
||||
|
||||
`deploy/time_attestation_uri_linux_acceptance.py` SHA256
|
||||
`b156729ef7e8bf4b19f6f95be87b4b3be2145dad820146d1d935191484386898`
|
||||
verwendet eigene Fall-/Remote-/Profilnamen und denselben begrenzten
|
||||
Einmal-/Readback-/Erhaltungsvertrag. Tatsächlich prepare, genau ein execute
|
||||
und separater read mit Originalfall `a22de8d2-7cf7-4820-affa-79b4792132d1`
|
||||
ausgeführt: **Cloud-Linux4/4,0ignored/filtered, Exit0**, Readback vollständig.
|
||||
Bekannte Prozess-/Kontroll-/Stateidentitätszeugen erneut unverändert.
|
||||
FallmanifestSHA256
|
||||
`c20c8ce40ea3fa55ec6db4aa5614a15ca63ded88b913835e2c29f78ae1eb3fcb`;
|
||||
ExecuteSHA256
|
||||
`d2340962c7b1a56aa6d51d81eb7b2259ea2dcab80d0c9a1d251e8c5cbd23cf0e`;
|
||||
ReadbackSHA256
|
||||
`2b5c4a428fab45f5f1e865dbb00bbacce2f0e86128134f31f6c3e9d3f4c3caf2`.
|
||||
|
||||
Keine reale Zeitqualifikation oder Windowsfähigkeit daraus ableiten. Die
|
||||
parallel hinzugefügte Linux-Providercrate ist separat lokal4/4 geprüft,
|
||||
noch nicht nativ abgefragt; ihr Code wird durch diesen Codecbeleg nicht
|
||||
mitqualifiziert. [Providerstand](server-time-source.md).
|
||||
|
||||
Reference in New Issue
Block a user