-
Notifications
You must be signed in to change notification settings - Fork 185
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
hostsfile: Copy the SELinux context to the temp file before overwrite #273
Conversation
hmm the CI failures seem unrelated?
but I don't think I have perms to retry. |
Just retried them, let's see. |
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.
Unfortunately I'm not an SELinux user so I can't really confirm the correctness of the logic, but the code looks clean enough.
Do you think it's worth the hassle to do this context copying compared to, say, only allowing overwriting /etc/hosts
in-place if SELinux is detected?
ed2c9e8
to
a89f422
Compare
IMO yes: SELinux-enabled is the default on a lot of systems, namely the RHEL variants & Fedora. Losing atomic updates on those systems in favor of potentially wiping the hosts file (learned the importance of atomic file updates the hard way before 🙃) would be pretty unfortunate 😅 . |
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.
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 good to me, I have just 2 considerations:
- @refi64 can you please rebase on current
main
? That should fix the Docker CI as a side-effect - I guess selinux is specific to Linux, i.e. what happens if one tries to build innernet on a Mac with
selinux
feature enabled? Maybe we should make it target-specific, but I'm not sure how cargo features and target-specific dependencies interact. (ideally we don't have the feature at all outside linux, but I fear that's not possible)
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.
Looks good, just a small suggestion.
I also agree with @strohel we need a rebase on main
which should fix CI and the existing merge conflict.
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.
Adding some more notes on logging messages.
whoops looks like this fell off my radar, all comments should be fixed now. |
Clippy failure seems unrelated:
|
@refi64 I'll take care of the clippy issues in |
@refi64 done, if you rebase on |
84e8c65
to
3440b79
Compare
@bschwind just rebased 🤞 |
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++
I'll wait for a quick review from @strohel before merging.
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 is looking good, but one late request @refi64: could you please document the new feature (flag) in README.md? Also stating that it is currently disabled by default. We'll then make sure we mention it in the next relase notes, pinging package maintainers to decide whether they want to activate the flag or not.
Since @refi64 hasn't responded, and I'd really like to see this merged (I use the code, works fine for me) I've added the documentation; I'm including it here as a patch...
|
On SELinux-enabled systems, /etc/hosts has a different type `net_conf_t` than the other files in /etc, so the temporary file that overwrites it ends up with the wrong context, resulting in many system services becoming unable to access the file. To fix this, manually look up the context /etc/hosts has and copy it to the temporary file before the rename. In order to avoid depending on libselinux on systems that don't use it, this support is gated behind the new "selinux" feature. It *is* installed and enabled in the Dockerfile, however, in order to ensure that it still builds.
oops sorry it looks like I completely missed the last comment 😅 thanks for pushing that update! |
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++, added some REAME nits which would be nice to address, but very minor and approving already.
So, how about someone merge this? |
On SELinux-enabled systems, /etc/hosts has a different type
net_conf_t
than the other files in /etc, so the temporary file that overwrites it ends up with the wrong context, resulting in many system services becoming unable to access the file. To fix this, manually look up the context /etc/hosts has and copy it to the temporary file before the rename.In order to avoid depending on libselinux on systems that don't use it, this support is gated behind the new "selinux" feature. It is installed and enabled in the Dockerfile, however, in order to ensure that it still builds.