The default pki.conf has been modified to export the environment
variables such that they can be used by PKI client.

Pushed to master under trivial rule.

--
Endi S. Dewata
>From f2c3331176be82317cd5401b8b69d8adef18b188 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edew...@redhat.com>
Date: Thu, 16 Mar 2017 06:22:09 +0100
Subject: [PATCH] Exporting environment variables for PKI client.

The default pki.conf has been modified to export the environment
variables such that they can be used by PKI client.
---
 base/common/python/pki/cli/main.py | 26 +++++---------------------
 base/common/share/etc/pki.conf     |  8 ++++++++
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/base/common/python/pki/cli/main.py b/base/common/python/pki/cli/main.py
index 53e1b893a7e7a5f80c309039e08507b1ddf9c85e..268547bfc1544b2019aa004b2076bd93b3294a07 100644
--- a/base/common/python/pki/cli/main.py
+++ b/base/common/python/pki/cli/main.py
@@ -21,6 +21,7 @@
 
 from __future__ import absolute_import
 from __future__ import print_function
+import os
 import shlex
 import subprocess
 import sys
@@ -70,23 +71,9 @@ class PKICLI(pki.cli.CLI):
 
     def execute_java(self, args, stdout=sys.stdout):
 
-        # read Java home
-        value = subprocess.check_output(
-            '. /usr/share/pki/etc/pki.conf && . /etc/pki/pki.conf && echo $JAVA_HOME',
-            shell=True)
-        java_home = value.decode(sys.getfilesystemencoding()).strip()
-
-        # read PKI library
-        value = subprocess.check_output(
-            '. /usr/share/pki/etc/pki.conf && . /etc/pki/pki.conf && echo $PKI_LIB',
-            shell=True)
-        pki_lib = value.decode(sys.getfilesystemencoding()).strip()
-
-        # read logging configuration path
-        value = subprocess.check_output(
-            '. /usr/share/pki/etc/pki.conf && . /etc/pki/pki.conf && echo $LOGGING_CONFIG',
-            shell=True)
-        logging_config = value.decode(sys.getfilesystemencoding()).strip()
+        java_home = os.getenv('JAVA_HOME')
+        pki_lib = os.getenv('PKI_LIB')
+        logging_config = os.getenv('LOGGING_CONFIG')
 
         cmd = [
             java_home + '/bin/java',
@@ -122,10 +109,7 @@ class PKICLI(pki.cli.CLI):
     def execute(self, argv):
 
         # append global options
-        value = subprocess.check_output(
-            '. /usr/share/pki/etc/pki.conf && . /etc/pki/pki.conf && echo $PKI_CLI_OPTIONS',
-            shell=True)
-        value = value.decode(sys.getfilesystemencoding()).strip()
+        value = os.getenv('PKI_CLI_OPTIONS')
         args = shlex.split(value)
         args.extend(argv[1:])
 
diff --git a/base/common/share/etc/pki.conf b/base/common/share/etc/pki.conf
index 97f3777fed9d2b5274a4fb305c81234900857a88..5eeb187922791c51c851e30a4b38475a20c6bd9b 100644
--- a/base/common/share/etc/pki.conf
+++ b/base/common/share/etc/pki.conf
@@ -1,11 +1,19 @@
 # Java home
 JAVA_HOME=${JAVA_HOME}
+export JAVA_HOME
 
 # JNI jar file location
 JNI_JAR_DIR=/usr/lib/java
+export JNI_JAR_DIR
 
 # PKI library
 PKI_LIB=/usr/share/pki/lib
+export PKI_LIB
 
 # logging configuration location
 LOGGING_CONFIG=/usr/share/pki/etc/logging.properties
+export LOGGING_CONFIG
+
+# PKI CLI options
+PKI_CLI_OPTIONS=
+export PKI_CLI_OPTIONS
-- 
2.9.3

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to