summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-extended/python-pykickstart/files/0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-extended/python-pykickstart/files/0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch')
-rw-r--r--meta-python/recipes-extended/python-pykickstart/files/0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch36
1 files changed, 14 insertions, 22 deletions
diff --git a/meta-python/recipes-extended/python-pykickstart/files/0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch b/meta-python/recipes-extended/python-pykickstart/files/0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch
index cb21235460..4a001f3386 100644
--- a/meta-python/recipes-extended/python-pykickstart/files/0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch
+++ b/meta-python/recipes-extended/python-pykickstart/files/0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch
@@ -1,28 +1,26 @@
1From e6e747b883114bfad51ad93f823e65f5a4d6438a Mon Sep 17 00:00:00 2001 1From 62fdead139edb0f29b2f222efcb8f39be15b057e Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com> 2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Thu, 1 Jun 2017 15:12:29 +0800 3Date: Mon, 30 Jul 2018 15:47:13 +0800
4Subject: [PATCH 2/4] pykickstart/parser.py: add lock for readKickstart and 4Subject: [PATCH 2/4] pykickstart/parser.py: add lock for readKickstart and
5 support https without certification 5 support https without certification
6 6
7- Add lock for readKickstart to fix race issue 7- Add lock for readKickstart to fix race issue
8 8
9- Support to download kickstart file through https without certification 9- Support to download kickstart file through https without certification
10 10
11Upstream-Status: Inappropriate[oe specific]
12
13Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> 11Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
14--- 12---
15 pykickstart/load.py | 2 +- 13 pykickstart/load.py | 2 +-
16 pykickstart/parser.py | 24 ++++++++++++++++++++++++ 14 pykickstart/parser.py | 18 ++++++++++++++++++
17 2 files changed, 25 insertions(+), 1 deletion(-) 15 2 files changed, 19 insertions(+), 1 deletion(-)
18 16
19diff --git a/pykickstart/load.py b/pykickstart/load.py 17diff --git a/pykickstart/load.py b/pykickstart/load.py
20index 0f5741b..48c8276 100644 18index c6f013f..7adb751 100644
21--- a/pykickstart/load.py 19--- a/pykickstart/load.py
22+++ b/pykickstart/load.py 20+++ b/pykickstart/load.py
23@@ -30,7 +30,7 @@ from requests.exceptions import SSLError, RequestException 21@@ -30,7 +30,7 @@ from requests.exceptions import SSLError, RequestException
24 22
25 _is_url = lambda location: '://' in location # RFC 3986 23 _is_url = lambda location: '://' in location # RFC 3986
26 24
27-SSL_VERIFY = True 25-SSL_VERIFY = True
28+SSL_VERIFY = False 26+SSL_VERIFY = False
@@ -30,38 +28,32 @@ index 0f5741b..48c8276 100644
30 def load_to_str(location, user=None, passwd=None): 28 def load_to_str(location, user=None, passwd=None):
31 '''Load a destination URL or file into a string. 29 '''Load a destination URL or file into a string.
32diff --git a/pykickstart/parser.py b/pykickstart/parser.py 30diff --git a/pykickstart/parser.py b/pykickstart/parser.py
33index 26b5de9..264ba05 100644 31index e44099b..e68174d 100644
34--- a/pykickstart/parser.py 32--- a/pykickstart/parser.py
35+++ b/pykickstart/parser.py 33+++ b/pykickstart/parser.py
36@@ -57,6 +57,26 @@ STATE_COMMANDS = "commands" 34@@ -55,6 +55,20 @@ from pykickstart.i18n import _
37 35 STATE_END = "end"
38 ver = version.DEVEL 36 STATE_COMMANDS = "commands"
39 37
40+import logging
41+log = logging.getLogger("anaconda")
42+
43+import inspect
44+import threading 38+import threading
45+_private_ks_lock = threading.RLock() 39+_private_ks_lock = threading.RLock()
46+ 40+
47+class KsLock(object): 41+class KsLock(object):
48+ def __enter__(self): 42+ def __enter__(self):
49+ log.info("%s %s" % (self.__class__.__name__, inspect.stack()[0][3]))
50+ _private_ks_lock.acquire() 43+ _private_ks_lock.acquire()
51+ return _private_ks_lock 44+ return _private_ks_lock
52+ 45+
53+ def __exit__(self, exc_type, exc_val, exc_tb): 46+ def __exit__(self, exc_type, exc_val, exc_tb):
54+ log.info("%s %s" % (self.__class__.__name__, inspect.stack()[0][3]))
55+ _private_ks_lock.release() 47+ _private_ks_lock.release()
56+ 48+
57+ 49+
58+_ks_lock = KsLock() 50+_ks_lock = KsLock()
59+ 51+
60 def _preprocessStateMachine (lineIter): 52 def _preprocessStateMachine(lineIter):
61 l = None 53 l = None
62 lineno = 0 54 lineno = 0
63@@ -774,6 +794,10 @@ class KickstartParser(object): 55@@ -788,6 +802,10 @@ class KickstartParser(object):
64 self._stateMachine (i) 56 self._stateMachine(i)
65 57
66 def readKickstart(self, f, reset=True, username=None, password=None): 58 def readKickstart(self, f, reset=True, username=None, password=None):
67+ with _ks_lock: 59+ with _ks_lock: