diff --git a/Makefile b/Makefile index 712b3d7..94924fd 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ INSTALL_PREFIX := /usr/local/ CFLAGS := -Wall -Wextra -Wshadow -Wswitch -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Werror=implicit-function-declaration -Werror=format -Wno-unused-parameter CFLAGS += -O3 -std=c11 -pthread -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500 -DBUILD_REVISION='"$(BUILD_REVISION)"' CFLAGS += `pkg-config --cflags openssl` -CFLAGS += -ggdb3 -DDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak +#CFLAGS += -ggdb3 -DDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak PYPGMOPTS := ../Python/pypgmopts/pypgmopts LDFLAGS := `pkg-config --libs openssl` diff --git a/luks.c b/luks.c index c73809c..ab485be 100644 --- a/luks.c +++ b/luks.c @@ -57,22 +57,15 @@ bool open_luks_device(const uint8_t *encrypted_device_uuid, const char *mapping_ log_msg(LLVL_INFO, "Trying to unlock LUKS mapping %s based on %s", mapping_name, encrypted_device); struct exec_cmd_t cmd = { - .stdin_data = passphrase, - .stdin_length = passphrase_length, - .show_output = should_log(LLVL_DEBUG), - }; - - if (!allow_discards) { - cmd.argv = (const char *[]) { + .argv = !allow_discards ? (const char *[]) { "cryptsetup", "luksOpen", "-T", "1", encrypted_device, mapping_name, NULL, - }; - } else { - cmd.argv = (const char *[]) { + } : + (const char *[]) { "cryptsetup", "--allow-discards", "luksOpen", @@ -80,8 +73,11 @@ bool open_luks_device(const uint8_t *encrypted_device_uuid, const char *mapping_ encrypted_device, mapping_name, NULL, - }; - } + }, + .stdin_data = passphrase, + .stdin_length = passphrase_length, + .show_output = should_log(LLVL_DEBUG), + }; struct exec_result_t runresult = exec_command(&cmd); return runresult.success && (runresult.returncode == 0);