Skip to content

Commit 31dd189

Browse files
committed
dbus: rauc: prevent auto updates while in setup mode
This is to prevent a situation where a user enables auto-install in the setup mode and an update starts immediately, does a migration of whatever the user has configured so far and triggers a reboot while the user is still configuring things in the web interface. This should make the user experience a bit better: - Unbox TAC. - Enter setup mode. - Enable update polling and auto install. (A poll for updates will trigger immediately, but no auto install) - Configure the rest of the system. - Leave the setup mode. - Another poll for updates may be triggered and if available an installation will start. - The user is greeted by the normal web interface showing a notification about the ongoing installation. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
1 parent e5c3a3c commit 31dd189

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

src/dbus.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ impl DbusSession {
8282
wtb: &mut WatchedTasksBuilder,
8383
led_dut: Arc<Topic<BlinkPattern>>,
8484
led_uplink: Arc<Topic<BlinkPattern>>,
85+
setup_mode: Arc<Topic<bool>>,
8586
) -> anyhow::Result<Self> {
8687
let tacd = Tacd::new();
8788

@@ -94,7 +95,7 @@ impl DbusSession {
9495
Ok(Self {
9596
hostname: Hostname::new(bb, wtb, &conn)?,
9697
network: Network::new(bb, wtb, &conn, led_dut, led_uplink)?,
97-
rauc: Rauc::new(bb, wtb, &conn, systemd.rauc.clone())?,
98+
rauc: Rauc::new(bb, wtb, &conn, systemd.rauc.clone(), setup_mode)?,
9899
systemd,
99100
})
100101
}

src/dbus/rauc.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ async fn channel_list_update_task(
207207
reload: Arc<Topic<bool>>,
208208
enable_polling: Arc<Topic<bool>>,
209209
enable_auto_install: Arc<Topic<bool>>,
210+
setup_mode: Arc<Topic<bool>>,
210211
channels: Arc<Topic<Channels>>,
211212
rauc_service: Service,
212213
) -> Result<()> {
@@ -215,9 +216,11 @@ async fn channel_list_update_task(
215216
let (reload_stream, _) = reload.subscribe_unbounded();
216217
let (mut enable_polling_stream, _) = enable_polling.subscribe_unbounded();
217218
let (mut enable_auto_install_stream, _) = enable_auto_install.subscribe_unbounded();
219+
let (mut setup_mode_stream, _) = setup_mode.subscribe_unbounded();
218220

219221
let mut enable_polling = enable_polling_stream.next().await.unwrap_or(false);
220222
let mut enable_auto_install = enable_auto_install_stream.next().await.unwrap_or(false);
223+
let mut setup_mode = setup_mode_stream.next().await.unwrap_or(true);
221224

222225
'reload_loop: loop {
223226
futures::select! {
@@ -232,6 +235,9 @@ async fn channel_list_update_task(
232235
enable_auto_install_new = enable_auto_install_stream.recv().fuse() => {
233236
enable_auto_install = enable_auto_install_new?;
234237
}
238+
setup_mode_new = setup_mode_stream.recv().fuse() => {
239+
setup_mode = setup_mode_new?;
240+
}
235241
};
236242

237243
// Read the list of available update channels
@@ -243,8 +249,12 @@ async fn channel_list_update_task(
243249
}
244250
};
245251

246-
let should_reload =
247-
update_system_conf(new_channels.primary(), enable_polling, enable_auto_install)?;
252+
let should_reload = update_system_conf(
253+
new_channels.primary(),
254+
enable_polling,
255+
enable_auto_install,
256+
setup_mode,
257+
)?;
248258

249259
channels.set(new_channels);
250260

@@ -329,6 +339,7 @@ impl Rauc {
329339
wtb: &mut WatchedTasksBuilder,
330340
_conn: &Arc<Connection>,
331341
rauc_service: Service,
342+
setup_mode: Arc<Topic<bool>>,
332343
) -> Result<Self> {
333344
let inst = Self::setup_topics(bb);
334345

@@ -344,6 +355,7 @@ impl Rauc {
344355
inst.reload.clone(),
345356
inst.enable_polling.clone(),
346357
inst.enable_auto_install.clone(),
358+
setup_mode,
347359
inst.channels.clone(),
348360
rauc_service,
349361
),
@@ -358,6 +370,7 @@ impl Rauc {
358370
wtb: &mut WatchedTasksBuilder,
359371
conn: &Arc<Connection>,
360372
rauc_service: Service,
373+
setup_mode: Arc<Topic<bool>>,
361374
) -> Result<Self> {
362375
let inst = Self::setup_topics(bb);
363376

@@ -613,6 +626,7 @@ impl Rauc {
613626
inst.reload.clone(),
614627
inst.enable_polling.clone(),
615628
inst.enable_auto_install.clone(),
629+
setup_mode,
616630
inst.channels.clone(),
617631
rauc_service,
618632
),

src/dbus/rauc/system_conf.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub fn update_system_conf(
7474
primary_channel: Option<&Channel>,
7575
enable_polling: bool,
7676
enable_auto_install: bool,
77+
setup_mode: bool,
7778
) -> std::io::Result<bool> {
7879
let dynamic_conf = {
7980
// Allow force-enabling update polling and automatic installations
@@ -86,8 +87,13 @@ pub fn update_system_conf(
8687
.and_then(|pc| pc.force_auto_install)
8788
.unwrap_or(false);
8889

90+
// Allow polling for updates, but not automatically installing them
91+
// while the user is still in setup mode.
92+
// Otherwise they may unbox a TAC, click through the setup process,
93+
// activate auto installation, and then an installation starts in the
94+
// background without them even noticing.
8995
let polling = enable_polling || force_polling;
90-
let auto_install = enable_auto_install || force_auto_install;
96+
let auto_install = (enable_auto_install || force_auto_install) && !setup_mode;
9197

9298
match poll_section(primary_channel, polling, auto_install) {
9399
Ok(Some(ps)) => {

src/main.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,23 @@ async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder)>
107107
adc.iobus_curr.fast.clone(),
108108
adc.iobus_volt.fast.clone(),
109109
)?;
110+
111+
// Set up a http server and provide some static files like the web
112+
// interface and config files that may be edited inside the web ui.
113+
let mut http_server = HttpServer::new();
114+
115+
// Allow editing some aspects of the TAC configuration when in "setup mode".
116+
let setup_mode = SetupMode::new(&mut bb, &mut wtb, &mut http_server.server)?;
117+
110118
let (hostname, network, rauc, systemd) = {
111-
let dbus =
112-
DbusSession::new(&mut bb, &mut wtb, led.eth_dut.clone(), led.eth_lab.clone()).await?;
119+
let dbus = DbusSession::new(
120+
&mut bb,
121+
&mut wtb,
122+
led.eth_dut.clone(),
123+
led.eth_lab.clone(),
124+
setup_mode.setup_mode.clone(),
125+
)
126+
.await?;
113127

114128
(dbus.hostname, dbus.network, dbus.rauc, dbus.systemd)
115129
};
@@ -123,13 +137,6 @@ async fn init(screenshooter: ScreenShooter) -> Result<(Ui, WatchedTasksBuilder)>
123137
// (if requested on start).
124138
let watchdog = Watchdog::new(dut_pwr.tick());
125139

126-
// Set up a http server and provide some static files like the web
127-
// interface and config files that may be edited inside the web ui.
128-
let mut http_server = HttpServer::new();
129-
130-
// Allow editing some aspects of the TAC configuration when in "setup mode".
131-
let setup_mode = SetupMode::new(&mut bb, &mut wtb, &mut http_server.server)?;
132-
133140
// Expose a live log of the TAC's systemd journal so it can be viewed
134141
// in the web interface.
135142
journal::serve(&mut http_server.server);

0 commit comments

Comments
 (0)