1From 62fdead139edb0f29b2f222efcb8f39be15b057e Mon Sep 17 00:00:00 2001 2From: Hongxu Jia <hongxu.jia@windriver.com> 3Date: Mon, 30 Jul 2018 15:47:13 +0800 4Subject: [PATCH 2/4] pykickstart/parser.py: add lock for readKickstart and 5 support https without certification 6 7- Add lock for readKickstart to fix race issue 8 9- Support to download kickstart file through https without certification 10 11Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> 12Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> 13--- 14Upstream-Status: Pending 15 16 pykickstart/load.py | 2 +- 17 pykickstart/parser.py | 18 ++++++++++++++++++ 18 2 files changed, 19 insertions(+), 1 deletion(-) 19 20diff --git a/pykickstart/load.py b/pykickstart/load.py 21index 8da8051..e856c8d 100644 22--- a/pykickstart/load.py 23+++ b/pykickstart/load.py 24@@ -32,7 +32,7 @@ log = logging.getLogger("anaconda.main") 25 26 is_url = lambda location: '://' in location # RFC 3986 27 28-SSL_VERIFY = True 29+SSL_VERIFY = False 30 31 def load_to_str(location, user=None, passwd=None): 32 '''Load a destination URL or file into a string. 33diff --git a/pykickstart/parser.py b/pykickstart/parser.py 34index b95ba90..a55a9a3 100644 35--- a/pykickstart/parser.py 36+++ b/pykickstart/parser.py 37@@ -51,6 +51,20 @@ from pykickstart.i18n import _ 38 STATE_END = "end" 39 STATE_COMMANDS = "commands" 40 41+import threading 42+_private_ks_lock = threading.RLock() 43+ 44+class KsLock(object): 45+ def __enter__(self): 46+ _private_ks_lock.acquire() 47+ return _private_ks_lock 48+ 49+ def __exit__(self, exc_type, exc_val, exc_tb): 50+ _private_ks_lock.release() 51+ 52+ 53+_ks_lock = KsLock() 54+ 55 def _preprocessStateMachine(lineIter): 56 l = None 57 lineno = 0 58@@ -791,6 +805,10 @@ class KickstartParser(object): 59 self._stateMachine(i) 60 61 def readKickstart(self, f, reset=True, username=None, password=None): 62+ with _ks_lock: 63+ self._readKickstart(f, reset=reset, username=username, password=password) 64+ 65+ def _readKickstart(self, f, reset=True, username=None, password=None): 66 """Process a kickstart file, given by the filename f.""" 67 if reset: 68 self._reset() 69-- 702.34.1 71 72