From 4a43a2773a432dbf8601922cfefd653ee34f0405 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Fri, 24 Apr 2020 13:05:21 +0200 Subject: [PATCH] Add utilities cleanup routine. --- src/cryptsetup.c | 4 ++++ src/cryptsetup.h | 3 +++ src/cryptsetup_reencrypt.c | 4 ++++ src/integritysetup.c | 4 ++++ src/utils_tools.c | 1 + src/veritysetup.c | 4 ++++ 6 files changed, 20 insertions(+) diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 93e695f3..081e0419 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -127,6 +127,10 @@ static const char **action_argv; static int action_argc; static const char *null_action_argv[] = {NULL, NULL}; +void tools_cleanup(void) +{ +} + static const char *uuid_or_device_header(const char **data_device) { if (data_device) diff --git a/src/cryptsetup.h b/src/cryptsetup.h index 75e67977..6504f896 100644 --- a/src/cryptsetup.h +++ b/src/cryptsetup.h @@ -116,6 +116,9 @@ int tools_wipe_all_signatures(const char *path); int tools_lookup_crypt_device(struct crypt_device *cd, const char *type, const char *data_device_path, char *name, size_t name_length); +/* each utility is required to implement it */ +void tools_cleanup(void); + /* Log */ #define log_dbg(x...) clogger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x) #define log_std(x...) clogger(NULL, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x) diff --git a/src/cryptsetup_reencrypt.c b/src/cryptsetup_reencrypt.c index 3d86960d..3212d123 100644 --- a/src/cryptsetup_reencrypt.c +++ b/src/cryptsetup_reencrypt.c @@ -117,6 +117,10 @@ typedef enum { CHECK_OPEN, } header_magic; +void tools_cleanup(void) +{ +} + static void _quiet_log(int level, const char *msg, void *usrptr) { if (!opt_debug) diff --git a/src/integritysetup.c b/src/integritysetup.c index 3b4b26ca..f6106fde 100644 --- a/src/integritysetup.c +++ b/src/integritysetup.c @@ -63,6 +63,10 @@ static const char *integrity_alg = DEFAULT_ALG_NAME; static const char **action_argv; static int action_argc; +void tools_cleanup(void) +{ +} + // FIXME: move this to tools and handle EINTR static int _read_mk(const char *file, char **key, int keysize) { diff --git a/src/utils_tools.c b/src/utils_tools.c index 7c71e0bc..d523c1aa 100644 --- a/src/utils_tools.c +++ b/src/utils_tools.c @@ -238,6 +238,7 @@ __attribute__ ((noreturn)) void usage(poptContext popt_context, poptPrintUsage(popt_context, stderr, 0); if (error) log_err("%s: %s", more, error); + tools_cleanup(); poptFreeContext(popt_context); exit(exitcode); } diff --git a/src/veritysetup.c b/src/veritysetup.c index b58b5c16..dfb5c10e 100644 --- a/src/veritysetup.c +++ b/src/veritysetup.c @@ -46,6 +46,10 @@ static int opt_check_at_most_once = 0; static const char **action_argv; static int action_argc; +void tools_cleanup(void) +{ +} + static int _prepare_format(struct crypt_params_verity *params, const char *data_device, uint32_t flags)