From 82ad3594f72c4fbfd3a12a1f29aaa1a977619ba3 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 28 Jan 2010 18:33:39 +0100
Subject: [PATCH] Find OpenSSL program at configure time

Otherwise we depend on PATH at runtime.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 Makefile.am      | 1 +
 configure.ac     | 8 ++++++++
 lib/constants.py | 1 +
 lib/utils.py     | 3 ++-
 4 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 769fe9466..10650fcd1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -449,6 +449,7 @@ lib/_autoconf.py: Makefile stamp-directories
 	  echo "PKGLIBDIR = '$(pkglibdir)'"; \
 	  echo "DRBD_BARRIERS = $(DRBD_BARRIERS)"; \
 	  echo "SYSLOG_USAGE = '$(SYSLOG_USAGE)'"; \
+	  echo "OPENSSL_PATH = '$(OPENSSL)'"; \
 	} > $@
 
 $(REPLACE_VARS_SED): Makefile
diff --git a/configure.ac b/configure.ac
index 9836008bf..3bc5992de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -201,6 +201,14 @@ then
   AC_MSG_WARN([pylint not found, checking code will not be possible])
 fi
 
+# Check for openssl
+AC_ARG_VAR(OPENSSL, [openssl path])
+AC_PATH_PROG(OPENSSL, [openssl], [])
+if test -z "$OPENSSL"
+then
+  AC_MSG_ERROR([openssl not found])
+fi
+
 # Check for socat
 AC_ARG_VAR(SOCAT, [socat path])
 AC_PATH_PROG(SOCAT, [socat], [])
diff --git a/lib/constants.py b/lib/constants.py
index f73071fdb..574db4eaa 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -112,6 +112,7 @@ DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
 SYSCONFDIR = _autoconf.SYSCONFDIR
 TOOLSDIR = _autoconf.TOOLSDIR
 CONF_DIR = SYSCONFDIR + "/ganeti"
+OPENSSL_PATH = _autoconf.OPENSSL_PATH
 
 MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
 
diff --git a/lib/utils.py b/lib/utils.py
index 1a4011ee1..cd899a7d3 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -2273,7 +2273,8 @@ def GenerateSelfSignedSslCert(file_name, validity=(365 * 5)):
       # Set permissions before writing key
       os.chmod(tmp_file_name, 0600)
 
-      result = RunCmd(["openssl", "req", "-new", "-newkey", "rsa:1024",
+      result = RunCmd([constants.OPENSSL_PATH, "req",
+                       "-new", "-newkey", "rsa:1024",
                        "-days", str(validity), "-nodes", "-x509",
                        "-keyout", tmp_file_name, "-out", tmp_file_name,
                        "-batch"])
-- 
GitLab