diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2018-08-01 15:21:39 +0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2018-08-02 11:23:03 -0700 |
commit | 4c61e30cfb965d260fc0cd5339a3a7c8e781eac2 (patch) | |
tree | 0a6376d8b95c362088544d1b0aaf73ffd7bc0e22 /meta-python/recipes-extended/python-pykickstart/files/0001-support-authentication-for-kickstart.patch | |
parent | f38ff38f48468a4505ed6396e832d2574d7914d7 (diff) | |
download | meta-openembedded-4c61e30cfb965d260fc0cd5339a3a7c8e781eac2.tar.gz |
python3-pykickstart: 2.35 -> 3.15
- Rebase 0001 ~ 0004
- Drop 0005-tweak-shebang-to-python3.patch
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-python/recipes-extended/python-pykickstart/files/0001-support-authentication-for-kickstart.patch')
-rw-r--r-- | meta-python/recipes-extended/python-pykickstart/files/0001-support-authentication-for-kickstart.patch | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/meta-python/recipes-extended/python-pykickstart/files/0001-support-authentication-for-kickstart.patch b/meta-python/recipes-extended/python-pykickstart/files/0001-support-authentication-for-kickstart.patch index 617699db07..6af4bde08a 100644 --- a/meta-python/recipes-extended/python-pykickstart/files/0001-support-authentication-for-kickstart.patch +++ b/meta-python/recipes-extended/python-pykickstart/files/0001-support-authentication-for-kickstart.patch | |||
@@ -1,6 +1,6 @@ | |||
1 | From d0d8890b5ef74c315381c9e1cff4b1d32892116b Mon Sep 17 00:00:00 2001 | 1 | From b7070a79432b790dffa82401364e4fd8d906eb2b Mon Sep 17 00:00:00 2001 |
2 | From: Hongxu Jia <hongxu.jia@windriver.com> | 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
3 | Date: Thu, 1 Jun 2017 15:07:36 +0800 | 3 | Date: Tue, 31 Jul 2018 17:24:47 +0800 |
4 | Subject: [PATCH 1/4] support authentication for kickstart | 4 | Subject: [PATCH 1/4] support authentication for kickstart |
5 | 5 | ||
6 | While download kickstart file from web server, | 6 | While download kickstart file from web server, |
@@ -13,30 +13,29 @@ Upstream-Status: inappropriate [oe specific] | |||
13 | 13 | ||
14 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | 14 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
15 | --- | 15 | --- |
16 | pykickstart/errors.py | 19 +++++++++++++++++++ | 16 | pykickstart/errors.py | 17 +++++++++++++++++ |
17 | pykickstart/load.py | 32 +++++++++++++++++++++++++++----- | 17 | pykickstart/load.py | 34 ++++++++++++++++++++++++++++------ |
18 | pykickstart/parser.py | 4 ++-- | 18 | pykickstart/parser.py | 4 ++-- |
19 | 3 files changed, 48 insertions(+), 7 deletions(-) | 19 | 3 files changed, 47 insertions(+), 8 deletions(-) |
20 | 20 | ||
21 | diff --git a/pykickstart/errors.py b/pykickstart/errors.py | 21 | diff --git a/pykickstart/errors.py b/pykickstart/errors.py |
22 | index b76e84c..fd81bc8 100644 | 22 | index bf08ac5..aada7aa 100644 |
23 | --- a/pykickstart/errors.py | 23 | --- a/pykickstart/errors.py |
24 | +++ b/pykickstart/errors.py | 24 | +++ b/pykickstart/errors.py |
25 | @@ -35,6 +35,10 @@ It also exports several exception classes: | 25 | @@ -32,6 +32,9 @@ This module exports several exception classes: |
26 | |||
27 | KickstartVersionError - An exception for errors relating to unsupported | 26 | KickstartVersionError - An exception for errors relating to unsupported |
28 | syntax versions. | 27 | syntax versions. |
29 | + | 28 | |
30 | + KickstartAuthError - An exception for errors relating to authentication | 29 | + KickstartAuthError - An exception for errors relating to authentication |
31 | + failed while downloading kickstart from web server | 30 | + failed while downloading kickstart from web server |
32 | + | 31 | + |
33 | """ | 32 | And some warning classes: |
34 | import warnings | ||
35 | |||
36 | @@ -103,3 +107,18 @@ class KickstartVersionError(KickstartError): | ||
37 | 33 | ||
38 | def __str__ (self): | 34 | KickstartWarning - A generic warning class. |
39 | return self.value | 35 | @@ -131,3 +134,17 @@ class KickstartDeprecationWarning(KickstartParseWarning, DeprecationWarning): |
36 | commands and options. | ||
37 | """ | ||
38 | pass | ||
40 | + | 39 | + |
41 | +class KickstartAuthError(KickstartError): | 40 | +class KickstartAuthError(KickstartError): |
42 | + """An exception for errors relating to authentication failed while | 41 | + """An exception for errors relating to authentication failed while |
@@ -51,9 +50,8 @@ index b76e84c..fd81bc8 100644 | |||
51 | + | 50 | + |
52 | + def __str__(self): | 51 | + def __str__(self): |
53 | + return self.value | 52 | + return self.value |
54 | + | ||
55 | diff --git a/pykickstart/load.py b/pykickstart/load.py | 53 | diff --git a/pykickstart/load.py b/pykickstart/load.py |
56 | index 1f69b9c..0f5741b 100644 | 54 | index fb935f2..c6f013f 100644 |
57 | --- a/pykickstart/load.py | 55 | --- a/pykickstart/load.py |
58 | +++ b/pykickstart/load.py | 56 | +++ b/pykickstart/load.py |
59 | @@ -18,10 +18,13 @@ | 57 | @@ -18,10 +18,13 @@ |
@@ -71,7 +69,7 @@ index 1f69b9c..0f5741b 100644 | |||
71 | from pykickstart.i18n import _ | 69 | from pykickstart.i18n import _ |
72 | from requests.exceptions import SSLError, RequestException | 70 | from requests.exceptions import SSLError, RequestException |
73 | 71 | ||
74 | @@ -29,7 +32,7 @@ _is_url = lambda location: '://' in location # RFC 3986 | 72 | @@ -29,7 +32,7 @@ _is_url = lambda location: '://' in location # RFC 3986 |
75 | 73 | ||
76 | SSL_VERIFY = True | 74 | SSL_VERIFY = True |
77 | 75 | ||
@@ -89,10 +87,12 @@ index 1f69b9c..0f5741b 100644 | |||
89 | else: | 87 | else: |
90 | return _load_file(location) | 88 | return _load_file(location) |
91 | 89 | ||
92 | @@ -71,13 +74,32 @@ def load_to_file(location, destination): | 90 | @@ -70,11 +73,30 @@ def load_to_file(location, destination): |
93 | _copy_file(location, destination) | 91 | _copy_file(location, destination) |
94 | return destination | 92 | return destination |
95 | 93 | ||
94 | -def _load_url(location): | ||
95 | - '''Load a location (URL or filename) and return contents as string''' | ||
96 | +def _get_auth(location, user=None, passwd=None): | 96 | +def _get_auth(location, user=None, passwd=None): |
97 | + | 97 | + |
98 | + auth = None | 98 | + auth = None |
@@ -101,7 +101,7 @@ index 1f69b9c..0f5741b 100644 | |||
101 | + if user is None or passwd is None: | 101 | + if user is None or passwd is None: |
102 | + log.info("Require Authentication") | 102 | + log.info("Require Authentication") |
103 | + raise KickstartAuthError("Require Authentication.\nAppend 'ksuser=<username> kspasswd=<password>' to boot command") | 103 | + raise KickstartAuthError("Require Authentication.\nAppend 'ksuser=<username> kspasswd=<password>' to boot command") |
104 | 104 | + | |
105 | + reasons = request.headers.get("WWW-Authenticate", "").split() | 105 | + reasons = request.headers.get("WWW-Authenticate", "").split() |
106 | + if reasons: | 106 | + if reasons: |
107 | + auth_type = reasons[0] | 107 | + auth_type = reasons[0] |
@@ -109,15 +109,12 @@ index 1f69b9c..0f5741b 100644 | |||
109 | + auth = HTTPBasicAuth(user, passwd) | 109 | + auth = HTTPBasicAuth(user, passwd) |
110 | + elif auth_type == "Digest": | 110 | + elif auth_type == "Digest": |
111 | + auth=HTTPDigestAuth(user, passwd) | 111 | + auth=HTTPDigestAuth(user, passwd) |
112 | |||
113 | -def _load_url(location): | ||
114 | + return auth | ||
115 | + | 112 | + |
116 | +def _load_url(location, user=None, passwd=None): | 113 | + return auth |
117 | '''Load a location (URL or filename) and return contents as string''' | ||
118 | 114 | ||
115 | +def _load_url(location, user=None, passwd=None): | ||
116 | + '''Load a location (URL or filename) and return contents as string''' | ||
119 | + auth = _get_auth(location, user=user, passwd=passwd) | 117 | + auth = _get_auth(location, user=user, passwd=passwd) |
120 | + | ||
121 | try: | 118 | try: |
122 | - request = requests.get(location, verify=SSL_VERIFY) | 119 | - request = requests.get(location, verify=SSL_VERIFY) |
123 | + request = requests.get(location, verify=SSL_VERIFY, auth=auth) | 120 | + request = requests.get(location, verify=SSL_VERIFY, auth=auth) |
@@ -125,26 +122,26 @@ index 1f69b9c..0f5741b 100644 | |||
125 | raise KickstartError(_('Error securely accessing URL "%s"') % location + ': {e}'.format(e=str(e))) | 122 | raise KickstartError(_('Error securely accessing URL "%s"') % location + ': {e}'.format(e=str(e))) |
126 | except RequestException as e: | 123 | except RequestException as e: |
127 | diff --git a/pykickstart/parser.py b/pykickstart/parser.py | 124 | diff --git a/pykickstart/parser.py b/pykickstart/parser.py |
128 | index d2b0fbe..26b5de9 100644 | 125 | index d8880eb..22d14cb 100644 |
129 | --- a/pykickstart/parser.py | 126 | --- a/pykickstart/parser.py |
130 | +++ b/pykickstart/parser.py | 127 | +++ b/pykickstart/parser.py |
131 | @@ -773,7 +773,7 @@ class KickstartParser(object): | 128 | @@ -787,7 +787,7 @@ class KickstartParser(object): |
132 | i = PutBackIterator(s.splitlines(True) + [""]) | 129 | i = PutBackIterator(s.splitlines(True) + [""]) |
133 | self._stateMachine (i) | 130 | self._stateMachine(i) |
134 | 131 | ||
135 | - def readKickstart(self, f, reset=True): | 132 | - def readKickstart(self, f, reset=True): |
136 | + def readKickstart(self, f, reset=True, username=None, password=None): | 133 | + def readKickstart(self, f, reset=True, username=None, password=None): |
137 | """Process a kickstart file, given by the filename f.""" | 134 | """Process a kickstart file, given by the filename f.""" |
138 | if reset: | 135 | if reset: |
139 | self._reset() | 136 | self._reset() |
140 | @@ -794,7 +794,7 @@ class KickstartParser(object): | 137 | @@ -808,7 +808,7 @@ class KickstartParser(object): |
141 | self.currentdir[self._includeDepth] = cd | 138 | self.currentdir[self._includeDepth] = cd |
142 | 139 | ||
143 | try: | 140 | try: |
144 | - s = load_to_str(f) | 141 | - s = load_to_str(f) |
145 | + s = load_to_str(f, user=username, passwd=password) | 142 | + s = load_to_str(f, user=username, passwd=password) |
146 | except KickstartError as e: | 143 | except KickstartError as e: |
147 | raise KickstartError(formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % str(e))) | 144 | raise KickstartError(_("Unable to open input kickstart file: %s") % str(e), lineno=0) |
148 | 145 | ||
149 | -- | 146 | -- |
150 | 2.7.4 | 147 | 2.7.4 |