util: explicitly chmod generated files to enforce permissions - #614
Merged
Merged
Conversation
vpashaiev
force-pushed
the
fix/umask-file-permissions
branch
from
September 14, 2026 13:19
dad2ee7 to
cf5000f
Compare
When netplan generate is executed under a restrictive umask (such as 0077), files written by g_file_set_contents_full() end up with mode 0600 instead of 0640. This prevents systemd-networkd from reading the generated .network files, breaking network configuration. Explicitly call chmod() after chown() so target permissions are guaranteed regardless of the caller's umask. Also add a unit test in test_netplan_misc to verify file creation under a restrictive umask. LP: #2164636 Signed-off-by: Viktor Pashaiev <w.paszajew@gmail.com>
vpashaiev
force-pushed
the
fix/umask-file-permissions
branch
from
September 14, 2026 13:55
cf5000f to
e0f4cc7
Compare
JegadishD
approved these changes
Sep 18, 2026
JegadishD
left a comment
Collaborator
There was a problem hiding this comment.
@vpashaiev Thanks for the PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
netplan generateruns under a restrictive umask (such as0077), files created byg_file_set_contents_full()end up with permissions0600instead of0640. As a result,systemd-networkd(running unprivileged assystemd-network:systemd-network) cannot read/run/systemd/network/10-netplan-*.network, causing network configuration to fail on boot.This PR explicitly calls
chmod()afterchown()in_netplan_g_string_free_to_file_with_permissions()so that the intended file mode is enforced regardless of the caller's umask. It also adds a unit test intest_netplan_miscto verify file permissions under umask0077.Addresses feedback from @puida on Launchpad #2164636.
Fixes: https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/2164636