chiark / gitweb /
timesyncd: only attempt to connect when an address is configured
[elogind.git] / src / timesync / timesyncd.c
index 21843363d2ac03259ad7b48cb980f45c25b2eb52..6dcd942ec12fc968b644f19dcc4b7fb73d25632d 100644 (file)
@@ -978,8 +978,8 @@ static int manager_new(Manager **ret) {
 
         sd_event_set_watchdog(m->event, true);
 
-        sd_event_add_signal(m->event, &m->sigterm, SIGTERM, NULL,  NULL);
-        sd_event_add_signal(m->event, &m->sigint, SIGINT, NULL, NULL);
+        sd_event_add_signal(m->event, NULL, SIGTERM, NULL,  NULL);
+        sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
 
         r = sd_resolve_default(&m->resolve);
         if (r < 0)
@@ -1006,9 +1006,6 @@ static void manager_free(Manager *m) {
         manager_disconnect(m);
         manager_flush_names(m);
 
-        sd_event_source_unref(m->sigint);
-        sd_event_source_unref(m->sigterm);
-
         sd_event_source_unref(m->event_retry);
 
         sd_event_source_unref(m->network_event_source);
@@ -1073,7 +1070,7 @@ static bool network_is_online(void) {
         int r;
 
         r = sd_network_get_operational_state(&state);
-        if (r >= 0 && streq("carrier", state))
+        if (r >= 0 && (streq("routable", state) || streq("degraded", state)))
                 return true;
         else
                 return false;
@@ -1144,7 +1141,7 @@ static int manager_network_monitor_listen(Manager *m) {
         return 0;
 }
 
-static int drop_priviliges(void) {
+static int drop_privileges(void) {
         static const cap_value_t bits[] = {
                 CAP_SYS_TIME,
         };
@@ -1155,7 +1152,7 @@ static int drop_priviliges(void) {
         gid_t gid;
         int r;
 
-        /* Unfortunately we cannot leave privilige dropping to PID 1
+        /* Unfortunately we cannot leave privilege dropping to PID 1
          * here, since we want to run as user but want to keep te
          * CAP_SYS_TIME capability. Since file capabilities have been
          * introduced this cannot be done across exec() anymore,
@@ -1234,7 +1231,7 @@ int main(int argc, char *argv[]) {
 
         umask(0022);
 
-        r = drop_priviliges();
+        r = drop_privileges();
         if (r < 0)
                 goto out;