Fixed issue with member access
This is kind of hacky, but it avoids the segfault at runtime. So, preferrable. If we ever have more options, we need to properly generate the argv[] array.
This commit is contained in:
parent
b0fc16bfc7
commit
37b239b179
2
Makefile
2
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 := -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 += -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 += `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
|
PYPGMOPTS := ../Python/pypgmopts/pypgmopts
|
||||||
|
|
||||||
LDFLAGS := `pkg-config --libs openssl`
|
LDFLAGS := `pkg-config --libs openssl`
|
||||||
|
20
luks.c
20
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);
|
log_msg(LLVL_INFO, "Trying to unlock LUKS mapping %s based on %s", mapping_name, encrypted_device);
|
||||||
|
|
||||||
struct exec_cmd_t cmd = {
|
struct exec_cmd_t cmd = {
|
||||||
.stdin_data = passphrase,
|
.argv = !allow_discards ? (const char *[]) {
|
||||||
.stdin_length = passphrase_length,
|
|
||||||
.show_output = should_log(LLVL_DEBUG),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!allow_discards) {
|
|
||||||
cmd.argv = (const char *[]) {
|
|
||||||
"cryptsetup",
|
"cryptsetup",
|
||||||
"luksOpen",
|
"luksOpen",
|
||||||
"-T", "1",
|
"-T", "1",
|
||||||
encrypted_device,
|
encrypted_device,
|
||||||
mapping_name,
|
mapping_name,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
} :
|
||||||
} else {
|
(const char *[]) {
|
||||||
cmd.argv = (const char *[]) {
|
|
||||||
"cryptsetup",
|
"cryptsetup",
|
||||||
"--allow-discards",
|
"--allow-discards",
|
||||||
"luksOpen",
|
"luksOpen",
|
||||||
@ -80,8 +73,11 @@ bool open_luks_device(const uint8_t *encrypted_device_uuid, const char *mapping_
|
|||||||
encrypted_device,
|
encrypted_device,
|
||||||
mapping_name,
|
mapping_name,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
},
|
||||||
}
|
.stdin_data = passphrase,
|
||||||
|
.stdin_length = passphrase_length,
|
||||||
|
.show_output = should_log(LLVL_DEBUG),
|
||||||
|
};
|
||||||
|
|
||||||
struct exec_result_t runresult = exec_command(&cmd);
|
struct exec_result_t runresult = exec_command(&cmd);
|
||||||
return runresult.success && (runresult.returncode == 0);
|
return runresult.success && (runresult.returncode == 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user