mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-14 20:50:44 +01:00
Unix: Disable 'crypt' command on Python >= 3.13
The module is not available anymore
This commit is contained in:
parent
e18332efde
commit
9ae7690484
@ -40,7 +40,6 @@ class InternetTestCase(PluginTestCase):
|
||||
'Host not found.')
|
||||
|
||||
def testWhois(self):
|
||||
self.assertNotError('internet whois ohio-state.edu')
|
||||
self.assertNotError('internet whois microsoft.com')
|
||||
self.assertNotError('internet whois inria.fr')
|
||||
self.assertNotError('internet whois slime.com.au')
|
||||
|
@ -33,7 +33,6 @@ import os
|
||||
import re
|
||||
import pwd
|
||||
import sys
|
||||
import crypt
|
||||
import errno
|
||||
import random
|
||||
import select
|
||||
@ -41,6 +40,12 @@ import struct
|
||||
import subprocess
|
||||
import shlex
|
||||
|
||||
try:
|
||||
import crypt
|
||||
except ImportError:
|
||||
# Python >= 3.13
|
||||
crypt = None
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
@ -119,25 +124,26 @@ class Unix(callbacks.Plugin):
|
||||
irc.reply(format('%i', os.getpid()), private=True)
|
||||
pid = wrap(pid, [('checkCapability', 'owner')])
|
||||
|
||||
_cryptre = re.compile(b'[./0-9A-Za-z]')
|
||||
@internationalizeDocstring
|
||||
def crypt(self, irc, msg, args, password, salt):
|
||||
"""<password> [<salt>]
|
||||
if crypt is not None: # Python < 3.13
|
||||
_cryptre = re.compile(b'[./0-9A-Za-z]')
|
||||
@internationalizeDocstring
|
||||
def crypt(self, irc, msg, args, password, salt):
|
||||
"""<password> [<salt>]
|
||||
|
||||
Returns the resulting of doing a crypt() on <password>. If <salt> is
|
||||
not given, uses a random salt. If running on a glibc2 system,
|
||||
prepending '$1$' to your salt will cause crypt to return an MD5sum
|
||||
based crypt rather than the standard DES based crypt.
|
||||
"""
|
||||
def makeSalt():
|
||||
s = b'\x00'
|
||||
while self._cryptre.sub(b'', s) != b'':
|
||||
s = struct.pack('<h', random.randrange(-(2**15), 2**15))
|
||||
return s
|
||||
if not salt:
|
||||
salt = makeSalt().decode()
|
||||
irc.reply(crypt.crypt(password, salt))
|
||||
crypt = wrap(crypt, ['something', additional('something')])
|
||||
Returns the resulting of doing a crypt() on <password>. If <salt> is
|
||||
not given, uses a random salt. If running on a glibc2 system,
|
||||
prepending '$1$' to your salt will cause crypt to return an MD5sum
|
||||
based crypt rather than the standard DES based crypt.
|
||||
"""
|
||||
def makeSalt():
|
||||
s = b'\x00'
|
||||
while self._cryptre.sub(b'', s) != b'':
|
||||
s = struct.pack('<h', random.randrange(-(2**15), 2**15))
|
||||
return s
|
||||
if not salt:
|
||||
salt = makeSalt().decode()
|
||||
irc.reply(crypt.crypt(password, salt))
|
||||
crypt = wrap(crypt, ['something', additional('something')])
|
||||
|
||||
@internationalizeDocstring
|
||||
def spell(self, irc, msg, args, word):
|
||||
|
@ -31,6 +31,11 @@
|
||||
import os
|
||||
import socket
|
||||
|
||||
try:
|
||||
import crypt
|
||||
except ImportError:
|
||||
crypt = None
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
try:
|
||||
@ -106,8 +111,9 @@ if os.name == 'posix':
|
||||
def testProgstats(self):
|
||||
self.assertNotError('progstats')
|
||||
|
||||
def testCrypt(self):
|
||||
self.assertNotError('crypt jemfinch')
|
||||
if crypt is not None: # Python < 3.13
|
||||
def testCrypt(self):
|
||||
self.assertNotError('crypt jemfinch')
|
||||
|
||||
@skipUnlessFortune
|
||||
def testFortune(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user