Commit 1cc33f94 authored by Milan Broz's avatar Milan Broz

patch 1.patch

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@109 36d66b0a-2a48-0410-832c-cd162a569da5
parent e479b098
2009-09-10 Milan Broz <mbroz@redhat.com>
* Clean up Makefiles and configure script.
* Version 1.1.0-test0.
2009-09-08 Milan Broz <mbroz@redhat.com>
* Use dm-uuid for all crypt devices, contains device type and name now.
* Try to read first sector from device to properly check that device is ready.
......
AC_PREREQ(2.57)
AC_INIT(cryptsetup,1.0.7)
AC_INIT(cryptsetup,1.1.0-test0)
AC_CONFIG_SRCDIR(src/cryptsetup.c)
AC_CONFIG_MACRO_DIR([m4])
......@@ -29,12 +29,13 @@ AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR('You need the uuid library')])
AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR('You need the device-mapper library')])
saved_LIBS="$LIBS"
saved_LIBS=$LIBS
AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR('You need the uuid library')])
AC_CHECK_LIB(devmapper, dm_task_set_name,,[AC_MSG_ERROR('You need the device-mapper library')])
UUID_LIBS="$LIBS"
LIBS="$saved_LIBS"
AC_SUBST(UUID_LIBS)
AC_SUBST(UUID_LIBS, $LIBS)
LIBS=$saved_LIBS
AM_PATH_LIBGCRYPT(1.1.42,,[AC_MSG_ERROR('You need the gcrypt library')])
AC_CHECK_FUNCS([setlocale, posix_memalign])
......@@ -53,12 +54,11 @@ AM_GNU_GETTEXT_VERSION([0.15])
dnl ==========================================================================
saved_LIBS="$LIBS"
saved_LIBS=$LIBS
AC_CHECK_LIB(popt, poptConfigFileToString,,
AC_MSG_ERROR([You need popt 1.7 or newer to compile.]))
POPT_LIBS="$LIBS"
LIBS="$saved_LIBS"
AC_SUBST(POPT_LIBS)
[AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
AC_SUBST(POPT_LIBS, $LIBS)
LIBS=$saved_LIBS
dnl ==========================================================================
......@@ -68,52 +68,30 @@ AC_ARG_ENABLE(shared-library,
enable_shared_library=yes)
AM_CONDITIONAL(STATIC_LIBRARY, test x$enable_shared_library = xno)
AC_ARG_ENABLE(plugins,
[ --enable-plugins disable shared library plugins],,enable_plugins=no)
if test "x$enable_plugins" = xyes; then
AC_DEFINE(USE_PLUGINS, 1, [Define if you wish to use the plugin loader])
fi
AC_ARG_ENABLE(, [
Modules:
--with-MODULE[[=shared]] builds the module MODULE as a shared library plugin
],,)
AC_ARG_ENABLE(all,
[ --disable-all disable all modules built by default],,enable_all=default)
MODULE_HELPER(libgcrypt,
[ --enable-libgcrypt enable libgcrypt crypto functions [[default=auto]]],auto,[
AM_PATH_LIBGCRYPT(1.1.42,have_module=yes)
])
AM_CONDITIONAL(BUILD_LIBGCRYPT, test x$build_static = xyes)
AM_CONDITIONAL(SHARED_LIBGCRYPT, test x$build_shared = xyes)
AC_ARG_ENABLE(selinux,
[ --disable-selinux disable selinux support [[default=auto]]],[], [])
saved_LIBS="$LIBS"
saved_LIBS=$LIBS
AC_CHECK_LIB(devmapper, dm_task_set_name,,[AC_MSG_ERROR('You need the device-mapper library')])
DEVMAPPER_LIBS=$LIBS
LIBS=$saved_LIBS
if test "x$enable_selinux" != xno; then
AC_CHECK_LIB(sepol, sepol_bool_set)
AC_CHECK_LIB(selinux, is_selinux_enabled)
# Check if we need -pthread with --enable-static and selinux
if test x$build_static = xyes; then
saved_LIBS2="$LIBS"
if test x$enable_static = xyes; then
SELINUX_STATIC_LIBS=$LIBS
# Check if we need -pthread with --enable-static and selinux
saved_LIBS2=$LIBS
LIBS="$LIBS -static"
AC_SEARCH_LIBS([pthread_mutex_lock], [pthread],
[test "$ac_cv_search_pthread_mutex_lock" = "none required" || LIB_PTHREAD=-lpthread])
LIBS="$saved_LIBS2"
SELINUX_STATIC_LIBS="$LIBS"
LIBS=$saved_LIBS2
fi
fi
LIBS=$saved_LIBS
DEVMAPPER_LIBS="$DEVMAPPER_LIBS $LIB_PTHREAD"
AC_SUBST(DEVMAPPER_LIBS)
AC_SUBST(SELINUX_STATIC_LIBS)
LIBDEVMAPPER_LIBS="$LIBS $LIB_PTHREAD"
LIBS="$saved_LIBS"
AC_SUBST(LIBDEVMAPPER_LIBS)
AC_SUBST(LIBDEVMAPPER_CFLAGS)
AM_CONDITIONAL(BUILD_LIBDEVMAPPER, test x$build_static = xyes)
AM_CONDITIONAL(SHARED_LIBDEVMAPPER, test x$build_shared = xyes)
dnl ==========================================================================
......@@ -124,6 +102,7 @@ dnl ==========================================================================
AC_OUTPUT([ Makefile
lib/Makefile
lib/libcryptsetup.pc
src/Makefile
po/Makefile.in
luks/Makefile
......
moduledir = $(libdir)/cryptsetup
if BUILD_LIBDEVMAPPER
_LIBDEVMAPPER_LIBADD = @LIBDEVMAPPER_LIBS@
_LIBDEVMAPPER_SOURCES = libdevmapper.c
_LIBDEVMAPPER_CFLAGS = -DBUILTIN_LIBDEVMAPPER
endif
libbbackend_devmapper_la_SOURCES = libdevmapper.c
libbbackend_devmapper_la_LDFLAGS = -avoid-version -module
libbbackend_devmapper_la_LIBADD = @LIBDEVMAPPER_LIBS@
if SHARED_LIBDEVMAPPER
_LIBDEVMAPPER_SHLIB = libbbackend_devmapper.la
endif
if BUILD_LIBGCRYPT
_LIBGCRYPT_LIBADD = @LIBGCRYPT_LIBS@
_LIBGCRYPT_SOURCES = gcrypt.c
_LIBGCRYPT_CFLAGS = -DBUILTIN_GCRYPT
endif
libcrypto_gcrypt_la_SOURCES = gcrypt.c
libcrypto_gcrypt_la_LDFLAGS = -avoid-version -module
libcrypto_gcrypt_la_LIBADD = @LIBGCRYPT_LIBS@
if SHARED_LIBGCRYPT
_LIBGCRYPT_SHLIB = libcrypto_gcrypt.la
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcryptsetup.pc
INCLUDES = \
-I$(top_srcdir) \
......@@ -34,32 +13,27 @@ INCLUDES = \
-DVERSION=\""$(VERSION)"\" \
-D_GNU_SOURCE \
-D_LARGEFILE64_SOURCE \
-D_FILE_OFFSET_BITS=64 \
@LIBDEVMAPPER_CFLAGS@ \
$(_LIBDEVMAPPER_CFLAGS) \
@LIBGCRYPT_CFLAGS@ \
$(_LIBGCRYPT_CFLAGS)
lib_LTLIBRARIES = \
libcryptsetup.la
-D_FILE_OFFSET_BITS=64
module_LTLIBRARIES = \
$(_LIBDEVMAPPER_SHLIB) \
$(_LIBGCRYPT_SHLIB)
lib_LTLIBRARIES = libcryptsetup.la
if STATIC_LIBRARY
_STATIC_LIBRARY = -static
endif
libcryptsetup_la_DEPENDENCIES = libcryptsetup.sym
libcryptsetup_la_LDFLAGS = \
$(_STATIC_LIBRARY)
$(_STATIC_LIBRARY) \
--version-script=libcryptsetup.sym \
-version-info 1:0:0
libcryptsetup_la_CFLAGS = -Wall
libcryptsetup_la_LIBADD = \
$(_LIBDEVMAPPER_LIBADD) \
$(_LIBGCRYPT_LIBADD) \
@UUID_LIBS@ \
@DEVMAPPER_LIBS@ \
@LIBGCRYPT_LIBS@ \
../luks/libluks.la
libcryptsetup_la_SOURCES = \
......@@ -69,8 +43,9 @@ libcryptsetup_la_SOURCES = \
libcryptsetup.h \
utils.c \
backends.c \
$(_LIBDEVMAPPER_SOURCES) \
$(_LIBGCRYPT_SOURCES)
libdevmapper.c \
gcrypt.c
include_HEADERS = libcryptsetup.h
include_HEADERS = \
libcryptsetup.h
EXTRA_DIST = libcryptsetup.pc.in libcryptsetup.sym
......@@ -8,18 +8,8 @@
extern struct hash_backend hash_gcrypt_backend;
#ifdef USE_PLUGINS
static void init_plugins(void)
{
}
#else /* USE_PLUGINS */
# define init_plugins() do { } while(0)
#endif /* USE_PLUGINS */
static struct hash_backend *hash_backends[] = {
#ifdef BUILTIN_GCRYPT
&hash_gcrypt_backend,
#endif
NULL
};
......@@ -27,8 +17,6 @@ struct hash_backend *get_hash_backend(const char *name)
{
struct hash_backend **backend;
init_plugins();
for(backend = hash_backends; *backend; backend++)
if (!name || strcmp(name, (*backend)->name) == 0)
break;
......
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: cryptsetup
Description: cryptsetup library
Version: 1.0.0
Cflags: -I${includedir}
Libs: -L${libdir} -lcryptsetup
CRYPTSETUP_1.0 {
global:
crypt_init;
crypt_init_by_name;
crypt_set_log_callback;
crypt_set_confirm_callback;
crypt_set_password_callback;
crypt_set_timeout;
crypt_set_password_retry;
crypt_set_iterarion_time;
crypt_set_password_verify;
crypt_memory_lock;
crypt_format;
crypt_load;
crypt_suspend;
crypt_resume_by_passphrase;
crypt_resume_by_keyfile;
crypt_free;
crypt_keyslot_add_by_passphrase;
crypt_keyslot_add_by_keyfile;
crypt_keyslot_add_by_volume_key;
crypt_keyslot_destroy;
crypt_activate_by_passphrase;
crypt_activate_by_keyfile;
crypt_activate_by_volume_key;
crypt_deactivate;
crypt_volume_key_get;
crypt_volume_key_verify;
crypt_status;
crypt_dump;
crypt_get_cipher;
crypt_get_cipher_mode;
crypt_get_uuid;
crypt_get_data_offset;
crypt_get_volume_key_size;
crypt_keyslot_status;
crypt_get_error;
crypt_get_dir;
crypt_set_debug_level;
crypt_create_device;
crypt_update_device;
crypt_resize_device;
crypt_query_device;
crypt_remove_device;
crypt_luksFormat;
crypt_luksOpen;
crypt_luksKillSlot;
crypt_luksRemoveKey;
crypt_luksAddKey;
crypt_luksUUID;
crypt_isLuks;
crypt_luksDump;
crypt_put_options;
local:
*;
};
......@@ -198,20 +198,22 @@ static int verify_other_keyslot(struct crypt_device *cd,
if(!password)
return -EINVAL;
if (ki == SLOT_ACTIVE_LAST)
ki = crypt_keyslot_status(cd, keyIndex);
if (ki == SLOT_ACTIVE) /* Not last slot */
LUKS_keyslot_set(&cd->hdr, keyIndex, 0);
openedIndex = LUKS_open_key_with_hdr(cd->device, CRYPT_ANY_SLOT,
password, passwordLen,
&cd->hdr, &mk, cd);
if (openedIndex < 0) {
LUKS_keyslot_set(&cd->hdr, keyIndex, 1);
return -EPERM;
}
if (ki == SLOT_ACTIVE)
LUKS_keyslot_set(&cd->hdr, keyIndex, 1);
LUKS_dealloc_masterkey(mk);
safe_free(password);
if (openedIndex < 0)
return -EPERM;
log_std(cd, _("Key slot %d verified.\n"), openedIndex);
return 0;
}
......@@ -1430,10 +1432,9 @@ int crypt_keyslot_add_by_volume_key(struct crypt_device *cd,
const char *volume_key,
size_t volume_key_size,
const char *passphrase,
size_t passphrase_size
)
size_t passphrase_size)
{
struct luks_masterkey *mk;
struct luks_masterkey *mk = NULL;
int r = -EINVAL;
char *new_password = NULL; unsigned int new_passwordLen;
......
TESTS = apitest
EXTRA_DIST = apitest fileDiffer.py compatimage.img.bz2 test
EXTRA_DIST = fileDiffer.py compatimage.img.bz2
apitest_SOURCES = apitest.c
apitest_LDADD = ../lib/libcryptsetup.la
apitest_LDFLAGS = -static
apitest_CFLAGS = -g -O0 -I../lib/
apitest_CFLAGS = -g -O0 -I$(top_srcdir)/lib/
check_PROGRAMS = apitest compatimage.img test
check_PROGRAMS = apitest
compatimage.img:
@bzip2 -k -d compatimage.img.bz2
......
......@@ -683,6 +683,11 @@ int main (int argc, char *argv[])
{
int i;
if (getuid() != 0) {
printf("You must be root to run this test.\n");
exit(0);
}
for (i = 1; i < argc; i++) {
if (!strcmp("-v", argv[i]) || !strcmp("--verbose", argv[i]))
_verbose = 1;
......
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