[PATCH spice-server 2/2] reds: Use monotonic time for ticket expiration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Avoid time adjustment issues.
For instance ticket validity can change when daylight time changes.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/reds.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index bff5b68e..727c3a14 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2099,8 +2099,7 @@ static void reds_handle_ticket(void *opaque)
             goto error;
         }
 
-        //todo: use monotonic time
-        time(&ltime);
+        ltime = spice_get_monotonic_time_ns() / NSEC_PER_SEC;
         expired = (reds->config->taTicket.expiration_time < ltime);
 
         if (expired) {
@@ -3833,7 +3832,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *reds,
     if (lifetime == 0) {
         reds->config->taTicket.expiration_time = INT_MAX;
     } else {
-        time_t now = time(NULL);
+        time_t now = spice_get_monotonic_time_ns() / NSEC_PER_SEC;
         reds->config->taTicket.expiration_time = now + lifetime;
     }
     if (passwd != NULL) {
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]