diff options
author | Luca Boccassi <bluca@debian.org> | 2022-11-24 11:21:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-24 11:21:16 +0100 |
commit | 9f5bf99f1b296aeef3c84527b0a87f4734f1029c (patch) | |
tree | 541bf43644b30960f40e70b14e926a82f6158ad1 /src | |
parent | 2e776ed6c8649d5991de5d2a7c0334a77485456c (diff) | |
parent | f05bcc18941eef5c2f93cfa06660eb06e0dc4c55 (diff) | |
download | systemd-9f5bf99f1b296aeef3c84527b0a87f4734f1029c.tar.gz |
Merge pull request #25509 from enr0n/oomd-unpriv-container-fix
Fix `oomd_fetch_cgroup_oom_preference()` for unprivileged LXD containers
Diffstat (limited to 'src')
-rw-r--r-- | src/oom/oomd-util.c | 2 | ||||
-rw-r--r-- | src/oom/test-oomd-util.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c index 1fc81d1843..70a1dc941e 100644 --- a/src/oom/oomd-util.c +++ b/src/oom/oomd-util.c @@ -164,7 +164,7 @@ int oomd_fetch_cgroup_oom_preference(OomdCGroupContext *ctx, const char *prefix) if (r < 0) return log_debug_errno(r, "Failed to get owner/group from %s: %m", ctx->path); - if (uid == prefix_uid) { + if (uid == prefix_uid || uid == 0) { /* Ignore most errors when reading the xattr since it is usually unset and cgroup xattrs are only used * as an optional feature of systemd-oomd (and the system might not even support them). */ r = cg_get_xattr_bool(SYSTEMD_CGROUP_CONTROLLER, ctx->path, "user.oomd_avoid"); diff --git a/src/oom/test-oomd-util.c b/src/oom/test-oomd-util.c index 176e3a8d69..faa75c5578 100644 --- a/src/oom/test-oomd-util.c +++ b/src/oom/test-oomd-util.c @@ -475,9 +475,9 @@ static void test_oomd_fetch_cgroup_oom_preference(void) { /* Assert that avoid/omit are not set if the cgroup and prefix are not * owned by the same user.*/ - if (test_xattrs && !empty_or_root(ctx->path)) { + if (test_xattrs && !empty_or_root(cgroup)) { ctx = oomd_cgroup_context_free(ctx); - assert_se(cg_set_access(SYSTEMD_CGROUP_CONTROLLER, cgroup, 65534, 0) >= 0); + assert_se(cg_set_access(SYSTEMD_CGROUP_CONTROLLER, cgroup, 61183, 0) >= 0); assert_se(oomd_cgroup_context_acquire(cgroup, &ctx) == 0); assert_se(oomd_fetch_cgroup_oom_preference(ctx, NULL) == 0); |