Add utilities cleanup routine.

This commit is contained in:
Ondrej Kozina
2020-04-24 13:05:21 +02:00
committed by Milan Broz
parent 74c943c352
commit 4a43a2773a
6 changed files with 20 additions and 0 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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);
}

View File

@@ -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)