Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 62fdead139edb0f29b2f222efcb8f39be15b057e Mon Sep 17 00:00:00 2001 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3 | Date: Mon, 30 Jul 2018 15:47:13 +0800 |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 4 | Subject: [PATCH 2/4] pykickstart/parser.py: add lock for readKickstart and |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 12 | Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 13 | --- |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 14 | Upstream-Status: Pending |
| 15 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | pykickstart/load.py | 2 +- |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 17 | pykickstart/parser.py | 18 ++++++++++++++++++ |
| 18 | 2 files changed, 19 insertions(+), 1 deletion(-) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | |
| 20 | diff --git a/pykickstart/load.py b/pykickstart/load.py |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 21 | index 8da8051..e856c8d 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 22 | --- a/pykickstart/load.py |
| 23 | +++ b/pykickstart/load.py |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 24 | @@ -32,7 +32,7 @@ log = logging.getLogger("anaconda.main") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 26 | is_url = lambda location: '://' in location # RFC 3986 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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. |
| 33 | diff --git a/pykickstart/parser.py b/pykickstart/parser.py |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 34 | index b95ba90..a55a9a3 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 35 | --- a/pykickstart/parser.py |
| 36 | +++ b/pykickstart/parser.py |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 37 | @@ -51,6 +51,20 @@ from pykickstart.i18n import _ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 38 | STATE_END = "end" |
| 39 | STATE_COMMANDS = "commands" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 40 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 41 | +import threading |
| 42 | +_private_ks_lock = threading.RLock() |
| 43 | + |
| 44 | +class KsLock(object): |
| 45 | + def __enter__(self): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 46 | + _private_ks_lock.acquire() |
| 47 | + return _private_ks_lock |
| 48 | + |
| 49 | + def __exit__(self, exc_type, exc_val, exc_tb): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 50 | + _private_ks_lock.release() |
| 51 | + |
| 52 | + |
| 53 | +_ks_lock = KsLock() |
| 54 | + |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 55 | def _preprocessStateMachine(lineIter): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 56 | l = None |
| 57 | lineno = 0 |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 58 | @@ -791,6 +805,10 @@ class KickstartParser(object): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 59 | self._stateMachine(i) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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 | -- |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 70 | 2.34.1 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 71 | |