Skip to content

Commit b1d8baa

Browse files
committed
dbus: rauc: allow restricting installation to a specific manifest_hash
This makes sure that an user gets exact the bundle they intended to install, e.g. the bundle was not replaced by a newer one on the server or otherwise tampered with. Signed-off-by: Leonard Göhrs <[email protected]>
1 parent 0833495 commit b1d8baa

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,8 @@ components:
11071107
properties:
11081108
url:
11091109
type: string
1110+
manifest_hash:
1111+
type: string
11101112

11111113
UpdateChannels:
11121114
type: array

src/dbus/rauc.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,17 @@ impl From<(i32, String, i32)> for Progress {
117117
#[derive(Serialize, Deserialize, Clone)]
118118
#[serde(from = "UpdateRequestDe")]
119119
pub struct UpdateRequest {
120+
pub manifest_hash: Option<String>,
120121
pub url: Option<String>,
121122
}
122123

123124
#[derive(Deserialize)]
124125
#[serde(untagged)]
125126
enum UpdateRequestDe {
126-
UrlObject { url: Option<String> },
127+
UrlAndHash {
128+
manifest_hash: Option<String>,
129+
url: Option<String>,
130+
},
127131
UrlOnly(String),
128132
}
129133

@@ -132,8 +136,11 @@ impl From<UpdateRequestDe> for UpdateRequest {
132136
// Provide API backward compatibility by allowing either just a String
133137
// as argument or a map with url and manifest hash inside.
134138
match de {
135-
UpdateRequestDe::UrlObject { url } => Self { url },
136-
UpdateRequestDe::UrlOnly(url) => Self { url: Some(url) },
139+
UpdateRequestDe::UrlAndHash { manifest_hash, url } => Self { manifest_hash, url },
140+
UpdateRequestDe::UrlOnly(url) => Self {
141+
manifest_hash: None,
142+
url: Some(url),
143+
},
137144
}
138145
}
139146
}
@@ -579,7 +586,14 @@ impl Rauc {
579586
// Poor-mans validation. It feels wrong to let someone point to any
580587
// file on the TAC from the web interface.
581588
if url.starts_with("http://") || url.starts_with("https://") {
582-
let args = HashMap::new();
589+
let manifest_hash: Option<zbus::zvariant::Value> =
590+
update_request.manifest_hash.map(|mh| mh.into());
591+
592+
let mut args = HashMap::new();
593+
594+
if let Some(manifest_hash) = &manifest_hash {
595+
args.insert("require-manifest-hash", manifest_hash);
596+
}
583597

584598
if let Err(e) = proxy.install_bundle(&url, args).await {
585599
error!("Failed to install bundle: {}", e);

src/ui/screens/update_available.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ impl Selection {
126126
Highlight::Channel(ch) => {
127127
let req = UpdateRequest {
128128
url: Some(self.channels[ch].url.clone()),
129+
manifest_hash: None,
129130
};
130131

131132
install.set(req);

0 commit comments

Comments
 (0)