Commit ef4484ab authored by Milan Broz's avatar Milan Broz

Remove python bindings in favour of liblockdev.

parent 9e7f9f34
...@@ -25,8 +25,6 @@ tmpfilesd_DATA = ...@@ -25,8 +25,6 @@ tmpfilesd_DATA =
include man/Makemodule.am include man/Makemodule.am
include python/Makemodule.am
include scripts/Makemodule.am include scripts/Makemodule.am
if CRYPTO_INTERNAL_ARGON2 if CRYPTO_INTERNAL_ARGON2
...@@ -40,7 +38,6 @@ include src/Makemodule.am ...@@ -40,7 +38,6 @@ include src/Makemodule.am
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
DISTCHECK_CONFIGURE_FLAGS = \ DISTCHECK_CONFIGURE_FLAGS = \
--enable-python \
--with-tmpfilesdir=$$dc_install_base/usr/lib/tmpfiles.d \ --with-tmpfilesdir=$$dc_install_base/usr/lib/tmpfiles.d \
--enable-internal-argon2 --enable-internal-sse-argon2 --enable-internal-argon2 --enable-internal-sse-argon2
......
...@@ -546,35 +546,6 @@ AC_DEFUN([CS_ABSPATH], [ ...@@ -546,35 +546,6 @@ AC_DEFUN([CS_ABSPATH], [
esac esac
]) ])
dnl ==========================================================================
dnl Python bindings
AC_ARG_ENABLE([python],
AS_HELP_STRING([--enable-python], [enable Python bindings]))
AC_ARG_WITH([python_version],
AS_HELP_STRING([--with-python_version=VERSION], [required Python version [2.6]]),
[PYTHON_VERSION=$withval], [PYTHON_VERSION=2.6])
if test "x$enable_python" = "xyes"; then
AM_PATH_PYTHON([$PYTHON_VERSION])
AC_PATH_PROGS([PYTHON_CONFIG], [python${PYTHON_VERSION}-config python-config], [no])
if test "${PYTHON_CONFIG}" = "no"; then
AC_MSG_ERROR([cannot find python${PYTHON_VERSION}-config or python-config in PATH])
fi
AC_MSG_CHECKING(for python headers using $PYTHON_CONFIG --includes)
PYTHON_INCLUDES=$($PYTHON_CONFIG --includes)
AC_MSG_RESULT($PYTHON_INCLUDES)
AC_SUBST(PYTHON_INCLUDES)
AC_MSG_CHECKING(for python libraries using $PYTHON_CONFIG --libs)
PYTHON_LIBS=$($PYTHON_CONFIG --libs)
AC_MSG_RESULT($PYTHON_LIBS)
AC_SUBST(PYTHON_LIBS)
fi
AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$enable_python" = "xyes"])
dnl ========================================================================== dnl ==========================================================================
CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160]) CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes]) CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
......
EXTRA_DIST += python/pycryptsetup-test.py
CLEANFILES += python/*.img
if PYTHON_CRYPTSETUP
TESTS += python/pycryptsetup-test.py
pyexec_LTLIBRARIES = pycryptsetup.la
pycryptsetup_la_SOURCES = python/pycryptsetup.c
pycryptsetup_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_CPPFLAGS) $(PYTHON_INCLUDES) -fno-strict-aliasing
pycryptsetup_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
pycryptsetup_la_LIBADD = libcryptsetup.la $(PYTHON_LIBS)
endif
#!/usr/bin/python
#
# Python bindings to libcryptsetup test
#
# Copyright (C) 2011-2018, Red Hat, Inc. All rights reserved.
#
# This file is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this file; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from __future__ import print_function
import sys
import os
sys.path.insert(0, ".libs")
import pycryptsetup
IMG = "test.img"
PASSWORD = "password"
PASSWORD2 = "password2"
DEVICE = "pycryptsetup_test_dev"
def log(level, txt):
if level == pycryptsetup.CRYPT_LOG_ERROR:
print(txt,end="")
return
def askyes(txt):
print("Question:", txt)
return 1
def print_status(c):
r = c.status()
print("status :",end="")
if r == pycryptsetup.CRYPT_ACTIVE:
print("ACTIVE")
elif r == pycryptsetup.CRYPT_INACTIVE:
print("INACTIVE")
else:
print("ERROR")
return
if os.geteuid() != 0:
print("WARNING: You must be root to run this test, test skipped.")
sys.exit(77)
os.system("dd if=/dev/zero of=" + IMG + " bs=1M count=32 >/dev/null 2>&1")
c = pycryptsetup.CryptSetup(
device = IMG,
name = DEVICE,
yesDialog = askyes,
logFunc = log)
#c.debugLevel(pycryptsetup.CRYPT_DEBUG_ALL);
c.debugLevel(pycryptsetup.CRYPT_DEBUG_NONE);
c.iterationTime(1)
r = c.isLuks()
print("isLuks :", r)
c.askyes(message = "Is there anybody out there?")
c.log(priority = pycryptsetup.CRYPT_LOG_ERROR, message = "Nobody there...\n")
c.luksFormat(cipher = "aes", cipherMode= "xts-plain64", keysize = 512, hashMode = "sha256")
print("isLuks :", c.isLuks())
print("luksUUID:", c.luksUUID())
print("addKeyVK:", c.addKeyByVolumeKey(newPassphrase = PASSWORD, slot = 2))
print("addKeyP :", c.addKeyByPassphrase(passphrase = PASSWORD,
newPassphrase = PASSWORD2, slot = 3))
print("removeP :", c.removePassphrase(passphrase = PASSWORD2))
print("addKeyP :", c.addKeyByPassphrase(PASSWORD, PASSWORD2))
# original api required wrong passphrase parameter here
# print "killSlot:", c.killSlot(passphrase = "xxx", slot = 0)
print("killSlot:", c.killSlot(slot = 0))
print("activate:", c.activate(name = DEVICE, passphrase = PASSWORD))
print("suspend :", c.suspend())
# os.system("dmsetup info -c " + DEVICE)
print("resume :", c.resume(passphrase = PASSWORD))
print_status(c)
info = c.info()
print("cipher :", info["cipher"])
print("cmode :", info["cipher_mode"])
print("keysize :", info["keysize"])
print("dir :", info["dir"])
print("device :", info["device"])
print("offset :", info["offset"])
print("name :", info["name"])
print("uuid :", info["uuid"])
# os.system("cryptsetup luksDump " + info["device"])
print("deact. :", c.deactivate())
del c
c = pycryptsetup.CryptSetup(
device = IMG,
name = DEVICE,
yesDialog = askyes,
logFunc = log)
print("activate:", c.activate(name = DEVICE, passphrase = PASSWORD))
c2 = pycryptsetup.CryptSetup(
name = DEVICE,
yesDialog = askyes,
logFunc = log)
info = c2.info()
print("cipher :", info["cipher"])
print("cmode :", info["cipher_mode"])
print("keysize :", info["keysize"])
print("deact. :", c.deactivate())
r = c2.deactivate()
print("deact. :", r)
del c
del c2
os.remove(IMG)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment