diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-01-18 15:40:21 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-01-18 15:40:21 +0100 |
commit | 8d53b4534a5923721b5f1e9dd7e8f4a903d02d51 (patch) | |
tree | 7b0a03a93fc3aa706676713e8062bdbb6dc4ad2d /src/execute.c | |
parent | 62f21ec91ad8e7e24079962f4df066b0094fe68d (diff) |
exec: introduce ControlGroupPersistant= to make cgroups persistant
Diffstat (limited to 'src/execute.c')
-rw-r--r-- | src/execute.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/execute.c b/src/execute.c index cacc8a73c5..650c6c1436 100644 --- a/src/execute.c +++ b/src/execute.c @@ -993,7 +993,7 @@ int exec_spawn(ExecCommand *command, char **our_env = NULL, **pam_env = NULL, **final_env = NULL, **final_argv = NULL; unsigned n_env = 0; int saved_stdout = -1, saved_stdin = -1; - bool keep_stdout = false, keep_stdin = false; + bool keep_stdout = false, keep_stdin = false, set_access = false; /* child */ @@ -1218,11 +1218,21 @@ int exec_spawn(ExecCommand *command, if (cgroup_bondings && context->control_group_modify) { err = cgroup_bonding_set_group_access_list(cgroup_bondings, 0755, uid, gid); if (err >= 0) - err = cgroup_bonding_set_task_access_list(cgroup_bondings, 0644, uid, gid); + err = cgroup_bonding_set_task_access_list(cgroup_bondings, 0644, uid, gid, context->control_group_persistant); if (err < 0) { r = EXIT_CGROUP; goto fail_child; } + + set_access = true; + } + } + + if (cgroup_bondings && !set_access && context->control_group_persistant >= 0) { + err = cgroup_bonding_set_task_access_list(cgroup_bondings, (mode_t) -1, (uid_t) -1, (uid_t) -1, context->control_group_persistant); + if (err < 0) { + r = EXIT_CGROUP; + goto fail_child; } } @@ -1488,6 +1498,7 @@ void exec_context_init(ExecContext *c) { c->mount_flags = MS_SHARED; c->kill_signal = SIGTERM; c->send_sigkill = true; + c->control_group_persistant = -1; } void exec_context_done(ExecContext *c) { @@ -1673,6 +1684,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { "%sNonBlocking: %s\n" "%sPrivateTmp: %s\n" "%sControlGroupModify: %s\n" + "%sControlGroupPersistant: %s\n" "%sPrivateNetwork: %s\n", prefix, c->umask, prefix, c->working_directory ? c->working_directory : "/", @@ -1680,6 +1692,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { prefix, yes_no(c->non_blocking), prefix, yes_no(c->private_tmp), prefix, yes_no(c->control_group_modify), + prefix, yes_no(c->control_group_persistant), prefix, yes_no(c->private_network)); STRV_FOREACH(e, c->environment) |