How to create a firmware which does not allow preserving existing settings with Image Builder?

I've noticed that at least with Luci there could be a message saying "The uploaded firmware does not allow keeping current configuration."

Is it possible to use an image builder to generate an image which would be like that (ie not allow to keep existing settings when using it for sysupgrade)? How?

A possibly nit-picky type question here (because I don't have a device to test this)...

Does the LuCI sysupgrade process actually prevent keeping settings? Or does it just say that the settings won't be compatible??

IIRC, it's the latter -- essentially a very strong suggestion that you should make sure the keep settings checkbox is de-selected, else there are problems. But I am not aware of it explicitly preventing the user from maintaining settings across the upgrade.

Meanwhile, if I'm wrong about the above and an image can indeed be made to specifically dis-allow keeping settings, I must apologize for possibly asking a dumb question and the fact that I obviously won't be able to help with the technical solution.

1 Like

Well, great question, but in order to test that I'll need an image which doesn't allow keeping settings, won't I? :wink:

1 Like

Touché.

I would think that this could be tested on a device that has gone through swconfig > DSA -- especially one that has had it most recently (22.03 > 23.05). If you start with 22.03 and then upgrade, the premise should be tested and we'd have an answer. I don't have such a device to test with, though.

According to this, set ALLOW_BACKUP=0

https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg48500.html

the upload/flash GUI and this decision comes from the current firmware and not from the planned new firmware file.
If you plan on making more user friendly updates for others, you would need to create 2 updates and it would result in 2x flashing step for the user.

the first firmware would need to have compatible settings, so it would need to be a fork of the specific version that is currently on the device, just to get the adapted flash GUI onto the device

@samuel-w you're talking about modifying existing firmware not to allow backups, my question was how to disallow backups from the uploaded-about-to-be-flashed image.

@Pico what's your source for this? The Luci message clearly states: The uploaded firmware does not allow keeping current configuration. so the decision wherever to allow or not allow backup can also clearly come from the uploaded firmware. Moreover, looking at validate_firmware_image the trigger to disallow backups can come from image validation.

@aparcar @jow -- I see it's just some specific platforms which call notify_firmware_no_backup. I'm not versed enough in the image checking/creation, would it be possible to improve the generic base-files validate_firmware_image and all image builders so that images for all platforms can be created which do not allow backups?

Put a script under /etc/uci-defaults/ with a line like below (test it first, though). The first update with an image like that will have an option to keep backup or not. All subsequent backups will have that option disabled.

sed -i 's/ALLOW_BACKUP=1/ALLOW_BACKUP=0/' /usr/libexec/validate_firmware_image

This is how I do this.

Great, that doesn't answer my question.

No proof. Pure brain assumption. I was so far not expecting the deployed code to parse theuploaded firmware binary and then extract eval code from it to execute as check before esecuting

And yet on some platforms it does.