|
58 | 58 | import urllib.request, urllib.parse, urllib.error |
59 | 59 | from urllib.parse import urlparse |
60 | 60 |
|
61 | | -try: |
62 | | - import crypt |
63 | | -except ImportError: |
64 | | - crypt = None |
65 | 61 |
|
66 | 62 | from Mailman import mm_cfg |
67 | 63 | from Mailman import Utils |
68 | 64 | from Mailman import Errors |
69 | 65 | from Mailman.Logging.Syslog import syslog |
70 | | -from Mailman.Utils import md5_new, sha_new, hash_password, verify_password |
| 66 | +from Mailman.Utils import sha_new, hash_password, verify_password |
71 | 67 |
|
72 | 68 |
|
73 | 69 | class SecurityManager(object): |
@@ -152,47 +148,20 @@ def Authenticate(self, authcontexts, response, user=None): |
152 | 148 | if ok: |
153 | 149 | return mm_cfg.AuthSiteAdmin |
154 | 150 | elif ac == mm_cfg.AuthListAdmin: |
155 | | - def cryptmatchp(response, secret): |
156 | | - try: |
157 | | - salt = secret[:2] |
158 | | - if crypt and crypt.crypt(response, salt) == secret: |
159 | | - return True |
160 | | - return False |
161 | | - except TypeError: |
162 | | - # BAW: Hard to say why we can get a TypeError here. |
163 | | - # SF bug report #585776 says crypt.crypt() can raise |
164 | | - # this if salt contains null bytes, although I don't |
165 | | - # know how that can happen (perhaps if a MM2.0 list |
166 | | - # with USE_CRYPT = 0 has been updated? Doubtful. |
167 | | - return False |
168 | 151 | # The password for the list admin is stored as a hash. |
169 | 152 | # We support multiple formats for backwards compatibility: |
170 | 153 | # - New format: PBKDF2-SHA256 with $pbkdf2$ prefix |
171 | | - # - Old format: SHA1 hexdigest (40 hex chars) |
172 | | - # - Legacy: MD5 or crypt() (auto-upgrade to PBKDF2) |
| 154 | + # - Old format: SHA1 hexdigest (40 hex chars, auto-upgrade to PBKDF2) |
173 | 155 | key, secret = self.AuthContextInfo(ac) |
174 | 156 | if secret is None: |
175 | 157 | continue |
176 | 158 | if isinstance(response, str): |
177 | 159 | response = response.encode('utf-8') |
178 | 160 |
|
179 | | - # Try new PBKDF2 or old SHA1 format first |
| 161 | + # Try new PBKDF2 or old SHA1 format (verify_password handles both) |
180 | 162 | ok, needs_upgrade = verify_password(response, secret) |
181 | 163 | upgrade = needs_upgrade |
182 | 164 |
|
183 | | - # If that didn't work, try legacy MD5 and crypt() formats |
184 | | - if not ok: |
185 | | - sharesponse = sha_new(response).hexdigest() |
186 | | - if sharesponse == secret: |
187 | | - ok = True |
188 | | - upgrade = True |
189 | | - elif md5_new(response).digest() == secret: |
190 | | - ok = True |
191 | | - upgrade = True |
192 | | - elif cryptmatchp(response, secret): |
193 | | - ok = True |
194 | | - upgrade = True |
195 | | - |
196 | 165 | # Upgrade to new PBKDF2 format if needed |
197 | 166 | if upgrade and ok: |
198 | 167 | save_and_unlock = False |
|
0 commit comments