mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-17 16:09:14 +00:00
21 lines
619 B
Python
21 lines
619 B
Python
|
#!/usr/bin/env python3
|
||
|
from flask import Flask, jsonify, request, json
|
||
|
from flask_restful import Resource
|
||
|
import subprocess
|
||
|
|
||
|
from selfprivacy_api.utils import get_domain
|
||
|
|
||
|
# Decrypt disk
|
||
|
class DecryptDisk(Resource):
|
||
|
def post(self):
|
||
|
decryptionCommand = """
|
||
|
echo -n {0} | cryptsetup luksOpen /dev/sdb decryptedVar""".format(
|
||
|
request.headers.get("X-Decryption-Key")
|
||
|
)
|
||
|
|
||
|
decryptionService = subprocess.Popen(
|
||
|
decryptionCommand, shell=True, stdout=subprocess.PIPE
|
||
|
)
|
||
|
decryptionService.communicate()
|
||
|
return {"status": decryptionService.returncode}
|