diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-03-05 03:49:00 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-03-05 04:08:04 +0100 |
commit | d584f638940366c46a48e34a25cf43e2b77475be (patch) | |
tree | 2192d874ce2fa937507312a7502ce2ccee06bcfd /src/core | |
parent | 1ac67edb7c4d31a287fa98c0b554ae98bd34e71b (diff) |
core: make the LimitXYZ= properties settable for transient service units
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/dbus-execute.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 4c3ad65825..bf4a682d3a 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -851,6 +851,44 @@ int bus_exec_context_set_transient_property( } return 1; + + } else if (rlimit_from_string(name) >= 0) { + uint64_t rl; + rlim_t x; + + r = sd_bus_message_read(message, "t", &rl); + if (r < 0) + return r; + + if (rl == (uint64_t) -1) + x = RLIM_INFINITY; + else { + x = (rlim_t) rl; + + if ((uint64_t) x != rl) + return -ERANGE; + } + + if (mode != UNIT_CHECK) { + int z; + + z = rlimit_from_string(name); + + if (!c->rlimit[z]) { + c->rlimit[z] = new(struct rlimit, 1); + if (!c->rlimit[z]) + return -ENOMEM; + } + + c->rlimit[z]->rlim_cur = c->rlimit[z]->rlim_max = x; + + if (x == RLIM_INFINITY) + unit_write_drop_in_private_format(u, mode, name, "%s=infinity\n", name); + else + unit_write_drop_in_private_format(u, mode, name, "%s=%" PRIu64 "\n", name, rl); + } + + return 1; } return 0; |