Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic config mechanism #7

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Add generic config mechanism #7

merged 1 commit into from
Sep 27, 2023

Conversation

robin-nitrokey
Copy link
Member

This patch adds a generic configuration mechanism to the admin app. There are two new commands, GET_CONFIG and SET_CONFIG, that can be used to query and change configuration values by key. The runner is responsible for providing the configuration struct and a mapping from key to field.

Points to discuss:

  1. This implementation stores a format version in the config file. We could drop that and just change the file name if we change format.
  2. The config is loaded when the app is created and kept in memory during the app’s lifetime. We could also just load it on demand.
  3. Currently, we just panic on load failure. It could be better to just the default settings and signal an error.
  4. Do we need touch confirmation for the get/set operations?

@robin-nitrokey
Copy link
Member Author

Example implementation in the runner: Nitrokey/nitrokey-3-firmware#337

src/config.rs Outdated Show resolved Hide resolved
@sosthene-nitrokey
Copy link

Looks good!

@robin-nitrokey
Copy link
Member Author

Main changes since the initial implementation:

  • Use ClientFilestore directly instead of a Trussed client to load the configuration so that it works during initialization.
  • Serialize data as strings instead of CBOR types.
  • Drop the format version as part of the config file.
  • Don’t write a config file if the config is equals to the default config.

Still, a case could be made to use a backend instead so that applications can access changed configuration values without reboot. Though that would mean that applications need to be aware of the configuration mechanism.

@robin-nitrokey robin-nitrokey marked this pull request as ready for review September 26, 2023 21:13
@robin-nitrokey
Copy link
Member Author

pynitrokey PR for testing: Nitrokey/pynitrokey#448

@sosthene-nitrokey
Copy link

Still, a case could be made to use a backend instead so that applications can access changed configuration values without reboot. Though that would mean that applications need to be aware of the configuration mechanism.

For that, could the Config be passed to the applications in components/app everytime (apdu|ctaphid)_dispatch is called, that way the admin app can still mutate it, but the apps get the latest config on every call.

@daringer
Copy link

lgtm

This patch adds a generic configuration mechanism to the admin app.
There are two new commands, GET_CONFIG and SET_CONFIG, that can be used
to query and change configuration values by key.  The runner is
responsible for providing the configuration struct and a mapping from
key to field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants