blob: f5483db825ca247ecd5dce9afc1f48487df2d5cc [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---
Patrick Williams520786c2023-06-25 16:20:36 -050014Upstream-Status: Pending
15
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016 pykickstart/load.py | 2 +-
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080017 pykickstart/parser.py | 18 ++++++++++++++++++
18 2 files changed, 19 insertions(+), 1 deletion(-)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019
20diff --git a/pykickstart/load.py b/pykickstart/load.py
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060021index 8da8051..e856c8d 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050022--- a/pykickstart/load.py
23+++ b/pykickstart/load.py
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060024@@ -32,7 +32,7 @@ log = logging.getLogger("anaconda.main")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060026 is_url = lambda location: '://' in location # RFC 3986
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027
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
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060034index b95ba90..a55a9a3 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050035--- a/pykickstart/parser.py
36+++ b/pykickstart/parser.py
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060037@@ -51,6 +51,20 @@ from pykickstart.i18n import _
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038 STATE_END = "end"
39 STATE_COMMANDS = "commands"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050040
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041+import threading
42+_private_ks_lock = threading.RLock()
43+
44+class KsLock(object):
45+ def __enter__(self):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046+ _private_ks_lock.acquire()
47+ return _private_ks_lock
48+
49+ def __exit__(self, exc_type, exc_val, exc_tb):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050050+ _private_ks_lock.release()
51+
52+
53+_ks_lock = KsLock()
54+
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055 def _preprocessStateMachine(lineIter):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050056 l = None
57 lineno = 0
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060058@@ -791,6 +805,10 @@ class KickstartParser(object):
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080059 self._stateMachine(i)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050060
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--
Andrew Geissler6aa7eec2023-03-03 12:41:14 -0600702.34.1
Brad Bishopd7bf8c12018-02-25 22:55:05 -050071