]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Hook more properties for transient units 1250/head
authorGabriel de Perthuis <g2p.code@gmail.com>
Thu, 10 Sep 2015 14:45:28 +0000 (16:45 +0200)
committerGabriel de Perthuis <g2p.code@gmail.com>
Fri, 11 Sep 2015 16:25:41 +0000 (18:25 +0200)
systemd-run can now launch units with PrivateTmp, PrivateDevices,
PrivateNetwork, NoNewPrivileges set.

src/core/dbus-execute.c
src/shared/bus-util.c

index ed55fcfca29317e7b0f2239ee947d68adfc3317d..fd13c6d01905feee8ebcbd197391b04ea1f75c20 100644 (file)
@@ -933,7 +933,10 @@ int bus_exec_context_set_transient_property(
 
                 return 1;
 
-        } else if (streq(name, "IgnoreSIGPIPE")) {
+        } else if (STR_IN_SET(name,
+                              "IgnoreSIGPIPE", "TTYVHangup", "TTYReset",
+                              "PrivateTmp", "PrivateDevices", "PrivateNetwork",
+                              "NoNewPrivileges")) {
                 int b;
 
                 r = sd_bus_message_read(message, "b", &b);
@@ -941,39 +944,22 @@ int bus_exec_context_set_transient_property(
                         return r;
 
                 if (mode != UNIT_CHECK) {
-                        c->ignore_sigpipe = b;
-
-                        unit_write_drop_in_private_format(u, mode, name, "IgnoreSIGPIPE=%s\n", yes_no(b));
-                }
-
-                return 1;
-
-        } else if (streq(name, "TTYVHangup")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->tty_vhangup = b;
-
-                        unit_write_drop_in_private_format(u, mode, name, "TTYVHangup=%s\n", yes_no(b));
-                }
-
-                return 1;
-
-        } else if (streq(name, "TTYReset")) {
-                int b;
-
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (mode != UNIT_CHECK) {
-                        c->tty_reset = b;
-
-                        unit_write_drop_in_private_format(u, mode, name, "TTYReset=%s\n", yes_no(b));
+                        if (streq(name, "IgnoreSIGPIPE"))
+                                c->ignore_sigpipe = b;
+                        else if (streq(name, "TTYVHangup"))
+                                c->tty_vhangup = b;
+                        else if (streq(name, "TTYReset"))
+                                c->tty_reset = b;
+                        else if (streq(name, "PrivateTmp"))
+                                c->private_tmp = b;
+                        else if (streq(name, "PrivateDevices"))
+                                c->private_devices = b;
+                        else if (streq(name, "PrivateNetwork"))
+                                c->private_network = b;
+                        else if (streq(name, "NoNewPrivileges"))
+                                c->no_new_privileges = b;
+
+                        unit_write_drop_in_private_format(u, mode, name, "%s=%s\n", name, yes_no(b));
                 }
 
                 return 1;
index 4dc4ca581d35a5247d902760e5e1a526b9ff98b7..e144f86009b0826ec37025f8dad6f806798f4dbf 100644 (file)
@@ -1423,7 +1423,8 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
         if (STR_IN_SET(field,
                        "CPUAccounting", "MemoryAccounting", "BlockIOAccounting", "TasksAccounting",
                        "SendSIGHUP", "SendSIGKILL", "WakeSystem", "DefaultDependencies",
-                       "IgnoreSIGPIPE", "TTYVHangup", "TTYReset", "RemainAfterExit")) {
+                       "IgnoreSIGPIPE", "TTYVHangup", "TTYReset", "RemainAfterExit",
+                       "PrivateTmp", "PrivateDevices", "PrivateNetwork", "NoNewPrivileges")) {
 
                 r = parse_boolean(eq);
                 if (r < 0) {