blob: 5e0d6166faf9ad454e325e8bca80eadb28bad104 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 62fdead139edb0f29b2f222efcb8f39be15b057e Mon Sep 17 00:00:00 2001
Brad Bishopd7bf8c12018-02-25 22:55:05 -05002From: Hongxu Jia <hongxu.jia@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08003Date: Mon, 30 Jul 2018 15:47:13 +0800
Andrew Geissler6aa7eec2023-03-03 12:41:14 -06004Subject: [PATCH 2/4] pykickstart/parser.py: add lock for readKickstart and
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005 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
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060012Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013---
14 pykickstart/load.py | 2 +-
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080015 pykickstart/parser.py | 18 ++++++++++++++++++
16 2 files changed, 19 insertions(+), 1 deletion(-)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017
18diff --git a/pykickstart/load.py b/pykickstart/load.py
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060019index 8da8051..e856c8d 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020--- a/pykickstart/load.py
21+++ b/pykickstart/load.py
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060022@@ -32,7 +32,7 @@ log = logging.getLogger("anaconda.main")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050023
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060024 is_url = lambda location: '://' in location # RFC 3986
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025
26-SSL_VERIFY = True
27+SSL_VERIFY = False
28
29 def load_to_str(location, user=None, passwd=None):
30 '''Load a destination URL or file into a string.
31diff --git a/pykickstart/parser.py b/pykickstart/parser.py
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060032index b95ba90..a55a9a3 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033--- a/pykickstart/parser.py
34+++ b/pykickstart/parser.py
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060035@@ -51,6 +51,20 @@ from pykickstart.i18n import _
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080036 STATE_END = "end"
37 STATE_COMMANDS = "commands"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050038
Brad Bishopd7bf8c12018-02-25 22:55:05 -050039+import threading
40+_private_ks_lock = threading.RLock()
41+
42+class KsLock(object):
43+ def __enter__(self):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050044+ _private_ks_lock.acquire()
45+ return _private_ks_lock
46+
47+ def __exit__(self, exc_type, exc_val, exc_tb):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050048+ _private_ks_lock.release()
49+
50+
51+_ks_lock = KsLock()
52+
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053 def _preprocessStateMachine(lineIter):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050054 l = None
55 lineno = 0
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060056@@ -791,6 +805,10 @@ class KickstartParser(object):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057 self._stateMachine(i)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050058
59 def readKickstart(self, f, reset=True, username=None, password=None):
60+ with _ks_lock:
61+ self._readKickstart(f, reset=reset, username=username, password=password)
62+
63+ def _readKickstart(self, f, reset=True, username=None, password=None):
64 """Process a kickstart file, given by the filename f."""
65 if reset:
66 self._reset()
67--
Andrew Geissler6aa7eec2023-03-03 12:41:14 -0600682.34.1
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069