Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[storage] Secure use of cached keyfiles
This is a Jolla-unique change due to heavy customization of storage.c Upstream decided to save its service data to file with an assumption that it is empty by default and it is ok to create a new keyfile. Meanwhile, we have decided to cache the keyfiles read from config files. This causes a conflict, where service_save may order storage_save to write a different keyfile to disk than the one loaded to cache with storage_load. Afterwards, reading key-var values with storage_load would return values stored in cache instead of those stored in file. Thus, just like upstream storage_save would write to disk, and subsequent storage_load would read from disk, we clean the cache, and any subsequent storage_load would use the keyfile that was ordered to be stored. Although the fact that the keyfile variables are different would already be suspicious, and is indicated by a debug print, this order may work perfectly in upstream, and with this change we can be relatively sure that we are not introducing any regressions compared to upstream.
- Loading branch information