core,run: add timer related options to Bus-API
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Dec 2017 12:19:19 +0000 (21:19 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Dec 2017 12:19:19 +0000 (21:19 +0900)
src/core/dbus-timer.c
src/shared/bus-unit-util.c

index e440320..3e64536 100644 (file)
@@ -285,7 +285,7 @@ static int bus_timer_set_transient_property(
 
                 return 1;
 
-        } else if (streq(name, "WakeSystem")) {
+        } else if (STR_IN_SET(name, "WakeSystem", "Persistent", "RemainAfterElapse")) {
                 int b;
 
                 r = sd_bus_message_read(message, "b", &b);
@@ -293,21 +293,13 @@ static int bus_timer_set_transient_property(
                         return r;
 
                 if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
-                        t->wake_system = b;
-                        unit_write_settingf(UNIT(t), flags, name, "%s=%s", name, yes_no(b));
-                }
-
-                return 1;
-
-        } else if (streq(name, "RemainAfterElapse")) {
-                int b;
+                        if (streq(name, "WakeSystem"))
+                                t->wake_system = b;
+                        else if (streq(name, "Persistent"))
+                                t->persistent = b;
+                        else /* RemainAfterElapse */
+                                t->remain_after_elapse = b;
 
-                r = sd_bus_message_read(message, "b", &b);
-                if (r < 0)
-                        return r;
-
-                if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
-                        t->remain_after_elapse = b;
                         unit_write_settingf(UNIT(t), flags, name, "%s=%s", name, yes_no(b));
                 }
 
index 1625ee7..b58abed 100644 (file)
@@ -357,7 +357,7 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                               "TasksAccounting", "IPAccounting", "SendSIGHUP", "SendSIGKILL", "WakeSystem",
                               "DefaultDependencies", "IgnoreSIGPIPE", "TTYVHangup", "TTYReset", "TTYVTDisallocate",
                               "RemainAfterExit", "PrivateTmp", "PrivateDevices", "PrivateNetwork", "PrivateUsers",
-                              "NoNewPrivileges", "SyslogLevelPrefix", "RemainAfterElapse",
+                              "NoNewPrivileges", "SyslogLevelPrefix", "RemainAfterElapse", "Persistent",
                               "MemoryDenyWriteExecute", "RestrictRealtime", "DynamicUser", "RemoveIPC",
                               "ProtectKernelTunables", "ProtectKernelModules", "ProtectControlGroups", "MountAPIVFS",
                               "CPUSchedulingResetOnFork", "LockPersonality")) {
@@ -411,7 +411,9 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
                               "RootDirectory", "SyslogIdentifier", "ProtectSystem",
                               "ProtectHome", "SELinuxContext", "Restart", "RootImage",
                               "NotifyAccess", "RuntimeDirectoryPreserve", "Personality",
-                              "KeyringMode", "CollectMode", "FailureAction", "SuccessAction"))
+                              "KeyringMode", "CollectMode", "FailureAction", "SuccessAction",
+                              "OnCalendar"))
+
                 r = sd_bus_message_append(m, "v", "s", eq);
 
         else if (streq(field, "StandardInputData")) {
@@ -1290,6 +1292,17 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
 
                 r = sd_bus_message_close_container(m);
 
+        } else if (STR_IN_SET(field,
+                              "OnActiveSec", "OnBootSec", "OnStartupSec",
+                              "OnUnitActiveSec","OnUnitInactiveSec")) {
+                usec_t t;
+
+                r = parse_sec(eq, &t);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to parse %s= parameter: %s", field, eq);
+
+                r = sd_bus_message_append(m, "v", "t", t);
+
         } else {
                 log_error("Unknown assignment: %s", assignment);
                 return -EINVAL;