]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: convert LOGON timestamp only with LOGON message
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Aug 2014 11:58:52 +0000 (13:58 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Aug 2014 14:06:28 +0000 (16:06 +0200)
Avoid always calling UTI_TimevalNetworkToHost() and make the code more
readable.

cmdmon.c

index 2f354e38a337b67f2505055f26c013b2305c368e..58a6c90b2870796140adab957ebf43e45d9d4a0f 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -1843,20 +1843,22 @@ read_from_cmd_socket(void *anything)
   }
 
   valid_ts = 0;
+  issue_token = 0;
 
   if (auth_ok) {
-    struct timeval ts;
-
-    UTI_TimevalNetworkToHost(&rx_message.data.logon.ts, &ts);
-    if ((utoken_ok && token_ok) ||
-        ((ntohl(rx_message.utoken) == SPECIAL_UTOKEN) &&
-         (rx_command == REQ_LOGON) &&
-         (valid_ts = ts_is_unique_and_not_stale(&ts, &now))))
+    if (utoken_ok && token_ok) {
       issue_token = 1;
-    else 
-      issue_token = 0;
-  } else {
-    issue_token = 0;
+    } else if (rx_command == REQ_LOGON &&
+               ntohl(rx_message.utoken) == SPECIAL_UTOKEN) {
+      struct timeval ts;
+
+      UTI_TimevalNetworkToHost(&rx_message.data.logon.ts, &ts);
+      valid_ts = ts_is_unique_and_not_stale(&ts, &now);
+
+      if (valid_ts) {
+        issue_token = 1;
+      }
+    }
   }
 
   authenticated = auth_ok & utoken_ok & token_ok;