From 3a579e2d722968ee5954f179da891ff9ea184617 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Mon, 19 Nov 2018 12:24:50 +0530 Subject: [PATCH] openvpn: is-setup checks for non-empty dh.pem file Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- actions/openvpn | 4 ++-- plinth/utils.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/actions/openvpn b/actions/openvpn index 6b4629843..464b151b5 100755 --- a/actions/openvpn +++ b/actions/openvpn @@ -25,7 +25,7 @@ import subprocess import augeas -from plinth import action_utils +from plinth import action_utils, utils KEYS_DIRECTORY = '/etc/openvpn/freedombox-keys' @@ -120,7 +120,7 @@ def parse_arguments(): def subcommand_is_setup(_): """Return whether setup is complete.""" - print('true' if os.path.isfile(DH_KEY) else 'false') + print('true' if utils.is_non_empty_file(DH_KEY) else 'false') def subcommand_setup(_): diff --git a/plinth/utils.py b/plinth/utils.py index b139bd574..052a08f86 100644 --- a/plinth/utils.py +++ b/plinth/utils.py @@ -154,3 +154,7 @@ def gunzip(gzip_file, output_file): with open(output_file, 'wb', opener=opener) as file_handle: file_handle.write(contents) + + +def is_non_empty_file(file_path): + return os.path.isfile(file_path) and os.path.getsize(file_path) > 0