From 553bd93f0905a4b93d899377b792a354049ea595 Mon Sep 17 00:00:00 2001
From: Vitaly Kuznetsov <vitty@altlinux.ru>
Date: Thu, 25 Feb 2010 18:39:16 +0000
Subject: [PATCH] Make SSH_CONFIG_DIR customizable

This patch adds ability to customize ssh config directory with --with-ssh-config-dir
(instead of hardcoded /etc/ssh value). This is useful in Linux distributions with
custom ssh config directories (/etc/openssh in ALTLinux, for example).

Signed-off-by: Vitaly Kuznetsov <vitty@altlinux.ru>
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 Makefile.am      |  1 +
 configure.ac     | 10 ++++++++++
 lib/constants.py |  6 +++---
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a4672de1e..ab7d0b664 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -445,6 +445,7 @@ lib/_autoconf.py: Makefile stamp-directories
 	  echo "VERSION_FULL = '$(VERSION_FULL)'"; \
 	  echo "LOCALSTATEDIR = '$(localstatedir)'"; \
 	  echo "SYSCONFDIR = '$(sysconfdir)'"; \
+	  echo "SSH_CONFIG_DIR = '$(SSH_CONFIG_DIR)'"; \
 	  echo "EXPORT_DIR = '$(EXPORT_DIR)'"; \
 	  echo "OS_SEARCH_PATH = [$(OS_SEARCH_PATH)]"; \
 	  echo "XEN_BOOTLOADER = '$(XEN_BOOTLOADER)'"; \
diff --git a/configure.ac b/configure.ac
index 9836008bf..b06320808 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,6 +39,16 @@ AC_ARG_WITH([export-dir],
   [export_dir="/srv/ganeti/export"])
 AC_SUBST(EXPORT_DIR, $export_dir)
 
+# --with-ssh-config-dir=...
+AC_ARG_WITH([ssh-config-dir],
+  [AS_HELP_STRING([--with-ssh-config-dir=DIR],
+    [ directory with ssh host keys ]
+    [ (default is /etc/ssh)]
+  )],
+  [ssh_config_dir="$withval"],
+  [ssh_config_dir="/etc/ssh"])
+AC_SUBST(SSH_CONFIG_DIR, $ssh_config_dir)
+
 # --with-os-search-path=...
 # do a bit of black sed magic to for quoting of the strings in the list
 AC_ARG_WITH([os-search-path],
diff --git a/lib/constants.py b/lib/constants.py
index c98d37a5d..27ca325ad 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -367,10 +367,10 @@ OS_API_FILE = 'ganeti_api_version'
 OS_VARIANTS_FILE = 'variants.list'
 
 # ssh constants
-SSH_CONFIG_DIR = "/etc/ssh/"
-SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "ssh_host_dsa_key"
+SSH_CONFIG_DIR = _autoconf.SSH_CONFIG_DIR
+SSH_HOST_DSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_dsa_key"
 SSH_HOST_DSA_PUB = SSH_HOST_DSA_PRIV + ".pub"
-SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "ssh_host_rsa_key"
+SSH_HOST_RSA_PRIV = SSH_CONFIG_DIR + "/ssh_host_rsa_key"
 SSH_HOST_RSA_PUB = SSH_HOST_RSA_PRIV + ".pub"
 SSH = "ssh"
 SCP = "scp"
-- 
GitLab