cmdmon: convert LOGON timestamp only with LOGON message

Avoid always calling UTI_TimevalNetworkToHost() and make the code more
readable.
This commit is contained in:
Miroslav Lichvar 2014-08-18 13:58:52 +02:00
parent 07f7f28058
commit 09d039fba6

View file

@ -1843,20 +1843,22 @@ read_from_cmd_socket(void *anything)
} }
valid_ts = 0; valid_ts = 0;
issue_token = 0;
if (auth_ok) { if (auth_ok) {
if (utoken_ok && token_ok) {
issue_token = 1;
} else if (rx_command == REQ_LOGON &&
ntohl(rx_message.utoken) == SPECIAL_UTOKEN) {
struct timeval ts; struct timeval ts;
UTI_TimevalNetworkToHost(&rx_message.data.logon.ts, &ts); UTI_TimevalNetworkToHost(&rx_message.data.logon.ts, &ts);
if ((utoken_ok && token_ok) || valid_ts = ts_is_unique_and_not_stale(&ts, &now);
((ntohl(rx_message.utoken) == SPECIAL_UTOKEN) &&
(rx_command == REQ_LOGON) && if (valid_ts) {
(valid_ts = ts_is_unique_and_not_stale(&ts, &now))))
issue_token = 1; issue_token = 1;
else }
issue_token = 0; }
} else {
issue_token = 0;
} }
authenticated = auth_ok & utoken_ok & token_ok; authenticated = auth_ok & utoken_ok & token_ok;