@@ -394,33 +394,50 @@ impl Rauc {
394
394
} ) ?;
395
395
396
396
let conn_task = conn. clone ( ) ;
397
+ let channels = inst. channels . clone ( ) ;
397
398
let ( mut install_stream, _) = inst. install . clone ( ) . subscribe_unbounded ( ) ;
398
399
399
400
// Forward the "install" topic from the broker framework to RAUC
400
401
wtb. spawn_task ( "rauc-forward-install" , async move {
401
402
let proxy = InstallerProxy :: new ( & conn_task) . await . unwrap ( ) ;
402
403
403
404
while let Some ( update_request) = install_stream. next ( ) . await {
404
- let url = match update_request. url {
405
- Some ( url) => url,
406
- None => continue ,
405
+ let channels = match channels. try_get ( ) {
406
+ Some ( chs) => chs,
407
+ None => {
408
+ warn ! ( "Got install request with no channels available yet" ) ;
409
+ continue ;
410
+ }
407
411
} ;
408
412
409
- // Poor-mans validation. It feels wrong to let someone point to any
410
- // file on the TAC from the web interface.
411
- if url. starts_with ( "http://" ) || url. starts_with ( "https://" ) {
412
- let manifest_hash: Option < zbus:: zvariant:: Value > =
413
- update_request. manifest_hash . map ( |mh| mh. into ( ) ) ;
414
-
415
- let mut args = HashMap :: new ( ) ;
416
-
417
- if let Some ( manifest_hash) = & manifest_hash {
418
- args. insert ( "require-manifest-hash" , manifest_hash) ;
413
+ let primary = match channels. primary ( ) {
414
+ Some ( primary) => primary,
415
+ None => {
416
+ warn ! ( "Got install request with no primary channel configured" ) ;
417
+ continue ;
419
418
}
419
+ } ;
420
420
421
- if let Err ( e) = proxy. install_bundle ( & url, args) . await {
422
- error ! ( "Failed to install bundle: {}" , e) ;
421
+ let url = match & update_request. url {
422
+ None => & primary. url ,
423
+ Some ( url) if url == & primary. url => & primary. url ,
424
+ Some ( _) => {
425
+ warn ! ( "Got install request with URL not matching primary channel URL" ) ;
426
+ continue ;
423
427
}
428
+ } ;
429
+
430
+ let manifest_hash: Option < zbus:: zvariant:: Value > =
431
+ update_request. manifest_hash . map ( |mh| mh. into ( ) ) ;
432
+
433
+ let mut args = HashMap :: new ( ) ;
434
+
435
+ if let Some ( manifest_hash) = & manifest_hash {
436
+ args. insert ( "require-manifest-hash" , manifest_hash) ;
437
+ }
438
+
439
+ if let Err ( e) = proxy. install_bundle ( url, args) . await {
440
+ error ! ( "Failed to install bundle: {}" , e) ;
424
441
}
425
442
}
426
443
0 commit comments