forked from shaba/openuds
Fixed headers
This commit is contained in:
parent
6fc6fa0fe1
commit
69f1c88c3d
@ -11,7 +11,7 @@
|
|||||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
# and/or other materials provided with the distribution.
|
# and/or other materials provided with the distribution.
|
||||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
# * Neither the name of Virtual Cable S.L.U. nor the names of its contributors
|
||||||
# may be used to endorse or promote products derived from this software
|
# may be used to endorse or promote products derived from this software
|
||||||
# without specific prior written permission.
|
# without specific prior written permission.
|
||||||
#
|
#
|
||||||
|
@ -52,8 +52,6 @@ _unlinkFiles = []
|
|||||||
_tasksToWait = []
|
_tasksToWait = []
|
||||||
_execBeforeExit = []
|
_execBeforeExit = []
|
||||||
|
|
||||||
sys_fs_enc = sys.getfilesystemencoding() or 'mbcs'
|
|
||||||
|
|
||||||
# Public key for scripts
|
# Public key for scripts
|
||||||
PUBLIC_KEY = b'''-----BEGIN PUBLIC KEY-----
|
PUBLIC_KEY = b'''-----BEGIN PUBLIC KEY-----
|
||||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAuNURlGjBpqbglkTTg2lh
|
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAuNURlGjBpqbglkTTg2lh
|
||||||
@ -73,7 +71,9 @@ nVgtClKcDDlSaBsO875WDR0CAwEAAQ==
|
|||||||
|
|
||||||
def saveTempFile(content, filename=None):
|
def saveTempFile(content, filename=None):
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
|
filename = ''.join(
|
||||||
|
random.choice(string.ascii_lowercase + string.digits) for _ in range(16)
|
||||||
|
)
|
||||||
filename = filename + '.uds'
|
filename = filename + '.uds'
|
||||||
|
|
||||||
filename = os.path.join(tempfile.gettempdir(), filename)
|
filename = os.path.join(tempfile.gettempdir(), filename)
|
||||||
@ -116,28 +116,29 @@ def findApp(appName, extraPath=None):
|
|||||||
|
|
||||||
|
|
||||||
def getHostName():
|
def getHostName():
|
||||||
'''
|
"""
|
||||||
Returns current host name
|
Returns current host name
|
||||||
In fact, it's a wrapper for socket.gethostname()
|
In fact, it's a wrapper for socket.gethostname()
|
||||||
'''
|
"""
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
logger.info('Hostname: %s', hostname)
|
logger.info('Hostname: %s', hostname)
|
||||||
return hostname
|
return hostname
|
||||||
|
|
||||||
|
|
||||||
# Queing operations (to be executed before exit)
|
# Queing operations (to be executed before exit)
|
||||||
|
|
||||||
|
|
||||||
def addFileToUnlink(filename):
|
def addFileToUnlink(filename):
|
||||||
'''
|
"""
|
||||||
Adds a file to the wait-and-unlink list
|
Adds a file to the wait-and-unlink list
|
||||||
'''
|
"""
|
||||||
_unlinkFiles.append(filename)
|
_unlinkFiles.append(filename)
|
||||||
|
|
||||||
|
|
||||||
def unlinkFiles():
|
def unlinkFiles():
|
||||||
'''
|
"""
|
||||||
Removes all wait-and-unlink files
|
Removes all wait-and-unlink files
|
||||||
'''
|
"""
|
||||||
if _unlinkFiles:
|
if _unlinkFiles:
|
||||||
time.sleep(5) # Wait 5 seconds before deleting anything
|
time.sleep(5) # Wait 5 seconds before deleting anything
|
||||||
|
|
||||||
@ -171,16 +172,14 @@ def execBeforeExit():
|
|||||||
for fnc in _execBeforeExit:
|
for fnc in _execBeforeExit:
|
||||||
fnc.__call__()
|
fnc.__call__()
|
||||||
|
|
||||||
|
|
||||||
def verifySignature(script, signature):
|
def verifySignature(script, signature):
|
||||||
public_key = load_pem_public_key(backend=default_backend(), data=PUBLIC_KEY)
|
public_key = load_pem_public_key(backend=default_backend(), data=PUBLIC_KEY)
|
||||||
|
|
||||||
# Message option
|
# Message option
|
||||||
try:
|
try:
|
||||||
public_key.verify(
|
public_key.verify(
|
||||||
base64.b64decode(signature),
|
base64.b64decode(signature), script, padding.PKCS1v15(), hashes.SHA256()
|
||||||
script,
|
|
||||||
padding.PKCS1v15(),
|
|
||||||
hashes.SHA256()
|
|
||||||
)
|
)
|
||||||
except Exception: # InvalidSignature
|
except Exception: # InvalidSignature
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user