From 5345a73ca060262dea2b435f7ba46bdab1f03408 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Thu, 23 Apr 2020 11:28:44 +0200 Subject: [PATCH] Group all string options variables together. --- src/cryptsetup.c | 52 ++++++++++++++++++-------------------- src/cryptsetup_reencrypt.c | 18 +++++++------ src/integritysetup.c | 25 ++++++++---------- src/veritysetup.c | 12 ++++----- 4 files changed, 52 insertions(+), 55 deletions(-) diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 78715b22..0fa1af94 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -27,19 +27,40 @@ static const char *opt_cipher = NULL; static const char *opt_keyslot_cipher = NULL; static const char *opt_hash = NULL; -static int opt_verify_passphrase = 0; - static const char *opt_json_file = NULL; static const char *opt_key_file = NULL; static const char *opt_keyfile_stdin = NULL; -static int opt_keyfiles_count = 0; static const char *opt_keyfiles[MAX_KEYFILES]; - static const char *opt_master_key_file = NULL; static const char *opt_header_backup_file = NULL; static const char *opt_uuid = NULL; static const char *opt_header_device = NULL; static const char *opt_type = "luks"; +static const char *opt_pbkdf = NULL; +static const char *opt_priority = NULL; /* normal */ +static const char *opt_integrity = NULL; /* none */ +static const char *opt_key_description = NULL; +static const char *opt_label = NULL; +static const char *opt_subsystem = NULL; +static const char *opt_active_name = NULL; +static const char *opt_resilience_mode = "checksum"; // TODO: default resilience +static const char *opt_resilience_hash = "sha256"; // TODO: default checksum hash + +/* helper strings converted to uint64_t later */ +static const char *opt_reduce_size_str = NULL; +static const char *opt_hotzone_size_str = NULL; +static const char *opt_device_size_str = NULL; +static const char *opt_luks2_metadata_size_str = NULL; +static const char *opt_luks2_keyslots_size_str = NULL; + +static uint64_t opt_reduce_size = 0; +static uint64_t opt_hotzone_size = 0; +static uint64_t opt_device_size = 0; +static uint64_t opt_luks2_metadata_size = 0; +static uint64_t opt_luks2_keyslots_size = 0; + +static int opt_keyfiles_count = 0; +static int opt_verify_passphrase = 0; static int opt_key_size = 0; static int opt_keyslot_key_size = 0; static long opt_keyfile_size = 0; @@ -76,53 +97,30 @@ static int opt_veracrypt_query_pim = 0; static int opt_deferred_remove = 0; static int opt_serialize_memory_hard_pbkdf = 0; //FIXME: check uint32 overflow for long type -static const char *opt_pbkdf = NULL; static long opt_pbkdf_memory = DEFAULT_LUKS2_MEMORY_KB; static long opt_pbkdf_parallel = DEFAULT_LUKS2_PARALLEL_THREADS; static long opt_pbkdf_iterations = 0; static int opt_iteration_time = 0; static int opt_disable_locks = 0; static int opt_disable_keyring = 0; -static const char *opt_priority = NULL; /* normal */ -static const char *opt_integrity = NULL; /* none */ static int opt_integrity_nojournal = 0; static int opt_integrity_no_wipe = 0; static int opt_integrity_legacy_padding = 0; -static const char *opt_key_description = NULL; static int opt_sector_size = 0; static int opt_iv_large_sectors = 0; static int opt_persistent = 0; -static const char *opt_label = NULL; -static const char *opt_subsystem = NULL; static int opt_unbound = 0; static int opt_refresh = 0; /* LUKS2 reencryption parameters */ -static const char *opt_active_name = NULL; -static const char *opt_resilience_mode = "checksum"; // TODO: default resilience -static const char *opt_resilience_hash = "sha256"; // TODO: default checksum hash static int opt_encrypt = 0; static int opt_reencrypt_init_only = 0; static int opt_reencrypt_resume_only = 0; static int opt_decrypt = 0; -static const char *opt_reduce_size_str = NULL; -static uint64_t opt_reduce_size = 0; - -static const char *opt_hotzone_size_str = NULL; -static uint64_t opt_hotzone_size = 0; - -static const char *opt_device_size_str = NULL; -static uint64_t opt_device_size = 0; - /* do not set from command line, use helpers above */ static int64_t opt_data_shift; -static const char *opt_luks2_metadata_size_str = NULL; -static uint64_t opt_luks2_metadata_size = 0; -static const char *opt_luks2_keyslots_size_str = NULL; -static uint64_t opt_luks2_keyslots_size = 0; - static const char **action_argv; static int action_argc; static const char *null_action_argv[] = {NULL, NULL}; diff --git a/src/cryptsetup_reencrypt.c b/src/cryptsetup_reencrypt.c index b9461b77..fde97b91 100644 --- a/src/cryptsetup_reencrypt.c +++ b/src/cryptsetup_reencrypt.c @@ -35,10 +35,19 @@ static const char *opt_key_file = NULL; static const char *opt_master_key_file = NULL; static const char *opt_uuid = NULL; static const char *opt_type = "luks"; +static const char *opt_pbkdf = NULL; +static const char *opt_header_device = NULL; + +/* helper strings converted to uint64_t later */ +static const char *opt_reduce_size_str = NULL; +static const char *opt_device_size_str = NULL; + +static uint64_t opt_reduce_size = 0; +static uint64_t opt_device_size = 0; + static long opt_keyfile_size = 0; static long opt_keyfile_offset = 0; static int opt_iteration_time = 0; -static const char *opt_pbkdf = NULL; static long opt_pbkdf_memory = DEFAULT_LUKS2_MEMORY_KB; static long opt_pbkdf_parallel = DEFAULT_LUKS2_PARALLEL_THREADS; static long opt_pbkdf_iterations = 0; @@ -54,13 +63,6 @@ static int opt_key_size = 0; static int opt_new = 0; static int opt_keep_key = 0; static int opt_decrypt = 0; -static const char *opt_header_device = NULL; - -static const char *opt_reduce_size_str = NULL; -static uint64_t opt_reduce_size = 0; - -static const char *opt_device_size_str = NULL; -static uint64_t opt_device_size = 0; static const char **action_argv; diff --git a/src/integritysetup.c b/src/integritysetup.c index b3235690..c7b1d3f7 100644 --- a/src/integritysetup.c +++ b/src/integritysetup.c @@ -27,8 +27,19 @@ #define DEFAULT_ALG_NAME "crc32c" #define MAX_KEY_SIZE 4096 +static const char *opt_data_device = NULL; +static const char *opt_integrity = DEFAULT_ALG_NAME; +static const char *opt_integrity_key_file = NULL; +static const char *opt_journal_integrity = NULL; /* none */ +static const char *opt_journal_integrity_key_file = NULL; +static const char *opt_journal_crypt = NULL; /* none */ +static const char *opt_journal_crypt_key_file = NULL; + +/* helper strings converted to uint64_t later */ static const char *opt_journal_size_str = NULL; + static uint64_t opt_journal_size = 0; + static int opt_interleave_sectors = 0; static int opt_journal_watermark = 0; static int opt_bitmap_sectors_per_bit = 0; @@ -37,28 +48,14 @@ static int opt_bitmap_flush_time = 0; static int opt_tag_size = 0; static int opt_sector_size = 0; static int opt_buffer_sectors = 0; - static int opt_no_wipe = 0; - -static const char *opt_data_device = NULL; - -static const char *opt_integrity = DEFAULT_ALG_NAME; -static const char *opt_integrity_key_file = NULL; static int opt_integrity_key_size = 0; - -static const char *opt_journal_integrity = NULL; /* none */ -static const char *opt_journal_integrity_key_file = NULL; static int opt_journal_integrity_key_size = 0; - -static const char *opt_journal_crypt = NULL; /* none */ -static const char *opt_journal_crypt_key_file = NULL; static int opt_journal_crypt_key_size = 0; - static int opt_integrity_nojournal = 0; static int opt_integrity_recovery = 0; static int opt_integrity_bitmap = 0; static int opt_integrity_legacy_padding = 0; - static int opt_integrity_recalculate = 0; static int opt_allow_discards = 0; diff --git a/src/veritysetup.c b/src/veritysetup.c index 8bed35b7..344c7e44 100644 --- a/src/veritysetup.c +++ b/src/veritysetup.c @@ -23,25 +23,25 @@ #define PACKAGE_VERITY "veritysetup" -static int opt_use_superblock = 1; - static const char *opt_fec_device = NULL; -static int opt_fec_roots = DEFAULT_VERITY_FEC_ROOTS; static const char *opt_hash_algorithm = NULL; +static const char *opt_salt = NULL; +static const char *opt_uuid = NULL; +static const char *opt_root_hash_signature = NULL; + +static int opt_use_superblock = 1; +static int opt_fec_roots = DEFAULT_VERITY_FEC_ROOTS; static int opt_hash_type = 1; static int opt_data_block_size = DEFAULT_VERITY_DATA_BLOCK; static int opt_hash_block_size = DEFAULT_VERITY_HASH_BLOCK; static uint64_t data_blocks = 0; -static const char *opt_salt = NULL; static uint64_t hash_offset = 0; static uint64_t fec_offset = 0; -static const char *opt_uuid = NULL; static int opt_restart_on_corruption = 0; static int opt_panic_on_corruption = 0; static int opt_ignore_corruption = 0; static int opt_ignore_zero_blocks = 0; static int opt_check_at_most_once = 0; -static const char *opt_root_hash_signature = NULL; static const char **action_argv; static int action_argc;