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

logger: fix file open issue if crypto algorithm is disabled #24156

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jnippula
Copy link
Contributor

@jnippula jnippula commented Dec 27, 2024

Open log file only once to avoid conflicts.

Solved Problem

Fixes #24155

Solution

  • The init_logfile_encryption() call is moved after the buffer's start_log() is called. This way file is opened only once and is already open when storing possible key data into the beginning of the file.

Changelog Entry

For release notes:

Bugfix: Fix logger file open when SDLOG_ALGORITHM is 0 (crypto disabled)

Alternatives

Could also add "append" parameter to start_log() function to select whether file needs to be opened as APPEND or CREATE flag. Another option is to store the keydata into temporary memory buffer and store it to file when opened in buffer's start_log() method.

Test coverage

  • Unit/integration test: Logging functionality with encryption enabled and disabled verified with Pixhawk4 and px4_fmu-v5_cryptotest target

@jnippula jnippula marked this pull request as draft January 3, 2025 13:08
move init_logfile_encryption() call after the buffer start_log() call
to have log file already open while storing the header and key data to
the beginning of the file.
@jnippula jnippula force-pushed the fix-logger-no-crypto branch from 38a0fe3 to dfd8f2c Compare January 3, 2025 13:54
@jnippula jnippula marked this pull request as ready for review January 3, 2025 14:10
PX4_ERR("Failed to start encrypted logging");
_crypto.close();
_buffers[(int)type]._should_run = false;
_buffers[(int)type].close_file();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_buffers[(int)type].close_file();
_buffers[(int)type].close_file();
_buffers[(int)type].reset();

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.

[Bug] Logging not working with crypto_algorithm==NONE
2 participants