Enable explicitly configured private artifact storage for authenticated production releases
This commit is contained in:
@@ -123,11 +123,13 @@ pub fn store() -> Result<UpdateArtifacts, Error> {
|
||||
if !metadata.is_file() || metadata.permissions().mode() & 0o077 != 0 {
|
||||
return Err(fail("AGENT_UPDATE_NOT_CONFIGURED"));
|
||||
}
|
||||
let profile = std::env::var("RMM_PROFILE").unwrap_or_default();
|
||||
Ok(UpdateArtifacts::new(
|
||||
&std::env::var("RMM_PROFILE").unwrap_or_default(),
|
||||
&profile,
|
||||
match std::env::var_os("RMM_AGENT_UPDATE_ARTIFACT_DIR") {
|
||||
Some(value) if FsPath::new(&value).is_absolute() => value.into(),
|
||||
Some(_) => return Err(fail("AGENT_UPDATE_NOT_CONFIGURED")),
|
||||
None if profile != "development" => return Err(fail("AGENT_UPDATE_NOT_CONFIGURED")),
|
||||
None => path
|
||||
.parent()
|
||||
.ok_or_else(|| fail("AGENT_UPDATE_NOT_CONFIGURED"))?
|
||||
|
||||
@@ -51,8 +51,8 @@ fn regular(file: &File, owner: u32, expected_size: u64) -> Result<fs::Metadata>
|
||||
impl UpdateArtifacts {
|
||||
pub fn new(profile: &str, root: PathBuf, owner: u32) -> Result<Self> {
|
||||
ensure!(
|
||||
profile == "development",
|
||||
"update object adapter is development-only"
|
||||
matches!(profile, "development" | "production") && root.is_absolute(),
|
||||
"release store requires a configured profile and absolute path"
|
||||
);
|
||||
Self::private_directory(root, owner)
|
||||
}
|
||||
@@ -246,7 +246,9 @@ mod tests {
|
||||
fs::set_permissions(&root, fs::Permissions::from_mode(0o700)).unwrap();
|
||||
let owner = fs::metadata(&root).unwrap().uid();
|
||||
let store = UpdateArtifacts::new("development", root.clone(), owner).unwrap();
|
||||
assert!(UpdateArtifacts::new("production", root.clone(), owner).is_err());
|
||||
assert!(UpdateArtifacts::new("production", root.clone(), owner).is_ok());
|
||||
assert!(UpdateArtifacts::new("unknown", root.clone(), owner).is_err());
|
||||
assert!(UpdateArtifacts::new("production", PathBuf::from("relative"), owner).is_err());
|
||||
let tenant = Uuid::new_v4();
|
||||
let bytes = vec![37_u8; 300_007];
|
||||
let hash = rmm_domain::jobs::hash(&bytes);
|
||||
|
||||
Reference in New Issue
Block a user