Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

Add generic config mechanism - #7

Merged
robin-nitrokey merged 1 commit into
mainfrom
config
Sep 27, 2023
Merged

Add generic config mechanism#7
robin-nitrokey merged 1 commit into
mainfrom
config

Conversation

@robin-nitrokey

Copy link
Copy Markdown
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
Copy Markdown
Member Author

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

Comment thread src/config.rs Outdated
@sosthene-nitrokey

Copy link
Copy Markdown

Looks good!

@robin-nitrokey

Copy link
Copy Markdown
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
Copy Markdown
Member Author

pynitrokey PR for testing: Nitrokey/pynitrokey#448

@sosthene-nitrokey

Copy link
Copy Markdown

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
Copy Markdown

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants