X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fdbus-execute.c;h=13b3d0dd14c8214ede175f2a972fe2dfac68dcd0;hp=3a05303f084070ffa8fbcab543bc49f7420a2ec7;hb=4e595329a93ed190795c2e24bf132d5028ec6a72;hpb=6e18964d3a365567954fe10ddcfad74babdc427c diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 3a05303f0..13b3d0dd1 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -87,6 +87,7 @@ static int property_get_rlimit( struct rlimit *rl; uint64_t u; + rlim_t x; assert(bus); assert(reply); @@ -94,7 +95,7 @@ static int property_get_rlimit( rl = *(struct rlimit**) userdata; if (rl) - u = (uint64_t) rl->rlim_max; + x = rl->rlim_max; else { struct rlimit buf = {}; int z; @@ -103,10 +104,14 @@ static int property_get_rlimit( assert(z >= 0); getrlimit(z, &buf); - - u = (uint64_t) buf.rlim_max; + x = buf.rlim_max; } + /* rlim_t might have different sizes, let's map + * RLIMIT_INFINITY to (uint64_t) -1, so that it is the same on + * all archs */ + u = x == RLIM_INFINITY ? (uint64_t) -1 : (uint64_t) x; + return sd_bus_message_append(reply, "t", u); } @@ -613,7 +618,6 @@ const sd_bus_vtable bus_exec_vtable[] = { SD_BUS_PROPERTY("User", "s", NULL, offsetof(ExecContext, user), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Group", "s", NULL, offsetof(ExecContext, group), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("SupplementaryGroups", "as", NULL, offsetof(ExecContext, supplementary_groups), SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("TCPWrapName", "s", NULL, offsetof(ExecContext, tcpwrap_name), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("PAMName", "s", NULL, offsetof(ExecContext, pam_name), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("ReadWriteDirectories", "as", NULL, offsetof(ExecContext, read_write_dirs), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("ReadOnlyDirectories", "as", NULL, offsetof(ExecContext, read_only_dirs), SD_BUS_VTABLE_PROPERTY_CONST), @@ -845,6 +849,44 @@ int bus_exec_context_set_transient_property( unit_write_drop_in_private_format(u, mode, name, "Environment=%s\n", joined); } + 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; }