ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Zbigniew Jędrzejewski-Szmek 27bd1b
From c64c6a8b259abfbff5ce202d5d5982b120cf928f Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 27bd1b
From: Andrew Soutar <andrew@andrewsoutar.com>
Zbigniew Jędrzejewski-Szmek 27bd1b
Date: Mon, 31 Jul 2017 02:19:16 -0400
Zbigniew Jędrzejewski-Szmek 27bd1b
Subject: [PATCH] cryptsetup: fix infinite timeout (#6486)
Zbigniew Jędrzejewski-Szmek 27bd1b
Zbigniew Jędrzejewski-Szmek 27bd1b
0004f698d causes `arg_timeout` to be infinity instead of 0 when timeout=0. The
Zbigniew Jędrzejewski-Szmek 27bd1b
logic here now matches this change.
Zbigniew Jędrzejewski-Szmek 27bd1b
Zbigniew Jędrzejewski-Szmek 27bd1b
Fixes #6381
Zbigniew Jędrzejewski-Szmek 27bd1b
Zbigniew Jędrzejewski-Szmek 27bd1b
(cherry picked from commit 0864d311766498563331f486909a0d950ba7de87)
Zbigniew Jędrzejewski-Szmek 27bd1b
---
Zbigniew Jędrzejewski-Szmek 27bd1b
 src/cryptsetup/cryptsetup.c | 8 ++++----
Zbigniew Jędrzejewski-Szmek 27bd1b
 1 file changed, 4 insertions(+), 4 deletions(-)
Zbigniew Jędrzejewski-Szmek 27bd1b
Zbigniew Jędrzejewski-Szmek 27bd1b
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
Zbigniew Jędrzejewski-Szmek 27bd1b
index 3b4c086162..08ed7e53ba 100644
Zbigniew Jędrzejewski-Szmek 27bd1b
--- a/src/cryptsetup/cryptsetup.c
Zbigniew Jędrzejewski-Szmek 27bd1b
+++ b/src/cryptsetup/cryptsetup.c
Zbigniew Jędrzejewski-Szmek 27bd1b
@@ -56,7 +56,7 @@ static bool arg_tcrypt_veracrypt = false;
Zbigniew Jędrzejewski-Szmek 27bd1b
 static char **arg_tcrypt_keyfiles = NULL;
Zbigniew Jędrzejewski-Szmek 27bd1b
 static uint64_t arg_offset = 0;
Zbigniew Jędrzejewski-Szmek 27bd1b
 static uint64_t arg_skip = 0;
Zbigniew Jędrzejewski-Szmek 27bd1b
-static usec_t arg_timeout = 0;
Zbigniew Jędrzejewski-Szmek 27bd1b
+static usec_t arg_timeout = USEC_INFINITY;
Zbigniew Jędrzejewski-Szmek 27bd1b
 
Zbigniew Jędrzejewski-Szmek 27bd1b
 /* Options Debian's crypttab knows we don't:
Zbigniew Jędrzejewski-Szmek 27bd1b
 
Zbigniew Jędrzejewski-Szmek 27bd1b
@@ -670,10 +670,10 @@ int main(int argc, char *argv[]) {
Zbigniew Jędrzejewski-Szmek 27bd1b
                 if (arg_discards)
Zbigniew Jędrzejewski-Szmek 27bd1b
                         flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
Zbigniew Jędrzejewski-Szmek 27bd1b
 
Zbigniew Jędrzejewski-Szmek 27bd1b
-                if (arg_timeout > 0)
Zbigniew Jędrzejewski-Szmek 27bd1b
-                        until = now(CLOCK_MONOTONIC) + arg_timeout;
Zbigniew Jędrzejewski-Szmek 27bd1b
-                else
Zbigniew Jędrzejewski-Szmek 27bd1b
+                if (arg_timeout == USEC_INFINITY)
Zbigniew Jędrzejewski-Szmek 27bd1b
                         until = 0;
Zbigniew Jędrzejewski-Szmek 27bd1b
+                else
Zbigniew Jędrzejewski-Szmek 27bd1b
+                        until = now(CLOCK_MONOTONIC) + arg_timeout;
Zbigniew Jędrzejewski-Szmek 27bd1b
 
Zbigniew Jędrzejewski-Szmek 27bd1b
                 arg_key_size = (arg_key_size > 0 ? arg_key_size : (256 / 8));
Zbigniew Jędrzejewski-Szmek 27bd1b