Reproduced on resolute with umask 0077.

The problem is in src/util.c:96
(_netplan_g_string_free_to_file_with_permissions). It writes files with
g_file_set_contents_full(), which creates files using the caller's umask
(mode & ~umask). With umask 0077, /run/systemd/network/*.network files
are created with 0600 instead of 0640.

Netplan does chown() to set group systemd-network, but never calls
chmod(). Because of that, systemd-networkd gets Permission denied and
drops the interface.

Adding chmod(full_path, mode) right after chown() fixes it and makes
sure the file always gets 0640.

Tested with umask 0077 && netplan generate:

Before: -rw------- 1 root systemd-network (sudo -u systemd-network cat fails 
with Permission denied)
After: -rw-r----- 1 root systemd-network (sudo -u systemd-network cat works 
fine)


Attaching debdiff for netplan.io 1.2-1ubuntu5.1 with the fix.

** Patch added: "debdiff for netplan.io 1.2-1ubuntu5.2"
   
https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/2164636/+attachment/5999574/+files/netplan.io_1.2-1ubuntu5.2.debdiff

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2164636

Title:
  Netplan generates unreadable networkd files when called with umask
  0077

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/2164636/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to