keyfile: for keyfile owner check allow root and euid

This partly restores the previous behavior. The point of the
file owner check is to ensure that the file cannot be read
by unpriviledged processes as it may contain secrets. If the
file is owned by root, that is considered secure (even if our
euid is different).

Possibly, if our euid is not root, then we couldn't read the
file, but that is a different problem.
This commit is contained in:
Thomas Haller 2022-01-18 17:47:17 +01:00
parent b1a14e3398
commit b2660b7012
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -337,7 +337,7 @@ nms_keyfile_utils_check_file_permissions_stat(NMSKeyfileFiletype filetype,
g_return_val_if_reached(FALSE);
if (!NM_FLAGS_HAS(nm_utils_get_testing(), NM_UTILS_TEST_NO_KEYFILE_OWNER_CHECK)) {
if (st->st_uid != nm_utils_get_nm_uid()) {
if (!NM_IN_SET(st->st_uid, 0, nm_utils_get_nm_uid())) {
g_set_error(error,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_CONNECTION,