]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timedate: treat 'activating' or 'inactivating' NTP client status as 'active'
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Jan 2019 17:59:48 +0000 (02:59 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Jan 2019 05:44:32 +0000 (14:44 +0900)
When `timedatectl set-time` is called, NTP client may be in
'activating' or something. For safety, let's treat such states as
'active'.

This also changes all unit file status except for 'masked' or 'disabled'
are treated as 'enabled'.

src/timedate/timedated.c

index e16888945c156fd69e771f9e972a1fcaba4aaf4d..12308bed42b2fb947a6a759567b5bde6822d3a2a 100644 (file)
@@ -160,7 +160,7 @@ static int context_ntp_service_is_active(Context *c) {
         /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
 
         LIST_FOREACH(units, info, c->units)
-                count += streq_ptr(info->active_state, "active");
+                count += !STRPTR_IN_SET(info->active_state, "inactive", "failed");
 
         return count;
 }
@@ -174,7 +174,7 @@ static int context_ntp_service_is_enabled(Context *c) {
         /* Call context_update_ntp_status() to update UnitStatusInfo before calling this. */
 
         LIST_FOREACH(units, info, c->units)
-                count += STRPTR_IN_SET(info->unit_file_state, "enabled", "enabled-runtime");
+                count += !STRPTR_IN_SET(info->unit_file_state, "masked", "masked-runtime", "disabled", "bad");
 
         return count;
 }