-
Notifications
You must be signed in to change notification settings - Fork 177
fix(agentlog): use proper file permissions when appending logs #5487
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
Conversation
eriknordmark
left a comment
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.
You need to fix the file in pkg/pillar/agentlog/agentlog.c (as one commit), and then
run make bump-eve-pillar
which will update edgeview etc vendoring of pillar and commit those.
[I think that will make the go.mod/go.sum shas be correct without using two separate PRs.]
Is there other code which has the same bug in the use of os.OpenFile?
as far as I know there is no way to do it in one PR: the go package needs to be published first for us to know which hash it's going to have. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5487 +/- ##
==========================================
+ Coverage 19.52% 28.08% +8.55%
==========================================
Files 19 19
Lines 3021 2314 -707
==========================================
+ Hits 590 650 +60
+ Misses 2310 1520 -790
- Partials 121 144 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I can't find this file :/ |
Oh shoot, I see now! I fixed in the vendor directory! sorry I just search for the function and picked the wrong file! |
c9c9782 to
f9862a4
Compare
at least Semgrep can't find anything obvious. It is not possible to do bitwise check on flag value in Semgrep so this rule is limited to string matching. |
f9862a4 to
51983d3
Compare
Wrong programming language on my part ;-) |
eriknordmark
left a comment
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
|
@shjala tests/semgrep-rules/os-openfile-non-perm-mode.yaml is missing Copyright note. Please, once we merge it, don't forget to open the PR updating vendor files.... in all dependencies (pkg/edgeview, etc). |
51983d3 to
3a5534d
Compare
3a5534d to
965f1fc
Compare
Replace os.ModeAppend with 0644 in OpenFile to correctly set Unix rw-r--r-- permissions when creating or appending to log files. Signed-off-by: Shahriyar Jalayeri <shahriyar@posteo.de>
965f1fc to
02eaf7c
Compare
make bump-eve-pilllar (or something like that) |
Description
Bug report
Fix
RebootReasonfunction in EdgeView creates/persist/log/reboot-reason.logby callingprintToFile,printToFilecreates the file if it doesn't exist, incorrectly passingos.ModeAppendas permission. This will lead to unix perm being 000, hence no permission.This PR replace os.ModeAppend with 0644 in OpenFile to correctly set Unix
rw-r--r--permissions when creating or appending to log files.PR dependencies
None
How to test and validate this PR
Apply the fixes, or use an image with the fix in place and run "Reboot reason“ command from Edge View, it should succeed.
Changelog notes
Fix “Reboot reason” command in EdgeView failing due to log file permission errors
PR Backports
To be determined.
Checklist
For backport PRs (remove it if it's not a backport):
And the last but not least:
check them.
Please, check the boxes above after submitting the PR in interactive mode.