Skip to content

Commit

Permalink
autoupdater: verify the image before upgrading (#247)
Browse files Browse the repository at this point in the history
Let sysupgrade run a --test upgrade to verify that the image is
compatible before attempting an upgrade.
This fixes an issue where a router can get stuck without network
connectivity when a a remote autoupgrade was triggered.

Fixes #193
  • Loading branch information
grische authored Sep 8, 2021
1 parent 8353495 commit 0648b2d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions admin/autoupdater/src/autoupdater.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,24 @@ static bool autoupdate(const char *mirror, struct settings *s, int lock_fd) {
}
}

/* Test the image upgrade (issue #193) */
{
static const char *const exec_builtin = "exec ";
static const char *const test_option = " --test ";

char buf[strlen(exec_builtin) + strlen(sysupgrade_path) + strlen(test_option) + strlen(firmware_path) + 1];
strcpy(buf, exec_builtin);
strcat(buf, sysupgrade_path);
strcat(buf, test_option);
strcat(buf, firmware_path);

const int sysupgrade_ret = system(buf);
if (WEXITSTATUS(sysupgrade_ret) != 0 ) {
fprintf(stderr, "autoupdater: warning: sysupgrade --test failed with return code: %d\n", WEXITSTATUS(sysupgrade_ret));
goto fail_after_download;
}
}

clear_manifest(m);

/**** Call sysupgrade ************************************************/
Expand Down

0 comments on commit 0648b2d

Please sign in to comment.