Compare commits
44
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba43aee4a9 | ||
|
|
92b50f25e3 | ||
|
|
cd0257fbe9 | ||
|
|
bd0a426019 | ||
|
|
eb3fa560d6 | ||
|
|
cf2c1a632b | ||
|
|
45ce622370 | ||
|
|
fcec400ec6 | ||
|
|
dffdd401c5 | ||
|
|
97d4f86940 | ||
|
|
6fb973a247 | ||
|
|
e32f6330a0 | ||
|
|
c41c8c7286 | ||
|
|
0902a44671 | ||
|
|
e7cf1aed73 | ||
|
|
b614b6f5be | ||
|
|
242641de72 | ||
|
|
454e08f942 | ||
|
|
38e6df51ea | ||
|
|
5adf209f1e | ||
|
|
48662f97e3 | ||
|
|
16c9c3cefe | ||
|
|
07c5b0e12d | ||
|
|
c46873ff95 | ||
|
|
1a502a1c46 | ||
|
|
715287a559 | ||
|
|
a5ec061a92 | ||
|
|
9a6599fddd | ||
|
|
f023d790a4 | ||
|
|
5f21b753ed | ||
|
|
0b32859d74 | ||
|
|
331cdddac5 | ||
|
|
e952698f5e | ||
|
|
00717e4283 | ||
|
|
aa36b178aa | ||
|
|
d37160ba41 | ||
|
|
577132fb42 | ||
|
|
ca588abce4 | ||
|
|
53d17757ab | ||
|
|
27bb6a1257 | ||
|
|
81d78aaf8f | ||
|
|
0ecfb98204 | ||
|
|
cd44bdb735 | ||
|
|
b0076d14be |
@@ -53,7 +53,7 @@ impl Client {
|
|||||||
ipc::service_sid(crate::SERVICE_NAME)?,
|
ipc::service_sid(crate::SERVICE_NAME)?,
|
||||||
ipc::service_sid(ipc::HELPER_SERVICE)?,
|
ipc::service_sid(ipc::HELPER_SERVICE)?,
|
||||||
];
|
];
|
||||||
let _root = ipc::PinnedFile::open(Path::new(PUBLIC_ROOT), true, &readers, &[], false)?;
|
let _root = ipc::PinnedFile::open_read_shared(Path::new(PUBLIC_ROOT), true, &readers, &[])?;
|
||||||
let mut file = ipc::PinnedFile::open(Path::new(PIN_PATH), false, &readers, &[], false)?;
|
let mut file = ipc::PinnedFile::open(Path::new(PIN_PATH), false, &readers, &[], false)?;
|
||||||
ensure!(file.file.metadata()?.len() <= 16384, "HELPER_PIN_SIZE");
|
ensure!(file.file.metadata()?.len() <= 16384, "HELPER_PIN_SIZE");
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
|
|||||||
@@ -216,7 +216,9 @@ pub fn read_settings() -> Result<(Settings, Vec<PinnedFile>)> {
|
|||||||
let agent = ipc::service_sid(crate::SERVICE_NAME)?;
|
let agent = ipc::service_sid(crate::SERVICE_NAME)?;
|
||||||
let helper = ipc::service_sid(ipc::HELPER_SERVICE)?;
|
let helper = ipc::service_sid(ipc::HELPER_SERVICE)?;
|
||||||
let readers = vec![agent, helper];
|
let readers = vec![agent, helper];
|
||||||
let root = PinnedFile::open(Path::new(PUBLIC_ROOT), true, &readers, &[], false)?;
|
// A rename into PUBLIC_ROOT opens the directory with FILE_ADD_FILE.
|
||||||
|
// The handle stays read-only and denies deletion of the pinned directory.
|
||||||
|
let root = PinnedFile::open_read_shared(Path::new(PUBLIC_ROOT), true, &readers, &[])?;
|
||||||
let mut file = PinnedFile::open(Path::new(CONFIG_PATH), false, &readers, &[], false)?;
|
let mut file = PinnedFile::open(Path::new(CONFIG_PATH), false, &readers, &[], false)?;
|
||||||
ensure!(file.file.metadata()?.len() <= 32768, "SYSTEM_CONFIG_SIZE");
|
ensure!(file.file.metadata()?.len() <= 32768, "SYSTEM_CONFIG_SIZE");
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|||||||
@@ -39,6 +39,51 @@ struct Config {
|
|||||||
// Explicit protected opt-in only; this flag never qualifies a clock or pins.
|
// Explicit protected opt-in only; this flag never qualifies a clock or pins.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
enable_jobs: bool,
|
enable_jobs: bool,
|
||||||
|
#[serde(
|
||||||
|
default,
|
||||||
|
deserialize_with = "rmm_domain::jobs::deserialize_windows_execution_profile"
|
||||||
|
)]
|
||||||
|
windows_execution_profile: Option<rmm_domain::jobs::WindowsExecutionProfile>,
|
||||||
|
}
|
||||||
|
impl Config {
|
||||||
|
fn profile_enabled(&self, profile: rmm_domain::jobs::WindowsExecutionProfile) -> bool {
|
||||||
|
self.enable_jobs
|
||||||
|
&& self.job_binding_file.is_some()
|
||||||
|
&& cfg!(feature = "system-helper")
|
||||||
|
&& self.windows_execution_profile == Some(profile)
|
||||||
|
}
|
||||||
|
fn read(path: &Path) -> Result<Self> {
|
||||||
|
let raw = protected_read(path, 32768)?;
|
||||||
|
let config: Self = serde_json::from_slice(&raw)?;
|
||||||
|
if let Some(profile) = config.windows_execution_profile {
|
||||||
|
ensure!(
|
||||||
|
config.profile_enabled(profile),
|
||||||
|
"WINDOWS_PROFILE_REQUIRES_JOB_CONFIGURATION"
|
||||||
|
);
|
||||||
|
#[cfg(feature = "system-helper")]
|
||||||
|
{
|
||||||
|
use rmm_agent_windows::helper_ipc::PinnedFile;
|
||||||
|
use std::io::Read;
|
||||||
|
// Verify the exact bytes used for the opt-in under the existing
|
||||||
|
// administrator-owned, service-read-only file and directory ACLs.
|
||||||
|
let readers = [native::service_sid()?];
|
||||||
|
let mut parent = PinnedFile::open(
|
||||||
|
path.parent().context("CONFIG_PARENT")?,
|
||||||
|
true,
|
||||||
|
&readers,
|
||||||
|
&[],
|
||||||
|
false,
|
||||||
|
)?;
|
||||||
|
let mut pin = PinnedFile::open(path, false, &readers, &[], false)?;
|
||||||
|
let mut verified = Vec::new();
|
||||||
|
(&mut pin.file).take(32769).read_to_end(&mut verified)?;
|
||||||
|
ensure!(verified == raw, "WINDOWS_PROFILE_CONFIGURATION_CHANGED");
|
||||||
|
pin.check()?;
|
||||||
|
parent.check()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn create_private(path: &Path, bytes: &[u8]) -> Result<()> {
|
fn create_private(path: &Path, bytes: &[u8]) -> Result<()> {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@@ -830,6 +875,13 @@ impl Agent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if rmm_agent_windows::actions::supported(job) {
|
if rmm_agent_windows::actions::supported(job) {
|
||||||
|
if let rmm_domain::jobs::Action::RunScript {
|
||||||
|
windows_execution_profile: Some(profile),
|
||||||
|
..
|
||||||
|
} = &job.action
|
||||||
|
{
|
||||||
|
return self.binding.is_some() && self.config.profile_enabled(*profile);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#[cfg(feature = "system-helper")]
|
#[cfg(feature = "system-helper")]
|
||||||
@@ -859,9 +911,12 @@ impl Agent {
|
|||||||
{
|
{
|
||||||
caps.extend(["rmm.sync.v1", "refresh_inventory"].map(str::to_string));
|
caps.extend(["rmm.sync.v1", "refresh_inventory"].map(str::to_string));
|
||||||
if rmm_agent_windows::actions::powershell().is_ok() {
|
if rmm_agent_windows::actions::powershell().is_ok() {
|
||||||
// The process_remote_signed profile is implemented but remains
|
|
||||||
// unpublished until its separate native qualification passes.
|
|
||||||
caps.extend(["run_script", "script.powershell/1"].map(str::to_string));
|
caps.extend(["run_script", "script.powershell/1"].map(str::to_string));
|
||||||
|
if self.config.profile_enabled(
|
||||||
|
rmm_domain::jobs::WindowsExecutionProfile::PowerShell51RemoteSigned,
|
||||||
|
) {
|
||||||
|
caps.push(rmm_agent_windows::actions::REMOTE_SIGNED_PROFILE_CAPABILITY.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
caps
|
caps
|
||||||
@@ -1810,7 +1865,7 @@ fn service_run(stop: &'static AtomicBool) -> Result<()> {
|
|||||||
);
|
);
|
||||||
let path = Path::new(&arguments[2]);
|
let path = Path::new(&arguments[2]);
|
||||||
ensure!(path.is_absolute(), "ABSOLUTE_CONFIG_REQUIRED");
|
ensure!(path.is_absolute(), "ABSOLUTE_CONFIG_REQUIRED");
|
||||||
let config: Config = serde_json::from_slice(&protected_read(path, 32768)?)?;
|
let config = Config::read(path)?;
|
||||||
native::require_local_service()?;
|
native::require_local_service()?;
|
||||||
ensure!(
|
ensure!(
|
||||||
config.state_directory.is_absolute(),
|
config.state_directory.is_absolute(),
|
||||||
@@ -1951,7 +2006,7 @@ pub fn main() -> Result<()> {
|
|||||||
args.len() == 3 && args[1] == "--config",
|
args.len() == 3 && args[1] == "--config",
|
||||||
"SERVICE_ARGUMENTS"
|
"SERVICE_ARGUMENTS"
|
||||||
);
|
);
|
||||||
let config: Config = serde_json::from_slice(&protected_read(Path::new(&args[2]), 32768)?)?;
|
let config = Config::read(Path::new(&args[2]))?;
|
||||||
// Shared transport reads its one DNS identity. Set it before SCM dispatch
|
// Shared transport reads its one DNS identity. Set it before SCM dispatch
|
||||||
// creates its service thread and before any Tokio/collector threads exist.
|
// creates its service thread and before any Tokio/collector threads exist.
|
||||||
unsafe {
|
unsafe {
|
||||||
@@ -2053,15 +2108,58 @@ mod tests {
|
|||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn old_passive_configuration_cannot_enable_jobs_or_read_the_clock() {
|
fn old_passive_configuration_cannot_enable_jobs_or_read_the_clock() {
|
||||||
let config:Config=serde_json::from_value(serde_json::json!({"server_name":"example.invalid","connect_address":"127.0.0.1:443","ca_file":"C:/fixture/ca.pem","state_directory":"C:/fixture/state","enrollment_token_file":"C:/fixture/token","transport":"auto"})).unwrap();
|
let config: Config = serde_json::from_value(passive_test_config()).unwrap();
|
||||||
assert!(!config.enable_jobs);
|
assert!(!config.enable_jobs);
|
||||||
assert!(config.job_binding_file.is_none());
|
assert!(config.job_binding_file.is_none());
|
||||||
|
assert!(config.windows_execution_profile.is_none());
|
||||||
let clock = JobClock::new(config.enable_jobs);
|
let clock = JobClock::new(config.enable_jobs);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
clock.now().unwrap_err().to_string(),
|
clock.now().unwrap_err().to_string(),
|
||||||
"WINDOWS_JOBS_NOT_ENABLED"
|
"WINDOWS_JOBS_NOT_ENABLED"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
fn passive_test_config() -> serde_json::Value {
|
||||||
|
serde_json::json!({
|
||||||
|
"server_name":"example.invalid","connect_address":"127.0.0.1:443",
|
||||||
|
"ca_file":"C:/fixture/ca.pem","state_directory":"C:/fixture/state",
|
||||||
|
"enrollment_token_file":"C:/fixture/token","transport":"auto"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn remote_signed_requires_explicit_profile_jobs_and_binding() {
|
||||||
|
let profile = rmm_domain::jobs::WindowsExecutionProfile::PowerShell51RemoteSigned;
|
||||||
|
let mut config: Config = serde_json::from_value(passive_test_config()).unwrap();
|
||||||
|
config.enable_jobs = true;
|
||||||
|
config.job_binding_file = Some("C:/fixture/binding.json".into());
|
||||||
|
assert!(!config.profile_enabled(profile));
|
||||||
|
config.windows_execution_profile = Some(profile);
|
||||||
|
assert_eq!(
|
||||||
|
config.profile_enabled(profile),
|
||||||
|
cfg!(feature = "system-helper")
|
||||||
|
);
|
||||||
|
config.enable_jobs = false;
|
||||||
|
assert!(!config.profile_enabled(profile));
|
||||||
|
config.enable_jobs = true;
|
||||||
|
config.job_binding_file = None;
|
||||||
|
assert!(!config.profile_enabled(profile));
|
||||||
|
|
||||||
|
let mut value = passive_test_config();
|
||||||
|
value["windows_execution_profile"] = serde_json::json!("powershell_51_remote_signed");
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::from_value::<Config>(value.clone())
|
||||||
|
.unwrap()
|
||||||
|
.windows_execution_profile,
|
||||||
|
Some(profile)
|
||||||
|
);
|
||||||
|
for invalid in [
|
||||||
|
serde_json::Value::Null,
|
||||||
|
serde_json::json!(true),
|
||||||
|
serde_json::json!("Bypass"),
|
||||||
|
] {
|
||||||
|
value["windows_execution_profile"] = invalid;
|
||||||
|
assert!(serde_json::from_value::<Config>(value.clone()).is_err());
|
||||||
|
}
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn legacy_inventory_keeps_original_bytes_until_concrete_core_ack() {
|
fn legacy_inventory_keeps_original_bytes_until_concrete_core_ack() {
|
||||||
let directory =
|
let directory =
|
||||||
|
|||||||
@@ -751,12 +751,11 @@ mod installed {
|
|||||||
settings.agent.service_sid.clone(),
|
settings.agent.service_sid.clone(),
|
||||||
settings.helper.service_sid.clone(),
|
settings.helper.service_sid.clone(),
|
||||||
];
|
];
|
||||||
files.push(PinnedFile::open(
|
files.push(PinnedFile::open_read_shared(
|
||||||
Path::new(PUBLIC_ROOT),
|
Path::new(PUBLIC_ROOT),
|
||||||
true,
|
true,
|
||||||
&readers,
|
&readers,
|
||||||
&[],
|
&[],
|
||||||
false,
|
|
||||||
)?);
|
)?);
|
||||||
let mut config_file =
|
let mut config_file =
|
||||||
PinnedFile::open(Path::new(CONFIG_PATH), false, &readers, &[], false)?;
|
PinnedFile::open(Path::new(CONFIG_PATH), false, &readers, &[], false)?;
|
||||||
|
|||||||
@@ -2,15 +2,32 @@
|
|||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const crypto = require('node:crypto');
|
const crypto = require('node:crypto');
|
||||||
|
const { isDeepStrictEqual } = require('node:util');
|
||||||
const { chromium } = require('../../web/node_modules/playwright');
|
const { chromium } = require('../../web/node_modules/playwright');
|
||||||
const root = path.resolve(__dirname, '../..');
|
const root = path.resolve(__dirname, '../..');
|
||||||
const assert = (value) => { if (!value) throw new Error('UI contract mismatch'); };
|
const assert = (value) => { if (!value) throw new Error('UI contract mismatch'); };
|
||||||
|
function checkWindowsHello(job, planBytes) {
|
||||||
|
const payload = job.payload;
|
||||||
|
const action = {
|
||||||
|
action: 'run_script', interpreter: 'powershell', script_utf8: "Write-Output 'Zeitprofil-Test'\r\n",
|
||||||
|
arguments: [], expected_stdout: 'Zeitprofil-Test\r\n', windows_execution_profile: 'powershell_51_remote_signed',
|
||||||
|
};
|
||||||
|
const stored = JSON.parse(Buffer.from(planBytes).toString('utf8'));
|
||||||
|
assert(stored.jobs.length === 1 && isDeepStrictEqual(stored.jobs[0].payload, payload));
|
||||||
|
assert(payload.tenant_id === '11111111-1111-4111-8111-111111111111'
|
||||||
|
&& payload.agent_id === '63ea15b2-0643-403d-b5b4-cba1288dbea3'
|
||||||
|
&& payload.asset_id === 'a176520e-8a91-4e93-a78b-8e7620f430e0'
|
||||||
|
&& payload.execution_identity === 'agent_service' && isDeepStrictEqual(payload.action, action));
|
||||||
|
assert(stored.jobs[0].job_payload_hash === job.job_payload_hash
|
||||||
|
&& stored.jobs[0].script_sha256 === job.script_sha256
|
||||||
|
&& crypto.createHash('sha256').update(action.script_utf8, 'utf8').digest('hex') === job.script_sha256);
|
||||||
|
}
|
||||||
(async () => {
|
(async () => {
|
||||||
const file = path.resolve(process.argv[2]);
|
const file = path.resolve(process.argv[2]);
|
||||||
const stat = fs.lstatSync(file);
|
const stat = fs.lstatSync(file);
|
||||||
assert(stat.isFile() && !stat.isSymbolicLink() && stat.uid === process.getuid() && (stat.mode & 0o777) === 0o600);
|
assert(stat.isFile() && !stat.isSymbolicLink() && stat.uid === process.getuid() && (stat.mode & 0o777) === 0o600);
|
||||||
const expected = JSON.parse(fs.readFileSync(file, 'utf8'));
|
const expected = JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||||
assert(expected.profile === 'dev/test' && ['hello', 'refresh_inventory', 'cancel_queued'].includes(expected.case));
|
assert(expected.profile === 'dev/test' && ['hello', 'refresh_inventory', 'cancel_queued', 'windows_hello'].includes(expected.case));
|
||||||
assert(expected.expected_principal === 'simulated-testprincipal-a');
|
assert(expected.expected_principal === 'simulated-testprincipal-a');
|
||||||
const loginFile = path.join(root, 'credentials/server-browser-login.json');
|
const loginFile = path.join(root, 'credentials/server-browser-login.json');
|
||||||
const loginStat = fs.lstatSync(loginFile);
|
const loginStat = fs.lstatSync(loginFile);
|
||||||
@@ -38,7 +55,7 @@ const assert = (value) => { if (!value) throw new Error('UI contract mismatch');
|
|||||||
assert(pending.approval_state === 'pending_approval' && pending.job_count === 0 && pending.execution_state === null);
|
assert(pending.approval_state === 'pending_approval' && pending.job_count === 0 && pending.execution_state === null);
|
||||||
await op.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen', exact: true }).click();
|
await op.getByRole('button', { name: 'Unveränderlichen Plan zur Prüfung öffnen', exact: true }).click();
|
||||||
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
|
const detail = page.locator('section').filter({ has: page.getByRole('heading', { name: 'Unveränderlicher Plan / Genehmigungsdetail', exact: true }) });
|
||||||
const rendered = JSON.parse(await detail.locator('pre').first().innerText());
|
const rendered = JSON.parse(await detail.getByLabel('Alle festen Zielpreviews, exakte Skriptinhalte/Hashes, Parameter, Rechte, Fristen, Rollout und Nachbedingungen', { exact: true }).innerText());
|
||||||
assert(rendered.plan_hash === expected.plan.plan_hash && crypto.createHash('sha256').update(Buffer.from(rendered.plan_payload_bytes)).digest('hex') === expected.plan.plan_hash);
|
assert(rendered.plan_hash === expected.plan.plan_hash && crypto.createHash('sha256').update(Buffer.from(rendered.plan_payload_bytes)).digest('hex') === expected.plan.plan_hash);
|
||||||
assert(JSON.stringify(rendered.plan_payload_bytes) === JSON.stringify(expected.plan.plan_payload_bytes));
|
assert(JSON.stringify(rendered.plan_payload_bytes) === JSON.stringify(expected.plan.plan_payload_bytes));
|
||||||
assert(rendered.jobs.length === 1 && rendered.resolved_targets.length === 1);
|
assert(rendered.jobs.length === 1 && rendered.resolved_targets.length === 1);
|
||||||
@@ -47,7 +64,15 @@ const assert = (value) => { if (!value) throw new Error('UI contract mismatch');
|
|||||||
assert(payload.agent_id === expected.agent_id && payload.asset_id === expected.asset_id && payload.tenant_id === expected.tenant_id);
|
assert(payload.agent_id === expected.agent_id && payload.asset_id === expected.asset_id && payload.tenant_id === expected.tenant_id);
|
||||||
assert(payload.execution_identity === 'agent_service' && payload.max_runtime_seconds === 60 && payload.max_output_bytes <= 65536);
|
assert(payload.execution_identity === 'agent_service' && payload.max_runtime_seconds === 60 && payload.max_output_bytes <= 65536);
|
||||||
assert(Date.parse(payload.start_before) > Date.now());
|
assert(Date.parse(payload.start_before) > Date.now());
|
||||||
if (expected.case === 'hello' || expected.case === 'cancel_queued') assert(payload.action.action === 'run_script' && payload.action.interpreter === 'posix_sh' && payload.action.script_utf8 === "printf '%s\\n' 'Hello World'\n" && payload.action.expected_stdout === 'Hello World\n');
|
if (expected.case === 'windows_hello') {
|
||||||
|
checkWindowsHello(job, rendered.plan_payload_bytes);
|
||||||
|
assert(expected.stage === 'pending_approval' && expected.preapproval.jobs === 0
|
||||||
|
&& expected.preapproval.outbox === 0 && expected.preapproval.permits === 0);
|
||||||
|
assert(pending.plan_id === rendered.plan_id && pending.operation_id === expected.operation_id);
|
||||||
|
await detail.getByLabel('Feste PowerShell-Prozessprofile', { exact: true })
|
||||||
|
.getByText('Asset: ' + payload.asset_id + ' · Windows PowerShell5.1 · agent_service · RemoteSigned · nur Jobprozess', { exact: true }).waitFor();
|
||||||
|
}
|
||||||
|
else if (expected.case === 'hello' || expected.case === 'cancel_queued') assert(payload.action.action === 'run_script' && payload.action.interpreter === 'posix_sh' && payload.action.script_utf8 === "printf '%s\\n' 'Hello World'\n" && payload.action.expected_stdout === 'Hello World\n');
|
||||||
else assert(payload.action.action === 'refresh_inventory' && payload.action.scope === 'linux.base');
|
else assert(payload.action.action === 'refresh_inventory' && payload.action.scope === 'linux.base');
|
||||||
const approve = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
|
const approve = detail.getByRole('button', { name: 'SIMULIERT: Diesen festen Plan ausdrücklich genehmigen', exact: true });
|
||||||
assert(await approve.isDisabled());
|
assert(await approve.isDisabled());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Credentials stay on the cloud server; the browser reads its protected login
|
|||||||
file. All SQL is fixed read-only evidence, scoped to the one cloud VM.
|
file. All SQL is fixed read-only evidence, scoped to the one cloud VM.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
|
from datetime import timedelta
|
||||||
import hashlib
|
import hashlib
|
||||||
import http.client
|
import http.client
|
||||||
import json
|
import json
|
||||||
@@ -24,6 +25,38 @@ import vm_mvp_acceptance as contract
|
|||||||
ROOT = bootstrap.ROOT
|
ROOT = bootstrap.ROOT
|
||||||
TENANT = bootstrap.TENANT
|
TENANT = bootstrap.TENANT
|
||||||
require = bootstrap.require
|
require = bootstrap.require
|
||||||
|
WINDOWS_AGENT = '63ea15b2-0643-403d-b5b4-cba1288dbea3'
|
||||||
|
WINDOWS_ASSET = 'a176520e-8a91-4e93-a78b-8e7620f430e0'
|
||||||
|
WINDOWS_SCRIPT = "Write-Output 'Zeitprofil-Test'\r\n"
|
||||||
|
WINDOWS_STDOUT = 'Zeitprofil-Test\r\n'
|
||||||
|
|
||||||
|
|
||||||
|
def windows_hello_input():
|
||||||
|
start = contract.now()
|
||||||
|
return dict(
|
||||||
|
tenant_id=TENANT, action='run_script', targets=dict(asset_ids=[WINDOWS_ASSET]),
|
||||||
|
parameters=dict(
|
||||||
|
execution_identity='agent_service', timeout_seconds=60, max_output_bytes=65536,
|
||||||
|
arguments=[], expected_stdout=WINDOWS_STDOUT,
|
||||||
|
variants=[dict(os_family='windows', interpreter='powershell', encoding='utf-8',
|
||||||
|
script_utf8=WINDOWS_SCRIPT, windows_execution_profile='powershell_51_remote_signed')]),
|
||||||
|
schedule=contract.schedule(start, start + timedelta(minutes=15)),
|
||||||
|
rollout=dict(max_parallel=1, halt_after_failures=1),
|
||||||
|
reason='Erste genehmigte PowerShell-Textausgabe auf der Windows-Test-VM')
|
||||||
|
|
||||||
|
|
||||||
|
def verify_windows_hello(result):
|
||||||
|
report = result['result']
|
||||||
|
proof = report['evidence']
|
||||||
|
contract.require(result['state'] == 'succeeded' and report['exit_code'] == 0
|
||||||
|
and bytes(report['stdout']) == WINDOWS_STDOUT.encode() and bytes(report['stderr']) == b''
|
||||||
|
and report['output_truncated'] is False and proof['postconditions_passed'] is True
|
||||||
|
and proof['execution_sid'] == 'S-1-5-19' and proof['interpreter'] == 'powershell'
|
||||||
|
and proof['script_sha256'] == hashlib.sha256(WINDOWS_SCRIPT.encode()).hexdigest()
|
||||||
|
and proof['windows_execution_profile'] == 'powershell_51_remote_signed'
|
||||||
|
and proof['execution_policy'] == 'process_remote_signed_requested'
|
||||||
|
and proof['execution_policy_requested'] == 'RemoteSigned'
|
||||||
|
and proof['execution_policy_scope'] == 'process', 'windows_hello_evidence')
|
||||||
|
|
||||||
|
|
||||||
def prepare_browser():
|
def prepare_browser():
|
||||||
@@ -147,13 +180,18 @@ class Backend:
|
|||||||
def main():
|
def main():
|
||||||
parser=argparse.ArgumentParser(description=__doc__)
|
parser=argparse.ArgumentParser(description=__doc__)
|
||||||
parser.add_argument('--execute-dev-test-ui',action='store_true',required=True)
|
parser.add_argument('--execute-dev-test-ui',action='store_true',required=True)
|
||||||
parser.add_argument('--case',choices=('hello','refresh_inventory','cancel_queued'),default='hello')
|
parser.add_argument('--case',choices=('hello','refresh_inventory','cancel_queued','windows_hello'),default='hello')
|
||||||
parser.add_argument('--transport',choices=('wss','https'))
|
parser.add_argument('--transport',choices=('wss','https'))
|
||||||
args=parser.parse_args();os.umask(0o077)
|
args=parser.parse_args();os.umask(0o077)
|
||||||
contract.require(not (Path.home()/'.local/share/rust-discovery/remote-agent').exists(),'notebook_must_not_have_client')
|
contract.require(not (Path.home()/'.local/share/rust-discovery/remote-agent').exists(),'notebook_must_not_have_client')
|
||||||
prepare_browser()
|
windows = args.case == 'windows_hello'
|
||||||
installed=contract.protected_json(ROOT/'devstate/remote-vm.json')
|
if windows:
|
||||||
identity=installed['identity']
|
contract.require(args.transport is None, 'windows_keep_current_transport')
|
||||||
|
identity = dict(agent_id=WINDOWS_AGENT, asset_id=WINDOWS_ASSET)
|
||||||
|
else:
|
||||||
|
prepare_browser()
|
||||||
|
installed=contract.protected_json(ROOT/'devstate/remote-vm.json')
|
||||||
|
identity=installed['identity']
|
||||||
settings=dict(tenant_id=TENANT,**identity)
|
settings=dict(tenant_id=TENANT,**identity)
|
||||||
def evidence(kind,**extra):
|
def evidence(kind,**extra):
|
||||||
return bootstrap.rpc('server.conf',server,dict(kind=kind,tenant_id=TENANT,agent_id=identity['agent_id'],**extra))
|
return bootstrap.rpc('server.conf',server,dict(kind=kind,tenant_id=TENANT,agent_id=identity['agent_id'],**extra))
|
||||||
@@ -172,11 +210,18 @@ def main():
|
|||||||
observed=bootstrap.rpc('server.conf',bootstrap.server,dict(action='observe',agent_id=identity['agent_id']))
|
observed=bootstrap.rpc('server.conf',bootstrap.server,dict(action='observe',agent_id=identity['agent_id']))
|
||||||
contract.require(observed['sync_ready'] and not observed['restore_blocked'],'signed_sync_gate_required')
|
contract.require(observed['sync_ready'] and not observed['restore_blocked'],'signed_sync_gate_required')
|
||||||
needed={'refresh_inventory' if args.case=='refresh_inventory' else 'run_script','rmm.sync.v1'}
|
needed={'refresh_inventory' if args.case=='refresh_inventory' else 'run_script','rmm.sync.v1'}
|
||||||
|
if windows:
|
||||||
|
needed.update(('windows.base/1', 'script.powershell/1', 'script.powershell.process_remote_signed/1'))
|
||||||
contract.require(needed<=set(device['capabilities']),'actual_vm_capability_required')
|
contract.require(needed<=set(device['capabilities']),'actual_vm_capability_required')
|
||||||
request=contract.case_input(args.case,settings)
|
if windows:
|
||||||
|
prepare_browser()
|
||||||
|
request=windows_hello_input() if windows else contract.case_input(args.case,settings)
|
||||||
plan=backend.call('operations.plan',dict(tenant_id=TENANT,input=request))
|
plan=backend.call('operations.plan',dict(tenant_id=TENANT,input=request))
|
||||||
contract.require(hashlib.sha256(bytes(plan['plan_payload_bytes'])).hexdigest()==plan['plan_hash'] and len(plan['jobs'])==1,'immutable_plan')
|
contract.require(hashlib.sha256(bytes(plan['plan_payload_bytes'])).hexdigest()==plan['plan_hash'] and len(plan['jobs'])==1,'immutable_plan')
|
||||||
job=plan['jobs'][0]
|
job=plan['jobs'][0]
|
||||||
|
if windows:
|
||||||
|
contract.require(job['payload']['agent_id']==WINDOWS_AGENT and job['payload']['asset_id']==WINDOWS_ASSET
|
||||||
|
and job['payload']['tenant_id']==TENANT, 'fixed_windows_target_required')
|
||||||
folder=ROOT/'devstate/cloud-acceptance'/uuid.uuid4().hex;folder.mkdir(mode=0o700,parents=True)
|
folder=ROOT/'devstate/cloud-acceptance'/uuid.uuid4().hex;folder.mkdir(mode=0o700,parents=True)
|
||||||
checkpoint=dict(profile='dev/test',case=args.case,expected_principal='simulated-testprincipal-a',**settings,
|
checkpoint=dict(profile='dev/test',case=args.case,expected_principal='simulated-testprincipal-a',**settings,
|
||||||
plan=plan,job=job,stage='planned',no_retry=True,transport=observed['transport'],server_connection=observed)
|
plan=plan,job=job,stage='planned',no_retry=True,transport=observed['transport'],server_connection=observed)
|
||||||
@@ -205,6 +250,8 @@ def main():
|
|||||||
contract.require(result['state']=='succeeded' and result['result']['evidence']['postconditions_passed'],'native_postconditions_required')
|
contract.require(result['state']=='succeeded' and result['result']['evidence']['postconditions_passed'],'native_postconditions_required')
|
||||||
if args.case=='hello':
|
if args.case=='hello':
|
||||||
contract.require(result['result']['exit_code']==0 and bytes(result['result']['stdout'])==b'Hello World\n','exact_stdout_required')
|
contract.require(result['result']['exit_code']==0 and bytes(result['result']['stdout'])==b'Hello World\n','exact_stdout_required')
|
||||||
|
elif windows:
|
||||||
|
verify_windows_hello(result)
|
||||||
elif args.case=='refresh_inventory':
|
elif args.case=='refresh_inventory':
|
||||||
contract.require(contract.timestamp(result['result']['evidence']['observed_at'])>=contract.timestamp(request['schedule']['not_before']),'fresh_inventory_required')
|
contract.require(contract.timestamp(result['result']['evidence']['observed_at'])>=contract.timestamp(request['schedule']['not_before']),'fresh_inventory_required')
|
||||||
gate=evidence('gate',job_id=job['job_id']);audit=evidence('audit',operation_id=pending['operation_id'])
|
gate=evidence('gate',job_id=job['job_id']);audit=evidence('audit',operation_id=pending['operation_id'])
|
||||||
|
|||||||
@@ -0,0 +1,428 @@
|
|||||||
|
#requires -Version 5.1
|
||||||
|
#requires -RunAsAdministrator
|
||||||
|
# Finish the single, console-verified public-file publication on the test VM.
|
||||||
|
# Run in a fresh Windows PowerShell process. No SSH or RMM job is involved.
|
||||||
|
[CmdletBinding()]
|
||||||
|
param([switch]$InitialCreate, [switch]$ResumeEmpty)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
if ($InitialCreate -and $ResumeEmpty) { throw 'Choose one publication operation' }
|
||||||
|
$caseId = 'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'
|
||||||
|
$controllerHash = 'd8b4fd4fd9ca5310cc1591ce3c2ccae5bd72a2ade43b21a8187cfdfb960b3427'
|
||||||
|
$configHash = '2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b'
|
||||||
|
$bootstrap = 'C:\ProgramData\RustDiscoveryBootstrap'
|
||||||
|
$casePath = Join-Path $bootstrap "time-profile-$caseId"
|
||||||
|
$original = Join-Path (Join-Path $bootstrap $controllerHash) 'InstallPublicTimeProfile.ps1'
|
||||||
|
$originalBytes = [IO.File]::ReadAllBytes($original)
|
||||||
|
$sha = [Security.Cryptography.SHA256]::Create()
|
||||||
|
try {
|
||||||
|
$digest = [BitConverter]::ToString($sha.ComputeHash($originalBytes)).Replace('-', '')
|
||||||
|
} finally { $sha.Dispose() }
|
||||||
|
if ($digest -ne $controllerHash) { throw 'Unexpected original controller' }
|
||||||
|
|
||||||
|
# Import the verified definitions (including native FileID/SCM checks) from the
|
||||||
|
# installed original. Its first top-level preflight and install body are excluded.
|
||||||
|
$source = [Text.Encoding]::UTF8.GetString($originalBytes)
|
||||||
|
$boundary = "`nCheckControl `$boot `$true`n"
|
||||||
|
$index = $source.IndexOf($boundary, [StringComparison]::Ordinal)
|
||||||
|
if ($index -lt 1 -or $index -ne $source.LastIndexOf($boundary, [StringComparison]::Ordinal)) {
|
||||||
|
throw 'Original controller definition boundary missing'
|
||||||
|
}
|
||||||
|
$intent = Get-Content -LiteralPath (Join-Path $casePath 'intent.json') -Raw | ConvertFrom-Json
|
||||||
|
if ($intent.id -cne $caseId -or $intent.request.id -cne $caseId -or
|
||||||
|
$intent.request.script_sha256 -cne $controllerHash -or $intent.request.config_sha256 -cne $configHash) {
|
||||||
|
throw 'Unexpected original intent'
|
||||||
|
}
|
||||||
|
$global:RmmTimeProfilePayload = $intent.request
|
||||||
|
. ([scriptblock]::Create($source.Substring(0, $index)))
|
||||||
|
|
||||||
|
CheckControl $boot $true
|
||||||
|
CheckControl $folder $true
|
||||||
|
foreach ($leaf in 'intent.json','publish-intent.json','directory-acl-intent.json','directory-acl-done.json') {
|
||||||
|
CheckControl (Join-Path $folder $leaf) $false
|
||||||
|
}
|
||||||
|
CheckControl $active $false
|
||||||
|
$activeRecord = Get-Content -LiteralPath $active -Raw | ConvertFrom-Json
|
||||||
|
if ($activeRecord.id -cne $caseId -or $activeRecord.script_sha256 -cne $controllerHash -or
|
||||||
|
$activeRecord.config_sha256 -cne $configHash -or $activeRecord.no_retry -ne $true) {
|
||||||
|
throw 'Unexpected active publication record'
|
||||||
|
}
|
||||||
|
$bytes = ConfigBytes
|
||||||
|
$publish = Get-Content -LiteralPath (Join-Path $folder 'publish-intent.json') -Raw | ConvertFrom-Json
|
||||||
|
$aclDone = Get-Content -LiteralPath (Join-Path $folder 'directory-acl-done.json') -Raw | ConvertFrom-Json
|
||||||
|
$staged = Join-Path $folder 'time-attestation.candidate.json'
|
||||||
|
$resultPath = Join-Path $folder 'result.json'
|
||||||
|
$reservation = Join-Path $folder 'console-finalization-intent.json'
|
||||||
|
$initialReservation = Join-Path $folder 'console-initial-create-intent.json'
|
||||||
|
$initialResult = Join-Path $folder 'console-initial-create-result.json'
|
||||||
|
$initialError = Join-Path $folder 'console-initial-create-error.json'
|
||||||
|
$initialVerified = Join-Path $folder 'console-initial-create-verified.json'
|
||||||
|
$resumeReservation = Join-Path $folder 'console-resume-empty-intent.json'
|
||||||
|
$resumeVerified = Join-Path $folder 'console-resume-empty-verified.json'
|
||||||
|
$resumeResult = Join-Path $folder 'console-resume-empty-result.json'
|
||||||
|
$resumeError = Join-Path $folder 'console-resume-empty-error.json'
|
||||||
|
$absent = @($resultPath,$initialVerified,$initialResult,$resumeReservation,$resumeVerified,$resumeResult,$resumeError)
|
||||||
|
if (!$ResumeEmpty) { $absent += @($target,$initialReservation,$initialError) }
|
||||||
|
if ($InitialCreate -or $ResumeEmpty) {
|
||||||
|
$priorError = Join-Path $folder 'console-finalization-error.json'
|
||||||
|
CheckControl $reservation $false
|
||||||
|
CheckControl $priorError $false
|
||||||
|
$priorReservation = Get-Content -LiteralPath $reservation -Raw | ConvertFrom-Json
|
||||||
|
$priorFailure = Get-Content -LiteralPath $priorError -Raw | ConvertFrom-Json
|
||||||
|
if ($priorReservation.id -cne $caseId -or $priorReservation.config_sha256 -cne $configHash -or
|
||||||
|
$priorFailure.id -cne $caseId -or $priorFailure.phase -cne 'File.Move' -or
|
||||||
|
$priorFailure.hresult -cne '0x80070020' -or $priorFailure.exception -cne 'System.IO.IOException') {
|
||||||
|
throw 'Expected the recorded sharing violation from the original single finalization attempt'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$absent += $reservation
|
||||||
|
}
|
||||||
|
foreach ($path in $absent) {
|
||||||
|
if (Test-Path -LiteralPath $path) { throw 'Existing target or finalization record: read original case' }
|
||||||
|
}
|
||||||
|
$stagedAcl = ReadAcl $staged $false
|
||||||
|
$rootAcl = ReadAcl $helperRoot $true
|
||||||
|
$expected = @{
|
||||||
|
volume_serial = '9815088561147542064'
|
||||||
|
file_id = '6d990300000003000000000000000000'
|
||||||
|
bytes = 1177
|
||||||
|
acl_sha256 = '3a426f649cd6ff4e82bf70205c8ecc7d5b2c0775fa1e10fc30ce35de9bb12493'
|
||||||
|
sha256 = $configHash
|
||||||
|
}
|
||||||
|
if ($publish.create_once -ne $true -or $publish.config_sha256 -cne $configHash -or
|
||||||
|
!(JsonEqual $expected $publish.staged) -or !(JsonEqual $expected (FileIdentity $staged)) -or
|
||||||
|
(FileVolume $helperRoot) -cne $expected.volume_serial -or $rootAcl.Sddl -cne $aclDone.sddl -or
|
||||||
|
(AclHash $helperRoot) -cne '186d85132cf0e16cbb9623ad9636b7777741939a8cae3d689a2af1eb267a7f49') {
|
||||||
|
throw 'Original file identity or permissions changed'
|
||||||
|
}
|
||||||
|
if ($ResumeEmpty) {
|
||||||
|
CheckControl $initialReservation $false
|
||||||
|
CheckControl $initialError $false
|
||||||
|
$creation = Get-Content -LiteralPath $initialReservation -Raw | ConvertFrom-Json
|
||||||
|
$failure = Get-Content -LiteralPath $initialError -Raw | ConvertFrom-Json
|
||||||
|
if ($creation.id -cne $caseId -or $creation.config_sha256 -cne $configHash -or
|
||||||
|
$creation.create_new -isnot [bool] -or !$creation.create_new -or !$creation.utc -or
|
||||||
|
!(JsonEqual $expected $creation.staged) -or $failure.id -cne $caseId -or
|
||||||
|
$failure.phase -cne 'verify_creation' -or $failure.hresult -cne '0x80131501' -or
|
||||||
|
$failure.exception -cne 'System.Management.Automation.RuntimeException') {
|
||||||
|
throw 'Unexpected initial creation intent or failure'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($p.probe_sha256 -cne '727732fb4b38ac5431a330527bd52a3ab80af8f189ae75a7b48eceb1d4b69cac' -or
|
||||||
|
$p.system_probe_sha256 -cne '77a344912c61b7ac4a92152ae1b534ca7c36fe6f7dc4675783f20558c3a7f434') {
|
||||||
|
throw 'Unexpected native status probes'
|
||||||
|
}
|
||||||
|
$before = ActualState $true
|
||||||
|
SameLive $request.expected_native $before
|
||||||
|
SameLive $intent.before $before
|
||||||
|
if ($before.agent_kernel.creation_filetime -cne '134392294174782153' -or
|
||||||
|
$before.helper_kernel.creation_filetime -cne '134392294130218261') { throw 'Service generation changed' }
|
||||||
|
|
||||||
|
# FileStandardInfo supplies the hard-link count and directory/delete-pending state
|
||||||
|
# from the same exclusive handle used to write, flush, hash and publish the DACL.
|
||||||
|
function Initialize-InitialProfileNative {
|
||||||
|
Add-Type -TypeDefinition @'
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Microsoft.Win32.SafeHandles;
|
||||||
|
|
||||||
|
public static class RmmInitialProfileFile {
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct StandardInfo {
|
||||||
|
public long AllocationSize, EndOfFile;
|
||||||
|
public uint NumberOfLinks;
|
||||||
|
public byte DeletePending, Directory;
|
||||||
|
}
|
||||||
|
[DllImport("kernel32.dll", SetLastError=true)]
|
||||||
|
private static extern bool GetFileInformationByHandleEx(
|
||||||
|
SafeFileHandle handle, int infoClass, out StandardInfo info, uint size);
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct TagInfo { public uint Attributes, ReparseTag; }
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError=true)]
|
||||||
|
private static extern bool GetFileInformationByHandleEx(
|
||||||
|
SafeFileHandle handle, int infoClass, out TagInfo info, uint size);
|
||||||
|
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, ExactSpelling=true, SetLastError=true)]
|
||||||
|
private static extern SafeFileHandle CreateFileW(string path, uint access, uint sharing,
|
||||||
|
IntPtr security, uint disposition, uint flags, IntPtr template);
|
||||||
|
|
||||||
|
private static void CheckAttributes(SafeFileHandle handle, bool directory) {
|
||||||
|
TagInfo info;
|
||||||
|
if (!GetFileInformationByHandleEx(handle, 9, out info, (uint)Marshal.SizeOf(typeof(TagInfo))))
|
||||||
|
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||||
|
if ((info.Attributes & (uint)FileAttributes.ReparsePoint) != 0 ||
|
||||||
|
((info.Attributes & (uint)FileAttributes.Directory) != 0) != directory)
|
||||||
|
throw new InvalidOperationException("Unexpected file type or reparse point");
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct UnicodeString { public ushort Length, MaximumLength; public IntPtr Buffer; }
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct ObjectAttributes {
|
||||||
|
public int Length;
|
||||||
|
public IntPtr RootDirectory, ObjectName;
|
||||||
|
public uint Attributes;
|
||||||
|
public IntPtr SecurityDescriptor, SecurityQoS;
|
||||||
|
}
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct IoStatus { public IntPtr Status, Information; }
|
||||||
|
[DllImport("ntdll.dll")]
|
||||||
|
private static extern int NtOpenFile(out SafeFileHandle file, uint access, ref ObjectAttributes attributes,
|
||||||
|
out IoStatus io, uint share, uint options);
|
||||||
|
[DllImport("ntdll.dll")]
|
||||||
|
private static extern uint RtlNtStatusToDosError(int status);
|
||||||
|
|
||||||
|
// Open-only, relative to the held volume root. OBJ_DONT_REPARSE applies to
|
||||||
|
// the complete relative path, including ProgramData and the helper directory.
|
||||||
|
public static FileStream OpenExistingTarget() {
|
||||||
|
const string relativePath = @"ProgramData\RustDiscoverySystem\time-attestation.json";
|
||||||
|
const uint backupSemanticsNoFollow = 0x02200000;
|
||||||
|
using (SafeFileHandle root = CreateFileW(@"C:\", 0xA0, 7, IntPtr.Zero, 3,
|
||||||
|
backupSemanticsNoFollow, IntPtr.Zero)) {
|
||||||
|
if (root.IsInvalid) throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||||
|
CheckAttributes(root, true);
|
||||||
|
UnicodeString name = new UnicodeString();
|
||||||
|
name.Length = checked((ushort)(relativePath.Length * sizeof(char)));
|
||||||
|
name.MaximumLength = name.Length;
|
||||||
|
name.Buffer = Marshal.StringToHGlobalUni(relativePath);
|
||||||
|
IntPtr nativeName = IntPtr.Zero;
|
||||||
|
try {
|
||||||
|
nativeName = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(UnicodeString)));
|
||||||
|
Marshal.StructureToPtr(name, nativeName, false);
|
||||||
|
ObjectAttributes attributes = new ObjectAttributes();
|
||||||
|
attributes.Length = Marshal.SizeOf(typeof(ObjectAttributes));
|
||||||
|
attributes.RootDirectory = root.DangerousGetHandle();
|
||||||
|
attributes.ObjectName = nativeName;
|
||||||
|
attributes.Attributes = 0x1040; // OBJ_DONT_REPARSE | OBJ_CASE_INSENSITIVE
|
||||||
|
const uint readWriteAcl = 0x00160083; // synchronize, WRITE_DAC, READ_CONTROL, attributes and data
|
||||||
|
const uint options = 0x62; // FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_WRITE_THROUGH
|
||||||
|
IoStatus io;
|
||||||
|
SafeFileHandle h;
|
||||||
|
int status = NtOpenFile(out h, readWriteAcl, ref attributes, out io, 0, options);
|
||||||
|
if (status != 0) throw new Win32Exception((int)RtlNtStatusToDosError(status));
|
||||||
|
try {
|
||||||
|
CheckSingleFile(h, 0);
|
||||||
|
return new FileStream(h, FileAccess.ReadWrite);
|
||||||
|
} catch { h.Dispose(); throw; }
|
||||||
|
} finally {
|
||||||
|
Marshal.FreeHGlobal(nativeName);
|
||||||
|
Marshal.FreeHGlobal(name.Buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void CheckSingleFile(SafeFileHandle handle, long expectedLength) {
|
||||||
|
CheckAttributes(handle, false);
|
||||||
|
StandardInfo info;
|
||||||
|
if (!GetFileInformationByHandleEx(handle, 1, out info, (uint)Marshal.SizeOf(typeof(StandardInfo))))
|
||||||
|
throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||||
|
if (info.NumberOfLinks != 1 || info.DeletePending != 0 || info.Directory != 0 ||
|
||||||
|
info.EndOfFile != expectedLength)
|
||||||
|
throw new InvalidOperationException("Expected one regular file of the exact size");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'@
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-HeldProfileFileId([IO.FileStream]$Stream) {
|
||||||
|
$id = New-Object RmmPipeNative+FileId
|
||||||
|
if (![RmmPipeNative]::GetFileInformationByHandleEx($Stream.SafeFileHandle, 18, [ref]$id, 24)) {
|
||||||
|
throw 'New file identity unavailable'
|
||||||
|
}
|
||||||
|
return @{
|
||||||
|
volume_serial=$id.Volume.ToString([Globalization.CultureInfo]::InvariantCulture)
|
||||||
|
file_id=([BitConverter]::ToString($id.Id)).Replace('-','').ToLowerInvariant()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-HeldProfileIdentity([IO.FileStream]$Stream) {
|
||||||
|
[RmmInitialProfileFile]::CheckSingleFile($Stream.SafeFileHandle, 1177)
|
||||||
|
$identity = Get-HeldProfileFileId $Stream
|
||||||
|
$Stream.Position = 0
|
||||||
|
$algorithm = [Security.Cryptography.SHA256]::Create()
|
||||||
|
try { $digest = [BitConverter]::ToString($algorithm.ComputeHash($Stream)).Replace('-','').ToLowerInvariant() }
|
||||||
|
finally { $algorithm.Dispose() }
|
||||||
|
$sddl = $Stream.GetAccessControl().GetSecurityDescriptorSddlForm($aclSections)
|
||||||
|
$identity.bytes = $Stream.Length
|
||||||
|
$identity.sha256 = $digest
|
||||||
|
$identity.acl_sha256 = BytesHash ([Text.Encoding]::UTF8.GetBytes($sddl))
|
||||||
|
return $identity
|
||||||
|
}
|
||||||
|
|
||||||
|
# Both accepted strings retain the protected DACL, owner, group and all ACEs.
|
||||||
|
# Windows stored the newly created file without the auto-inherited marker.
|
||||||
|
function Test-ProfileDescriptor([string]$ExpectedSddl, [string]$ActualSddl) {
|
||||||
|
if (!$ExpectedSddl.StartsWith('O:BAG:BAD:PAI(', [StringComparison]::Ordinal)) { return $false }
|
||||||
|
return $ActualSddl -ceq $ExpectedSddl -or $ActualSddl -ceq $ExpectedSddl.Replace('D:PAI(', 'D:P(')
|
||||||
|
}
|
||||||
|
|
||||||
|
function New-OriginalPublicProfile {
|
||||||
|
Initialize-InitialProfileNative
|
||||||
|
$aclSections = [Security.AccessControl.AccessControlSections]'Owner,Group,Access'
|
||||||
|
$accessOnly = [Security.AccessControl.AccessControlSections]::Access
|
||||||
|
$draftAcl = [Security.AccessControl.FileSecurity]::new()
|
||||||
|
$draftAcl.SetSecurityDescriptorSddlForm($stagedAcl.Sddl, $aclSections)
|
||||||
|
foreach ($sid in @($agentSid,$helperSid)) {
|
||||||
|
$deny = [Security.AccessControl.FileSystemAccessRule]::new(
|
||||||
|
[Security.Principal.SecurityIdentifier]::new($sid),
|
||||||
|
[Security.AccessControl.FileSystemRights]::ReadData, [Security.AccessControl.AccessControlType]::Deny)
|
||||||
|
$draftAcl.AddAccessRule($deny)
|
||||||
|
}
|
||||||
|
$draftSddl = $draftAcl.GetSecurityDescriptorSddlForm($aclSections)
|
||||||
|
if (!$draftAcl.AreAccessRulesProtected -or $draftSddl -ceq $stagedAcl.Sddl) { throw 'Initial protected DACL required' }
|
||||||
|
|
||||||
|
if ((BytesHash ([Text.Encoding]::UTF8.GetBytes($draftSddl))) -cne
|
||||||
|
'd4726c7973c9b0cd8a66c1b129d1b5eb58d2bbfc1b103018e0a31a71fb1d9020') {
|
||||||
|
throw 'Unexpected draft descriptor for this case'
|
||||||
|
}
|
||||||
|
$reserved = $false
|
||||||
|
$phase = 'CreateNew'
|
||||||
|
$descriptorFailure = $null
|
||||||
|
if ($ResumeEmpty) {
|
||||||
|
$attemptResult = $resumeResult
|
||||||
|
$attemptError = $resumeError
|
||||||
|
$attemptVerified = $resumeVerified
|
||||||
|
} else {
|
||||||
|
$attemptResult = $initialResult
|
||||||
|
$attemptError = $initialError
|
||||||
|
$attemptVerified = $initialVerified
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if ($ResumeEmpty) {
|
||||||
|
$phase = 'open_existing_empty'
|
||||||
|
$stream = [RmmInitialProfileFile]::OpenExistingTarget()
|
||||||
|
} else {
|
||||||
|
$since = [DateTime]::UtcNow.ToString('o')
|
||||||
|
WriteNew $initialReservation @{id=$caseId; config_sha256=$configHash; utc=$since; staged=$expected; create_new=$true}
|
||||||
|
$reserved = $true
|
||||||
|
$rights = [Security.AccessControl.FileSystemRights]'ReadData,WriteData,ReadAttributes,ReadPermissions,ChangePermissions,Synchronize'
|
||||||
|
$stream = [IO.FileStream]::new($target, [IO.FileMode]::CreateNew,
|
||||||
|
$rights, [IO.FileShare]::None, 4096,
|
||||||
|
[IO.FileOptions]::WriteThrough, $draftAcl)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$phase = 'verify_creation'
|
||||||
|
$actualSddl = $stream.GetAccessControl().GetSecurityDescriptorSddlForm($aclSections)
|
||||||
|
if (!(Test-ProfileDescriptor $draftSddl $actualSddl)) {
|
||||||
|
$descriptorFailure = @{expected_sddl=$draftSddl; actual_sddl=$actualSddl; bytes=$null}
|
||||||
|
try {
|
||||||
|
$descriptorFailure.bytes = $stream.Length
|
||||||
|
$fileId = Get-HeldProfileFileId $stream
|
||||||
|
$descriptorFailure.file_id = $fileId.file_id
|
||||||
|
$descriptorFailure.volume_serial = $fileId.volume_serial
|
||||||
|
} catch {
|
||||||
|
$descriptorFailure.metadata_hresult = '0x{0:X8}' -f $_.Exception.GetBaseException().HResult
|
||||||
|
}
|
||||||
|
throw 'Unexpected security descriptor on new file'
|
||||||
|
}
|
||||||
|
[RmmInitialProfileFile]::CheckSingleFile($stream.SafeFileHandle, 0)
|
||||||
|
$emptyId = Get-HeldProfileFileId $stream
|
||||||
|
if ($emptyId.volume_serial -cne $expected.volume_serial -or
|
||||||
|
$emptyId.file_id -ceq $expected.file_id -or $emptyId.file_id -ceq ('0' * 32)) {
|
||||||
|
throw 'Unexpected volume or identity on held empty target'
|
||||||
|
}
|
||||||
|
$draftHash = BytesHash ([Text.Encoding]::UTF8.GetBytes($actualSddl))
|
||||||
|
if ($ResumeEmpty) {
|
||||||
|
$since = [DateTime]::UtcNow.ToString('o')
|
||||||
|
WriteNew $resumeReservation @{
|
||||||
|
id=$caseId; utc=$since; config_sha256=$configHash; target_id=$emptyId.file_id
|
||||||
|
volume_serial=$emptyId.volume_serial; draft_acl_sha256=$draftHash; bytes=0
|
||||||
|
}
|
||||||
|
$reserved = $true
|
||||||
|
}
|
||||||
|
$phase = 'write_verify'
|
||||||
|
$stream.Write($bytes, 0, $bytes.Length)
|
||||||
|
$stream.Flush($true)
|
||||||
|
$new = Get-HeldProfileIdentity $stream
|
||||||
|
if ($new.volume_serial -cne $expected.volume_serial -or $new.file_id -ceq $expected.file_id -or
|
||||||
|
$new.file_id -cne $emptyId.file_id -or $new.sha256 -cne $configHash -or
|
||||||
|
$new.acl_sha256 -cne $draftHash) {
|
||||||
|
throw 'New held bytes, identity or staging permissions differ'
|
||||||
|
}
|
||||||
|
SameLive $before (ActualState $true)
|
||||||
|
$null = Kernel 'agent' $before.service $heldAgent
|
||||||
|
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||||
|
if (!(JsonEqual $expected (FileIdentity $staged)) -or (AclHash $helperRoot) -cne $rootAclHash) {
|
||||||
|
throw 'Original source or target directory changed before publication'
|
||||||
|
}
|
||||||
|
WriteNew $attemptVerified @{
|
||||||
|
id=$caseId; utc=$since; original_candidate=$expected; held_target=$new
|
||||||
|
}
|
||||||
|
# Change only the DACL by handle after the verified bytes and FileID
|
||||||
|
# are durable. A crash before this point leaves service reads denied.
|
||||||
|
$phase = 'publish_dacl'
|
||||||
|
$final = $stream.GetAccessControl()
|
||||||
|
$final.SetSecurityDescriptorSddlForm($stagedAcl.Sddl, $accessOnly)
|
||||||
|
$stream.SetAccessControl($final)
|
||||||
|
$stream.Flush($true)
|
||||||
|
$actualFinal = $stream.GetAccessControl().GetSecurityDescriptorSddlForm($aclSections)
|
||||||
|
if (!(Test-ProfileDescriptor $stagedAcl.Sddl $actualFinal)) { throw 'Unexpected final descriptor' }
|
||||||
|
$new.acl_sha256 = BytesHash ([Text.Encoding]::UTF8.GetBytes($actualFinal))
|
||||||
|
if (!(JsonEqual $new (Get-HeldProfileIdentity $stream))) { throw 'Held publication readback failed' }
|
||||||
|
} finally { $stream.Dispose() }
|
||||||
|
|
||||||
|
$phase = 'readback'
|
||||||
|
$null = ReadAcl $target $false
|
||||||
|
$published = FileIdentity $target
|
||||||
|
if (!(JsonEqual $new $published) -or !(JsonEqual $expected (FileIdentity $staged)) -or
|
||||||
|
(AclHash $helperRoot) -cne $rootAclHash) { throw 'Final source/target binding failed' }
|
||||||
|
$after = ActualState $true
|
||||||
|
SameLive $before $after
|
||||||
|
$null = Kernel 'agent' $before.service $heldAgent
|
||||||
|
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||||
|
$outcome = @{
|
||||||
|
id=$caseId; installed=$true; publication_since=$since; configuration=$published
|
||||||
|
original_candidate=$expected; source_candidate_preserved=$true; initial_create=$true
|
||||||
|
native=$after; clock_runtime_qualified=$false; services_changed=$false; private_key_read=$false
|
||||||
|
no_jobs=$true; original_move_failed=$true
|
||||||
|
}
|
||||||
|
if ($ResumeEmpty) { $outcome.resumed_empty = $true }
|
||||||
|
WriteNew $attemptResult $outcome
|
||||||
|
} catch {
|
||||||
|
$cause = $_.Exception.GetBaseException()
|
||||||
|
$failure = @{id=$caseId; phase=$phase; hresult=('0x{0:X8}' -f $cause.HResult); exception=$cause.GetType().FullName}
|
||||||
|
if ($null -ne $descriptorFailure) { $failure.creation_descriptor = $descriptorFailure }
|
||||||
|
if ($reserved) { WriteNew $attemptError $failure }
|
||||||
|
throw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$heldAgent = [RmmPipeNative]::Open([int]$before.service.pid)
|
||||||
|
try {
|
||||||
|
$heldHelper = [RmmPipeNative]::Open([int]$before.helper_service.pid)
|
||||||
|
try {
|
||||||
|
$null = Kernel 'agent' $before.service $heldAgent
|
||||||
|
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||||
|
if ($InitialCreate -or $ResumeEmpty) {
|
||||||
|
$rootAclHash = '186d85132cf0e16cbb9623ad9636b7777741939a8cae3d689a2af1eb267a7f49'
|
||||||
|
New-OriginalPublicProfile
|
||||||
|
'Zeitprofil am gebundenen Dateihandle veroeffentlicht und nachgelesen.'
|
||||||
|
return
|
||||||
|
}
|
||||||
|
# WriteNew uses CreateNew. Concurrent or later invocations cannot republish.
|
||||||
|
WriteNew $reservation @{id=$caseId; config_sha256=$configHash; utc=[DateTime]::UtcNow.ToString('o')}
|
||||||
|
try {
|
||||||
|
[IO.File]::Move($staged, $target)
|
||||||
|
} catch {
|
||||||
|
$cause = $_.Exception.GetBaseException()
|
||||||
|
$failure = @{id=$caseId; phase='File.Move'; hresult=('0x{0:X8}' -f $cause.HResult); exception=$cause.GetType().FullName}
|
||||||
|
WriteNew (Join-Path $folder 'console-finalization-error.json') $failure
|
||||||
|
throw ("File.Move: {0} ({1})." -f $failure.exception, $failure.hresult)
|
||||||
|
}
|
||||||
|
$null = ReadAcl $target $false
|
||||||
|
$published = FileIdentity $target
|
||||||
|
if (!(JsonEqual $expected $published) -or (Test-Path -LiteralPath $staged)) { throw 'Publication postcheck failed' }
|
||||||
|
$after = ActualState $true
|
||||||
|
SameLive $before $after
|
||||||
|
$null = Kernel 'agent' $before.service $heldAgent
|
||||||
|
$null = Kernel 'helper' $before.helper_service $heldHelper
|
||||||
|
WriteNew $resultPath @{
|
||||||
|
id=$caseId; installed=$true; install_not_before=$intent.install_not_before
|
||||||
|
configuration=$published; native=$after; original_root_sddl=$intent.original_root_sddl
|
||||||
|
root_sddl=(Get-Acl -LiteralPath $helperRoot).Sddl; no_jobs=$true
|
||||||
|
clock_runtime_qualified=$false; services_changed=$false; private_key_read=$false
|
||||||
|
console_finalized=$true; original_move_failed=$true
|
||||||
|
}
|
||||||
|
'Zeitprofil veroeffentlicht; Dateiidentitaet und Dienstgenerationen geprueft.'
|
||||||
|
} finally { $heldHelper.Dispose() }
|
||||||
|
} finally { $heldAgent.Dispose() }
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
#requires -Version 5.1
|
||||||
|
#requires -RunAsAdministrator
|
||||||
|
# The relay receives a fixed public receipt. There is no command reader.
|
||||||
|
param([Parameter(Mandatory)][DateTimeOffset]$Until, [switch]$ResumeEmpty)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$deadline = [DateTimeOffset]::UtcNow.AddMinutes(12)
|
||||||
|
if ($deadline -gt $until) { $deadline = $until }
|
||||||
|
if ($deadline -le [DateTimeOffset]::UtcNow) { throw 'Das Wartungsfenster ist abgelaufen.' }
|
||||||
|
|
||||||
|
$base = 'https://gitea.incoso.eu/kevin_janssen/rust-discovery/raw/commit/b614b6f5be9d700eef20586a038aa9643356049a/deploy/windows'
|
||||||
|
$bootstrap = 'C:\ProgramData\RustDiscoveryBootstrap'
|
||||||
|
$caseId = 'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'
|
||||||
|
$case = Join-Path $bootstrap "time-profile-$caseId"
|
||||||
|
$access = 'C:\ProgramData\RmmDevAccess'
|
||||||
|
$sshBin = Join-Path $env:WINDIR 'System32\OpenSSH'
|
||||||
|
$known = Join-Path $access 'known_hosts'
|
||||||
|
$key = Join-Path $access 'tunnel_ed25519'
|
||||||
|
$fp = & "$sshBin\ssh-keygen.exe" -lf $known
|
||||||
|
if ($LASTEXITCODE -ne 0 -or @($fp).Count -ne 1 -or
|
||||||
|
$fp.Split(' ')[1] -cne 'SHA256:+NEin4XJc3CbhjQi7/ZpMIgxOrXn8AT2tlpTaXW5quw') { throw 'Server-Hostpin stimmt nicht.' }
|
||||||
|
$session = [guid]::NewGuid().ToString()
|
||||||
|
$work = Join-Path $bootstrap "time-receipt-$session"
|
||||||
|
$null = New-Item -ItemType Directory -Path $work
|
||||||
|
$listener = $null
|
||||||
|
$ssh = $null
|
||||||
|
$scripts = [ordered]@{
|
||||||
|
'Complete-OriginalTimeProfile.ps1' = 'aacc56321dccc6efe496a782d4cf67defba5b0be6759cba08d9e0b775913210b'
|
||||||
|
'Read-PassiveTimeSamples.ps1' = 'd9e2b9344c19af1296b86ec70ba754ef820f369ac5ec897979bd4233e0722d04'
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
foreach ($name in $scripts.Keys) {
|
||||||
|
$path = Join-Path $work $name
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri "$base/$name" -OutFile $path -TimeoutSec 30
|
||||||
|
if ((Get-FileHash -LiteralPath $path).Hash -ne $scripts[$name]) { throw "Downloadhash: $name" }
|
||||||
|
Unblock-File -LiteralPath $path
|
||||||
|
}
|
||||||
|
$listener = [Net.Sockets.TcpListener]::new([Net.IPAddress]::Loopback, 0)
|
||||||
|
$listener.Start(4)
|
||||||
|
$port = $listener.LocalEndpoint.Port
|
||||||
|
$options = @('-F','NUL','-N','-T','-o','BatchMode=yes','-o','IdentitiesOnly=yes',
|
||||||
|
'-o','ForwardAgent=no','-o','StrictHostKeyChecking=yes','-o','GlobalKnownHostsFile=NUL',
|
||||||
|
'-o',"UserKnownHostsFile=$known",'-o','ExitOnForwardFailure=yes','-o','ConnectTimeout=10',
|
||||||
|
'-o','ServerAliveInterval=15','-o','ServerAliveCountMax=2','-i',$key,
|
||||||
|
'-R',"127.0.0.1:22240:127.0.0.1:$port",'rmm-win-tunnel@discovery.ease-technologies.de')
|
||||||
|
$ssh = Start-Process -FilePath "$sshBin\ssh.exe" -ArgumentList $options -PassThru -NoNewWindow
|
||||||
|
if ($ssh.WaitForExit(1800)) { throw "SSH Exit $($ssh.ExitCode)" }
|
||||||
|
Write-Host 'Wartungsfenster aktiv. Dieses Fenster offen lassen. Strg+C beendet es.'
|
||||||
|
$method = 'initial_create'
|
||||||
|
$prefix = 'console-initial-create'
|
||||||
|
$arguments = @{ InitialCreate=$true }
|
||||||
|
if ($ResumeEmpty) {
|
||||||
|
$method = 'resume_empty'
|
||||||
|
$prefix = 'console-resume-empty'
|
||||||
|
$arguments = @{ ResumeEmpty=$true }
|
||||||
|
}
|
||||||
|
$receipt = [ordered]@{session=$session; case_id=$caseId; method=$method; phase='preflight'; read_only_channel=$true}
|
||||||
|
$result = Join-Path $case "$prefix-result.json"
|
||||||
|
$intentPath = Join-Path $case "$prefix-intent.json"
|
||||||
|
$failurePath = Join-Path $case "$prefix-error.json"
|
||||||
|
$receipt.finalizer_invoked = $false
|
||||||
|
try {
|
||||||
|
if (Test-Path -LiteralPath $failurePath) { throw 'Previous profile finalization error recorded' }
|
||||||
|
if (!(Test-Path -LiteralPath $result)) {
|
||||||
|
if (Test-Path -LiteralPath $intentPath) { throw 'Previous profile finalization intent without result' }
|
||||||
|
$receipt.finalizer_invoked = $true
|
||||||
|
$null = & (Join-Path $work 'Complete-OriginalTimeProfile.ps1') @arguments
|
||||||
|
}
|
||||||
|
$record = Get-Content -LiteralPath $result -Raw | ConvertFrom-Json
|
||||||
|
$actual = Get-FileHash -LiteralPath 'C:\ProgramData\RustDiscoverySystem\time-attestation.json'
|
||||||
|
if ($record.id -cne $caseId -or $record.installed -ne $true -or
|
||||||
|
$record.initial_create -ne $true -or $record.source_candidate_preserved -ne $true -or
|
||||||
|
$record.services_changed -ne $false -or $record.private_key_read -ne $false -or $record.clock_runtime_qualified -ne $false -or
|
||||||
|
$actual.Hash -ne '2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b') { throw 'Unexpected publication result' }
|
||||||
|
$marker = Get-Content -LiteralPath $intentPath -Raw | ConvertFrom-Json
|
||||||
|
if ($marker.id -cne $caseId -or $marker.utc -cne $record.publication_since -or
|
||||||
|
$marker.config_sha256 -ne $actual.Hash -or $record.configuration.sha256 -ne $actual.Hash -or
|
||||||
|
$record.original_candidate.file_id -cne '6d990300000003000000000000000000' -or
|
||||||
|
$record.configuration.file_id -cnotmatch '^[0-9a-f]{32}$' -or $record.configuration.file_id -ceq '6d990300000003000000000000000000') { throw 'Unexpected finalization intent' }
|
||||||
|
if ($ResumeEmpty) {
|
||||||
|
if ($record.resumed_empty -ne $true -or $marker.target_id -cne $record.configuration.file_id) {
|
||||||
|
throw 'Recovered profile file identity differs from the recovery intent'
|
||||||
|
}
|
||||||
|
$receipt.resumed_empty = $true
|
||||||
|
$receipt.reserved_target_id = $marker.target_id
|
||||||
|
}
|
||||||
|
$receipt.phase = 'published'
|
||||||
|
$receipt.publication_since = $record.publication_since
|
||||||
|
$receipt.initial_create = $record.initial_create
|
||||||
|
$receipt.source_candidate_preserved = $record.source_candidate_preserved
|
||||||
|
$receipt.services_changed = $record.services_changed
|
||||||
|
$receipt.private_key_read = $record.private_key_read
|
||||||
|
$receipt.clock_runtime_qualified = $record.clock_runtime_qualified
|
||||||
|
$receipt.source_id = $record.original_candidate.file_id
|
||||||
|
$receipt.target_id = $record.configuration.file_id
|
||||||
|
$receipt.config_sha256 = $actual.Hash.ToLowerInvariant()
|
||||||
|
$receipt.result_sha256 = (Get-FileHash -LiteralPath $result).Hash
|
||||||
|
} catch {
|
||||||
|
$receipt.phase = 'finalization_failed'
|
||||||
|
$receipt.exception_type = $_.Exception.GetBaseException().GetType().FullName
|
||||||
|
$receipt.line = $_.InvocationInfo.ScriptLineNumber
|
||||||
|
$receipt.file = [IO.Path]::GetFileName($_.InvocationInfo.ScriptName)
|
||||||
|
Write-Warning $_.Exception.Message
|
||||||
|
if (Test-Path -LiteralPath $failurePath) {
|
||||||
|
$failure = Get-Content -LiteralPath $failurePath -Raw | ConvertFrom-Json
|
||||||
|
if ($failure.id -ceq $caseId -and $failure.hresult -cmatch '^0x[0-9A-Fa-f]{8}$') {
|
||||||
|
$receipt.hresult = $failure.hresult
|
||||||
|
if ($failure.phase -cmatch '^[A-Za-z][A-Za-z0-9_.-]{0,63}$') { $receipt.failure_phase = $failure.phase }
|
||||||
|
$descriptor = $failure.creation_descriptor
|
||||||
|
if ($failure.phase -ceq 'verify_creation' -and $null -ne $descriptor -and
|
||||||
|
$descriptor.expected_sddl -is [string] -and $descriptor.expected_sddl.Length -le 4096 -and
|
||||||
|
$descriptor.actual_sddl -is [string] -and $descriptor.actual_sddl.Length -le 4096) {
|
||||||
|
$receipt.creation_descriptor = @{
|
||||||
|
expected_sddl=$descriptor.expected_sddl; actual_sddl=$descriptor.actual_sddl; bytes=$descriptor.bytes
|
||||||
|
}
|
||||||
|
if ($descriptor.file_id -cmatch '^[0-9a-f]{32}$' -and $descriptor.volume_serial -cmatch '^[0-9]{1,20}$') {
|
||||||
|
$receipt.creation_descriptor.file_id = $descriptor.file_id
|
||||||
|
$receipt.creation_descriptor.volume_serial = $descriptor.volume_serial
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$readScript = Join-Path $work 'Read-PassiveTimeSamples.ps1'
|
||||||
|
$readInput = @{id=$session; agent_sha256='0549d9ebea73cff996938f859b92192cc333de194128d7c6859a3f1d2e85893c'; helper_sha256='59675a3cbb3a5d213fc764f38379d6b81baaf9d47a7124470cc2767d4985763e'} | ConvertTo-Json -Compress
|
||||||
|
while ([DateTimeOffset]::UtcNow -lt $deadline -and !$ssh.HasExited) {
|
||||||
|
if (!$listener.Pending()) { Start-Sleep -Milliseconds 250; continue }
|
||||||
|
$client = $listener.AcceptTcpClient()
|
||||||
|
try {
|
||||||
|
if ($receipt.phase -eq 'published') {
|
||||||
|
$receipt.native = $null
|
||||||
|
try {
|
||||||
|
$json = $readInput | & "$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy RemoteSigned -File $readScript
|
||||||
|
if ($LASTEXITCODE -eq 0) { $receipt.native = ($json -join "`n") | ConvertFrom-Json }
|
||||||
|
} catch { Write-Warning 'Passive Zeitbelege aktuell nicht lesbar.' }
|
||||||
|
}
|
||||||
|
$client.SendTimeout = 3000
|
||||||
|
$body = [Text.Encoding]::UTF8.GetBytes(($receipt | ConvertTo-Json -Depth 16 -Compress))
|
||||||
|
if ($body.Length -gt 65536) { throw 'Ergebnis zu gross.' }
|
||||||
|
$client.GetStream().Write($body,0,$body.Length)
|
||||||
|
} catch { Write-Warning $_.Exception.Message } finally { $client.Dispose() }
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if ($null -ne $ssh) {
|
||||||
|
try { if (!$ssh.HasExited) { $ssh.Kill(); $ssh.WaitForExit() } } finally { $ssh.Dispose() }
|
||||||
|
}
|
||||||
|
if ($null -ne $listener) { $listener.Stop() }
|
||||||
|
foreach ($name in $scripts.Keys) {
|
||||||
|
$path = Join-Path $work $name
|
||||||
|
if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path }
|
||||||
|
}
|
||||||
|
if ((Get-ChildItem -LiteralPath $work -Force | Measure-Object).Count -eq 0) { [IO.Directory]::Delete($work) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
#requires -Version 5.1
|
||||||
|
#requires -RunAsAdministrator
|
||||||
|
# Publish the next trusted-OS profile from actual passive service observations.
|
||||||
|
[CmdletBinding()]
|
||||||
|
param([Parameter(Mandatory)][ValidateSet('Prepare','Publish','Read','FinishStarts')][string]$Action)
|
||||||
|
$ErrorActionPreference='Stop'
|
||||||
|
$commonHash='c54e36b32a2fcccb072f2cca52a38b6c4da31755d86205599016c5d180f5cec4'
|
||||||
|
$common=Join-Path $PSScriptRoot 'Set-PassiveJobPair.ps1'
|
||||||
|
if ((Get-FileHash -LiteralPath $common -Algorithm SHA256).Hash -ne $commonHash) {
|
||||||
|
throw 'The reviewed passive-pair controller must be next to this script'
|
||||||
|
}
|
||||||
|
$text=[Text.Encoding]::UTF8.GetString([IO.File]::ReadAllBytes($common))
|
||||||
|
$first="`n`$originalCase = "
|
||||||
|
$last="`nif (`$Mode -eq 'Read') {"
|
||||||
|
$i=$text.IndexOf($first,[StringComparison]::Ordinal)
|
||||||
|
$j=$text.IndexOf($last,[StringComparison]::Ordinal)
|
||||||
|
if ($i -lt 0 -or $j -le $i -or $i -ne $text.LastIndexOf($first,[StringComparison]::Ordinal) -or
|
||||||
|
$j -ne $text.LastIndexOf($last,[StringComparison]::Ordinal)) { throw 'Passive-pair definition boundary' }
|
||||||
|
# Fixed declarations and functions only. Its Prepare, Install and Restore bodies are excluded.
|
||||||
|
. ([scriptblock]::Create($text.Substring($i,$j-$i)))
|
||||||
|
CheckControl $work $true
|
||||||
|
$activation=(Marker 'profile-publish-intent')
|
||||||
|
$ready=(Marker 'profile-prepared')
|
||||||
|
$success=(Marker 'profile-published')
|
||||||
|
function RequireNewPassivePair {
|
||||||
|
if ((Hash $config) -cne $configHash -or (Hash $helperBinary) -cne $helperHash -or
|
||||||
|
(Test-Path -LiteralPath (Marker 'restore-intent'))) { throw 'Passive successor pair required' }
|
||||||
|
VerifyFiles (CurrentFiles) $newHashes
|
||||||
|
}
|
||||||
|
function RoleDigests($platformHash,$installedHash,$independentHash,$previous) {
|
||||||
|
$out=@{}
|
||||||
|
foreach ($name in @('agent','system_helper')) {
|
||||||
|
$bound=$installed.agent
|
||||||
|
if ($name -ceq 'system_helper') { $bound=$installed.helper }
|
||||||
|
$old=@($previous.trusted_os_active_guest.qualifications | Where-Object { $_.role -ceq $name })
|
||||||
|
if ($old.Count -ne 1) { throw 'Expected one predecessor witness per role' }
|
||||||
|
$archive=Join-Path $oldFolder ($name+'-qualification.json')
|
||||||
|
CheckControl $archive $false
|
||||||
|
if ((Hash $archive) -cne $old[0].qualification_sha256) { throw 'Original role provenance changed' }
|
||||||
|
$archived=Get-Content -LiteralPath $archive -Raw | ConvertFrom-Json
|
||||||
|
$build='a003dfa8cc2397a99933aceeb2d8dab51f883ab9cdf27876fbfc94a78873044c'
|
||||||
|
if ($name -ceq 'system_helper') { $build=$archived.product_pair_receipt_sha256 }
|
||||||
|
Record ('profile-role-'+$name) ([ordered]@{
|
||||||
|
profile='rmm.windows.trusted-os.product-role-prerequisite.v1';role=$name
|
||||||
|
binary_sha256=$bound.image_file.sha256; service=$bound.service; kernel=$bound.kernel
|
||||||
|
image_file=$bound.image_file; predecessor_qualification_sha256=$old[0].qualification_sha256
|
||||||
|
pair_case_id=$id; pair_result_sha256=$installedHash; independent_pair_readback_sha256=$independentHash
|
||||||
|
product_build_receipt_sha256=$build; platform_provenance_sha256=$platformHash
|
||||||
|
raw_capture=$archived.raw_capture; signed_runtime_verified=$false; physical_calibration_claimed=$false
|
||||||
|
})
|
||||||
|
$out[$name]=Hash (Marker ('profile-role-'+$name))
|
||||||
|
}
|
||||||
|
return $out
|
||||||
|
}
|
||||||
|
function BuildSuccessor {
|
||||||
|
$installedHash=Hash (Marker 'installed')
|
||||||
|
$unit=Join-Path $boot 'profile-unit-fcec400-result.json'
|
||||||
|
if ((Hash $unit) -cne '48de474d842ebc87550ba2e27b66086e6aa573973f252f4b8e19ac7b12b75a63') { throw 'Windows unit evidence changed' }
|
||||||
|
$independent=[ordered]@{agent=(LiveRole 'agent' $newHashes.agent);helper=(LiveRole 'helper' $helperHash);files=(CurrentFiles);device=(PreservedDevice)}
|
||||||
|
foreach ($field in $independent.Keys) {
|
||||||
|
if (!(JsonEqual $installed.$field $independent.$field)) { throw "Independent native pair read differs: $field" }
|
||||||
|
}
|
||||||
|
$independent.utc=[DateTime]::UtcNow.ToString('o')
|
||||||
|
$independent.pair_case=$id
|
||||||
|
Record 'profile-independent-native-read' $independent
|
||||||
|
$independentHash=Hash (Marker 'profile-independent-native-read')
|
||||||
|
$old=Get-Content -LiteralPath $target -Raw | ConvertFrom-Json
|
||||||
|
if ($old.schema_version -ne 2 -or $old.key_generation -ne 1 -or
|
||||||
|
$old.server_instance -cne 'c6f9657a-446f-49af-8fb8-bd8932939568' -or
|
||||||
|
$old.trusted_os_active_guest.operating_assumption -cne 'active_guest_no_pause_save_restore_snapshot_migration_host_suspend' -or
|
||||||
|
$old.trusted_os_active_guest.platform -cne 'kvm_qemu_hypervclock' -or
|
||||||
|
@($old.trusted_os_active_guest.qualifications).Count -ne 2) { throw 'Unexpected original V2 contract' }
|
||||||
|
$platform=Join-Path $oldFolder 'platform-provenance.json'
|
||||||
|
CheckControl $platform $false
|
||||||
|
$oldPlatformHash=Hash $platform
|
||||||
|
if ($oldPlatformHash -cne $old.trusted_os_active_guest.platform_provenance_sha256) { throw 'Original platform provenance changed' }
|
||||||
|
Record 'profile-platform' ([ordered]@{
|
||||||
|
profile='rmm.windows.trusted-os.platform-provenance.v1';operating_assumption=$old.trusted_os_active_guest.operating_assumption
|
||||||
|
platform=$old.trusted_os_active_guest.platform;previous_platform_provenance_sha256=$oldPlatformHash
|
||||||
|
predecessor_profile_sha256=$profileHash;pair_case_id=$id;pair_result_sha256=$installedHash
|
||||||
|
independent_pair_readback_sha256=$independentHash;independent_physical_calibration_claimed=$false
|
||||||
|
agent_build_receipt_sha256='a003dfa8cc2397a99933aceeb2d8dab51f883ab9cdf27876fbfc94a78873044c'
|
||||||
|
linux_profile_unit_sha256='ee3a2c99651491a2fd876f1a3463919dc32d9509d9f9ef4eb73a36aa848bb56d'
|
||||||
|
windows_profile_unit_sha256=(Hash $unit)
|
||||||
|
})
|
||||||
|
$platformHash=Hash (Marker 'profile-platform')
|
||||||
|
$roles=RoleDigests $platformHash $installedHash $independentHash $old
|
||||||
|
$profileText=[Text.Encoding]::UTF8.GetString([IO.File]::ReadAllBytes($target))
|
||||||
|
$changes=[ordered]@{}
|
||||||
|
$changes[$oldHashes.agent]=$newHashes.agent
|
||||||
|
$changes[$oldPlatformHash]=$platformHash
|
||||||
|
foreach ($r in $old.trusted_os_active_guest.qualifications) {
|
||||||
|
$changes[$r.qualification_sha256]=$roles[$r.role]
|
||||||
|
}
|
||||||
|
if ($changes.Count -ne 4) { throw 'Expected four independent substitutions' }
|
||||||
|
foreach ($oldValue in $changes.Keys) {
|
||||||
|
$pos=$profileText.IndexOf($oldValue,[StringComparison]::Ordinal)
|
||||||
|
if ($pos -lt 0 -or $pos -ne $profileText.LastIndexOf($oldValue,[StringComparison]::Ordinal)) { throw 'Cannot uniquely bind successor' }
|
||||||
|
$profileText=$profileText.Replace($oldValue,$changes[$oldValue])
|
||||||
|
}
|
||||||
|
$updated=$profileText | ConvertFrom-Json
|
||||||
|
if ($updated.key_generation -ne $old.key_generation -or $updated.server_instance -cne $old.server_instance -or
|
||||||
|
!(JsonEqual $old.binding $updated.binding) -or !(JsonEqual $old.public_keys_hex $updated.public_keys_hex)) {
|
||||||
|
throw 'Unexpected trust-root changes'
|
||||||
|
}
|
||||||
|
$draft=Join-Path $work 'new-time-profile'
|
||||||
|
WriteBytes $draft ([Text.UTF8Encoding]::new($false).GetBytes($profileText))
|
||||||
|
CheckControl $draft $false
|
||||||
|
$oldCopy=Join-Path $work 'old-time-profile'
|
||||||
|
WriteBytes $oldCopy ([IO.File]::ReadAllBytes($target))
|
||||||
|
if ((Hash $oldCopy) -cne $profileHash) { throw 'Time profile predecessor changed' }
|
||||||
|
Record 'profile-prepared' ([ordered]@{
|
||||||
|
id=$id;utc=[DateTime]::UtcNow.ToString('o');predecessor=(FileIdentity $target);successor_sha256=(Hash $draft)
|
||||||
|
source_sha256=$installedHash;independent_sha256=$independentHash;platform_sha256=$platformHash;role_sha256=$roles
|
||||||
|
original_publish_result_sha256='62a04be9c7d08d3687b51eacd6adbe290b91e16ba934d6b5bb531e8764a56cf5'
|
||||||
|
predecessor_revision=1;successor_revision=2;signing_key_generation=$old.key_generation;clock_qualified=$false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function CheckPrepared {
|
||||||
|
if ($prepared.id -cne $id -or $prepared.predecessor.sha256 -cne $profileHash -or
|
||||||
|
$prepared.successor_revision -ne 2 -or $prepared.predecessor_revision -ne 1 -or $prepared.signing_key_generation -ne 1 -or
|
||||||
|
$prepared.source_sha256 -cne (Hash (Marker 'installed')) -or
|
||||||
|
$prepared.independent_sha256 -cne (Hash (Marker 'profile-independent-native-read')) -or
|
||||||
|
$prepared.platform_sha256 -cne (Hash (Marker 'profile-platform')) -or
|
||||||
|
$prepared.successor_sha256 -cne (Hash (Join-Path $work 'new-time-profile')) -or
|
||||||
|
$prepared.successor_sha256 -ceq $profileHash -or
|
||||||
|
(Hash (Join-Path $work 'old-time-profile')) -cne $profileHash) { throw 'Successor preparation inconsistent' }
|
||||||
|
foreach ($name in @('agent','system_helper')) {
|
||||||
|
if ($prepared.role_sha256.$name -cne (Hash (Marker ('profile-role-'+$name)))) { throw 'Role proof changed' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function FinishPublication {
|
||||||
|
$intent=LoadRecord 'profile-publish-intent'
|
||||||
|
$actual=FileIdentity $target
|
||||||
|
if ($intent.id -cne $id -or $intent.prepared_sha256 -cne (Hash $ready) -or
|
||||||
|
$actual.sha256 -cne $prepared.successor_sha256 -or
|
||||||
|
$actual.acl_sha256 -cne $prepared.predecessor.acl_sha256) { throw 'Successor readback failed' }
|
||||||
|
if (Test-Path -LiteralPath (Marker 'time-installed-time')) {
|
||||||
|
if (!(JsonEqual (LoadRecord 'time-installed-time') $actual)) { throw 'Installed profile identity changed' }
|
||||||
|
} else {
|
||||||
|
# An interrupted Replace can finish before the final journal write.
|
||||||
|
# Recognize the recorded candidate and native backup without another Replace.
|
||||||
|
StopCheck
|
||||||
|
$attempt=LoadRecord 'time-replace-time'
|
||||||
|
$previous=FileIdentity (Join-Path $work 'time-replaced-time')
|
||||||
|
if (!(JsonEqual $attempt.previous $prepared.predecessor) -or
|
||||||
|
$previous.sha256 -cne $prepared.predecessor.sha256 -or $previous.file_id -cne $prepared.predecessor.file_id -or
|
||||||
|
$actual.file_id -cne $attempt.candidate.file_id -or $actual.volume_serial -cne $attempt.candidate.volume_serial) {
|
||||||
|
throw 'Unconfirmed profile replacement: inspect current state'
|
||||||
|
}
|
||||||
|
Record 'time-installed-time' $actual
|
||||||
|
}
|
||||||
|
if (Test-Path -LiteralPath $success) { throw 'Already published: use Read' }
|
||||||
|
foreach ($role in @('helper','agent')) {
|
||||||
|
$hash=$newHashes.agent;$name=$agentName
|
||||||
|
if ($role -eq 'helper') { $hash=$helperHash;$name=$helperName }
|
||||||
|
$s=Service $role
|
||||||
|
if ($s.state -ceq 'Stopped') {
|
||||||
|
if (Test-Path -LiteralPath (Marker ('time-start-'+$role))) { throw "Existing unconfirmed $role start; read current state" }
|
||||||
|
StartKnownRole $role $name $hash 'time'
|
||||||
|
} elseif ($s.state -ceq 'Running') {
|
||||||
|
if (!(Test-Path -LiteralPath (Marker ('time-start-'+$role)))) { throw "Unexpected independently started $role" }
|
||||||
|
$null=LiveRole $role $hash
|
||||||
|
} else { throw "Unexpected state $role" }
|
||||||
|
}
|
||||||
|
Record 'profile-published' ([ordered]@{
|
||||||
|
id=$id;utc=[DateTime]::UtcNow.ToString('o');configuration=(FileIdentity $target)
|
||||||
|
predecessor=$prepared.predecessor; successor_revision=2; signing_key_generation=1
|
||||||
|
role_proofs=$prepared.role_sha256; publication_since=$intent.utc
|
||||||
|
agent=(LiveRole 'agent' $newHashes.agent); helper=(LiveRole 'helper' $helperHash)
|
||||||
|
signed_runtime_verified=$false; job_mode=$false;privileged_effects=$false
|
||||||
|
})
|
||||||
|
Write-Output "Published successor profile $id"
|
||||||
|
}
|
||||||
|
if ($Action -ceq 'Read') {
|
||||||
|
$o=[ordered]@{id=$id;read_only=$true;configuration=(FileIdentity $target);agent=(Service 'agent');helper=(Service 'helper');marks=@()}
|
||||||
|
$o.marks=@(Get-ChildItem -LiteralPath $work -Filter 'profile-*.json' -File | Select-Object -ExpandProperty Name)
|
||||||
|
if (Test-Path -LiteralPath $success) { $o.published=LoadRecord 'profile-published' }
|
||||||
|
$o|ConvertTo-Json -Depth 15 -Compress
|
||||||
|
return
|
||||||
|
}
|
||||||
|
RequireNewPassivePair
|
||||||
|
$installed=LoadRecord 'installed'
|
||||||
|
if ($installed.id -cne $id -or $installed.job_mode -ne $false -or $installed.clock_qualified -ne $false) { throw 'Expected passive installation' }
|
||||||
|
if ($Action -ceq 'Prepare') {
|
||||||
|
VerifyPassiveContext
|
||||||
|
if (Test-Path -LiteralPath $activation) { throw 'Already began publication' }
|
||||||
|
BuildSuccessor
|
||||||
|
Write-Output "Prepared successor profile from independent passive service proofs $id"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$prepared=LoadRecord 'profile-prepared'
|
||||||
|
CheckPrepared
|
||||||
|
if ($Action -ceq 'FinishStarts') { FinishPublication;return }
|
||||||
|
VerifyPassiveContext
|
||||||
|
$held=LoadRecord 'profile-independent-native-read'
|
||||||
|
if (!(JsonEqual $held.agent (LiveRole 'agent' $newHashes.agent)) -or
|
||||||
|
!(JsonEqual $held.helper (LiveRole 'helper' $helperHash)) -or
|
||||||
|
!(JsonEqual $held.device (PreservedDevice)) -or !(JsonEqual $prepared.predecessor (FileIdentity $target))) {
|
||||||
|
throw 'Positive, unchanged passive pair and original time profile required before publication'
|
||||||
|
}
|
||||||
|
Record 'profile-publish-intent' ([ordered]@{id=$id;utc=[DateTime]::UtcNow.ToString('o');prepared_sha256=(Hash $ready)})
|
||||||
|
StopKnownRole 'agent' $agentName $held.agent 'time'
|
||||||
|
StopKnownRole 'helper' $helperName $held.helper 'time'
|
||||||
|
$locations.Add('time',$target)
|
||||||
|
SwapFile 'time' (Join-Path $work 'new-time-profile') $prepared.predecessor $prepared.successor_sha256 'time'
|
||||||
|
$locations.Remove('time')
|
||||||
|
FinishPublication
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
$ErrorActionPreference='Stop';$p=([Console]::In.ReadLine()|ConvertFrom-Json)
|
||||||
|
if((($p.PSObject.Properties.Name|Sort-Object)-join',')-cne'agent_sha256,helper_sha256,id'-or[guid]::ParseExact($p.id,'D').ToString()-cne$p.id-or$p.agent_sha256-cnotmatch'^[0-9a-f]{64}$'-or$p.helper_sha256-cnotmatch'^[0-9a-f]{64}$'){throw 'Fixed public sample read'}
|
||||||
|
$state='C:\ProgramData\RustDiscovery\state';$agent='RmmDiscoveryWindows';$helper='RmmDiscoverySystemHelper'
|
||||||
|
$agentSid=(New-Object Security.Principal.NTAccount('NT SERVICE',$agent)).Translate([Security.Principal.SecurityIdentifier]).Value
|
||||||
|
$allowed=@('S-1-5-18','S-1-5-32-544',$agentSid)
|
||||||
|
function Check($path,[bool]$directory){
|
||||||
|
$i=Get-Item -LiteralPath $path -Force
|
||||||
|
if($i.PSIsContainer-ne$directory-or($i.Attributes-band[IO.FileAttributes]::ReparsePoint)){throw 'Regular public report path'}
|
||||||
|
$ancestor=$i.Directory;if($directory){$ancestor=$i.Parent};while($null-ne$ancestor){if($ancestor.Attributes-band[IO.FileAttributes]::ReparsePoint){throw 'Public report reparse ancestry'};$ancestor=$ancestor.Parent}
|
||||||
|
$acl=Get-Acl -LiteralPath $path;$owner=$acl.GetOwner([Security.Principal.SecurityIdentifier]).Value
|
||||||
|
if($owner-cnotin$allowed-and!(!$directory-and$owner-ceq'S-1-5-19')){throw 'Public report owner'}
|
||||||
|
$rules=@($acl.GetAccessRules($true,$true,[Security.Principal.SecurityIdentifier]));if(!$rules.Count){throw 'Public report empty DACL'}
|
||||||
|
foreach($r in $rules){if($r.AccessControlType-ne'Allow'-or$r.IdentityReference.Value-cnotin$allowed){throw 'Public report broad DACL'}}
|
||||||
|
if($directory-and!$acl.AreAccessRulesProtected){throw 'Protected public report directory'}
|
||||||
|
return @{owner_sid=$owner;sddl=$acl.Sddl;dacl_checked=$true}
|
||||||
|
}
|
||||||
|
Add-Type -TypeDefinition @'
|
||||||
|
using System; using System.Text; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles;
|
||||||
|
public static class RmmPassiveTimeRead {
|
||||||
|
[StructLayout(LayoutKind.Sequential)] public struct Info {public uint Attr,CL,CH,AL,AH,WL,WH,Volume,SizeH,SizeL,Links,IndexH,IndexL;}
|
||||||
|
[DllImport("kernel32.dll",SetLastError=true)] public static extern bool GetFileInformationByHandle(SafeFileHandle h,out Info i);
|
||||||
|
[DllImport("kernel32.dll",SetLastError=true)] static extern IntPtr OpenProcess(uint access,bool inherit,int pid);
|
||||||
|
[DllImport("kernel32.dll",SetLastError=true,CharSet=CharSet.Unicode)] static extern bool QueryFullProcessImageName(IntPtr h,uint flags,StringBuilder text,ref uint size);
|
||||||
|
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetProcessTimes(IntPtr h,out long creation,out long exit,out long kernel,out long user);
|
||||||
|
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetExitCodeProcess(IntPtr h,out uint code);
|
||||||
|
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr h);
|
||||||
|
public static string[] Process(int pid){IntPtr h=OpenProcess(0x1000,false,pid);if(h==IntPtr.Zero)throw new InvalidOperationException("QUERY_PROCESS");try{long c,e,k,u;uint code,size=32768;StringBuilder image=new StringBuilder((int)size);if(!GetProcessTimes(h,out c,out e,out k,out u)||!QueryFullProcessImageName(h,0,image,ref size)||!GetExitCodeProcess(h,out code)||code!=259)throw new InvalidOperationException("LIVE_PROCESS");return new string[]{c.ToString(System.Globalization.CultureInfo.InvariantCulture),image.ToString()};}finally{CloseHandle(h);}}
|
||||||
|
}
|
||||||
|
'@
|
||||||
|
function Hash([byte[]]$bytes){$h=[Security.Cryptography.SHA256]::Create();try{return([BitConverter]::ToString($h.ComputeHash($bytes))).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()}}
|
||||||
|
function Runtime($role){
|
||||||
|
$name=$agent;$image='C:\Program Files\RustDiscovery\rmm-agent-windows.exe';$owner='NT AUTHORITY\LocalService';$mode='Auto';$sha=$p.agent_sha256
|
||||||
|
if($role-ceq'helper'){$name=$helper;$image='C:\Program Files\RustDiscovery\rmm-helper-windows.exe';$owner='LocalSystem';$mode='Manual';$sha=$p.helper_sha256}
|
||||||
|
$s=Get-CimInstance Win32_Service -Filter ("Name='"+$name+"'") -OperationTimeoutSec 5
|
||||||
|
if(!$s-or$s.State-cne'Running'-or$s.StartName-cne$owner-or$s.StartMode-cne$mode-or$s.ProcessId-le0-or$s.ServiceType-cne'Own Process'){throw 'Current fixed service role'}
|
||||||
|
$expected='"'+$image+'" --service';if($role-ceq'agent'){$expected+=' --config "C:\ProgramData\RustDiscovery\config.json"'}
|
||||||
|
if($s.PathName-cne$expected){throw 'Current fixed service command'}
|
||||||
|
$native=[RmmPassiveTimeRead]::Process([int]$s.ProcessId)
|
||||||
|
if($native[1]-cne$image-or(Get-FileHash -LiteralPath $image -Algorithm SHA256).Hash.ToLowerInvariant()-cne$sha){throw 'Current fixed service image'}
|
||||||
|
return [ordered]@{pid=[uint32]$s.ProcessId;birth_filetime=$native[0];image=$native[1];sha256=$sha;start_name=$s.StartName;start_mode=$s.StartMode;command=$s.PathName}
|
||||||
|
}
|
||||||
|
function Boot{return (Get-CimInstance Win32_OperatingSystem -Property LastBootUpTime -OperationTimeoutSec 5).LastBootUpTime.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture)}
|
||||||
|
$null=Check 'C:\ProgramData\RustDiscovery' $true;$directory=Check $state $true
|
||||||
|
$boot=Boot;$before=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')};$reports=[ordered]@{}
|
||||||
|
foreach($name in @('agent-time-sample.json','helper-time-sample.json')){
|
||||||
|
$path=Join-Path $state $name
|
||||||
|
if(!(Test-Path -LiteralPath $path)){$reports[$name]=$null;continue}
|
||||||
|
$stream=[IO.File]::Open($path,[IO.FileMode]::Open,[IO.FileAccess]::Read,[IO.FileShare]::Read)
|
||||||
|
try{
|
||||||
|
$meta=Check $path $false;$info=New-Object RmmPassiveTimeRead+Info
|
||||||
|
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$info)-or$info.Links-ne1-or($info.Attr-band0x410)-ne0-or$info.SizeH-ne0-or$info.SizeL-lt1-or$info.SizeL-gt8192-or$stream.Length-ne$info.SizeL){throw 'Single-link bounded public report'}
|
||||||
|
$raw=New-Object byte[] $info.SizeL;$offset=0;while($offset-lt$raw.Length){$count=$stream.Read($raw,$offset,$raw.Length-$offset);if($count-le0){throw 'Complete held public report'};$offset+=$count}
|
||||||
|
$after=New-Object RmmPassiveTimeRead+Info
|
||||||
|
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$after)-or$after.IndexH-ne$info.IndexH-or$after.IndexL-ne$info.IndexL-or$after.WH-ne$info.WH-or$after.WL-ne$info.WL-or$after.SizeL-ne$info.SizeL-or$after.Links-ne1){throw 'Stable held public report'}
|
||||||
|
$again=Check $path $false;if($again.sddl-cne$meta.sddl-or$again.owner_sid-cne$meta.owner_sid){throw 'Stable public report security'}
|
||||||
|
$meta['volume']=$info.Volume;$meta['index_high']=$info.IndexH;$meta['index_low']=$info.IndexL;$meta['last_write_filetime']=(([uint64]$info.WH-shl32)-bor$info.WL).ToString([Globalization.CultureInfo]::InvariantCulture)
|
||||||
|
$reports[$name]=@{raw_base64=[Convert]::ToBase64String($raw);sha256=(Hash $raw);metadata=$meta}
|
||||||
|
}finally{$stream.Dispose()}
|
||||||
|
}
|
||||||
|
$after=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')}
|
||||||
|
$directoryAfter=Check $state $true
|
||||||
|
if(($before|ConvertTo-Json -Depth 8 -Compress)-cne($after|ConvertTo-Json -Depth 8 -Compress)-or(Boot)-cne$boot-or$directory.sddl-cne$directoryAfter.sddl){throw 'Stable process, directory and boot during public read'}
|
||||||
|
@{id=$p.id;read_only=$true;boot_ticks=$boot;runtime=$after;state_metadata=$directory;reports=$reports;observed_at=[DateTime]::UtcNow.ToString('o')}|ConvertTo-Json -Depth 12 -Compress
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
#requires -Version 5.1
|
||||||
|
#requires -RunAsAdministrator
|
||||||
|
[CmdletBinding()]
|
||||||
|
param([Parameter(Mandatory)][ValidateSet('Inspect','Prepare','Activate','Readback')][string]$Mode)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$caseId = '49c230d8-fb5d-4c64-96b6-e0edce03ed90'
|
||||||
|
$boot = 'C:\ProgramData\RustDiscoveryBootstrap'
|
||||||
|
$case = Join-Path $boot "job-config-$caseId"
|
||||||
|
$root = 'C:\ProgramData\RustDiscovery'
|
||||||
|
$state = Join-Path $root 'state'
|
||||||
|
$config = Join-Path $root 'config.json'
|
||||||
|
$binding = Join-Path $root 'binding.json'
|
||||||
|
$jobs = Join-Path $state 'jobs'
|
||||||
|
$systemRoot = 'C:\ProgramData\RustDiscoverySystem'
|
||||||
|
$pin = Join-Path $systemRoot 'agent-pin.json'
|
||||||
|
$clock = Join-Path $systemRoot 'time-attestation.json'
|
||||||
|
$image = 'C:\Program Files\RustDiscovery\rmm-agent-windows.exe'
|
||||||
|
$helperImage = 'C:\Program Files\RustDiscovery\rmm-helper-windows.exe'
|
||||||
|
$oldConfig = '7c9f6f3642ef84337c3cd761d8a4788c4babe81522fdd987a3eb9b819bc8d851'
|
||||||
|
$oldConfigAcl = '014e89cc8674259dd9ac7f490ffef056b85ada96c6e3574c23f27668b7a9b991'
|
||||||
|
$expectedBinding = '9239ee9f4142735867e77451478bf309fbf449d730a0ede6c958bc8018830dde'
|
||||||
|
$oldAgent = '0549d9ebea73cff996938f859b92192cc333de194128d7c6859a3f1d2e85893c'
|
||||||
|
$newAgent = 'df80b00fc2119b973d690053b9f9e4bdedd8fbc211f67599c3301eeb42e7702f'
|
||||||
|
$helper = '59675a3cbb3a5d213fc764f38379d6b81baaf9d47a7124470cc2767d4985763e'
|
||||||
|
$agentSid = ([Security.Principal.NTAccount]::new('NT SERVICE','RmmDiscoveryWindows')).Translate([Security.Principal.SecurityIdentifier]).Value
|
||||||
|
$utf8 = [Text.UTF8Encoding]::new($false,$true)
|
||||||
|
$sidType = [Security.Principal.SecurityIdentifier]
|
||||||
|
$admins = @('S-1-5-18','S-1-5-32-544')
|
||||||
|
$ready = Join-Path $case 'prepared.json'
|
||||||
|
$entered = Join-Path $case 'activation-intent.json'
|
||||||
|
$done = Join-Path $case 'activated.json'
|
||||||
|
$candidate = Join-Path $case 'job-config.candidate.json'
|
||||||
|
$original = Join-Path $case 'passive-config.original.json'
|
||||||
|
$publicBinding = Join-Path $case 'public-binding.json'
|
||||||
|
$next = Join-Path $root "config-$caseId.next"
|
||||||
|
$backup = Join-Path $case 'replaced.original.json'
|
||||||
|
|
||||||
|
function Assert-NormalPath([string]$Path,[bool]$Directory) {
|
||||||
|
$item = Get-Item -LiteralPath $Path -Force
|
||||||
|
if ($item.PSIsContainer -ne $Directory) { throw "Unerwarteter Pfadtyp: $Path" }
|
||||||
|
while ($null -ne $item) {
|
||||||
|
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw "Reparsepunkt: $Path" }
|
||||||
|
if ($item -is [IO.FileInfo]) { $item = $item.Directory } else { $item = $item.Parent }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function Get-PublicHash([string]$Path) {
|
||||||
|
Assert-NormalPath $Path $false
|
||||||
|
return (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||||
|
}
|
||||||
|
function Get-BytesDigest([byte[]]$Bytes) {
|
||||||
|
$alg = [Security.Cryptography.SHA256]::Create()
|
||||||
|
try { return [BitConverter]::ToString($alg.ComputeHash($Bytes)).Replace('-','').ToLowerInvariant() }
|
||||||
|
finally { $alg.Dispose() }
|
||||||
|
}
|
||||||
|
function Assert-DirectoryAcl([string]$Path,[bool]$AgentCanRead) {
|
||||||
|
Assert-NormalPath $Path $true
|
||||||
|
$acl = Get-Acl -LiteralPath $Path
|
||||||
|
if ($acl.GetOwner($sidType).Value -notin $admins) { throw "Verzeichniseigentuemer: $Path" }
|
||||||
|
$rules = @($acl.GetAccessRules($true,$true,$sidType))
|
||||||
|
if (!$rules.Count) { throw "Leere DACL: $Path" }
|
||||||
|
foreach ($rule in $rules) {
|
||||||
|
$sid = $rule.IdentityReference.Value
|
||||||
|
if ($rule.AccessControlType -ne 'Allow' -or
|
||||||
|
($sid -notin $admins -and !($AgentCanRead -and $sid -ceq $agentSid -and
|
||||||
|
(([long]$rule.FileSystemRights -band (-bnot 0x1200a9)) -eq 0)))) { throw "Verzeichnisrechte: $Path" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function Write-Once([string]$Path,[byte[]]$Bytes,[Security.AccessControl.FileSecurity]$Acl) {
|
||||||
|
if ($null -eq $Acl) {
|
||||||
|
$stream = [IO.File]::Open($Path,'CreateNew','Write','None')
|
||||||
|
} else {
|
||||||
|
$stream = [IO.FileStream]::new($Path,[IO.FileMode]::CreateNew,[Security.AccessControl.FileSystemRights]::Write,
|
||||||
|
[IO.FileShare]::None,4096,[IO.FileOptions]::WriteThrough,$Acl)
|
||||||
|
}
|
||||||
|
try { $stream.Write($Bytes,0,$Bytes.Length); $stream.Flush($true) } finally { $stream.Dispose() }
|
||||||
|
}
|
||||||
|
function Save-Record([string]$Path,$Record) {
|
||||||
|
Write-Once $Path ($utf8.GetBytes(($Record | ConvertTo-Json -Depth 8 -Compress))) $null
|
||||||
|
}
|
||||||
|
function Read-PublicJson([string]$Path) {
|
||||||
|
Assert-NormalPath $Path $false
|
||||||
|
if ((Get-Item -LiteralPath $Path).Length -gt 32768) { throw "Datei zu gross: $Path" }
|
||||||
|
return ($utf8.GetString([IO.File]::ReadAllBytes($Path)) | ConvertFrom-Json)
|
||||||
|
}
|
||||||
|
function Get-OriginalAcl {
|
||||||
|
$acl = Get-Acl -LiteralPath $config
|
||||||
|
if ((Get-BytesDigest ($utf8.GetBytes($acl.Sddl))) -cne $oldConfigAcl) { throw 'Originale Konfigurations-DACL abweichend' }
|
||||||
|
return $acl
|
||||||
|
}
|
||||||
|
function Assert-FileAcl([string]$Path,$Expected) {
|
||||||
|
$sections = [Security.AccessControl.AccessControlSections]'Owner,Group,Access'
|
||||||
|
$actual = (Get-Acl -LiteralPath $Path).GetSecurityDescriptorSddlForm($sections)
|
||||||
|
$wanted = $Expected.GetSecurityDescriptorSddlForm($sections)
|
||||||
|
# File creation can omit the auto-inherited marker on this VM. Owner,
|
||||||
|
# group, protected DACL, access masks and ACE sequence must all match.
|
||||||
|
if ($actual -cne $wanted -and $actual -cne $wanted.Replace('D:PAI(', 'D:P(')) {
|
||||||
|
throw "Dateiberechtigungen abweichend: $Path"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function Get-ConfigurationInputs {
|
||||||
|
if ((Get-PublicHash $config) -cne $oldConfig) { throw 'Passive Originalkonfiguration abweichend' }
|
||||||
|
$null = Get-OriginalAcl
|
||||||
|
$value = Read-PublicJson $config
|
||||||
|
$names = @($value.PSObject.Properties.Name | Sort-Object)
|
||||||
|
if (($names -join ',') -cne 'ca_file,connect_address,enrollment_token_file,server_name,state_directory,transport' -or
|
||||||
|
$value.server_name -cne 'discovery.ease-technologies.de' -or $value.state_directory -ine $state -or $value.transport -cne 'auto') {
|
||||||
|
throw 'Unerwartete passive Konfigurationsfelder'
|
||||||
|
}
|
||||||
|
$value | Add-Member -NotePropertyName job_binding_file -NotePropertyValue $binding
|
||||||
|
$value | Add-Member -NotePropertyName enable_jobs -NotePropertyValue $true
|
||||||
|
$value | Add-Member -NotePropertyName windows_execution_profile -NotePropertyValue 'powershell_51_remote_signed'
|
||||||
|
$peer = Read-PublicJson $pin
|
||||||
|
$b = $peer.binding
|
||||||
|
$canonical = [ordered]@{agent_id=$b.agent_id;asset_id=$b.asset_id;assignment_version=$b.assignment_version;
|
||||||
|
enrollment_generation=$b.enrollment_generation;public_key_hex=$b.public_key_hex;tenant_id=$b.tenant_id}
|
||||||
|
$bindingBytes = $utf8.GetBytes(($canonical | ConvertTo-Json -Compress))
|
||||||
|
if ((Get-BytesDigest $bindingBytes) -cne $expectedBinding) { throw 'Oeffentliche Jobbindung abweichend' }
|
||||||
|
return @{config=$utf8.GetBytes(($value | ConvertTo-Json -Compress)); binding=$bindingBytes}
|
||||||
|
}
|
||||||
|
function Get-JobsAcl {
|
||||||
|
$acl = [Security.AccessControl.DirectorySecurity]::new()
|
||||||
|
$acl.SetSecurityDescriptorSddlForm("O:BAG:BAD:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;0x1301bf;;;$agentSid)")
|
||||||
|
return $acl
|
||||||
|
}
|
||||||
|
function Assert-JobsAcl {
|
||||||
|
Assert-NormalPath $jobs $true
|
||||||
|
$acl = Get-Acl -LiteralPath $jobs
|
||||||
|
if (!$acl.AreAccessRulesProtected -or $acl.GetOwner($sidType).Value -notin $admins) { throw 'Jobverzeichnis nicht geschuetzt' }
|
||||||
|
$expected = (Get-JobsAcl).GetAccessRules($true,$false,$sidType)
|
||||||
|
$rules = $acl.GetAccessRules($true,$true,$sidType)
|
||||||
|
if ($rules.Count -ne $expected.Count) { throw 'Job-DACL Anzahl' }
|
||||||
|
foreach ($e in $expected) {
|
||||||
|
$match = @($rules | Where-Object { !$_.IsInherited -and $_.IdentityReference.Value -ceq $e.IdentityReference.Value -and
|
||||||
|
$_.FileSystemRights -eq $e.FileSystemRights -and $_.AccessControlType -eq $e.AccessControlType -and
|
||||||
|
$_.InheritanceFlags -eq $e.InheritanceFlags -and $_.PropagationFlags -eq $e.PropagationFlags })
|
||||||
|
if ($match.Count -ne 1) { throw 'Job-DACL abweichend' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function Get-Readback {
|
||||||
|
$files = [ordered]@{}
|
||||||
|
foreach ($p in @($config,$binding,$candidate,$publicBinding,$original,$next,$backup,$ready,$entered,$done,$image,$helperImage,$clock)) {
|
||||||
|
$files[$p] = if ([IO.File]::Exists($p)) { Get-PublicHash $p } else { $null }
|
||||||
|
}
|
||||||
|
$jobsAcl = $null
|
||||||
|
if (Test-Path -LiteralPath $jobs) {
|
||||||
|
try { Assert-JobsAcl; $jobsAcl = $true } catch { $jobsAcl = $false }
|
||||||
|
}
|
||||||
|
$aclHashes = [ordered]@{}
|
||||||
|
foreach ($p in @($root,$state,$config,$binding,$jobs,$case)) {
|
||||||
|
if (Test-Path -LiteralPath $p) {
|
||||||
|
Assert-NormalPath $p ([IO.Directory]::Exists($p))
|
||||||
|
$aclHashes[$p] = Get-BytesDigest ($utf8.GetBytes((Get-Acl -LiteralPath $p).Sddl))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$live = Read-PublicJson $config
|
||||||
|
return [ordered]@{case_id=$caseId; agent_state=[string](Get-Service RmmDiscoveryWindows).Status;
|
||||||
|
helper_state=[string](Get-Service RmmDiscoverySystemHelper).Status; files=$files;
|
||||||
|
acl_sha256=$aclHashes; job_profile=$live.windows_execution_profile; jobs_enabled=($live.enable_jobs -eq $true);
|
||||||
|
binding_path_matches=($live.job_binding_file -ceq $binding);
|
||||||
|
jobs_directory=[IO.Directory]::Exists($jobs); jobs_acl_verified=$jobsAcl}
|
||||||
|
}
|
||||||
|
Assert-DirectoryAcl $boot $false
|
||||||
|
Assert-DirectoryAcl $root $true
|
||||||
|
Assert-NormalPath $state $true
|
||||||
|
if (Test-Path -LiteralPath $case) { Assert-DirectoryAcl $case $false }
|
||||||
|
if ($Mode -in @('Inspect','Readback')) { Get-Readback | ConvertTo-Json -Depth 5; return }
|
||||||
|
if ((Get-PublicHash $helperImage) -cne $helper) { throw 'Helper-Build abweichend' }
|
||||||
|
$inputs = Get-ConfigurationInputs
|
||||||
|
$configHash = Get-BytesDigest $inputs.config
|
||||||
|
foreach ($p in @($jobs,$binding,$next,$backup,$entered,$done)) {
|
||||||
|
if (Test-Path -LiteralPath $p) { throw 'Frueherer oder teilweiser Wechsel: Readback verwenden' }
|
||||||
|
}
|
||||||
|
if ($Mode -eq 'Prepare') {
|
||||||
|
if ((Get-PublicHash $image) -cne $oldAgent -or (Get-Service RmmDiscoveryWindows).Status -ne 'Running') { throw 'Passiver Ausgangsagent erforderlich' }
|
||||||
|
if (Test-Path -LiteralPath $case) { throw 'Vorhandener Vorbereitungsfall: Readback verwenden' }
|
||||||
|
$caseAcl = [Security.AccessControl.DirectorySecurity]::new()
|
||||||
|
$caseAcl.SetSecurityDescriptorSddlForm('O:BAG:BAD:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)')
|
||||||
|
$null = [IO.Directory]::CreateDirectory($case,$caseAcl)
|
||||||
|
Assert-DirectoryAcl $case $false
|
||||||
|
Write-Once $original ([IO.File]::ReadAllBytes($config)) $null
|
||||||
|
Write-Once $candidate $inputs.config $null
|
||||||
|
Write-Once $publicBinding $inputs.binding $null
|
||||||
|
if ((Get-PublicHash $candidate) -cne $configHash -or (Get-PublicHash $original) -cne $oldConfig -or
|
||||||
|
(Get-PublicHash $publicBinding) -cne $expectedBinding) { throw 'Vorbereitungsdateien abweichend' }
|
||||||
|
Save-Record $ready @{case_id=$caseId; config_sha256=$configHash; original_sha256=$oldConfig; binding_sha256=$expectedBinding}
|
||||||
|
Get-Readback | ConvertTo-Json -Depth 5
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$prepared = Read-PublicJson $ready
|
||||||
|
if ($prepared.case_id -cne $caseId -or $prepared.config_sha256 -cne $configHash -or
|
||||||
|
(Get-PublicHash $candidate) -cne $configHash -or (Get-PublicHash $original) -cne $oldConfig -or
|
||||||
|
(Get-PublicHash $publicBinding) -cne $expectedBinding) { throw 'Vorbereitungsbeleg abweichend' }
|
||||||
|
if ((Get-PublicHash $image) -cne $newAgent -or (Get-Service RmmDiscoveryWindows).Status -ne 'Stopped') { throw 'Neues Agentimage und gestoppter Dienst erforderlich' }
|
||||||
|
$peer = Read-PublicJson $pin
|
||||||
|
$time = Read-PublicJson $clock
|
||||||
|
$roles = @($time.trusted_os_active_guest.qualifications)
|
||||||
|
if ($peer.agent.binary_sha256 -cne $newAgent -or $peer.helper.binary_sha256 -cne $helper -or
|
||||||
|
$roles.Count -ne 2 -or @($roles | Where-Object { $_.role -ceq 'agent' -and $_.binary_sha256 -ceq $newAgent }).Count -ne 1 -or
|
||||||
|
@($roles | Where-Object { $_.role -ceq 'system_helper' -and $_.binary_sha256 -ceq $helper }).Count -ne 1) { throw 'Paar-Pins und Zeitprofil abweichend' }
|
||||||
|
$acl = Get-OriginalAcl
|
||||||
|
Save-Record $entered @{case_id=$caseId; utc=[DateTime]::UtcNow.ToString('o'); config_sha256=$configHash; binding_sha256=$expectedBinding}
|
||||||
|
Write-Once $binding $inputs.binding $acl
|
||||||
|
Assert-FileAcl $binding $acl
|
||||||
|
$null = [IO.Directory]::CreateDirectory($jobs,(Get-JobsAcl))
|
||||||
|
Assert-JobsAcl
|
||||||
|
Write-Once $next $inputs.config $acl
|
||||||
|
Assert-FileAcl $next $acl
|
||||||
|
if ((Get-PublicHash $binding) -cne $expectedBinding -or (Get-PublicHash $next) -cne $configHash -or
|
||||||
|
(Get-PublicHash $config) -cne $oldConfig) { throw 'Vor Austausch unerwartete Dateien' }
|
||||||
|
[IO.File]::Replace($next,$config,$backup,$false)
|
||||||
|
Assert-FileAcl $config $acl
|
||||||
|
if ((Get-PublicHash $config) -cne $configHash -or (Get-PublicHash $backup) -cne $oldConfig) { throw 'Konfigurationswechsel nicht bestaetigt' }
|
||||||
|
Save-Record $done @{case_id=$caseId; utc=[DateTime]::UtcNow.ToString('o'); config_sha256=$configHash; binding_sha256=$expectedBinding}
|
||||||
|
Get-Readback | ConvertTo-Json -Depth 5
|
||||||
@@ -0,0 +1,278 @@
|
|||||||
|
#requires -Version 5.1
|
||||||
|
#requires -RunAsAdministrator
|
||||||
|
# Fixed console maintenance of the passive test guest. No queue, network, or script job.
|
||||||
|
[CmdletBinding()]
|
||||||
|
param([Parameter(Mandatory)][ValidateSet('Prepare','InstallPassive','Read','RestorePrevious')][string]$Mode)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$originalCase = 'ad9fd154-b2be-4f5d-9e17-65abb721ceaf'
|
||||||
|
$originalHash = 'd8b4fd4fd9ca5310cc1591ce3c2ccae5bd72a2ade43b21a8187cfdfb960b3427'
|
||||||
|
$bootstrap = 'C:\ProgramData\RustDiscoveryBootstrap'
|
||||||
|
$oldFolder = Join-Path $bootstrap "time-profile-$originalCase"
|
||||||
|
$original = Join-Path (Join-Path $bootstrap $originalHash) 'InstallPublicTimeProfile.ps1'
|
||||||
|
$raw = [IO.File]::ReadAllBytes($original)
|
||||||
|
$digest = [Security.Cryptography.SHA256]::Create()
|
||||||
|
try { $actual = [BitConverter]::ToString($digest.ComputeHash($raw)).Replace('-','') }
|
||||||
|
finally { $digest.Dispose() }
|
||||||
|
if ($actual -ne $originalHash) { throw 'Original controller hash changed' }
|
||||||
|
$src = [Text.Encoding]::UTF8.GetString($raw)
|
||||||
|
$boundary = "`nCheckControl `$boot `$true`n"
|
||||||
|
$end = $src.IndexOf($boundary,[StringComparison]::Ordinal)
|
||||||
|
if ($end -le 0 -or $end -ne $src.LastIndexOf($boundary,[StringComparison]::Ordinal)) {
|
||||||
|
throw 'Expected the original fixed definition boundary'
|
||||||
|
}
|
||||||
|
$originalIntent = Get-Content -LiteralPath (Join-Path $oldFolder 'intent.json') -Raw | ConvertFrom-Json
|
||||||
|
if ($originalIntent.id -cne $originalCase -or $originalIntent.request.script_sha256 -cne $originalHash) {
|
||||||
|
throw 'Unexpected original case'
|
||||||
|
}
|
||||||
|
$global:RmmTimeProfilePayload = $originalIntent.request
|
||||||
|
. ([scriptblock]::Create($src.Substring(0,$end)))
|
||||||
|
$id = '49c230d8-fb5d-4c64-96b6-e0edce03ed90'
|
||||||
|
$work = Join-Path $boot "job-passive-pair-$id"
|
||||||
|
$oldHashes = [ordered]@{
|
||||||
|
agent='0549d9ebea73cff996938f859b92192cc333de194128d7c6859a3f1d2e85893c'
|
||||||
|
settings='bbccd710fd564eb5ad57eec5732b413359d09bcb5953f5de9501ccfe826bd3c2'
|
||||||
|
pin='66ef481bd9ded320d6f3dcc82b0ddaf34fdef7d80ac15d06820ff7da75a18c56'
|
||||||
|
}
|
||||||
|
$newHashes = [ordered]@{
|
||||||
|
agent='df80b00fc2119b973d690053b9f9e4bdedd8fbc211f67599c3301eeb42e7702f'
|
||||||
|
settings='7172456d56a55cced2f6ed4af1e9141499f09e67cbb16db32e2308396f9de929'
|
||||||
|
pin='b9517517cec801b10adb5d53e470fc143b8909c45e3bb95b8e4a34281f303623'
|
||||||
|
}
|
||||||
|
$locations = [ordered]@{agent=$agentBinary;settings=$settings;pin=$pin}
|
||||||
|
$profileHash = '2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b'
|
||||||
|
$helperHash = '59675a3cbb3a5d213fc764f38379d6b81baaf9d47a7124470cc2767d4985763e'
|
||||||
|
$configHash = '7c9f6f3642ef84337c3cd761d8a4788c4babe81522fdd987a3eb9b819bc8d851'
|
||||||
|
$source = Join-Path (Join-Path $boot $newHashes.agent) 'rmm-agent-windows.exe'
|
||||||
|
CheckControl $boot $true
|
||||||
|
CheckControl $oldFolder $true
|
||||||
|
if ((Hash (Join-Path $oldFolder 'console-resume-empty-result.json')) -cne '62a04be9c7d08d3687b51eacd6adbe290b91e16ba934d6b5bb531e8764a56cf5') {
|
||||||
|
throw 'Unexpected original publication result'
|
||||||
|
}
|
||||||
|
|
||||||
|
function Marker($name) { Join-Path $work ($name+'.json') }
|
||||||
|
function Record($name,$value) { WriteNew (Marker $name) $value }
|
||||||
|
function LoadRecord($name) {
|
||||||
|
$path = Marker $name
|
||||||
|
CheckControl $path $false
|
||||||
|
return (Get-Content -LiteralPath $path -Raw | ConvertFrom-Json)
|
||||||
|
}
|
||||||
|
function VerifyPassiveContext {
|
||||||
|
if ((Hash $config) -cne $configHash -or (Hash $target) -cne $profileHash -or
|
||||||
|
(Hash $helperBinary) -cne $helperHash) { throw 'Passive config, predecessor time profile or unchanged helper differs' }
|
||||||
|
foreach ($dir in @((Split-Path $agentBinary),$agentRoot,$helperRoot)) { $null=ReadAcl $dir $true }
|
||||||
|
foreach ($file in @($config,$settings,$pin,$target,$agentBinary,$helperBinary)) { $null=ReadAcl $file $false }
|
||||||
|
$unitProof=Join-Path $boot 'profile-unit-fcec400-result.json'
|
||||||
|
CheckControl $unitProof $false
|
||||||
|
if ((Hash $unitProof) -cne '48de474d842ebc87550ba2e27b66086e6aa573973f252f4b8e19ac7b12b75a63') {
|
||||||
|
throw 'Current native Windows profile unit receipt differs'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function CurrentFiles {
|
||||||
|
$files=[ordered]@{}
|
||||||
|
foreach ($name in $locations.Keys) { $files[$name]=FileIdentity $locations[$name] }
|
||||||
|
return $files
|
||||||
|
}
|
||||||
|
function VerifyFiles($files,$hashes) {
|
||||||
|
foreach ($name in $locations.Keys) {
|
||||||
|
if ($files.$name.sha256 -cne $hashes.$name) { throw "Unexpected $name bytes" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function LiveRole($role,$expectedHash) {
|
||||||
|
$s=Service $role
|
||||||
|
if ($s.state -cne 'Running') { throw "$role must be running" }
|
||||||
|
$handle=[RmmPipeNative]::Open([int]$s.pid)
|
||||||
|
try {
|
||||||
|
$k=Kernel $role $s $handle
|
||||||
|
$f=FileIdentity $k.image
|
||||||
|
if ($f.sha256 -cne $expectedHash -or !(JsonEqual $s (Service $role)) -or ![RmmPipeNative]::Alive($handle)) {
|
||||||
|
throw "$role generation or image changed"
|
||||||
|
}
|
||||||
|
return [ordered]@{service=$s; kernel=$k; image_file=$f}
|
||||||
|
} finally { $handle.Dispose() }
|
||||||
|
}
|
||||||
|
function PreservedDevice {
|
||||||
|
return [ordered]@{
|
||||||
|
config=(FileIdentity $config)
|
||||||
|
identity=(FileIdentity (Join-Path $agentState 'identity.json') $true)
|
||||||
|
certificate=(FileIdentity (Join-Path $agentState 'device.pem') $true)
|
||||||
|
private_key_metadata=(FileIdentityMetadata (Join-Path $agentState 'device.key'))
|
||||||
|
helper=(FileIdentity $helperBinary)
|
||||||
|
time_profile=(FileIdentity $target)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function FlushFile($path) {
|
||||||
|
$f=[IO.File]::Open($path,'Open','ReadWrite','Read')
|
||||||
|
try { $f.Flush($true) } finally { $f.Dispose() }
|
||||||
|
}
|
||||||
|
function StopKnownRole($role,$name,$bound,$prefix) {
|
||||||
|
$s=Service $role
|
||||||
|
if (!(JsonEqual $s $bound.service)) { throw "$role changed before stop" }
|
||||||
|
$h=[RmmPipeNative]::Open([int]$s.pid)
|
||||||
|
try {
|
||||||
|
if (!(JsonEqual (Kernel $role $s $h) $bound.kernel)) { throw 'Kernel role changed' }
|
||||||
|
Record ($prefix+'-stop-'+$role) $bound
|
||||||
|
Stop-Service -Name $name
|
||||||
|
(Get-Service -Name $name).WaitForStatus('Stopped',[TimeSpan]::FromSeconds(30))
|
||||||
|
if (![RmmPipeNative]::Exited($h,5000)) { throw "$role did not exit" }
|
||||||
|
} finally { $h.Dispose() }
|
||||||
|
}
|
||||||
|
function StopCheck {
|
||||||
|
if ((Service 'agent').state -cne 'Stopped' -or (Service 'helper').state -cne 'Stopped') {
|
||||||
|
throw 'Both services must be stopped'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function SwapFile($name,$inputPath,$oldId,$newHash,$prefix) {
|
||||||
|
StopCheck
|
||||||
|
$dest=$locations[$name]
|
||||||
|
$backup=Join-Path $work ($prefix+'-replaced-'+$name)
|
||||||
|
$stage=Join-Path $work ($prefix+'-stage-'+$name)
|
||||||
|
CheckControl $inputPath $false
|
||||||
|
if (!(JsonEqual $oldId (FileIdentity $dest)) -or (Hash $inputPath) -cne $newHash -or (Test-Path -LiteralPath $backup)) {
|
||||||
|
throw "Replacement precondition $name"
|
||||||
|
}
|
||||||
|
[IO.File]::Copy($inputPath,$stage,$false)
|
||||||
|
FlushFile $stage
|
||||||
|
$candidate=FileIdentity $stage
|
||||||
|
if ($candidate.sha256 -cne $newHash -or $candidate.volume_serial -cne $oldId.volume_serial) { throw 'Invalid same-volume candidate' }
|
||||||
|
$originalAcl=Get-Acl -LiteralPath $dest
|
||||||
|
Record ($prefix+'-replace-'+$name) ([ordered]@{previous=$oldId;candidate=$candidate})
|
||||||
|
if (!(JsonEqual $oldId (FileIdentity $dest)) -or !(JsonEqual $candidate (FileIdentity $stage))) { throw 'Changed replacement identities' }
|
||||||
|
[IO.File]::Replace($stage,$dest,$backup)
|
||||||
|
$privateAcl=New-Object Security.AccessControl.FileSecurity
|
||||||
|
$privateAcl.SetSecurityDescriptorSddlForm('O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)')
|
||||||
|
Set-Acl -LiteralPath $backup -AclObject $privateAcl
|
||||||
|
CheckControl $backup $false
|
||||||
|
if ((AclHash $dest) -cne $oldId.acl_sha256) {
|
||||||
|
Set-Acl -LiteralPath $dest -AclObject $originalAcl
|
||||||
|
}
|
||||||
|
FlushFile $dest
|
||||||
|
$new=FileIdentity $dest
|
||||||
|
if ($new.sha256 -cne $newHash -or $new.acl_sha256 -cne $oldId.acl_sha256 -or (Hash $backup) -cne $oldId.sha256) {
|
||||||
|
throw "Replacement readback $name"
|
||||||
|
}
|
||||||
|
Record ($prefix+'-installed-'+$name) $new
|
||||||
|
}
|
||||||
|
function StartKnownRole($role,$name,$hash,$prefix) {
|
||||||
|
if ((Service $role).state -cne 'Stopped') { throw "$role not stopped" }
|
||||||
|
Record ($prefix+'-start-'+$role) @{old_state='Stopped';expected_hash=$hash}
|
||||||
|
Start-Service -Name $name
|
||||||
|
(Get-Service -Name $name).WaitForStatus('Running',[TimeSpan]::FromSeconds(30))
|
||||||
|
Record ($prefix+'-started-'+$role) (LiveRole $role $hash)
|
||||||
|
}
|
||||||
|
function PrepareFiles($before) {
|
||||||
|
CheckControl (Split-Path $source) $true
|
||||||
|
CheckControl $source $false
|
||||||
|
if ((FileIdentity $source).sha256 -cne $newHashes.agent) { throw 'New agent hash' }
|
||||||
|
foreach ($name in $locations.Keys) {
|
||||||
|
$copy=Join-Path $work ('old-'+$name)
|
||||||
|
[IO.File]::Copy($locations[$name],$copy,$false)
|
||||||
|
# Copy can retain the source descriptor. Restrict backups to the case.
|
||||||
|
$acl=New-Object Security.AccessControl.FileSecurity
|
||||||
|
$acl.SetSecurityDescriptorSddlForm('O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)')
|
||||||
|
Set-Acl -LiteralPath $copy -AclObject $acl
|
||||||
|
CheckControl $copy $false
|
||||||
|
FlushFile $copy
|
||||||
|
if ((Hash $copy) -cne $oldHashes.$name) { throw "Backup $name" }
|
||||||
|
}
|
||||||
|
$utf8=[Text.UTF8Encoding]::new($false,$true)
|
||||||
|
foreach ($name in @('settings','pin')) {
|
||||||
|
$data=$utf8.GetString([IO.File]::ReadAllBytes($locations[$name])).Replace($oldHashes.agent,$newHashes.agent)
|
||||||
|
if ($name -eq 'pin') { $data=$data.Replace($oldHashes.settings,$newHashes.settings) }
|
||||||
|
$path=Join-Path $work ('new-'+$name)
|
||||||
|
WriteBytes $path ($utf8.GetBytes($data))
|
||||||
|
if ((Hash $path) -cne $newHashes.$name) { throw "Closed successor bytes $name" }
|
||||||
|
}
|
||||||
|
if (!(JsonEqual $before (CurrentFiles))) { throw 'Original inputs changed during copy' }
|
||||||
|
}
|
||||||
|
if ($Mode -eq 'Read') {
|
||||||
|
$r=[ordered]@{id=$id;mode='read_only';files=(CurrentFiles);agent=(Service 'agent');helper=(Service 'helper');markers=@()}
|
||||||
|
if (Test-Path -LiteralPath $work) {
|
||||||
|
CheckControl $work $true
|
||||||
|
$r.markers=@(Get-ChildItem -LiteralPath $work -Filter '*.json' -File | Select-Object -ExpandProperty Name)
|
||||||
|
if ((Test-Path -LiteralPath (Marker 'installed')) -and $r.files.agent.sha256 -ceq $newHashes.agent -and
|
||||||
|
$r.agent.state -ceq 'Running' -and $r.helper.state -ceq 'Running') {
|
||||||
|
$r.new_agent=LiveRole 'agent' $newHashes.agent
|
||||||
|
$r.unchanged_helper=LiveRole 'helper' $helperHash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$r|ConvertTo-Json -Depth 12 -Compress
|
||||||
|
return
|
||||||
|
}
|
||||||
|
VerifyPassiveContext
|
||||||
|
if ($Mode -eq 'Prepare') {
|
||||||
|
$before=CurrentFiles
|
||||||
|
VerifyFiles $before $oldHashes
|
||||||
|
$agent=LiveRole 'agent' $oldHashes.agent
|
||||||
|
$helper=LiveRole 'helper' $helperHash
|
||||||
|
$device=PreservedDevice
|
||||||
|
CheckControl (Split-Path $source) $true
|
||||||
|
CheckControl $source $false
|
||||||
|
if ((Hash $source) -cne $newHashes.agent) { throw 'Candidate absent or incorrect before preparation' }
|
||||||
|
[RmmTimeProfileCase]::CreatePrivateOnce($work)
|
||||||
|
CheckControl $work $true
|
||||||
|
PrepareFiles $before
|
||||||
|
Record 'prepared' ([ordered]@{id=$id;utc=[DateTime]::UtcNow.ToString('o');files=$before;device=$device;agent=$agent;helper=$helper})
|
||||||
|
Write-Output "Prepared passive pair $id"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
CheckControl $work $true
|
||||||
|
$prep=LoadRecord 'prepared'
|
||||||
|
if ($prep.id -cne $id -or !(JsonEqual $prep.device (PreservedDevice))) { throw 'Prepared case or preserved device changed' }
|
||||||
|
if ($Mode -eq 'InstallPassive') {
|
||||||
|
if (!(JsonEqual $prep.files (CurrentFiles)) -or !(JsonEqual $prep.agent (LiveRole 'agent' $oldHashes.agent)) -or
|
||||||
|
!(JsonEqual $prep.helper (LiveRole 'helper' $helperHash))) { throw 'Prepared baseline changed' }
|
||||||
|
foreach ($name in $locations.Keys) {
|
||||||
|
if ((Hash (Join-Path $work ('old-'+$name))) -cne $oldHashes.$name) { throw 'Recovery backup changed' }
|
||||||
|
}
|
||||||
|
foreach ($name in @('settings','pin')) {
|
||||||
|
if ((Hash (Join-Path $work ('new-'+$name))) -cne $newHashes.$name) { throw 'Prepared successor changed' }
|
||||||
|
}
|
||||||
|
CheckControl $source $false
|
||||||
|
if ((Hash $source) -cne $newHashes.agent) { throw 'New binary changed' }
|
||||||
|
Record 'install-intent' @{id=$id;utc=[DateTime]::UtcNow.ToString('o')}
|
||||||
|
StopKnownRole 'agent' $agentName $prep.agent 'install'
|
||||||
|
StopKnownRole 'helper' $helperName $prep.helper 'install'
|
||||||
|
foreach ($name in $locations.Keys) {
|
||||||
|
$inputPath=Join-Path $work ('new-'+$name)
|
||||||
|
if ($name -eq 'agent') { $inputPath=$source }
|
||||||
|
SwapFile $name $inputPath $prep.files.$name $newHashes.$name 'install'
|
||||||
|
}
|
||||||
|
VerifyFiles (CurrentFiles) $newHashes
|
||||||
|
StartKnownRole 'helper' $helperName $helperHash 'install'
|
||||||
|
StartKnownRole 'agent' $agentName $newHashes.agent 'install'
|
||||||
|
$a=LiveRole 'agent' $newHashes.agent
|
||||||
|
$h=LiveRole 'helper' $helperHash
|
||||||
|
if (!(JsonEqual $prep.device (PreservedDevice))) { throw 'Device changed after passive restart' }
|
||||||
|
Record 'installed' ([ordered]@{id=$id;utc=[DateTime]::UtcNow.ToString('o');agent=$a;helper=$h;files=(CurrentFiles);device=$prep.device;job_mode=$false;clock_qualified=$false})
|
||||||
|
Write-Output "Installed passive pair $id"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
# An explicit recovery is valid only before publishing any successor time profile
|
||||||
|
# or enabling jobs. Verify all present files against the two known generations.
|
||||||
|
$null=LoadRecord 'install-intent'
|
||||||
|
$observed=CurrentFiles
|
||||||
|
foreach ($name in $locations.Keys) {
|
||||||
|
$hash=$observed.$name.sha256
|
||||||
|
if ($hash -cnotin @($oldHashes.$name,$newHashes.$name) -or
|
||||||
|
(Hash (Join-Path $work ('old-'+$name))) -cne $oldHashes.$name) { throw "Unknown recovery input $name" }
|
||||||
|
}
|
||||||
|
Record 'restore-intent' @{id=$id;utc=[DateTime]::UtcNow.ToString('o')}
|
||||||
|
foreach ($role in @('agent','helper')) {
|
||||||
|
$service=(Service $role)
|
||||||
|
$name=$agentName
|
||||||
|
$imageHash=$observed.agent.sha256
|
||||||
|
if ($role -eq 'helper') { $name=$helperName; $imageHash=$helperHash }
|
||||||
|
if ($service.state -ceq 'Running') { StopKnownRole $role $name (LiveRole $role $imageHash) 'restore' }
|
||||||
|
elseif ($service.state -cne 'Stopped') { throw "Unknown service transition $role" }
|
||||||
|
}
|
||||||
|
StopCheck
|
||||||
|
foreach ($name in $locations.Keys) {
|
||||||
|
if ($observed.$name.sha256 -cne $oldHashes.$name) {
|
||||||
|
SwapFile $name (Join-Path $work ('old-'+$name)) $observed.$name $oldHashes.$name 'restore'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VerifyFiles (CurrentFiles) $oldHashes
|
||||||
|
StartKnownRole 'helper' $helperName $helperHash 'restore'
|
||||||
|
StartKnownRole 'agent' $agentName $oldHashes.agent 'restore'
|
||||||
|
Record 'restored' @{id=$id;agent=(LiveRole 'agent' $oldHashes.agent);helper=(LiveRole 'helper' $helperHash)}
|
||||||
|
Write-Output "Restored passive predecessor $id"
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
#requires -Version 5.1
|
||||||
|
#requires -RunAsAdministrator
|
||||||
|
[CmdletBinding()]
|
||||||
|
param()
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
function Assert-PrivateUnitPath([string]$Path, [bool]$Directory) {
|
||||||
|
$item = Get-Item -LiteralPath $Path -Force
|
||||||
|
if ($item.PSIsContainer -ne $Directory -or ($item.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
|
||||||
|
throw 'Unexpected unit path type'
|
||||||
|
}
|
||||||
|
$acl = Get-Acl -LiteralPath $Path
|
||||||
|
$trusted = @('S-1-5-18', 'S-1-5-32-544')
|
||||||
|
$sidType = [Security.Principal.SecurityIdentifier]
|
||||||
|
if ($acl.GetOwner($sidType).Value -notin $trusted) { throw 'Unexpected unit path owner' }
|
||||||
|
$rules = @($acl.GetAccessRules($true, $true, $sidType))
|
||||||
|
if (!$rules.Count) { throw 'Missing unit path ACL' }
|
||||||
|
foreach ($rule in $rules) {
|
||||||
|
if ($rule.AccessControlType -ne 'Allow' -or $rule.IdentityReference.Value -notin $trusted) {
|
||||||
|
throw 'Unexpected unit path ACL'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$bootstrap = 'C:\ProgramData\RustDiscoveryBootstrap'
|
||||||
|
$unit = Join-Path $PSScriptRoot 'rmm_agent_windows-9b3e91d827c6ff16.exe'
|
||||||
|
$unitHash = '7d1715dc105c1eb482405511e1b3abf4437c448e186e73923c43dd3c7938710e'
|
||||||
|
$test = 'runtime::tests::remote_signed_requires_explicit_profile_jobs_and_binding'
|
||||||
|
if ((Split-Path -Parent $PSScriptRoot) -ne $bootstrap) { throw 'Private bootstrap directory required' }
|
||||||
|
Assert-PrivateUnitPath $bootstrap $true
|
||||||
|
Assert-PrivateUnitPath $PSScriptRoot $true
|
||||||
|
Assert-PrivateUnitPath $PSCommandPath $false
|
||||||
|
Assert-PrivateUnitPath $unit $false
|
||||||
|
foreach ($entry in (Get-ChildItem -LiteralPath $PSScriptRoot -Force)) {
|
||||||
|
if ($entry.Name -notin @([IO.Path]::GetFileName($PSCommandPath), [IO.Path]::GetFileName($unit))) {
|
||||||
|
throw 'Unit staging directory must contain only the runner and the unit executable'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$system32 = [Environment]::SystemDirectory
|
||||||
|
$shell = Join-Path $system32 'WindowsPowerShell\v1.0\powershell.exe'
|
||||||
|
if (![Environment]::Is64BitProcess -or [Diagnostics.Process]::GetCurrentProcess().MainModule.FileName -ne $shell -or
|
||||||
|
$PSVersionTable.PSEdition -ne 'Desktop' -or $PSVersionTable.PSVersion.Major -ne 5 -or $PSVersionTable.PSVersion.Minor -ne 1) {
|
||||||
|
throw 'Run with the installed 64-bit Windows PowerShell 5.1'
|
||||||
|
}
|
||||||
|
$policies = [ordered]@{}
|
||||||
|
foreach ($scope in 'MachinePolicy','UserPolicy','Process','CurrentUser','LocalMachine') {
|
||||||
|
$policies[$scope] = [string](Microsoft.PowerShell.Security\Get-ExecutionPolicy -Scope $scope)
|
||||||
|
}
|
||||||
|
|
||||||
|
$handle = [IO.File]::Open($unit, 'Open', 'Read', 'Read')
|
||||||
|
try {
|
||||||
|
$hasher = [Security.Cryptography.SHA256]::Create()
|
||||||
|
try { $actual = [BitConverter]::ToString($hasher.ComputeHash($handle)).Replace('-','').ToLowerInvariant() }
|
||||||
|
finally { $hasher.Dispose() }
|
||||||
|
if ($actual -cne $unitHash -or $handle.Length -ne 18608199) { throw 'Unexpected unit executable' }
|
||||||
|
$start = New-Object Diagnostics.ProcessStartInfo
|
||||||
|
$start.FileName = $unit
|
||||||
|
$start.Arguments = "--exact $test --test-threads=1 --color never"
|
||||||
|
$start.WorkingDirectory = $PSScriptRoot
|
||||||
|
$start.UseShellExecute = $false
|
||||||
|
$start.CreateNoWindow = $true
|
||||||
|
$start.RedirectStandardOutput = $true
|
||||||
|
$start.RedirectStandardError = $true
|
||||||
|
$start.EnvironmentVariables.Clear()
|
||||||
|
$windows = Split-Path -Parent $system32
|
||||||
|
$start.EnvironmentVariables['SystemRoot'] = $windows
|
||||||
|
$start.EnvironmentVariables['WINDIR'] = $windows
|
||||||
|
$start.EnvironmentVariables['SystemDrive'] = [IO.Path]::GetPathRoot($windows).TrimEnd('\')
|
||||||
|
$start.EnvironmentVariables['PATH'] = $system32
|
||||||
|
$proc = [Diagnostics.Process]::Start($start)
|
||||||
|
try {
|
||||||
|
$stdout = $proc.StandardOutput.ReadToEndAsync()
|
||||||
|
$stderr = $proc.StandardError.ReadToEndAsync()
|
||||||
|
if (!$proc.WaitForExit(30000)) {
|
||||||
|
$proc.Kill()
|
||||||
|
throw 'Fixed unit test timed out'
|
||||||
|
}
|
||||||
|
if (!$stdout.Wait(2000) -or !$stderr.Wait(2000) -or $proc.ExitCode -ne 0 -or $stderr.Result.Length -gt 0) {
|
||||||
|
throw 'Fixed unit test failed'
|
||||||
|
}
|
||||||
|
$lines = @($stdout.Result -split '\r?\n' | Where-Object { $_ })
|
||||||
|
if ($lines.Count -ne 3 -or $lines[0] -cne 'running 1 test' -or $lines[1] -cne "test $test ... ok" -or
|
||||||
|
$lines[2] -cnotmatch '^test result: ok\. 1 passed; 0 failed; 0 ignored; 0 measured; (\d+) filtered out; finished in \d+(?:\.\d+)?s$') {
|
||||||
|
throw 'Unexpected test result or filter count'
|
||||||
|
}
|
||||||
|
$filtered = [int]$Matches[1]
|
||||||
|
} finally { $proc.Dispose() }
|
||||||
|
} finally { $handle.Dispose() }
|
||||||
|
|
||||||
|
[ordered]@{
|
||||||
|
observed_at = [DateTimeOffset]::UtcNow.ToString('o')
|
||||||
|
unit_sha256 = $actual
|
||||||
|
test_name = $test
|
||||||
|
passed = 1
|
||||||
|
filtered_out = $filtered
|
||||||
|
powershell_path = $shell
|
||||||
|
powershell_sha256 = (Get-FileHash -LiteralPath $shell -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||||
|
powershell_version = $PSVersionTable.PSVersion.ToString()
|
||||||
|
admin_host_policy_scopes = $policies
|
||||||
|
} | ConvertTo-Json -Depth 3 -Compress
|
||||||
@@ -27,70 +27,7 @@ SECOND_NS = 1_000_000_000
|
|||||||
# No report is requested from a service. The only content reads on the guest
|
# No report is requested from a service. The only content reads on the guest
|
||||||
# are these two public JSONs and public executable hashes. CIM/process queries
|
# are these two public JSONs and public executable hashes. CIM/process queries
|
||||||
# obtain current boot/SCM/image/birth metadata without starting another binary.
|
# obtain current boot/SCM/image/birth metadata without starting another binary.
|
||||||
SCRIPT = r'''$ErrorActionPreference='Stop';$p=([Console]::In.ReadLine()|ConvertFrom-Json)
|
SCRIPT = Path(__file__).with_name('Read-PassiveTimeSamples.ps1').read_text(encoding='utf-8')
|
||||||
if((($p.PSObject.Properties.Name|Sort-Object)-join',')-cne'agent_sha256,helper_sha256,id'-or[guid]::ParseExact($p.id,'D').ToString()-cne$p.id-or$p.agent_sha256-cnotmatch'^[0-9a-f]{64}$'-or$p.helper_sha256-cnotmatch'^[0-9a-f]{64}$'){throw 'Fixed public sample read'}
|
|
||||||
$state='C:\ProgramData\RustDiscovery\state';$agent='RmmDiscoveryWindows';$helper='RmmDiscoverySystemHelper'
|
|
||||||
$agentSid=(New-Object Security.Principal.NTAccount('NT SERVICE',$agent)).Translate([Security.Principal.SecurityIdentifier]).Value
|
|
||||||
$allowed=@('S-1-5-18','S-1-5-32-544',$agentSid)
|
|
||||||
function Check($path,[bool]$directory){
|
|
||||||
$i=Get-Item -LiteralPath $path -Force
|
|
||||||
if($i.PSIsContainer-ne$directory-or($i.Attributes-band[IO.FileAttributes]::ReparsePoint)){throw 'Regular public report path'}
|
|
||||||
$ancestor=$i.Directory;if($directory){$ancestor=$i.Parent};while($null-ne$ancestor){if($ancestor.Attributes-band[IO.FileAttributes]::ReparsePoint){throw 'Public report reparse ancestry'};$ancestor=$ancestor.Parent}
|
|
||||||
$acl=Get-Acl -LiteralPath $path;$owner=$acl.GetOwner([Security.Principal.SecurityIdentifier]).Value
|
|
||||||
if($owner-cnotin$allowed-and!(!$directory-and$owner-ceq'S-1-5-19')){throw 'Public report owner'}
|
|
||||||
$rules=@($acl.GetAccessRules($true,$true,[Security.Principal.SecurityIdentifier]));if(!$rules.Count){throw 'Public report empty DACL'}
|
|
||||||
foreach($r in $rules){if($r.AccessControlType-ne'Allow'-or$r.IdentityReference.Value-cnotin$allowed){throw 'Public report broad DACL'}}
|
|
||||||
if($directory-and!$acl.AreAccessRulesProtected){throw 'Protected public report directory'}
|
|
||||||
return @{owner_sid=$owner;sddl=$acl.Sddl;dacl_checked=$true}
|
|
||||||
}
|
|
||||||
Add-Type -TypeDefinition @'
|
|
||||||
using System; using System.Text; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles;
|
|
||||||
public static class RmmPassiveTimeRead {
|
|
||||||
[StructLayout(LayoutKind.Sequential)] public struct Info {public uint Attr,CL,CH,AL,AH,WL,WH,Volume,SizeH,SizeL,Links,IndexH,IndexL;}
|
|
||||||
[DllImport("kernel32.dll",SetLastError=true)] public static extern bool GetFileInformationByHandle(SafeFileHandle h,out Info i);
|
|
||||||
[DllImport("kernel32.dll",SetLastError=true)] static extern IntPtr OpenProcess(uint access,bool inherit,int pid);
|
|
||||||
[DllImport("kernel32.dll",SetLastError=true,CharSet=CharSet.Unicode)] static extern bool QueryFullProcessImageName(IntPtr h,uint flags,StringBuilder text,ref uint size);
|
|
||||||
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetProcessTimes(IntPtr h,out long creation,out long exit,out long kernel,out long user);
|
|
||||||
[DllImport("kernel32.dll",SetLastError=true)] static extern bool GetExitCodeProcess(IntPtr h,out uint code);
|
|
||||||
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr h);
|
|
||||||
public static string[] Process(int pid){IntPtr h=OpenProcess(0x1000,false,pid);if(h==IntPtr.Zero)throw new InvalidOperationException("QUERY_PROCESS");try{long c,e,k,u;uint code,size=32768;StringBuilder image=new StringBuilder((int)size);if(!GetProcessTimes(h,out c,out e,out k,out u)||!QueryFullProcessImageName(h,0,image,ref size)||!GetExitCodeProcess(h,out code)||code!=259)throw new InvalidOperationException("LIVE_PROCESS");return new string[]{c.ToString(System.Globalization.CultureInfo.InvariantCulture),image.ToString()};}finally{CloseHandle(h);}}
|
|
||||||
}
|
|
||||||
'@
|
|
||||||
function Hash([byte[]]$bytes){$h=[Security.Cryptography.SHA256]::Create();try{return([BitConverter]::ToString($h.ComputeHash($bytes))).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()}}
|
|
||||||
function Runtime($role){
|
|
||||||
$name=$agent;$image='C:\Program Files\RustDiscovery\rmm-agent-windows.exe';$owner='NT AUTHORITY\LocalService';$mode='Auto';$sha=$p.agent_sha256
|
|
||||||
if($role-ceq'helper'){$name=$helper;$image='C:\Program Files\RustDiscovery\rmm-helper-windows.exe';$owner='LocalSystem';$mode='Manual';$sha=$p.helper_sha256}
|
|
||||||
$s=Get-CimInstance Win32_Service -Filter ("Name='"+$name+"'") -OperationTimeoutSec 5
|
|
||||||
if(!$s-or$s.State-cne'Running'-or$s.StartName-cne$owner-or$s.StartMode-cne$mode-or$s.ProcessId-le0-or$s.ServiceType-cne'Own Process'){throw 'Current fixed service role'}
|
|
||||||
$expected='"'+$image+'" --service';if($role-ceq'agent'){$expected+=' --config "C:\ProgramData\RustDiscovery\config.json"'}
|
|
||||||
if($s.PathName-cne$expected){throw 'Current fixed service command'}
|
|
||||||
$native=[RmmPassiveTimeRead]::Process([int]$s.ProcessId)
|
|
||||||
if($native[1]-cne$image-or(Get-FileHash -LiteralPath $image -Algorithm SHA256).Hash.ToLowerInvariant()-cne$sha){throw 'Current fixed service image'}
|
|
||||||
return [ordered]@{pid=[uint32]$s.ProcessId;birth_filetime=$native[0];image=$native[1];sha256=$sha;start_name=$s.StartName;start_mode=$s.StartMode;command=$s.PathName}
|
|
||||||
}
|
|
||||||
function Boot{return (Get-CimInstance Win32_OperatingSystem -Property LastBootUpTime -OperationTimeoutSec 5).LastBootUpTime.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture)}
|
|
||||||
$null=Check 'C:\ProgramData\RustDiscovery' $true;$directory=Check $state $true
|
|
||||||
$boot=Boot;$before=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')};$reports=[ordered]@{}
|
|
||||||
foreach($name in @('agent-time-sample.json','helper-time-sample.json')){
|
|
||||||
$path=Join-Path $state $name
|
|
||||||
if(!(Test-Path -LiteralPath $path)){$reports[$name]=$null;continue}
|
|
||||||
$stream=[IO.File]::Open($path,[IO.FileMode]::Open,[IO.FileAccess]::Read,[IO.FileShare]::Read)
|
|
||||||
try{
|
|
||||||
$meta=Check $path $false;$info=New-Object RmmPassiveTimeRead+Info
|
|
||||||
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$info)-or$info.Links-ne1-or($info.Attr-band0x410)-ne0-or$info.SizeH-ne0-or$info.SizeL-lt1-or$info.SizeL-gt8192-or$stream.Length-ne$info.SizeL){throw 'Single-link bounded public report'}
|
|
||||||
$raw=New-Object byte[] $info.SizeL;$offset=0;while($offset-lt$raw.Length){$count=$stream.Read($raw,$offset,$raw.Length-$offset);if($count-le0){throw 'Complete held public report'};$offset+=$count}
|
|
||||||
$after=New-Object RmmPassiveTimeRead+Info
|
|
||||||
if(![RmmPassiveTimeRead]::GetFileInformationByHandle($stream.SafeFileHandle,[ref]$after)-or$after.IndexH-ne$info.IndexH-or$after.IndexL-ne$info.IndexL-or$after.WH-ne$info.WH-or$after.WL-ne$info.WL-or$after.SizeL-ne$info.SizeL-or$after.Links-ne1){throw 'Stable held public report'}
|
|
||||||
$again=Check $path $false;if($again.sddl-cne$meta.sddl-or$again.owner_sid-cne$meta.owner_sid){throw 'Stable public report security'}
|
|
||||||
$meta['volume']=$info.Volume;$meta['index_high']=$info.IndexH;$meta['index_low']=$info.IndexL;$meta['last_write_filetime']=(([uint64]$info.WH-shl32)-bor$info.WL).ToString([Globalization.CultureInfo]::InvariantCulture)
|
|
||||||
$reports[$name]=@{raw_base64=[Convert]::ToBase64String($raw);sha256=(Hash $raw);metadata=$meta}
|
|
||||||
}finally{$stream.Dispose()}
|
|
||||||
}
|
|
||||||
$after=[ordered]@{agent=(Runtime 'agent');helper=(Runtime 'helper')}
|
|
||||||
$directoryAfter=Check $state $true
|
|
||||||
if(($before|ConvertTo-Json -Depth 8 -Compress)-cne($after|ConvertTo-Json -Depth 8 -Compress)-or(Boot)-cne$boot-or$directory.sddl-cne$directoryAfter.sddl){throw 'Stable process, directory and boot during public read'}
|
|
||||||
@{id=$p.id;read_only=$true;boot_ticks=$boot;runtime=$after;state_metadata=$directory;reports=$reports;observed_at=[DateTime]::UtcNow.ToString('o')}|ConvertTo-Json -Depth 12 -Compress
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
def need(value, tag):
|
def need(value, tag):
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# Migration0016: passives Updateinventar annehmen
|
||||||
|
|
||||||
|
Am2026-11-15 ist Migration0016 tatsächlich auf dem permanenten Server mit dem
|
||||||
|
regulären SQLx-Migrationspfad ausgeführt und separat nachgelesen worden. Der
|
||||||
|
bisherige Check `observations_source_id_check` ließ nur `linux.base` und
|
||||||
|
`windows.base` zu. Die laufende Gatewayversion kannte bereits die passive
|
||||||
|
`agent.update`-Beobachtung; der Datenbankcheck verweigerte deren Speicherung.
|
||||||
|
Nach dem neuen Windowsagentenwechsel waren15 entsprechende Fehler beobachtet
|
||||||
|
worden. Diese verweigerten Nachrichten werden nicht nachträglich als gespeichert
|
||||||
|
ausgegeben.
|
||||||
|
|
||||||
|
Die additive Datei `migrations/0016_agent_update_observation_scope.sql` erweitert
|
||||||
|
ausschließlich diese feste Dreiermenge. Freie Scopes bleiben verboten. Im
|
||||||
|
normalen SQLx-Transactionrahmen wird der alte Check ersetzt und der neue Check
|
||||||
|
validiert; ein Fehler rollt die Transaktion zurück. `lock_timeout=3s` begrenzt
|
||||||
|
das Warten auf Tabellenlocks, `statement_timeout=15s` jedes DDL-Statement.
|
||||||
|
Keine DML-, RLS-, FK-, PK-, Tenant-/Geräte-/Zertifikats-, Job-, Grant- oder
|
||||||
|
Policyänderung gehört zur Migration.
|
||||||
|
|
||||||
|
Tatsächlicher Fall: `cc3ea56d-6186-425a-8ef3-90562212fb1b`. Verwendet wurde das
|
||||||
|
bereits vom Orchestrator nativ ARM64 gebaute Image
|
||||||
|
`sha256:6a76343bf65c126458244f5540d4cb740988144fc77877b409f790251e7ddcc7`.
|
||||||
|
Es enthält den vorhandenen `rmm-server migrate`-Entrypoint und die echte
|
||||||
|
SQLx-`migrate!`-Migrationseinbettung. Es wurde kein zusätzlicher Builderlauf
|
||||||
|
gestartet und keine SQLx-Tabellenzeile manuell angelegt oder geändert.
|
||||||
|
|
||||||
|
Ein eigenes privates Compose-Overlay wählte ausschließlich für den temporären
|
||||||
|
`migrate`-Container dieses bereits vorhandene Image (`pull_policy: never`,
|
||||||
|
read-only RootFS, CapDropALL, NoNewPrivileges). Die vorhandene Migration-URL
|
||||||
|
blieb im normalen Compose-/Prozesskontext; sie wurde nicht ausgegeben. Der
|
||||||
|
unterstützte `docker compose … run --no-deps … migrate` führte genau einen
|
||||||
|
wirklichen SQLx-Lauf aus, Exit0. Der eigene gestoppte Container wurde nach
|
||||||
|
seinem Exit-/Image-/Falllabelbeleg entfernt. Kein API-, Gateway- oder
|
||||||
|
PostgreSQLdienst wurde durch diesen Agenten ersetzt oder neu gestartet.
|
||||||
|
API-Filterung und API-only-Deployment sind ein eigener Orchestratorschnitt.
|
||||||
|
|
||||||
|
Die tatsächliche SQLx-Historie besitzt danach Versionen1–16 jeweils mit
|
||||||
|
`success=true`; die alten15 Checksums stimmen unverändert mit den Quellinputs
|
||||||
|
überein. Version16 heißt `agent update observation scope` und besitzt SHA384
|
||||||
|
`e66ec49233c210555b5107d20b925ca6715925871aa2bf94dfb86bd5cfb39c6dc769fdf0049b615fcad503332e1cd8fc`.
|
||||||
|
Die SQL-Datei hat SHA256
|
||||||
|
`fa0953262e3a8da7f3f0366db6f3fa77ad7976ec04327b126036739eea46eebb`.
|
||||||
|
|
||||||
|
Vor dem echten SQLx-Start wurden3127 bestehende Observationzeilen serverseitig
|
||||||
|
über ihre vollständige JSON-Zeilendarstellung gehasht; unmittelbar danach waren alle
|
||||||
|
unverändert. Der ursprüngliche Fallbaseline enthielt3123Zeilen. Deren
|
||||||
|
unveränderte Fingerprints und die vollständige RLS-/Owner-/ACL-/Policy-,
|
||||||
|
FK-/PK-/sonstige Check- und Job-/Plan-/Authorization-/Outbox-/Permit-/Receipt-
|
||||||
|
Zeugen wurden nochmals in einem getrennten Read-only-SQL-Aufruf bestätigt.
|
||||||
|
Neue passive Zeilen durften parallel regulär hinzukommen. Die neue Constraint
|
||||||
|
war tatsächlich `VALIDATED` und enthielt genau
|
||||||
|
`linux.base`, `windows.base`, `agent.update`. API und Gateway liefen während
|
||||||
|
dieser Migration unverändert mit Image422c2c28; PostgreSQL behielt seine
|
||||||
|
ursprüngliche Container-/Imageidentität.
|
||||||
|
|
||||||
|
Ein weiterer lesender Serverabgleich fand bereits drei angenommene
|
||||||
|
`agent.update`-Zeilen, zuletzt15:40:50UTC. Das beweist die normale Speicherung
|
||||||
|
dieses Scopes nach der Migration, keinen separat geprüften Windows-ACK,
|
||||||
|
keine neue Basisinventarabnahme und keine Zeit-/Jobbereitschaft.
|
||||||
|
|
||||||
|
Die Vorherarchive enthalten Katalog-/Migrations-/Policyzeugen und
|
||||||
|
Zeilenfingerprints; ein vollständiger **Vorher-`pg_dump` wurde nicht angelegt**.
|
||||||
|
Ein vollständiger privater Customformat-Dump wurde ausdrücklich **nach** der
|
||||||
|
Migration archiviert: `after-migration-0016.pg_dump`,49,455,447Bytes, SHA256
|
||||||
|
`b89e74eaaea7ec2faa17a44358acca3aead1db0fcf9ccf673e2c5808b3259398`.
|
||||||
|
Er bleibt ausschließlich im Root0700-Fall auf dem Server, Datei0600, und wurde
|
||||||
|
nicht heruntergeladen oder als Vorherbackup bezeichnet. Ein Restoretest wurde
|
||||||
|
hier nicht ausgeführt.
|
||||||
|
|
||||||
|
Zwei harmlose Vorbedingungen scheiterten vor dem eigentlichen SQLx-Lauf und
|
||||||
|
bleiben erhalten: zunächst die Annahme eines vollständigen Buildkontexts
|
||||||
|
statt des tatsächlichen Minimal-Kontexts; danach ein hier nicht unterstütztes
|
||||||
|
Compose-Flag `--no-build`. Für letzteren Fall waren Exit1, Ledger15 und die
|
||||||
|
Abwesenheit eines eigenen Containers belegt. Nach Roots konkreter Korrektur
|
||||||
|
wurde derselbe Originalfall mit einem neuen Create-only-Fortsetzungsintent
|
||||||
|
verwendet; alte Fehler-/Vorherdateien wurden nicht überschrieben. Ein weiterer
|
||||||
|
reiner Absenzmatcher wurde an die tatsächliche Kleinschreibung der Docker-
|
||||||
|
Fehlermeldung angepasst, ebenfalls vor jedem Container-/SQLx-Start. Keine
|
||||||
|
verlorene SQLx-Wirkung wurde blind wiederholt.
|
||||||
|
|
||||||
|
Geschütztes Serverarchiv:
|
||||||
|
`/opt/rust-discovery/devstate/observation-scope-migration-cc3ea56d-6186-425a-8ef3-90562212fb1b/`.
|
||||||
|
Lokaler Belegordner im eigenen Worktree:
|
||||||
|
`devstate/observation-scope-migration/cc3ea56d-6186-425a-8ef3-90562212fb1b/`.
|
||||||
|
Die separate lokale `receipt.json` bindet Originalintent, Fehler, tatsächlichen
|
||||||
|
SQLx-Erfolg, getrennten Read und Nachbackup; SHA256
|
||||||
|
`00ff8f8ffa689bf3917937ce14ae23457e464b921ae7793e9091eab9a83d76c7`.
|
||||||
|
Private Zugangsdaten und
|
||||||
|
Datenbankinhalte wurden weder veröffentlicht noch in Git aufgenommen.
|
||||||
+26
-8
@@ -16,15 +16,33 @@ nach dem Wechsel gelang. Danach wies PostgreSQL den passiven Updatestatus
|
|||||||
gefilterte Basisinventarabfrage und Migration 16 aus dem zum laufenden
|
gefilterte Basisinventarabfrage und Migration 16 aus dem zum laufenden
|
||||||
ARM64-Image passenden Builder offline gebaut. Docker meldete Exit 0 für
|
ARM64-Image passenden Builder offline gebaut. Docker meldete Exit 0 für
|
||||||
Image `6a76343bf65c` (Buildfall `5ad7c74c-67a1-40b8-8960-d3ba016565af`).
|
Image `6a76343bf65c` (Buildfall `5ad7c74c-67a1-40b8-8960-d3ba016565af`).
|
||||||
[Dienstwechsel und Inventarabfrage](windows-signed-clock-upgrade-plan.md)
|
Die Migration lief anschließend erfolgreich. Die API arbeitet mit diesem
|
||||||
|
Image. MCP bestätigte zwei neue Windows-Heartbeats um **16:39:46 und
|
||||||
|
16:40:17 Uhr MEZ**, jeweils mit derselben Geräte- und Zertifikatsidentität wie
|
||||||
|
vor dem Dienstwechsel. Die Cloud-Linux-VM meldete sich weiterhin als online.
|
||||||
|
[Dienstwechsel und Telemetrienachweis](windows-signed-clock-upgrade-plan.md)
|
||||||
|
|
||||||
Die Zeitprofilinstallation scheiterte beim Veröffentlichen der Datei mit einer
|
Die Erstinstallation des Windows-Zeitprofils ist auf der VM belegt. Der Server empfing zunächst um
|
||||||
`IOException`. Eine separate Abfrage auf der VM bestätigte, dass die Zieldatei
|
17:05:36 Uhr MEZ den Fehlercode `0x80070020` beim Verschieben in das
|
||||||
fehlte und die Dienste weiterliefen. Das SSH-Fenster endete um 16:30 Uhr MEZ.
|
Zielverzeichnis. Der Helper hält dort einen Verzeichnishandle, der diesen
|
||||||
Für die nächste Gastprüfung muss der bestehende Teilzustand berücksichtigt
|
Schreibzugriff sperrt. Im korrigierten Quellstand erlauben die Handles für
|
||||||
werden. Die Zeitprüfung in beiden installierten Rollen und der erste über die
|
das öffentliche Verzeichnis diesen Zugriff. Löschsperre, DACL- und
|
||||||
WebUI genehmigte PowerShell-Auftrag stehen aus.
|
Dateiidentitätsprüfungen bleiben aktiv. Agent und Helper wurden damit für
|
||||||
[Zeitprofil und Originalbefund](windows-time-profile-config.md)
|
Windows x86-64 gebaut; dieser Build ist noch nicht auf der VM installiert
|
||||||
|
oder dort abgenommen. Beim anschließenden Versuch um 20:24 Uhr MEZ konnte der Gast
|
||||||
|
die neue Zieldatei öffnen. Der Sicherheitsdeskriptor entsprach beim Lesen
|
||||||
|
nicht exakt dem erwarteten Wert. Der Controller stoppte vor dem Schreiben
|
||||||
|
der Profilbytes. Die anschließende Konsolenlesung bestätigte 0 Byte.
|
||||||
|
Eigentümer, Gruppe, DACL-Schutz und alle sechs expliziten Zugriffsregeln
|
||||||
|
stimmten überein. Nur das DACL-Steuerbit für automatische Vererbung (`AI`)
|
||||||
|
fehlte im gelesenen Deskriptor. Um 20:40 Uhr MEZ gelang der Abschluss.
|
||||||
|
Der Gast las die 1177 Profilbytes mit dem erwarteten SHA-256 und derselben
|
||||||
|
Dateikennung zurück, die er vor dem Schreiben festgehalten hatte.
|
||||||
|
Um 20:41 Uhr MEZ bestätigte der Projektserver die ersten zwei getrennten
|
||||||
|
signierten Zeitvergleiche des laufenden Agenten und SYSTEM-Helpers.
|
||||||
|
Die Windows-Skript- und Paketabnahmen stehen aus.
|
||||||
|
[Zeitbelege beider Dienste](windows-passive-time-closeout.md)
|
||||||
|
[VM-Fehlerbeleg und Buildprüfung](windows-time-profile-config.md)
|
||||||
|
|
||||||
Die passive Zertifikatserneuerung ist implementiert. Fünf Wiederanlauf- und
|
Die passive Zertifikatserneuerung ist implementiert. Fünf Wiederanlauf- und
|
||||||
Fehlerfälle mit Testidentitäten bestanden auch auf Windows. Das Anlegen,
|
Fehlerfälle mit Testidentitäten bestanden auch auf Windows. Das Anlegen,
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
# Tatsächlicher Implementierungsstand
|
# Tatsächlicher Implementierungsstand
|
||||||
|
|
||||||
|
## Agent-Update-Telemetrie: Migration0016 tatsächlich angewendet — 2026-11-15
|
||||||
|
|
||||||
|
Der permanente Server akzeptiert nun zusätzlich den festen passiven Scope
|
||||||
|
`agent.update`. Regulärer SQLx-Runner aus dem vorhandenen ARM64-Kandidaten6a7634,
|
||||||
|
Exit0 und separate Read-only-Nachprüfung von Version16/Checksum/VALIDATED-Check
|
||||||
|
bestanden. Ursprüngliche Zeilen, RLS/FKs/PK/ACL und Corezeugen erhalten; keine
|
||||||
|
laufenden Dienste durch diesen Schnitt ersetzt. Erste drei regulär angenommene
|
||||||
|
Updatebeobachtungen belegt. API-Basisfilterung ist getrennt. Vorherfingerprints
|
||||||
|
und ausdrücklich erst nachher angelegter privater pg_dump sind dokumentiert;
|
||||||
|
kein vorgetäuschter Vorherbackup-/Restoretest. [Beleg](agent-update-observation-scope.md).
|
||||||
|
|
||||||
## Passiver Windows-Zeitabschluss vorbereitet — 2026-11-15
|
## Passiver Windows-Zeitabschluss vorbereitet — 2026-11-15
|
||||||
|
|
||||||
Ein kleiner rein lesender Collector für die beiden historischen Rollenbelege
|
Ein kleiner rein lesender Collector für die beiden historischen Rollenbelege
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Lesender Abschluss zweier passiver Windows-Zeitbeobachtungen
|
# Lesender Abschluss zweier passiver Windows-Zeitbeobachtungen
|
||||||
|
|
||||||
Der Collector `deploy/windows/passive_time_closeout.py` ist lokal vorbereitet
|
Der Collector `deploy/windows/passive_time_closeout.py` ist lokal vorbereitet
|
||||||
und ausführbar. **Noch kein Zielaufruf oder nativer Abschlussnachweis.** Die
|
und ausführbar. Der native Abschluss über den auf dem Server laufenden Empfänger ist unten dokumentiert. Die
|
||||||
V2-Profileinrichtung und ihr ausdrücklich gemeldetes Zeitfenster stehen vor
|
V2-Profileinrichtung und ihr ausdrücklich gemeldetes Zeitfenster stehen vor
|
||||||
dem Aufruf. Tunnel-/Zugangserneuerung, Profileinrichtung und Dienstwartung sind
|
dem Aufruf. Tunnel-/Zugangserneuerung, Profileinrichtung und Dienstwartung sind
|
||||||
keine Aktionen dieses Collectors.
|
keine Aktionen dieses Collectors.
|
||||||
@@ -129,3 +129,23 @@ Pipeeingrenzung helfen. Sie enthalten keinen vollständigen Timeworkerfehler;
|
|||||||
auch Metadaten vorhandener fester `.agent-time.pending`/`.helper-time.pending`
|
auch Metadaten vorhandener fester `.agent-time.pending`/`.helper-time.pending`
|
||||||
können eine unterbrochene Publikation erklären. Dieser Collector liest oder
|
können eine unterbrochene Publikation erklären. Dieser Collector liest oder
|
||||||
ändert diese zusätzlichen Dateien nicht und löst keine Diagnose aus.
|
ändert diese zusätzlichen Dateien nicht und löst keine Diagnose aus.
|
||||||
|
|
||||||
|
### Nativer Abschluss am 15. November 2026
|
||||||
|
|
||||||
|
Der Empfänger auf dem permanenten Server prüfte um **20:41:27 Uhr MEZ**
|
||||||
|
beide nach der Veröffentlichung des Profils entstandenen Belege. Der Agent
|
||||||
|
beobachtete seinen Vergleich um `19:40:52.455414900Z`, der SYSTEM-Helper
|
||||||
|
seinen um `19:40:52.524631100Z`. Beide gehörten zu Verbindungsgeneration 145
|
||||||
|
und demselben Windows-Boot. Verifier-UUIDs und die Hashes der beiden
|
||||||
|
Anfragen und Antworten unterschieden sich. Der Agent hatte PID 4420, der
|
||||||
|
Helper PID 10264. Die Serverzeugen vor und nach der Lesung stimmten überein.
|
||||||
|
|
||||||
|
Fall `c23245b7-017e-4643-9872-849f262faf21`, Lesung 36. Der SHA-256 des
|
||||||
|
empfangenen Datensatzes lautet
|
||||||
|
`40d45a9cb3145f8b1159b7c5da0509dd043355aca23d4bec860f37205e3a8551`,
|
||||||
|
der des Abschlussbelegs
|
||||||
|
`f1a79eed223487fa61890ccb274986660b33f2596ae33e1689e9b2afdc7b8884`.
|
||||||
|
Beim separaten Rücklesen stimmten die zwei ursprünglichen Rollenberichte
|
||||||
|
mit den validierten Einträgen überein. Der Server führte weiterhin nur
|
||||||
|
`windows.base/1`, `heartbeat/1` und `agent.update/1`. Für einen späteren
|
||||||
|
Auftrag muss die Uhr beim Prüfen des Grants erneut die Frischegrenzen erfüllen.
|
||||||
|
|||||||
@@ -63,3 +63,119 @@ Produktquellen erzwingen keine neue native Ausführung und verhindern ihren
|
|||||||
Readback nicht. Neue Starts benötigen weiterhin die exakt qualifizierten
|
Readback nicht. Neue Starts benötigen weiterhin die exakt qualifizierten
|
||||||
aktuellen Quellen. Vollständige Ausgaben/Transportfehler bleiben privat,
|
aktuellen Quellen. Vollständige Ausgaben/Transportfehler bleiben privat,
|
||||||
Standardausgabe enthält nur Status, Fallkennung und Nachweishashes.
|
Standardausgabe enthält nur Status, Fallkennung und Nachweishashes.
|
||||||
|
|
||||||
|
### MCP-Planprüfung nach dem nativen Zeitvergleich am 15. November 2026
|
||||||
|
|
||||||
|
Um 20:44 Uhr MEZ las MCP die Windows-VM über ihre bestehende Geräteidentität
|
||||||
|
als online. Sie meldete über WSS weiterhin `windows.base/1`, `heartbeat/1`
|
||||||
|
und `agent.update/1`. Ein erster lesender Vorabcheck brach vor der Planung
|
||||||
|
ab, weil er für diese passive Verbindung fälschlich `sync_ready=false`
|
||||||
|
erwartete. Der Gateway setzt beim Hello ohne `rmm.sync.v1` den Wert
|
||||||
|
`sync_required=false` und damit `sync_ready=true`. Ein signierter
|
||||||
|
Job-Sync ist daraus nicht abzuleiten.
|
||||||
|
|
||||||
|
Um 20:44:47 Uhr MEZ wies `operations.plan` für genau diese Windows-VM eine
|
||||||
|
PowerShell-Ausgabe einer festen Textzeile unter `agent_service` mit dem Profil
|
||||||
|
`powershell_51_remote_signed` als `UNSUPPORTED_CAPABILITY` zurück. Der
|
||||||
|
Windows-Agent veröffentlicht weder die Skript- noch die Profilfähigkeit.
|
||||||
|
Vor und nach der Plananfrage standen Jobs, Outbox-Einträge, Ausführungspermits
|
||||||
|
und offene Jobs dieses Geräts jeweils auf null. Es erfolgte kein Submit.
|
||||||
|
MCP-Korrelations-ID `b87605ab-69ce-4697-b9ed-9f5b1eeba22c`,
|
||||||
|
Beleg-SHA-256 `0df80d11f7e0ef5e300c4c9657dca3850dad839582b3ba945c1e69795fc68ecc`.
|
||||||
|
|
||||||
|
Für die erste erfolgreiche Skriptabnahme braucht der Dienst die an das Gerät
|
||||||
|
gebundene Jobkonfiguration, qualifizierte Profilfähigkeit, signierten
|
||||||
|
Auftragsabgleich und beim Start erneut frische Zeitbelege. Darauf folgt der
|
||||||
|
unveränderliche Antrag mit Genehmigung in der WebUI.
|
||||||
|
|
||||||
|
### Erster LocalService-Auftrag, Stand 15. November 2026, 21:44 Uhr MEZ
|
||||||
|
|
||||||
|
Der gemeinsame Abnahmelauf kennt jetzt den festen Fall `windows_hello`.
|
||||||
|
Er adressiert ausschließlich die bestehende Windows-Test-VM. Das Skript
|
||||||
|
`Write-Output 'Zeitprofil-Test'` und die erwartete Ausgabe enden jeweils
|
||||||
|
mit CRLF. Der Plan bindet `agent_service` und
|
||||||
|
`powershell_51_remote_signed`. Der Browser prüft diese Angaben am gespeicherten
|
||||||
|
Plan und die sichtbare Prozessoption vor der Freigabe. Der Ergebnisvergleich
|
||||||
|
fordert neben Exit 0 und vollständiger Ausgabe auch die LocalService-SID,
|
||||||
|
den Skripthash und den prozessgebundenen Policybeleg. Die vorhandenen
|
||||||
|
Prüfungen für das Pending, den Freigabeaudit und die Anzahl der Startpermits
|
||||||
|
gelten für diesen Fall.
|
||||||
|
|
||||||
|
Lokal bestanden beim Browser-Planvergleich ein positiver und elf negative
|
||||||
|
Fälle. Der Python-Lauf prüfte den festen Planinput, eine passende
|
||||||
|
Ergebnisquittung und neun abweichende Ergebnisse. Beim ersten lokalen
|
||||||
|
Negativlauf fing der Test eine andere Ausnahmeklasse ab als der Prüfer
|
||||||
|
warf. Der korrigierte Lauf mit dem gemeinsamen Abnahmefehler bestand.
|
||||||
|
|
||||||
|
Tatsächlich ausgeführt wurde
|
||||||
|
`python3 deploy/cloud_mvp_acceptance.py --case windows_hello --execute-dev-test-ui`.
|
||||||
|
Der Lauf stoppte vor der Planung bei `actual_vm_capability_required`.
|
||||||
|
Der gespeicherte MCP-Kontakt um 21:42:59 Uhr MEZ war online, die
|
||||||
|
Verbindungsgeneration betrug 146. Das Gerät meldete seine drei passiven
|
||||||
|
Fähigkeiten. Jobs, Outbox, Permits und offene Aufträge standen auf null.
|
||||||
|
SHA-256 des serverseitig nachgelesenen Zustands im lokalen Beleg
|
||||||
|
`fd0c9af5f4df03a655fcb491212eb62c7777182f02a4e0a69633e5602985943c`.
|
||||||
|
Um 21:44:08 Uhr MEZ bestätigte eine lesende Transaktion für dieselbe
|
||||||
|
Generation `sync_required=false`, `sync_ready=true`,
|
||||||
|
`helper_sync_ready=false` und null Sync-Checkpoints. Ein neuer Plan,
|
||||||
|
eine WebUI-Genehmigung und eine Windows-Ausführung stehen aus.
|
||||||
|
|
||||||
|
Der Browser erreichte um 21:46 Uhr MEZ die echte, private WebUI des
|
||||||
|
Projektservers über deren SSH-Weiterleitung mit TLS-Prüfung. Anmeldung,
|
||||||
|
sichtbare Kennzeichnung `SIMULIERT` und Abmeldung als
|
||||||
|
`simulated-testprincipal-a` gelangen. Die Sitzung meldete
|
||||||
|
`approval_origin=dev_test_browser_simulation` und `testsimulation=true`.
|
||||||
|
Der Server lieferte das Frontend-Bundle `index-CTgvl2jr.js` mit der
|
||||||
|
PowerShell-Profilanzeige. Der Browser öffnete und genehmigte bei diesem
|
||||||
|
Zugangscheck keinen Antrag.
|
||||||
|
|
||||||
|
### Cloud-Linux-Nachweis für die explizite Profilaktivierung
|
||||||
|
|
||||||
|
Am 15. November 2026 um 21:54:37 Uhr MEZ bestand auf der festgelegten
|
||||||
|
Cloud-Linux-VM der portable Test
|
||||||
|
`tests::remote_signed_requires_explicit_profile_jobs_and_binding`.
|
||||||
|
Die Konfigurationsdefinition, die Methode `profile_enabled` und der Test
|
||||||
|
stimmen als Quelltextabschnitte mit dem Windows-Agent in `fcec400` überein.
|
||||||
|
Mit dem Buildfeature `system-helper` akzeptiert die Konfiguration das
|
||||||
|
benannte Prozessprofil nur mit Job-Opt-in und Bindingpfad. Der Test
|
||||||
|
verweigerte einen fehlenden Opt-in, deaktivierten Jobbetrieb, einen
|
||||||
|
fehlenden Bindingpfad sowie ungültige Profilwerte einschließlich `Bypass`.
|
||||||
|
|
||||||
|
Die x86-64-Testdatei lief mit UID 65534, ohne ergänzende Gruppen, mit
|
||||||
|
`no_new_privs` und in einem eigenen Netzwerk-Namespace. Der Aufruf mit
|
||||||
|
exaktem Testnamen endete mit Exit 0, einem bestandenen Test, null
|
||||||
|
ausgefilterten Tests und leerem stderr. Der Bootstrap entfernte das
|
||||||
|
temporäre Testverzeichnis auf der VM. Der Test verwendete lokale
|
||||||
|
Konfigurations-Fixtures. Windows-Dateirechte, LocalService-Jobbetrieb und
|
||||||
|
die Genehmigung in der WebUI brauchen eigene Nachweise.
|
||||||
|
|
||||||
|
| Prüfgegenstand | SHA-256 |
|
||||||
|
| --- | --- |
|
||||||
|
| Originalquelle `runtime.rs` aus `fcec400` | `4f94cce2c0557436cef4ea5accffb4778af2a3faeb7339cea16592c30872b479` |
|
||||||
|
| Extrahierte Testquelle | `2f338af46f38ebe72471dbdc81b0416947a20000bfad18be5b2f626c5c8a5812` |
|
||||||
|
| Testmanifest | `df3fadfa8e94a710de99546c21b6b74635ac9ea70e8a157583ef7bae05cd76e8` |
|
||||||
|
| Linux-Testdatei | `2168e5a6c31e2349b67ad81bcc58a711c3e37a0f03b7fecf0ca24281c5b72b6b` |
|
||||||
|
| VM-Beleg im Fall `28fac5aa-66e4-466f-93fc-f97062031d43` | `ee3a2c99651491a2fd876f1a3463919dc32d9509d9f9ef4eb73a36aa848bb56d` |
|
||||||
|
|
||||||
|
### Native Windows-Profilprüfung des neuen Agenten
|
||||||
|
|
||||||
|
Am 15. November 2026 um 21:56:30 Uhr MEZ bestand auf der Windows-VM genau
|
||||||
|
`runtime::tests::remote_signed_requires_explicit_profile_jobs_and_binding`
|
||||||
|
aus dem Release-Testprogramm des Commits `fcec400`. Ergebnis 1 bestanden,
|
||||||
|
7 gefiltert, Exit 0. Der vor dem Start nachgelesene SHA-256 der EXE war
|
||||||
|
`7d1715dc105c1eb482405511e1b3abf4437c448e186e73923c43dd3c7938710e`.
|
||||||
|
Der Konsolencontroller meldete Windows PowerShell **5.1.26100.9818** (x64).
|
||||||
|
SHA-256 des auf dem Gast erzeugten JSON-Belegs
|
||||||
|
`48de474d842ebc87550ba2e27b66086e6aa573973f252f4b8e19ac7b12b75a63`.
|
||||||
|
Für die Übertragung diente ein temporäres schreibgeschütztes Testmedium.
|
||||||
|
Der Test lief in der bereitgestellten Administratorkonsole. Er prüfte die
|
||||||
|
Profilwahl im neuen Build. Die Ausführung als auftragsverarbeitender
|
||||||
|
LocalService-Dienst muss weiterhin über die normale Genehmigungsstrecke folgen.
|
||||||
|
|
||||||
|
Im selben Gast wurde der neue Agent mit SHA-256
|
||||||
|
`df80b00fc2119b973d690053b9f9e4bdedd8fbc211f67599c3301eeb42e7702f`
|
||||||
|
in das geschützte Bootstrap-Verzeichnis kopiert und dort erneut gehasht.
|
||||||
|
Im Wartungsfall `49c230d8-fb5d-4c64-96b6-e0edce03ed90` bestätigten die
|
||||||
|
beiden Controller ihre Vorbereitung. Sie prüften den laufenden Vorgänger,
|
||||||
|
seine öffentliche Bindung und die Dateirechte und legten die Kandidaten und
|
||||||
|
Rückkehrkopien an. Die Dienstkonfiguration blieb dabei passiv.
|
||||||
|
|||||||
@@ -423,3 +423,39 @@ bleiben im Resultat ausdrücklich **nicht bewiesen**. Windows-MVP damit nicht
|
|||||||
vollständig abgenommen. Wichtige spätere Werkzeugverbesserung: erwartete additive
|
vollständig abgenommen. Wichtige spätere Werkzeugverbesserung: erwartete additive
|
||||||
Schemaentwicklung vor Wartung aus dem qualifizierten Quellstand planen; hierfür
|
Schemaentwicklung vor Wartung aus dem qualifizierten Quellstand planen; hierfür
|
||||||
jetzt keinen allgemeinen Migrations-/Resumeframework bauen.
|
jetzt keinen allgemeinen Migrations-/Resumeframework bauen.
|
||||||
|
|
||||||
|
## Serverkorrektur für die passive Telemetrie am 15. November 2026
|
||||||
|
|
||||||
|
Nach SQLx-Migration 16 wurde um 16:39:24 Uhr MEZ ausschließlich der
|
||||||
|
API-Container auf dem permanenten Server neu gestartet. Sein ARM64-Image
|
||||||
|
`6a76343bf65c126458244f5540d4cb740988144fc77877b409f790251e7ddcc7`
|
||||||
|
enthält die Änderung an der Basisinventarabfrage und die Migration.
|
||||||
|
Gateway und PostgreSQL behielten Container-ID und Startzeit.
|
||||||
|
|
||||||
|
Der erste Nachvergleich schlug beim direkten Listenvergleich der
|
||||||
|
Containerkonfiguration fehl. Eine separate lesende Prüfung verglich die Mounts
|
||||||
|
nach Zielpfad. Docker lieferte sie in anderer Reihenfolge. Quelle, Ziel,
|
||||||
|
Modus und übrige Mountattribute stimmten vollständig mit dem vorherigen
|
||||||
|
Container überein. API-Umgebung und Startkonfiguration entsprachen Compose
|
||||||
|
und Image. Verifiziert wurden zudem die Loopback-Bindung, UID/GID 10001,
|
||||||
|
Read-only-Rootfs, CapDrop ALL und no-new-privileges. Es gab genau einen
|
||||||
|
API-Wechsel. Die weitere Prüfung erfolgte am laufenden Container.
|
||||||
|
|
||||||
|
### Erneute Abnahme über MCP
|
||||||
|
|
||||||
|
Zwei getrennte, nach Beginn der Prüfung eingegangene Kontakte des Windows-11-
|
||||||
|
Agenten wurden am 15. November um 16:39:46 und 16:40:17 Uhr MEZ aus
|
||||||
|
`inventory.get_device` gelesen. Beide hatten Präsenz `online`, dasselbe
|
||||||
|
Gerät, dieselbe Agent-ID, Zuordnung, Enrollmentgeneration und dasselbe
|
||||||
|
authentifizierte Zertifikat wie vor dem Paarwechsel. Der Agent meldet
|
||||||
|
`heartbeat/1`, `windows.base/1` und `agent.update/1`.
|
||||||
|
Beleg-SHA-256 `837c7580b9e7cd68de09533f50d91622272c2f2bc288da70d8b4624d2f6a747e`.
|
||||||
|
|
||||||
|
Die MCP-Geräteansicht lieferte das gespeicherte Windows-Basisinventar mit fünf
|
||||||
|
Bereichen und für die Cloud-Linux-VM den Datensatz `linux.base`. Das
|
||||||
|
Windows-Basisinventar stammte von 16:16:59 Uhr MEZ. Die Kontaktzeiten wurden
|
||||||
|
unabhängig davon aktualisiert. PostgreSQL speicherte die separaten
|
||||||
|
Updatemeldungen des Windowsagenten um 16:38:43, 16:39:45 und 16:40:50 Uhr MEZ.
|
||||||
|
Der zuletzt gelesene Updatezustand war `not_configured`. Die Windows-Jobtabelle
|
||||||
|
enthielt für dieses Gerät null Aufträge. Die Prüfung las gespeicherte
|
||||||
|
Telemetrie über den permanenten Server nach Ablauf des SSH-Fensters.
|
||||||
|
|||||||
@@ -180,6 +180,64 @@ getrennt zu prüfen. Eine spätere Fortsetzung benötigt zuerst eine lesende
|
|||||||
Ursachenklärung und einen konkret geprüften Vertrag für den ursprünglichen
|
Ursachenklärung und einen konkret geprüften Vertrag für den ursprünglichen
|
||||||
Teilfall; ein neuer Fall darf diesen Marker nicht umgehen.
|
Teilfall; ein neuer Fall darf diesen Marker nicht umgehen.
|
||||||
|
|
||||||
|
## Sharing-Verletzung bei der Konsolenfinalisierung
|
||||||
|
|
||||||
|
Die VM meldete beim gesonderten Konsolenabschluss für `File.Move` den HRESULT
|
||||||
|
`0x80070020` (Win32 32, Sharing-Verletzung). Der Helper hielt seit seinem
|
||||||
|
Start einen Lesehandle auf `C:\ProgramData\RustDiscoverySystem`. Der Code
|
||||||
|
erlaubte ausschließlich `FILE_SHARE_READ`. Beim Verschieben des Kandidaten
|
||||||
|
aus dem Bootstrap-Verzeichnis öffnet Windows den **Zielordner** für
|
||||||
|
`FILE_ADD_FILE`. Dieser Zugriff kollidiert mit dem gehaltenen Handle. Die
|
||||||
|
native Fehlermeldung nennt keine Prozess-ID. Die Zuordnung folgt aus den
|
||||||
|
Öffnungsmodi des Helpers und der dokumentierten Windows-Rename-Operation.
|
||||||
|
[Windows-Rename](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/87f86c9b-6c2a-4803-84b7-131a74a434fa)
|
||||||
|
· [Windows-Sharingprüfung](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/8c0e3f4f-0729-49f4-a14d-7f7add593819)
|
||||||
|
|
||||||
|
Im korrigierten Quellstand öffnen der Helper, der Agent beim Laden des
|
||||||
|
Peer-Pins und die Zeitprüfung genau diesen öffentlichen Stamm über
|
||||||
|
`PinnedFile::open_read_shared`. Der Lesehandle lässt auch einen berechtigten
|
||||||
|
Schreibzugriff auf den Ordner zu. Weiterhin sperrt er das Löschen und
|
||||||
|
Umbenennen des Ordners. Über Kinddateien entscheiden deren eigene DACL und
|
||||||
|
gehaltene Datei-Pins. Einstellungen, Peer-Pin und Zeitprofildatei werden
|
||||||
|
weiterhin mit geteiltem Lesezugriff geöffnet. Die vorhandenen Prüfungen von
|
||||||
|
Owner, DACL, Reparse-Attributen und Dateiidentität laufen bei jedem Pin.
|
||||||
|
|
||||||
|
Workspace-Formatprüfung, Cargo-Check aller Windows-Ziele mit `system-helper`
|
||||||
|
und Clippy mit `-D warnings` bestanden im Windows-Clock-Builder offline.
|
||||||
|
Beide x86-64-PE-Debugprogramme wurden dort gelinkt. Agent-SHA-256
|
||||||
|
`b5fe5ea55c857415c979f06851e54a2d1fbe4cbfe2fe7ad1660e209aae3fa583`,
|
||||||
|
Helper-SHA-256 `c6b41b0867df23f2c04c2550a39678672ef66d35a4b41215769265924deaf8a1`.
|
||||||
|
Der erste Buildversuch endete in einem anderen Builder wegen fehlendem
|
||||||
|
`widl`. Die Windows-VM hat diese Änderungen bisher weder ausgeführt noch
|
||||||
|
durch erneute Profilveröffentlichung und zwei passive Rollenbelege bestätigt.
|
||||||
|
|
||||||
|
### Optimiertes Release-Paar für die nächste Windows-Abnahme
|
||||||
|
|
||||||
|
Am 15. November 2026 wurden Agent und Helper aus Commit
|
||||||
|
`e952698f5e2bab808e816858a727ef40347f6142` auf dem Entwicklungsrechner
|
||||||
|
gebaut. Der Quellstand kam aus einem schreibgeschützt eingebundenen Git-Archiv.
|
||||||
|
Der unabhängige Vergleich nach dem Build bestätigte alle 708 Quelldateien
|
||||||
|
gegen Git-Tree `708c88b4d6a92d9f9cbebc70146250062532f45f`.
|
||||||
|
Rust 1.99.1 und Cargo 1.99.1 liefen im vorhandenen Clock-Builder ohne Netzwerk.
|
||||||
|
Der ausgeführte Befehl war
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo build --release --target x86_64-pc-windows-gnu --features system-helper --locked --offline -p rmm-agent-windows --bin rmm-agent-windows --bin rmm-helper-windows
|
||||||
|
```
|
||||||
|
|
||||||
|
| Datei | Bytes | SHA-256 |
|
||||||
|
| --- | ---: | --- |
|
||||||
|
| `rmm-agent-windows.exe` | 23 543 434 | `2dd64e743431ad4c8244e43bef30c4c1c2123ad26a094853811a418626bb87e7` |
|
||||||
|
| `rmm-helper-windows.exe` | 17 191 183 | `9c313c07a20c82797cbd8c8ca7c289c1d227b0bd6a4a686f38c4db3bbdded199` |
|
||||||
|
|
||||||
|
Beide Dateien haben einen ausführbaren PE32+-Header mit AMD64-Maschinenkennung
|
||||||
|
`0x8664`. Der private Originalbeleg `profile-share-release-e952698/receipt.json`
|
||||||
|
hat SHA-256 `1ec1ec472043e8673e5b92f9029fd809434451d9452e3b24bbd85b21f017017d`.
|
||||||
|
Das erste Prüfskript traf auf dem Notebook auf eine ältere Python-Hashlib ohne
|
||||||
|
`file_digest`. Die Nachprüfung lief mit SHA-256 über dieselben fertigen Bytes.
|
||||||
|
Die Installation dieses Paars und die native Profilveröffentlichung mit den
|
||||||
|
zu diesen Binaries passenden Zeitprofilbindungen stehen aus.
|
||||||
|
|
||||||
## Unabhängiger lokaler Review des Move-Fehlers und fester Diagnosepfad
|
## Unabhängiger lokaler Review des Move-Fehlers und fester Diagnosepfad
|
||||||
|
|
||||||
Der nachfolgende Review liest ausschließlich Quellen und vorhandene öffentliche
|
Der nachfolgende Review liest ausschließlich Quellen und vorhandene öffentliche
|
||||||
@@ -260,3 +318,254 @@ Source-/Intent-/Receiptbindung ohne Legacy-Hashadoption. Der Transport ist dabei
|
|||||||
vollständig gemockt; dies ist kein nativer Befund. Die Kontrollbelege des alten
|
vollständig gemockt; dies ist kein nativer Befund. Die Kontrollbelege des alten
|
||||||
fehlgeschlagenen Installationsfalls bleiben bytegleich erhalten. Ein konkreter
|
fehlgeschlagenen Installationsfalls bleiben bytegleich erhalten. Ein konkreter
|
||||||
Publikationsfix wurde mangels belegter nativer Fehlerursache nicht erfunden.
|
Publikationsfix wurde mangels belegter nativer Fehlerursache nicht erfunden.
|
||||||
|
|
||||||
|
## Nachlese durch die Bedienperson auf der Windows-VM
|
||||||
|
|
||||||
|
In der administrativen VM-Konsole konnte die Bedienperson den Kandidaten
|
||||||
|
`time-attestation.candidate.json` lesen. SHA-256 stimmte mit dem im
|
||||||
|
Publish-Intent hinterlegten Wert `2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b`
|
||||||
|
überein. Für den festen Zielpfad unter `RustDiscoverySystem` meldete
|
||||||
|
PowerShell `ObjectNotFound`. Dieser Konsolenbefund ergänzt den früheren
|
||||||
|
Readback um den Inhalt des verbliebenen Kandidaten. FileID, DACL und
|
||||||
|
Dienstgeneration wurden bei dieser Konsolenabfrage nicht erfasst.
|
||||||
|
|
||||||
|
Für die Fortsetzung an derselben VM-Konsole liegt
|
||||||
|
[`Complete-OriginalTimeProfile.ps1`](../deploy/windows/Complete-OriginalTimeProfile.ps1)
|
||||||
|
bereit. Der Befehl übernimmt die Prüffunktionen aus den SHA-256-geprüften
|
||||||
|
Bytes des bereits installierten Controllers. Vor der Veröffentlichung prüft er
|
||||||
|
die ursprüngliche Datei-ID und das Volume, den Inhalt, die DACL, die
|
||||||
|
ursprünglichen Marker und beide laufenden Dienstgenerationen. Er hält die
|
||||||
|
beiden Prozesshandles während der Veröffentlichung offen. Ein exklusiv
|
||||||
|
erstellter zusätzlicher Marker verhindert eine doppelte Ausführung.
|
||||||
|
|
||||||
|
Nach der Verschiebung an den festen Zielpfad vergleicht das Skript die
|
||||||
|
Dateiidentität und die Dienstzustände erneut. Bei einem neuen Move-Fehler erfasst
|
||||||
|
es Fehlerklasse und HRESULT für diesen Aufruf. Ein erneuter Start trifft auf
|
||||||
|
den Abschlussmarker oder den vorhandenen Zielpfad und beendet sich. Das
|
||||||
|
Ergebnis einer erfolgreichen Veröffentlichung hält die separate
|
||||||
|
Laufzeitprüfung der beiden Dienstrollen ausdrücklich offen.
|
||||||
|
|
||||||
|
Lokal geprüft wurden die PowerShell-Syntax, die Bindung an die gespeicherten
|
||||||
|
Originalbelege und der Vergleich mit der tatsächlichen Kandidatenidentität.
|
||||||
|
Eine veränderte FileID wurde im lokalen Vergleich abgewiesen. Die Ausführung
|
||||||
|
des Abschlussbefehls auf der VM und die anschließende Zeitprüfung stehen aus.
|
||||||
|
|
||||||
|
## Ergebnis vom Konsolenschritt automatisch abholen
|
||||||
|
|
||||||
|
Für den vorbereiteten Profilabschluss steht `Open-TimeProfileReceiptWindow.ps1`
|
||||||
|
zur Verfügung. Die Bedienperson startet es auf der Windows-VM. Das Skript prüft
|
||||||
|
die beiden Downloads gegen feste SHA-256-Werte, öffnet den vorhandenen
|
||||||
|
Reverse-SSH-Transport und führt den festen Abschluss lokal aus. Die
|
||||||
|
Weiterleitung auf dem Server ist an `127.0.0.1:22240` gebunden. Auf der VM
|
||||||
|
endet sie an einem temporären Loopback-Port. Der Prozess sendet dort den
|
||||||
|
Abschlussstatus und die öffentlichen Belege der beiden Zeitdienstrollen.
|
||||||
|
Er liest keine Befehle vom Socket. Die Gast-Kontofrist und die Aufgabenplanung
|
||||||
|
werden nicht geändert. Strg+C oder zwölf Minuten beenden das Vordergrundfenster.
|
||||||
|
|
||||||
|
Die serverseitige Frist für den vorhandenen Transportschlüssel und der aktive
|
||||||
|
Abschalttimer wurden für den 15. November 2026, 18:00 Uhr MEZ, geprüft.
|
||||||
|
Beim Bereitstellen wurden der PowerShell-Parser, die Downloadhashes, die
|
||||||
|
bestehenden Quellprüfungen und die sechs lokalen Prüffälle für die Zeitbelege
|
||||||
|
ausgeführt. Ein Ergebnis von der VM liegt bei Bereitstellung noch nicht vor.
|
||||||
|
|
||||||
|
Der Ergebnisempfänger auf dem permanenten Server wurde anschließend gestartet.
|
||||||
|
Seine Anfangsprüfung des laufenden Gateways und der gespeicherten
|
||||||
|
Windows-Gerätebindung war erfolgreich. Der Server fragt den Loopback-Port
|
||||||
|
nur bei vorhandenem SSH-Listener ab und legt eingehende Belege im privaten
|
||||||
|
Fall `time-profile-receipt-f7f56e9f` ab. Für Zeitbelege verwendet er die
|
||||||
|
bestehende Rollen-, Boot-, Generations- und Altersprüfung mit je einer
|
||||||
|
Datenbanklesung vor und nach dem Empfang. Die Bereitstellung des Empfängers
|
||||||
|
belegt noch keine Profilveröffentlichung auf dem Gast.
|
||||||
|
|
||||||
|
## Rückmeldung der Windows-VM am 15. November um 17:05:36 Uhr MEZ
|
||||||
|
|
||||||
|
Der Empfänger hat im Fall `time-profile-receipt-f7f56e9f` die Antwort
|
||||||
|
`finalization_failed` gespeichert. Der Abschlussbefehl bestand die Prüfungen
|
||||||
|
auf Kandidat, Berechtigungen und Dienstgenerationen bis zur Veröffentlichung.
|
||||||
|
Der Aufruf von `File.Move` meldete HRESULT **0x80070020**
|
||||||
|
(`ERROR_SHARING_VIOLATION`). Zeile 94 gibt diesen Fehler an den Aufrufer
|
||||||
|
weiter. Empfangsbeleg SHA-256
|
||||||
|
`7cc51d44abfbe7949b0896053a463f3bd140b1844229e9ba206683db34d6f2ba`,
|
||||||
|
Ergebnis `172edeaf54ca08f4e5b1ad3662884da6ec217636ca30bbd8274e73140f6ef35b`.
|
||||||
|
|
||||||
|
Der Code des installierten Helpers öffnet das öffentliche Stammverzeichnis
|
||||||
|
mit Lesezugriff und ausschließlich `FILE_SHARE_READ` und hält diesen Handle
|
||||||
|
im laufenden Dienst. Ein Rename aus einem anderen Verzeichnis benötigt am
|
||||||
|
Zielverzeichnis `FILE_ADD_FILE`. Das erklärt einen konkreten Konflikt.
|
||||||
|
Die VM-Rückmeldung enthält keine Liste der tatsächlich offenen Handles.
|
||||||
|
Für den älteren Installationsaufruf ohne HRESULT bleibt der Fehlercode
|
||||||
|
unbekannt. Das laufende Konsolenskript hat keine weitere Veröffentlichung
|
||||||
|
versucht. Für diesen Lauf liegt keine erfolgreiche Zeitprüfung vor.
|
||||||
|
[Windows-Dateisystemregeln für Rename](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/87f86c9b-6c2a-4803-84b7-131a74a434fa)
|
||||||
|
|
||||||
|
Nach der fehlgeschlagenen Erstveröffentlichung ergab eine unabhängige Abfrage
|
||||||
|
von `inventory.get_device` über den permanenten Server einen neuen Kontakt
|
||||||
|
um 17:12:44 Uhr MEZ, Präsenz `online` und Quelle `windows.base`.
|
||||||
|
Geräte-ID, Agent-ID, Assignment, Enrollmentgeneration und authentifiziertes
|
||||||
|
Zertifikat stimmten mit der Telemetrieabnahme vor dem Profilversuch überein.
|
||||||
|
Der Agent meldete weiterhin die drei passiven Fähigkeiten `heartbeat/1`,
|
||||||
|
`windows.base/1` und `agent.update/1`.
|
||||||
|
### Erstprovisionierung nach dem belegten Sharingkonflikt
|
||||||
|
|
||||||
|
`Complete-OriginalTimeProfile.ps1 -InitialCreate` ist eine eigene Reparatur
|
||||||
|
für das bislang fehlende Ziel. Sie setzt den vorhandenen Abschlussintent und
|
||||||
|
den gespeicherten Fehler `File.Move / System.IO.IOException / 0x80070020`
|
||||||
|
voraus. Die ursprünglichen Quell-, ACL-, Dienst-, Geräte- und
|
||||||
|
Kandidatenbindungen gelten weiter. Der ursprüngliche Kandidat bleibt als
|
||||||
|
Referenz erhalten. Der alte Move-Erfolg und dessen `result.json` werden durch
|
||||||
|
diesen Pfad nicht nachträglich erzeugt.
|
||||||
|
|
||||||
|
Der feste neue Name wird genau einmal mit `CreateNew` angelegt. Windows
|
||||||
|
erhält dabei bereits eine geschützte DACL mit explizitem Leseverbot für die
|
||||||
|
beiden Service-SIDs. Der kontrollierende Prozess besitzt den einzigen
|
||||||
|
Datenhandle. Er schreibt und flusht die 1177 qualifizierten Bytes und liest sie
|
||||||
|
über denselben Handle vollständig zurück. Er prüft Hash, Volume, neue FileID,
|
||||||
|
einzigen Hardlink, Länge und DACL. Dann prüft er die ursprüngliche
|
||||||
|
Kandidatenidentität und die laufenden Dienste noch einmal und schreibt einen
|
||||||
|
Prüfbeleg. Erst jetzt setzt er die bereits gebundene endgültige DACL auf dem
|
||||||
|
gehaltenen Handle und prüft Identität, Hash und DACL erneut. Nach Schließen
|
||||||
|
folgt eine separate Prüfung beider Pfade und Dienste. Damit wird eine neue
|
||||||
|
Ziel-FileID dokumentiert. Die DACL des öffentlichen Ordners bleibt unverändert.
|
||||||
|
[Windows-Dateierstellung](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/498a5eeb-afc9-445f-99ed-a7e4b73c648b)
|
||||||
|
[.NET-Framework-Konstruktor mit Erstellungs-DACL](https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream.-ctor?view=netframework-4.8)
|
||||||
|
|
||||||
|
Eine vor der DACL-Freigabe unterbrochene Erstellung kann eine vorhandene
|
||||||
|
Teildatei mit gesperrtem Dienstzugriff hinterlassen. Nach erfolgter
|
||||||
|
DACL-Freigabe ist die Datei lesbar, auch wenn der Prozess vor dem
|
||||||
|
abschließenden Ergebnis ausfällt. Ein neuer Versuch wird in beiden Fällen
|
||||||
|
verweigert. Die getrennten `console-initial-create-*`-Dateien dokumentieren
|
||||||
|
Intent, verifizierte neue Zielidentität und tatsächlichen Abschluss oder
|
||||||
|
Fehlerphase. Das Ergebnis weist `clock_runtime_qualified=false` aus. Für
|
||||||
|
dessen positive Bewertung sind weiterhin die unabhängigen Zeitbelege der
|
||||||
|
installierten Dienste erforderlich.
|
||||||
|
|
||||||
|
Lokal bestanden Parserprüfung, Kompilierung des kleinen nativen
|
||||||
|
Handle-Readers, Prüfung seines Strukturlayouts und drei simulierte
|
||||||
|
Entscheidungsfälle mit echtem beziehungsweise verändertem Fehlerbeleg.
|
||||||
|
Der frühere lokale Prüfharness wählte beim ersten Strukturlayoutaufruf die
|
||||||
|
falsche .NET-Überladung; nach Angabe des Typs bestand die Prüfung. Der
|
||||||
|
Original-Kandidaten-/FileID-Vergleich und die acht bisherigen Profilfixtures
|
||||||
|
bestanden ebenfalls. Dieser Stand wurde auf der Windows-VM noch nicht
|
||||||
|
ausgeführt.
|
||||||
|
|
||||||
|
Das passende Konsolenfenster ruft ausschließlich die Variante `-InitialCreate`
|
||||||
|
auf. Der neue Empfänger `time-profile-receipt-f0488aba` war vor Übergabe des
|
||||||
|
Befehls aktiv und hat die erwartete Geräte- und Gatewaybindung geprüft. Er
|
||||||
|
unterscheidet die neue Rückmeldung von der alten Move-Fehlermeldung und
|
||||||
|
speichert die Erstveröffentlichung und den signierten Rollenvergleich getrennt.
|
||||||
|
Für diesen Skriptstand liegen bei Bereitstellung ausschließlich lokale Prüfungen
|
||||||
|
vor. Die Bestätigung der VM steht aus.
|
||||||
|
|
||||||
|
Am 15. November endete die Freigabe um 18:00 Uhr MEZ. Der Empfänger für
|
||||||
|
die Erstveröffentlichung schloss mit `window_expired`. Es lag keine
|
||||||
|
entsprechende Gastquittung vor. Für die Fortsetzung wurde derselbe
|
||||||
|
Weiterleitungsschlüssel bis 23:45 Uhr MEZ freigegeben. Frist und aktiver
|
||||||
|
Abschalttimer wurden auf dem Server geprüft. Der neue Empfänger
|
||||||
|
`time-profile-receipt-a6bb4e2f` hat den Gateway- und Gerätebezug geprüft
|
||||||
|
und ist bereit. Der Konsolenstarter nimmt die Serverfrist als Parameter
|
||||||
|
`-Until` entgegen und begrenzt jeden lokalen Start weiterhin auf zwölf Minuten.
|
||||||
|
|
||||||
|
### Rückmeldung aus dem Abendfenster
|
||||||
|
|
||||||
|
Um 20:24:02 Uhr MEZ empfing der Server im Fall `time-profile-receipt-a6bb4e2f`
|
||||||
|
die Gastquittung `finalization_failed`. Der Aufruf mit `CreateNew` hatte das
|
||||||
|
Ziel geöffnet. Bei der ersten Prüfung am offenen Handle wich die vom Kernel
|
||||||
|
gelesene SDDL-Zeichenfolge vom vorbereiteten Sicherheitsdeskriptor ab. Der
|
||||||
|
Controller brach in `verify_creation` in Zeile 176 mit `0x80131501` ab.
|
||||||
|
Der Abbruch lag vor dem ersten Schreiben von Profilbytes und vor der Freigabe
|
||||||
|
der Datei für die Dienste. Der HRESULT stammt von der ausgelösten
|
||||||
|
PowerShell-Ausnahme. Er identifiziert keine abweichende Berechtigung.
|
||||||
|
|
||||||
|
Die Quittung enthält weder die beiden Deskriptoren noch eine spätere Nachlese
|
||||||
|
der Zieldatei. Der konkrete Unterschied und der aktuelle Dateizustand bleiben
|
||||||
|
zu prüfen. Der Empfänger beendete sich nach diesem Fehler wie vorgesehen.
|
||||||
|
Es gibt aus diesem Lauf keinen erfolgreichen signierten Rollenvergleich.
|
||||||
|
SHA-256 der Gastantwort samt Serverkontext:
|
||||||
|
`a1725dbc532f022857e828080bec107ec32efd58836e22dd250909b9d7c2d28b`.
|
||||||
|
|
||||||
|
Ein separater MCP-Abruf bestätigte anschließend einen neuen Windows-Heartbeat
|
||||||
|
um 20:25:35 Uhr MEZ. Präsenz war `online`, die Quelle `windows.base`.
|
||||||
|
Gerät, Agent, Assignment, Enrollmentgeneration und authentifiziertes Zertifikat
|
||||||
|
stimmten mit dem früheren Abnahmebeleg überein. Beleg-SHA-256
|
||||||
|
`7ea828b42b3c7948956aad56845502ffa52192ce6ca14728203f8574d70a28ec`.
|
||||||
|
|
||||||
|
Der Konsolenstarter prüft im aktualisierten Quellstand vor einem Aufruf des
|
||||||
|
Abschlussbefehls auf einen vorhandenen Fehler oder einen offenen Intent.
|
||||||
|
In beiden Fällen liest er den vorhandenen Stand. Die Rückmeldung kennzeichnet
|
||||||
|
mit `finalizer_invoked`, ob dieser Start den Abschlussbefehl aufgerufen hat.
|
||||||
|
Enthält der Fehlerbeleg die bei der Erstellung verglichenen Deskriptoren,
|
||||||
|
überträgt der Starter sie mit der Länge und den vorhandenen Datei-IDs an den
|
||||||
|
Ergebnisempfänger. Ältere Fehlerbelege bleiben ohne diese Angaben lesbar.
|
||||||
|
|
||||||
|
Der PowerShell-Parser und fünf lokale Fälle bestanden: erster Aufruf,
|
||||||
|
vorliegender Fehler, offener Intent, bereits vorliegender Erfolg und
|
||||||
|
widersprüchliche Erfolgs-/Fehlermarker. Nur der erste Fall rief im Test den
|
||||||
|
simulierten Abschluss auf. Diese Prüfung lief auf dem Entwicklungsrechner.
|
||||||
|
|
||||||
|
### Fehlerbeleg beim ersten Vergleich des Sicherheitsdeskriptors
|
||||||
|
|
||||||
|
Unterscheiden sich Soll- und Ist-SDDL an der neu angelegten Datei, erfasst der
|
||||||
|
Controller beide Werte für Besitzer, Gruppe und DACL am exklusiv gehaltenen
|
||||||
|
Dateihandle. Der private Fehlerbeleg enthält dazu das optionale Feld
|
||||||
|
`creation_descriptor` mit `expected_sddl`, `actual_sddl` und `bytes`.
|
||||||
|
Bei erfolgreicher nativer Identitätsabfrage kommen `file_id` und
|
||||||
|
`volume_serial` hinzu. Scheitert das Lesen der Zusatzmetadaten, hält
|
||||||
|
`metadata_hresult` dessen Fehlercode fest. Die ursprüngliche Abweichung
|
||||||
|
bricht den Aufruf vor dem Schreiben der Profilbytes und der Rechtefreigabe ab.
|
||||||
|
Der ältere Gastbeleg enthält diese neuen Felder noch nicht.
|
||||||
|
|
||||||
|
Lokal bestanden die Parserprüfung, vier PowerShell-Fälle für Vergleich und
|
||||||
|
Fehlerbeleg sowie die acht vorhandenen Profiltests. Die vier Fälle umfassten
|
||||||
|
ungleiche Deskriptoren mit lesbarer beziehungsweise fehlender FileID, einen
|
||||||
|
gleichen Deskriptor und einen unabhängigen Folgefehler. Die FileID-Abfrage war
|
||||||
|
simuliert. Eine native Abnahme dieser Belegerweiterung steht aus.
|
||||||
|
|
||||||
|
### Konsolennachweis der leeren Zieldatei
|
||||||
|
|
||||||
|
Die Bedienperson las den festen Zielpfad auf dem Windows-Gast. Die
|
||||||
|
Dateigröße betrug 0 Byte. Beim Vergleich der ungebrochenen SDDL-Texte
|
||||||
|
unterschieden sich ausschließlich die DACL-Steuerflags: erwartet `PAI`,
|
||||||
|
gelesen `P`. Beide Deskriptoren enthalten denselben Eigentümer und dieselbe
|
||||||
|
Gruppe (BUILTIN-Administratoren), die geschützte DACL und dieselben sechs
|
||||||
|
expliziten ACEs in identischer Reihenfolge. Die beiden Dienst-SIDs haben
|
||||||
|
je eine explizite Verweigerung von ReadData. Der Befund erklärt den
|
||||||
|
Textvergleichsabbruch. Er belegt keine Freigabe der Datei.
|
||||||
|
|
||||||
|
SHA-256 der UTF-8-Texte ohne die Zeilenumbrüche der Konsolendarstellung:
|
||||||
|
erwartet `d4726c7973c9b0cd8a66c1b129d1b5eb58d2bbfc1b103018e0a31a71fb1d9020`,
|
||||||
|
gelesen `a0e1d856ed3bdbe884b23599f7c53d8a281d6409a42bbfa48649127b2aa22793`.
|
||||||
|
Die erste Fehlerquittung enthielt keine FileID der leeren Zieldatei.
|
||||||
|
|
||||||
|
Der Modus `-ResumeEmpty` prüft die bestehenden Fallbelege und öffnet das
|
||||||
|
leere Ziel exklusiv. Vor dem Schreiben protokolliert er dessen jetzt
|
||||||
|
festgestellte FileID. Dieselbe Kennung muss nach dem Schreiben und nach
|
||||||
|
der Freigabe der Leserechte wieder vorliegen. Beim DACL-Vergleich sind nur
|
||||||
|
die beiden für diesen Fall beschriebenen Formen zulässig. Der Starter
|
||||||
|
vergleicht die FileID zusätzlich mit der Quittung. Der Rückkanal überträgt
|
||||||
|
das Ergebnis und die passiven Zeitmessungen.
|
||||||
|
|
||||||
|
Lokal bestanden acht Profiltests, die PowerShell-Parserprüfung, die
|
||||||
|
C#-Kompilierung, fünf AMD64-Strukturlayoutprüfungen und 20 Vergleiche
|
||||||
|
von Sicherheitsdeskriptoren. Acht lokale Fälle prüften die Auswahl des
|
||||||
|
Startmodus und das Verhalten bei vorhandenen Markern. Die Anwendung auf
|
||||||
|
dem Windowsgast und signierte Zeitmessungen beider Dienste stehen aus.
|
||||||
|
|
||||||
|
### Windows-VM, 15. November 2026, 20:40 Uhr MEZ
|
||||||
|
|
||||||
|
Der Controller schloss die Profilinstallation im Fall
|
||||||
|
`ad9fd154-b2be-4f5d-9e17-65abb721ceaf` ab. Ab
|
||||||
|
`2026-11-15T19:40:47.0850024Z` schrieb er die vorbereiteten 1177 Bytes.
|
||||||
|
Beim Rücklesen stimmten der erwartete SHA-256
|
||||||
|
`2b4a8a7080770304b80e2a665fa5f5ee1ebbd9182e7c80b184e75b114575b42b`
|
||||||
|
und die bei leerer Datei protokollierte FileID
|
||||||
|
`95990300000007000000000000000000` überein. Der Kandidat blieb erhalten.
|
||||||
|
Agent und Helper liefen während der Veröffentlichung weiter.
|
||||||
|
|
||||||
|
Der Empfänger auf dem Projektserver bestätigte die Quittung in Sitzung
|
||||||
|
`d8b4b255-8e3f-4aa7-8377-684ce9adbea1`.
|
||||||
|
SHA-256 des Gast-Ergebnisbelegs
|
||||||
|
`62a04be9c7d08d3687b51eacd6adbe290b91e16ba934d6b5bb531e8764a56cf5`,
|
||||||
|
SHA-256 der serverseitigen Publikationsquittung
|
||||||
|
`1a0ce65c852523072d6822024541591482e0bae3788834993c2548e9cbf7647e`.
|
||||||
|
Um 20:40:59 Uhr MEZ fehlte beim anschließenden Lesen noch mindestens
|
||||||
|
einer der beiden passiven Zeitbelege.
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
-- Passive agent-update observations share the existing tenant/device-bound
|
||||||
|
-- ingest path. Preserve both base scopes and every existing row/RLS/FK.
|
||||||
|
-- SQLx applies this file transactionally and records its normal checksum.
|
||||||
|
SET LOCAL lock_timeout = '3s';
|
||||||
|
SET LOCAL statement_timeout = '15s';
|
||||||
|
ALTER TABLE observations DROP CONSTRAINT observations_source_id_check;
|
||||||
|
ALTER TABLE observations ADD CONSTRAINT observations_source_id_check
|
||||||
|
CHECK (source_id IN ('linux.base', 'windows.base', 'agent.update')) NOT VALID;
|
||||||
|
ALTER TABLE observations VALIDATE CONSTRAINT observations_source_id_check;
|
||||||
Reference in New Issue
Block a user