diff --git a/Makefile b/Makefile index 0099f9c..fe3d251 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,24 @@ -.PHONY: all clean test testclient derive install -all: luksrku luksrku-config +.PHONY: all clean test testclient install +all: luksrku BUILD_REVISION := $(shell git describe --abbrev=10 --dirty --always --tags) 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 -O2 -Wmissing-prototypes -Wstrict-prototypes -CFLAGS += -std=c11 -pthread -D_POSIX_SOURCE -D_XOPEN_SOURCE=500 -DBUILD_REVISION='"$(BUILD_REVISION)"' -#CFLAGS += -g -DDEBUG +CFLAGS += -O3 -std=c11 -pthread -D_POSIX_SOURCE -D_XOPEN_SOURCE=500 -DBUILD_REVISION='"$(BUILD_REVISION)"' CFLAGS += `pkg-config --cflags openssl` +CFLAGS += -ggdb3 -DDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak LDFLAGS := `pkg-config --libs openssl` -OBJS := luksrku.o server.o log.o openssl.o client.o keyfile.o msg.o binkeyfile.o util.o cmdline.o luks.o exec.o blacklist.o -OBJS_CFG := luksrku-config.o keyfile.o binkeyfile.o parse-keyfile.o openssl.o log.o util.o +OBJS := luksrku.o editor.o util.o log.o keydb.o file_encryption.o uuid.o install: all - strip luksrku luksrku-config - cp luksrku luksrku-config $(INSTALL_PREFIX)sbin/ - chown root:root $(INSTALL_PREFIX)sbin/luksrku $(INSTALL_PREFIX)sbin/luksrku-config - chmod 755 $(INSTALL_PREFIX)sbin/luksrku $(INSTALL_PREFIX)sbin/luksrku-config + cp luksrku $(INSTALL_PREFIX)sbin/ + chown root:root $(INSTALL_PREFIX)sbin/luksrku + chmod 755 $(INSTALL_PREFIX)sbin/luksrku clean: - rm -f $(OBJS) $(OBJS_CFG) luksrku luksrku-config - -valgrind: luksrku - valgrind --leak-check=full --show-leak-kinds=all ./luksrku -v --client-mode -k client_keys.bin + rm -f $(OBJS) $(OBJS_CFG) luksrku test: luksrku ./luksrku -v --server-mode -k server_key.bin @@ -35,15 +29,8 @@ gdb: luksrku testclient: luksrku ./luksrku -v --client-mode -k client_keys.bin -derive: luksrku-config - ./luksrku-config server server_key.txt server_key.bin - ./luksrku-config client client_keys.txt client_keys.bin - .c.o: $(CC) $(CFLAGS) -c -o $@ $< luksrku: $(OBJS) $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) - -luksrku-config: $(OBJS_CFG) - $(CC) $(CFLAGS) -o $@ $(OBJS_CFG) $(LDFLAGS) diff --git a/editor.c b/editor.c index f4fd09b..0ec407d 100644 --- a/editor.c +++ b/editor.c @@ -49,9 +49,9 @@ struct editor_context_t { }; struct editor_command_t { - const char *cmdnames[MAX_COMMAND_ALIAS_COUNT]; unsigned int min_params; unsigned int max_params; + const char *cmdnames[MAX_COMMAND_ALIAS_COUNT]; const char *param_names; const char *description; enum cmd_returncode_t (*callback)(struct editor_context_t *ctx, const char *cmdname, unsigned int param_cnt, char **params); @@ -179,7 +179,7 @@ static const struct editor_command_t commands[] = { .description = "Dumps the raw representation of a file", }, #endif - { { 0 } } + { 0 } }; static void format_command(char dest[static 128], const struct editor_command_t *cmd, const char *command_name) { @@ -548,13 +548,3 @@ void editor_start(void) { } OPENSSL_cleanse(&editor_context, sizeof(editor_context)); } - -#ifndef __TEST_EDITOR__ -// gcc -O3 -ggdb3 -DDEBUG -D_POSIX_SOURCE -Wall -std=c11 -Wmissing-prototypes -Wstrict-prototypes -Werror=implicit-function-declaration -Wimplicit-fallthrough -Wshadow -pie -fPIE -fsanitize=address -fsanitize=undefined -fsanitize=leak -o editor editor.c util.c log.c keydb.c file_encryption.c uuid.c -lcrypto && ./editor - -int main(int argc, char **argv) { - editor_start(); - return 0; -} - -#endif diff --git a/keydb.h b/keydb.h index 4812c96..eb8dbe9 100644 --- a/keydb.h +++ b/keydb.h @@ -49,7 +49,7 @@ struct host_entry_t { struct keydb_t { unsigned int keydb_version; bool server_database; - int host_count; + unsigned int host_count; struct host_entry_t hosts[]; }; diff --git a/luksrku.c b/luksrku.c index 12da48c..3d91658 100644 --- a/luksrku.c +++ b/luksrku.c @@ -25,13 +25,8 @@ #include #include -#include "server.h" -#include "client.h" #include "openssl.h" -#include "binkeyfile.h" -#include "cmdline.h" #include "log.h" -#include "keyfile.h" #if OPENSSL_VERSION_NUMBER < 0x010100000 #error "luksrku requires at least OpenSSL v1.1 to work." @@ -42,6 +37,7 @@ int main(int argc, char **argv) { fprintf(stderr, "WARNING: This has been compiled in DEBUG mode and uses reduced security.\n"); #endif +#if 0 struct options_t options; if (!parse_cmdline_arguments(&options, argc, argv)) { print_syntax(argv[0]); @@ -108,6 +104,7 @@ int main(int argc, char **argv) { if (!success) { exit(EXIT_FAILURE); } +#endif return 0; } diff --git a/util.c b/util.c index 27c77d2..bf1619c 100644 --- a/util.c +++ b/util.c @@ -176,7 +176,7 @@ bool array_remove(void *base, unsigned int element_size, unsigned int element_co /* Then, wipe the last element */ const unsigned int last_element_offset = element_size * (element_count - 1); - memset(base + last_element_offset, 0, element_size); + memset(bytebase + last_element_offset, 0, element_size); return true; }