Support interactive customer transfers for enrolled devices
Rust development slice / linux (push) Failing after 8s
Rust development slice / linux (push) Failing after 8s
This commit is contained in:
@@ -802,10 +802,7 @@ mod installed {
|
||||
tenant_id: Uuid,
|
||||
job_signing_public_key_hex: String,
|
||||
}
|
||||
pub fn enrolled_binding(
|
||||
policy: &Path,
|
||||
registration: &rmm_protocol::EnrollmentResponse,
|
||||
) -> Result<rmm_agent_core::auth::Binding> {
|
||||
fn installed_policy(policy: &Path) -> Result<LocalPolicy> {
|
||||
crate::job_binding::check_admin_readonly(policy)?;
|
||||
ensure!(
|
||||
std::fs::metadata(policy)?.len() <= MAX_CONFIG_BYTES as u64,
|
||||
@@ -816,6 +813,16 @@ mod installed {
|
||||
p.schema_version == 1 && !p.tenant_id.is_nil() && digest(&p.job_signing_public_key_hex),
|
||||
"INSTALLED_JOB_TRUST"
|
||||
);
|
||||
Ok(p)
|
||||
}
|
||||
pub fn enrolled_transfer_signer(policy: &Path) -> Result<String> {
|
||||
Ok(installed_policy(policy)?.job_signing_public_key_hex)
|
||||
}
|
||||
pub fn enrolled_binding(
|
||||
policy: &Path,
|
||||
registration: &rmm_protocol::EnrollmentResponse,
|
||||
) -> Result<rmm_agent_core::auth::Binding> {
|
||||
let p = installed_policy(policy)?;
|
||||
let binding = rmm_agent_core::auth::Binding {
|
||||
tenant_id: p.tenant_id,
|
||||
agent_id: Uuid::parse_str(®istration.agent_id)?,
|
||||
@@ -963,6 +970,7 @@ mod installed {
|
||||
generation: u64,
|
||||
binding: &rmm_agent_core::auth::Binding,
|
||||
policy_file: &Path,
|
||||
installed_tenant: Uuid,
|
||||
helper: Option<&ipc::PeerPin>,
|
||||
) -> Result<Self> {
|
||||
let mut failure_fence = ConstructorFailureFence { armed: true };
|
||||
@@ -1002,7 +1010,7 @@ mod installed {
|
||||
.map(|(id, key)| Ok((id, independent_time_key(&key, &binding.public_key_hex)?)))
|
||||
.collect::<Result<BTreeMap<_, _>>>()?;
|
||||
ensure!(
|
||||
p.tenant_id == binding.tenant_id
|
||||
p.tenant_id == installed_tenant
|
||||
&& p.job_signing_public_key_hex == binding.public_key_hex,
|
||||
"TIME_POLICY_BINDING"
|
||||
);
|
||||
@@ -1394,7 +1402,7 @@ mod installed {
|
||||
pub struct RuntimeClock {
|
||||
role: Role,
|
||||
enrolled_helper: Option<ipc::PeerPin>,
|
||||
local_policy: Option<(rmm_agent_core::auth::Binding, std::path::PathBuf)>,
|
||||
local_policy: Option<(rmm_agent_core::auth::Binding, std::path::PathBuf, Uuid)>,
|
||||
state: Arc<Mutex<Option<(u64, SignedClock)>>>,
|
||||
}
|
||||
#[derive(Clone)]
|
||||
@@ -1414,14 +1422,16 @@ mod installed {
|
||||
pub fn enrolled_local_service(
|
||||
binding: rmm_agent_core::auth::Binding,
|
||||
policy: std::path::PathBuf,
|
||||
installed_tenant: Uuid,
|
||||
) -> Self {
|
||||
let mut value = Self::new(Role::Agent);
|
||||
value.local_policy = Some((binding, policy));
|
||||
value.local_policy = Some((binding, policy, installed_tenant));
|
||||
value
|
||||
}
|
||||
pub fn enrolled_windows_update_helper(binding: rmm_agent_core::auth::Binding, helper: ipc::PeerPin) -> Self {
|
||||
let mut value = Self::new(Role::SystemHelper);
|
||||
value.local_policy = Some((binding, std::path::PathBuf::from(r"C:\ProgramData\RustDiscovery\job-time.json")));
|
||||
let installed_tenant = binding.tenant_id;
|
||||
value.local_policy = Some((binding, std::path::PathBuf::from(r"C:\ProgramData\RustDiscovery\job-time.json"), installed_tenant));
|
||||
value.enrolled_helper = Some(helper);
|
||||
value
|
||||
}
|
||||
@@ -1440,8 +1450,8 @@ mod installed {
|
||||
ensure!(generation > 0, "TIME_RUNTIME_GENERATION");
|
||||
self.close()?;
|
||||
let clock = match &self.local_policy {
|
||||
Some((binding, policy)) => {
|
||||
SignedClock::open_local_service(generation, binding, policy, self.enrolled_helper.as_ref()).await?
|
||||
Some((binding, policy, installed_tenant)) => {
|
||||
SignedClock::open_local_service(generation, binding, policy, *installed_tenant, self.enrolled_helper.as_ref()).await?
|
||||
}
|
||||
None => SignedClock::open(self.role, generation).await?,
|
||||
};
|
||||
@@ -1561,7 +1571,7 @@ mod installed {
|
||||
#[cfg(all(windows, feature = "system-helper"))]
|
||||
pub use installed::{
|
||||
BoundClock, CONFIG_PATH, Comparison, RuntimeClock, SignedClock, UPDATER_CONFIG_PATH,
|
||||
enrolled_binding,
|
||||
enrolled_binding, enrolled_transfer_signer,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user