-
Notifications
You must be signed in to change notification settings - Fork 13
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 #857
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit weird, is it so that the file might be created in two places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is, should we really just push the key to the _buffers and let the file creation be only there?
9188888
to
b0a780b
Compare
Right, it was a bit confusing where and when the file is opened and how. Original idea was to create file already in init_logfile_encryption() even there is no key data (no_crypto) and then start_log would any case open file as append. Anyway, I made it now a bit different way: init_logfile_encryption() now gets keydata/keydatasize as param, allocate memory and store keydata there. Later the LogFileBuffer::start_log() gets the keydata buffer and if any data exists, it stores the keydata into the beginning of the recently opened file. How that looks? |
Store keydata into memory buffer in init phase. If keydata exists, write it into the beginning of the file when file is opened in LogFileBuffer::start_log()
b0a780b
to
eb54001
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
return; | ||
} | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering; would it simply work if you pushed the keydata into buffer right after start_log here? That is,
_buffers[(int)type].write_no_check(keydata, keydatasize);
?
Then you didn't need to pass the keydata down to the start_log, or modify that?
Just an idea, I don't know if it would work or not ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah.. sorry, now I understood what did you mean. That would be much much better! I'll check if that works.
Create empty file even if crypto key is not stored into the beginning of the log file to allow file logger to always append log data into existing file.