diff --git a/src/cryptsetup.c b/src/cryptsetup.c index ea8f09ee..4ab57ddd 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -129,7 +129,7 @@ static int _verify_passphrase(int def) /* Non-tty input doesn't allow verify */ if (def && !isatty(STDIN_FILENO)) { if (opt_verify_passphrase) - log_err(_("Can't do passphrase verification on non-tty inputs.\n")); + log_err(_("Can't do passphrase verification on non-tty inputs.")); def = 0; } @@ -182,7 +182,7 @@ static int action_open_plain(void) r = crypt_parse_name_and_mode(opt_cipher ?: DEFAULT_CIPHER(PLAIN), cipher, NULL, cipher_mode); if (r < 0) { - log_err(_("No known cipher specification pattern detected.\n")); + log_err(_("No known cipher specification pattern detected.")); goto out; } @@ -260,7 +260,7 @@ static int action_open_loopaes(void) int r; if (!opt_key_file) { - log_err(_("Option --key-file is required.\n")); + log_err(_("Option --key-file is required.")); return -EINVAL; } @@ -314,13 +314,13 @@ static int tcrypt_load(struct crypt_device *cd, struct crypt_params_tcrypt *para tmp_pim_ull = strtoull(tmp_pim_nptr, &tmp_pim_end, 10); if (*tmp_pim_nptr == '\0' || !tmp_pim_end || *tmp_pim_end != '\0') { - log_err(_("Invalid PIM value: parse error\n")); + log_err(_("Invalid PIM value: parse error.")); r = -EINVAL; } else if (tmp_pim_ull == 0) { - log_err(_("Invalid PIM value: 0\n")); + log_err(_("Invalid PIM value: 0.")); r = -EINVAL; } else if (tmp_pim_ull > UINT32_MAX) { - log_err(_("Invalid PIM value: outside of range\n")); + log_err(_("Invalid PIM value: outside of range.")); r = -ERANGE; } crypt_safe_free(CONST_CAST(char*)tmp_pim_nptr); @@ -343,7 +343,7 @@ static int tcrypt_load(struct crypt_device *cd, struct crypt_params_tcrypt *para r = crypt_load(cd, CRYPT_TCRYPT, params); if (r == -EPERM) { - log_err(_("No device header detected with this passphrase.\n")); + log_err(_("No device header detected with this passphrase.")); eperm = 1; } @@ -513,7 +513,7 @@ static int action_resize(void) if (opt_disable_keyring) { r = -EINVAL; log_err(_("Resize of active device requires volume key " - "in keyring but --disable-keyring option is set.\n")); + "in keyring but --disable-keyring option is set.")); goto out; } @@ -635,7 +635,7 @@ static int benchmark_callback(uint32_t time_ms, void *usrptr) check_signal(&r); if (r) - log_err(_("Benchmark interrupted.\n")); + log_err(_("Benchmark interrupted.")); else log_dbg("PBKDF benchmark: memory cost = %u, iterations = %u, " "threads = %u (took %u ms)", pbkdf->max_memory_kb, @@ -698,7 +698,7 @@ static int benchmark_cipher_loop(const char *cipher, const char *cipher_mode, if (buffer_size < 1024 * 1024 * 65) buffer_size *= 2; else { - log_err(_("Result of benchmark is not reliable.\n")); + log_err(_("Result of benchmark is not reliable.")); r = -ENOENT; } } @@ -757,7 +757,7 @@ static int action_benchmark(void) } else if (opt_cipher) { r = crypt_parse_name_and_mode(opt_cipher, cipher, NULL, cipher_mode); if (r < 0) { - log_err(_("No known cipher specification pattern detected.\n")); + log_err(_("No known cipher specification pattern detected.")); return r; } if ((c = strchr(cipher_mode, '-'))) @@ -781,7 +781,7 @@ static int action_benchmark(void) log_std("%11s-%s %9db %10.1f MiB/s %10.1f MiB/s\n", cipher, cipher_mode, key_size*8, enc_mbr, dec_mbr); } else if (r == -ENOENT) - log_err(_("Cipher %s is not available.\n"), opt_cipher); + log_err(_("Cipher %s is not available."), opt_cipher); } else { for (i = 0; bkdfs[i].type; i++) { r = action_benchmark_kdf(bkdfs[i].type, bkdfs[i].hash, key_size); @@ -817,9 +817,9 @@ static int action_benchmark(void) } if (r == -ENOTSUP) { - log_err(_("Required kernel crypto interface not available.\n")); + log_err(_("Required kernel crypto interface not available.")); #ifdef ENABLE_AF_ALG - log_err( _("Ensure you have algif_skcipher kernel module loaded.\n")); + log_err( _("Ensure you have algif_skcipher kernel module loaded.")); #endif } return r; @@ -866,7 +866,7 @@ static int action_luksRepair(void) r = crypt_load(cd, luksType(opt_type), NULL); crypt_set_log_callback(cd, tool_log, NULL); if (r == 0) { - log_verbose(_("No known problems detected for LUKS header.\n")); + log_verbose(_("No known problems detected for LUKS header.")); goto out; } @@ -908,7 +908,7 @@ static int _wipe_data_device(struct crypt_device *cd) r = crypt_wipe(cd, tmp_path, CRYPT_WIPE_ZERO, 0, 0, DEFAULT_WIPE_BLOCK, 0, &tools_wipe_progress, NULL); if (crypt_deactivate(cd, tmp_name)) - log_err(_("Cannot deactivate temporary device %s.\n"), tmp_path); + log_err(_("Cannot deactivate temporary device %s."), tmp_path); set_int_block(0); return r; @@ -944,7 +944,7 @@ static int action_luksFormat(void) luks_version = 1; if (opt_sector_size > SECTOR_SIZE && luks_version == 1) { - log_err(_("Unsupported encryption sector size.\n")); + log_err(_("Unsupported encryption sector size.")); return -EINVAL; } @@ -958,7 +958,7 @@ static int action_luksFormat(void) log_dbg("Creating header file."); fd = open(opt_header_device, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR|S_IWUSR); if (fd == -1 || posix_fallocate(fd, 0, 4096)) - log_err(_("Cannot create header file %s.\n"), opt_header_device); + log_err(_("Cannot create header file %s."), opt_header_device); else r = 0; if (fd != -1) @@ -982,19 +982,19 @@ static int action_luksFormat(void) r = crypt_parse_name_and_mode(opt_cipher ?: DEFAULT_CIPHER(LUKS1), cipher, NULL, cipher_mode); if (r < 0) { - log_err(_("No known cipher specification pattern detected.\n")); + log_err(_("No known cipher specification pattern detected.")); goto out; } if (luks_version != 2 && opt_integrity) { - log_err(_("Integrity option can be used only for LUKS2 format.\n")); + log_err(_("Integrity option can be used only for LUKS2 format.")); goto out; } if (opt_integrity) { r = crypt_parse_integrity_mode(opt_integrity, integrity, &integrity_keysize); if (r < 0) { - log_err(_("No known integrity specification pattern detected.\n")); + log_err(_("No known integrity specification pattern detected.")); goto out; } params2.integrity = integrity; @@ -1007,7 +1007,7 @@ static int action_luksFormat(void) if ((r = crypt_init(&cd, header_device))) { if (opt_header_device) - log_err(_("Cannot use %s as on-disk header.\n"), header_device); + log_err(_("Cannot use %s as on-disk header."), header_device); goto out; } @@ -1035,7 +1035,7 @@ static int action_luksFormat(void) else r = set_pbkdf_params(cd, CRYPT_LUKS2); if (r) { - log_err(_("Failed to set pbkdf parameters.\n")); + log_err(_("Failed to set pbkdf parameters.")); goto out; } @@ -1091,7 +1091,7 @@ static int action_open_luks(void) goto out; if (!data_device && (crypt_get_data_offset(cd) < 8)) { - log_err(_("Reduced data offset is allowed only for detached LUKS header.\n")); + log_err(_("Reduced data offset is allowed only for detached LUKS header.")); r = -EINVAL; goto out; } @@ -1130,7 +1130,7 @@ out: if (r >= 0 && opt_persistent && (crypt_get_active_device(cd, activated_name, &cad) || crypt_persistent_flags_set(cd, CRYPT_FLAGS_ACTIVATION, cad.flags & activate_flags))) - log_err(_("Device activated but cannot make flags persistent.\n")); + log_err(_("Device activated but cannot make flags persistent.")); crypt_safe_free(key); crypt_safe_free(password); @@ -1208,10 +1208,10 @@ static int action_luksKillSlot(void) case CRYPT_SLOT_ACTIVE_LAST: case CRYPT_SLOT_ACTIVE: case CRYPT_SLOT_UNBOUND: - log_verbose(_("Keyslot %d is selected for deletion.\n"), opt_key_slot); + log_verbose(_("Keyslot %d is selected for deletion."), opt_key_slot); break; case CRYPT_SLOT_INACTIVE: - log_err(_("Keyslot %d is not active.\n"), opt_key_slot); + log_err(_("Keyslot %d is not active."), opt_key_slot); /* pass through */ case CRYPT_SLOT_INVALID: return -EINVAL; @@ -1271,7 +1271,7 @@ static int action_luksRemoveKey(void) goto out; opt_key_slot = r; - log_verbose(_("Key slot %d selected for deletion.\n"), opt_key_slot); + log_verbose(_("Key slot %d selected for deletion."), opt_key_slot); if (crypt_keyslot_status(cd, opt_key_slot) == CRYPT_SLOT_ACTIVE_LAST && !yesDialog(_("This is the last keyslot. " @@ -1312,7 +1312,7 @@ static int luksAddUnboundKey(void) keysize = opt_key_size / 8; r = set_pbkdf_params(cd, crypt_get_type(cd)); if (r) { - log_err(_("Failed to set pbkdf parameters.\n")); + log_err(_("Failed to set pbkdf parameters.")); goto out; } @@ -1371,7 +1371,7 @@ static int action_luksAddKey(void) keysize = crypt_get_volume_key_size(cd); r = set_pbkdf_params(cd, crypt_get_type(cd)); if (r) { - log_err(_("Failed to set pbkdf parameters.\n")); + log_err(_("Failed to set pbkdf parameters.")); goto out; } @@ -1457,7 +1457,7 @@ static int action_luksChangeKey(void) r = set_pbkdf_params(cd, crypt_get_type(cd)); if (r) { - log_err(_("Failed to set pbkdf parameters.\n")); + log_err(_("Failed to set pbkdf parameters.")); goto out; } @@ -1508,7 +1508,7 @@ static int action_luksConvertKey(void) r = set_pbkdf_params(cd, crypt_get_type(cd)); if (r) { - log_err(_("Failed to set pbkdf parameters.\n")); + log_err(_("Failed to set pbkdf parameters.")); goto out; } @@ -1535,7 +1535,7 @@ static int action_isLuks(void) /* FIXME: argc > max should be checked for other operations as well */ if (action_argc > 1) { - log_err(_("Only one device argument for isLuks operation is supported.\n")); + log_err(_("Only one device argument for isLuks operation is supported.")); return -ENODEV; } @@ -1714,7 +1714,7 @@ static int action_luksBackup(void) int r; if (!opt_header_backup_file) { - log_err(_("Option --header-backup-file is required.\n")); + log_err(_("Option --header-backup-file is required.")); return -EINVAL; } @@ -1735,7 +1735,7 @@ static int action_luksRestore(void) int r = 0; if (!opt_header_backup_file) { - log_err(_("Option --header-backup-file is required.\n")); + log_err(_("Option --header-backup-file is required.")); return -EINVAL; } @@ -1774,10 +1774,10 @@ static int action_open(void) return action_open_tcrypt(); } - log_err(_("Unrecognized metadata device type %s.\n"), opt_type); + log_err(_("Unrecognized metadata device type %s."), opt_type); return -EINVAL; args: - log_err(_("Command requires device and mapped name as arguments.\n")); + log_err(_("Command requires device and mapped name as arguments.")); return -EINVAL; } @@ -1839,7 +1839,7 @@ static int action_luksConvert(void) } else if (!strcmp(opt_type, "luks1")) { to_type = CRYPT_LUKS1; } else { - log_err(_("Missing LUKS target type, option --type is required.\n")); + log_err(_("Missing LUKS target type, option --type is required.")); return -EINVAL; } @@ -1855,7 +1855,7 @@ static int action_luksConvert(void) } if (!strcmp(from_type, to_type)) { - log_err(_("Device is already %s type.\n"), to_type); + log_err(_("Device is already %s type."), to_type); crypt_free(cd); return -EINVAL; } @@ -1906,7 +1906,7 @@ static int action_luksConfig(void) int r; if (!opt_priority && !opt_label && !opt_subsystem) { - log_err(_("Option --priority, --label or --subsystem is missing.\n")); + log_err(_("Option --priority, --label or --subsystem is missing.")); return -EINVAL; } @@ -1937,10 +1937,10 @@ static int _token_add(struct crypt_device *cd) if (opt_token != CRYPT_ANY_TOKEN) { token_info = crypt_token_status(cd, opt_token, NULL); if (token_info < CRYPT_TOKEN_INACTIVE) { - log_err(_("Token %d is invalid.\n"), opt_token); + log_err(_("Token %d is invalid."), opt_token); return -EINVAL; } else if (token_info > CRYPT_TOKEN_INACTIVE) { - log_err(_("Token %d in use.\n"), opt_token); + log_err(_("Token %d in use."), opt_token); return -EINVAL; } } @@ -1953,7 +1953,7 @@ static int _token_add(struct crypt_device *cd) r = crypt_token_assign_keyslot(cd, token, opt_key_slot); if (r < 0) { - log_err(_("Failed to assign token %d to keyslot %d.\n"), token, opt_key_slot); + log_err(_("Failed to assign token %d to keyslot %d."), token, opt_key_slot); (void) crypt_token_json_set(cd, token, NULL); } @@ -1967,18 +1967,18 @@ static int action_token(void) if (!strcmp(action_argv[0], "add")) { if (!opt_key_description) { - log_err(_("--key-description parameter is mandatory for token add action.\n")); + log_err(_("--key-description parameter is mandatory for token add action.")); return -EINVAL; } add = 1; } else if (!strcmp(action_argv[0], "remove")) { if (opt_token == CRYPT_ANY_TOKEN) { - log_err(_("Missing --token option specifying token for removal.\n")); + log_err(_("Missing --token option specifying token for removal.")); return -EINVAL; } add = 0; } else { - log_err(_("Invalid token operation %s.\n"), action_argv[0]); + log_err(_("Invalid token operation %s."), action_argv[0]); return -EINVAL; } @@ -1993,9 +1993,9 @@ static int action_token(void) r = add ? _token_add(cd) : crypt_token_json_set(cd, opt_token, NULL); if (r < 0) { if (add) - log_err(_("Failed to add keyring token %d.\n"), opt_token); + log_err(_("Failed to add keyring token %d."), opt_token); else - log_err(_("Failed to remove token %d.\n"), opt_token); + log_err(_("Failed to remove token %d."), opt_token); } crypt_free(cd); @@ -2408,7 +2408,7 @@ int main(int argc, const char **argv) !strcmp(aname, "luksFormat")) && action_argc > 1) { if (opt_key_file) - log_err(_("Option --key-file takes precedence over specified key file argument.\n")); + log_err(_("Option --key-file takes precedence over specified key file argument.")); else opt_key_file = action_argv[1]; } diff --git a/src/cryptsetup_reencrypt.c b/src/cryptsetup_reencrypt.c index beb1750a..7fb6f8c2 100644 --- a/src/cryptsetup_reencrypt.c +++ b/src/cryptsetup_reencrypt.c @@ -169,13 +169,13 @@ static int set_reencrypt_requirement(const struct reenc_ctx *rc) /* reencrypt already in-progress */ if (reqs & CRYPT_REQUIREMENT_OFFLINE_REENCRYPT) { - log_err(_("Reencryption already in-progress.\n")); + log_err(_("Reencryption already in-progress.")); goto out; } /* raw integrity info is available since 2.0 */ if (crypt_get_integrity_info(cd, &ip) || ip.tag_size) { - log_err(_("Reencryption of device with integrity profile is not supported.\n")); + log_err(_("Reencryption of device with integrity profile is not supported.")); r = -ENOTSUP; goto out; } @@ -198,11 +198,11 @@ static int device_check(struct reenc_ctx *rc, const char *device, header_magic s devfd = open(device, O_RDWR | O_EXCL | O_DIRECT); if (devfd == -1) { if (errno == EBUSY) { - log_err(_("Cannot exclusively open %s, device in use.\n"), + log_err(_("Cannot exclusively open %s, device in use."), device); return -EBUSY; } - log_err(_("Cannot open device %s.\n"), device); + log_err(_("Cannot open device %s."), device); return -EINVAL; } @@ -212,14 +212,14 @@ static int device_check(struct reenc_ctx *rc, const char *device, header_magic s } if (posix_memalign((void *)&buf, alignment(devfd), buf_size)) { - log_err(_("Allocation of aligned memory failed.\n")); + log_err(_("Allocation of aligned memory failed.")); r = -ENOMEM; goto out; } s = read(devfd, buf, buf_size); if (s < 0 || s != (ssize_t)buf_size) { - log_err(_("Cannot read device %s.\n"), device); + log_err(_("Cannot read device %s."), device); r = -EIO; goto out; } @@ -230,11 +230,11 @@ static int device_check(struct reenc_ctx *rc, const char *device, header_magic s if (set_magic == MAKE_UNUSABLE && !memcmp(buf, MAGIC, MAGIC_L) && version == 1) { - log_verbose(_("Marking LUKS1 device %s unusable.\n"), device); + log_verbose(_("Marking LUKS1 device %s unusable."), device); memcpy(buf, NOMAGIC, MAGIC_L); r = 0; } else if (set_magic == MAKE_UNUSABLE && version == 2) { - log_verbose(_("Setting LUKS2 offline reencrypt flag on device %s.\n"), device); + log_verbose(_("Setting LUKS2 offline reencrypt flag on device %s."), device); r = set_reencrypt_requirement(rc); if (!r) rc->stained = 1; @@ -251,7 +251,7 @@ static int device_check(struct reenc_ctx *rc, const char *device, header_magic s goto out; s = write(devfd, buf, buf_size); if (s < 0 || s != (ssize_t)buf_size) { - log_err(_("Cannot write device %s.\n"), device); + log_err(_("Cannot write device %s."), device); r = -EIO; } if (s > 0 && set_magic == MAKE_UNUSABLE) @@ -335,7 +335,7 @@ static int write_log(struct reenc_ctx *rc) r = write(rc->log_fd, rc->log_buf, SECTOR_SIZE); if (r < 0 || r != SECTOR_SIZE) { - log_err(_("Cannot write reencryption log file.\n")); + log_err(_("Cannot write reencryption log file.")); return -EIO; } @@ -391,7 +391,7 @@ static int parse_log(struct reenc_ctx *rc) s = read(rc->log_fd, rc->log_buf, SECTOR_SIZE); if (s == -1) { - log_err(_("Cannot read reencryption log file.\n")); + log_err(_("Cannot read reencryption log file.")); return -EIO; } @@ -402,7 +402,7 @@ static int parse_log(struct reenc_ctx *rc) if (end) { *end++ = '\0'; if (parse_line_log(rc, start)) { - log_err("Wrong log format.\n"); + log_err("Wrong log format."); return -EINVAL; } } @@ -479,7 +479,7 @@ static int activate_luks_headers(struct reenc_ctx *rc) (r = crypt_set_data_device(cd, rc->device))) goto out; - log_verbose(_("Activating temporary device using old LUKS header.\n")); + log_verbose(_("Activating temporary device using old LUKS header.")); if ((r = crypt_activate_by_passphrase(cd, rc->header_file_org, opt_key_slot, pwd_old, pwd_old_len, CRYPT_ACTIVATE_READONLY|CRYPT_ACTIVATE_PRIVATE)) < 0) @@ -490,7 +490,7 @@ static int activate_luks_headers(struct reenc_ctx *rc) (r = crypt_set_data_device(cd_new, rc->device))) goto out; - log_verbose(_("Activating temporary device using new LUKS header.\n")); + log_verbose(_("Activating temporary device using new LUKS header.")); if ((r = crypt_activate_by_passphrase(cd_new, rc->header_file_new, opt_key_slot, pwd_new, pwd_new_len, CRYPT_ACTIVATE_SHARED|CRYPT_ACTIVATE_PRIVATE)) < 0) @@ -500,7 +500,7 @@ out: crypt_free(cd); crypt_free(cd_new); if (r < 0) - log_err(_("Activation of temporary devices failed.\n")); + log_err(_("Activation of temporary devices failed.")); return r; } @@ -582,14 +582,14 @@ static int create_new_header(struct reenc_ctx *rc, struct crypt_device *cd_old, r = set_pbkdf_params(cd_new, type); if (r) { - log_err(_("Failed to set PBKDF parameters.\n")); + log_err(_("Failed to set PBKDF parameters.")); goto out; } if ((r = crypt_format(cd_new, type, cipher, cipher_mode, uuid, key, key_size, params))) goto out; - log_verbose(_("New LUKS header for device %s created.\n"), rc->device); + log_verbose(_("New LUKS header for device %s created."), rc->device); for (i = 0; i < crypt_keyslot_max(type); i++) { if (!rc->p[i].password) @@ -598,7 +598,7 @@ static int create_new_header(struct reenc_ctx *rc, struct crypt_device *cd_old, r = create_new_keyslot(rc, i, cd_old, cd_new); if (r < 0) goto out; - log_verbose(_("Activated keyslot %i.\n"), r); + log_verbose(_("Activated keyslot %i."), r); r = 0; } out: @@ -648,7 +648,7 @@ static int luks2_metadata_copy(struct reenc_ctx *rc) case CRYPT_TOKEN_INACTIVE: break; case CRYPT_TOKEN_INTERNAL_UNKNOWN: - log_err(_("This version of cryptsetup-reencrypt can't handle new internal token type %s.\n"), type); + log_err(_("This version of cryptsetup-reencrypt can't handle new internal token type %s."), type); r = -EINVAL; goto out; case CRYPT_TOKEN_INTERNAL: @@ -670,19 +670,19 @@ static int luks2_metadata_copy(struct reenc_ctx *rc) } if ((r = crypt_persistent_flags_get(cd_old, CRYPT_FLAGS_ACTIVATION, &flags))) { - log_err(_("Failed to read activation flags from backup header.\n")); + log_err(_("Failed to read activation flags from backup header.")); goto out; } if ((r = crypt_persistent_flags_set(cd_new, CRYPT_FLAGS_ACTIVATION, flags))) { - log_err(_("Failed to write activation flags to new header.\n")); + log_err(_("Failed to write activation flags to new header.")); goto out; } if ((r = crypt_persistent_flags_get(cd_old, CRYPT_FLAGS_REQUIREMENTS, &flags))) { - log_err(_("Failed to read requirements from backup header.\n")); + log_err(_("Failed to read requirements from backup header.")); goto out; } if ((r = crypt_persistent_flags_set(cd_new, CRYPT_FLAGS_REQUIREMENTS, flags))) - log_err(_("Failed to read requirements from backup header.\n")); + log_err(_("Failed to read requirements from backup header.")); out: crypt_free(cd_old); crypt_free(cd_new); @@ -718,7 +718,7 @@ static int backup_luks_headers(struct reenc_ctx *rc) if ((r = chmod(rc->header_file_tmp, st.st_mode | S_IWUSR))) goto out; } - log_verbose(_("%s header backup of device %s created.\n"), rc->device, isLUKS2(rc->type) ? "LUKS2" : "LUKS1"); + log_verbose(_("%s header backup of device %s created."), rc->device, isLUKS2(rc->type) ? "LUKS2" : "LUKS1"); /* For decrypt, new header will be fake one, so we are done here. */ if (rc->reencrypt_mode == DECRYPT) @@ -738,7 +738,7 @@ static int backup_luks_headers(struct reenc_ctx *rc) if (opt_cipher) { r = crypt_parse_name_and_mode(opt_cipher, cipher, NULL, cipher_mode); if (r < 0) { - log_err(_("No known cipher specification pattern detected.\n")); + log_err(_("No known cipher specification pattern detected.")); goto out; } } @@ -778,7 +778,7 @@ out: crypt_free(cd); crypt_safe_free(key); if (r) - log_err(_("Creation of LUKS backup headers failed.\n")); + log_err(_("Creation of LUKS backup headers failed.")); return r; } @@ -812,7 +812,7 @@ static int backup_fake_header(struct reenc_ctx *rc) if (opt_cipher) { r = crypt_parse_name_and_mode(opt_cipher, cipher, NULL, cipher_mode); if (r < 0) { - log_err(_("No known cipher specification pattern detected.\n")); + log_err(_("No known cipher specification pattern detected.")); goto out; } } @@ -912,9 +912,9 @@ static int restore_luks_header(struct reenc_ctx *rc) crypt_free(cd); out: if (r) - log_err(_("Cannot restore %s header on device %s.\n"), hdr_device(rc), isLUKS2(rc->type) ? "LUKS2" : "LUKS1"); + log_err(_("Cannot restore %s header on device %s."), hdr_device(rc), isLUKS2(rc->type) ? "LUKS2" : "LUKS1"); else { - log_verbose(_("%s header on device %s restored.\n"), hdr_device(rc), isLUKS2(rc->type) ? "LUKS2" : "LUKS1"); + log_verbose(_("%s header on device %s restored."), hdr_device(rc), isLUKS2(rc->type) ? "LUKS2" : "LUKS1"); rc->stained = 0; } return r; @@ -952,7 +952,7 @@ static int copy_data_forward(struct reenc_ctx *rc, int fd_old, int fd_new, if (lseek64(fd_old, rc->device_offset, SEEK_SET) < 0 || lseek64(fd_new, rc->device_offset, SEEK_SET) < 0) { - log_err(_("Cannot seek to device offset.\n")); + log_err(_("Cannot seek to device offset.")); return -EIO; } @@ -1032,7 +1032,7 @@ static int copy_data_backward(struct reenc_ctx *rc, int fd_old, int fd_new, if (lseek64(fd_old, working_offset, SEEK_SET) < 0 || lseek64(fd_new, working_offset, SEEK_SET) < 0) { - log_err(_("Cannot seek to device offset.\n")); + log_err(_("Cannot seek to device offset.")); return -EIO; } @@ -1114,23 +1114,23 @@ static int copy_data(struct reenc_ctx *rc) fd_old = open(rc->crypt_path_org, O_RDONLY | (opt_directio ? O_DIRECT : 0)); if (fd_old == -1) { - log_err(_("Cannot open temporary LUKS device.\n")); + log_err(_("Cannot open temporary LUKS device.")); goto out; } fd_new = open(rc->crypt_path_new, O_WRONLY | (opt_directio ? O_DIRECT : 0)); if (fd_new == -1) { - log_err(_("Cannot open temporary LUKS device.\n")); + log_err(_("Cannot open temporary LUKS device.")); goto out; } if (ioctl(fd_old, BLKGETSIZE64, &rc->device_size_org_real) < 0) { - log_err(_("Cannot get device size.\n")); + log_err(_("Cannot get device size.")); goto out; } if (ioctl(fd_new, BLKGETSIZE64, &rc->device_size_new_real) < 0) { - log_err(_("Cannot get device size.\n")); + log_err(_("Cannot get device size.")); goto out; } @@ -1142,7 +1142,7 @@ static int copy_data(struct reenc_ctx *rc) rc->device_size = rc->device_size_new_real; if (posix_memalign((void *)&buf, alignment(fd_new), block_size)) { - log_err(_("Allocation of aligned memory failed.\n")); + log_err(_("Allocation of aligned memory failed.")); r = -ENOMEM; goto out; } @@ -1167,9 +1167,9 @@ static int copy_data(struct reenc_ctx *rc) set_int_block(1); if (r == -EAGAIN) - log_err(_("Interrupted by a signal.\n")); + log_err(_("Interrupted by a signal.")); else if (r < 0) - log_err(_("IO error during reencryption.\n")); + log_err(_("IO error during reencryption.")); (void)write_log(rc); out: @@ -1200,7 +1200,7 @@ static int initialize_uuid(struct reenc_ctx *rc) if (!r) rc->device_uuid = strdup(opt_uuid); else - log_err(_("Provided UUID is invalid.\n")); + log_err(_("Provided UUID is invalid.")); return r; } @@ -1303,7 +1303,7 @@ static int init_keyfile(struct reenc_ctx *rc, struct crypt_device *cd, int slot_ if (r >= 0 && opt_key_slot == CRYPT_ANY_SLOT && crypt_keyslot_status(cd, r) != CRYPT_SLOT_ACTIVE_LAST) { log_err(_("Key file can be used only with --key-slot or with " - "exactly one key slot active.\n")); + "exactly one key slot active.")); r = -EINVAL; } @@ -1391,13 +1391,13 @@ static int initialize_context(struct reenc_ctx *rc, const char *device) return -EINVAL; if (initialize_uuid(rc)) { - log_err(_("Device %s is not a valid LUKS device.\n"), device); + log_err(_("Device %s is not a valid LUKS device."), device); return -EINVAL; } if (opt_key_slot != CRYPT_ANY_SLOT && opt_key_slot >= crypt_keyslot_max(rc->type)) { - log_err(_("Key slot is invalid.\n")); + log_err(_("Key slot is invalid.")); return -EINVAL; } @@ -1426,14 +1426,14 @@ static int initialize_context(struct reenc_ctx *rc, const char *device) remove_headers(rc); if (open_log(rc) < 0) { - log_err(_("Cannot open reencryption log file.\n")); + log_err(_("Cannot open reencryption log file.")); return -EINVAL; } if (!rc->in_progress) { if (opt_uuid) { log_err(_("No decryption in progress, provided UUID can " - "be used only to resume suspended decryption process.\n")); + "be used only to resume suspended decryption process.")); return -EINVAL; } @@ -1507,7 +1507,7 @@ static int luks2_change_pbkdf_params(struct reenc_ctx *rc) rc->p[i].password, rc->p[i].passwordLen, rc->p[i].password, rc->p[i].passwordLen)) < 0) goto out; - log_verbose(_("Changed pbkdf parameters in keyslot %i.\n"), r); + log_verbose(_("Changed pbkdf parameters in keyslot %i."), r); r = 0; } @@ -1671,7 +1671,7 @@ int main(int argc, const char **argv) } if (!opt_batch_mode) - log_verbose(_("Reencryption will change: %s%s%s%s%s%s.\n"), + log_verbose(_("Reencryption will change: %s%s%s%s%s%s."), opt_keep_key ? "" : _("volume key"), (!opt_keep_key && opt_hash) ? ", " : "", opt_hash ? _("set hash to ") : "", opt_hash ?: "", diff --git a/src/integritysetup.c b/src/integritysetup.c index 9163887a..c271a25b 100644 --- a/src/integritysetup.c +++ b/src/integritysetup.c @@ -65,7 +65,7 @@ static int _read_mk(const char *file, char **key, int keysize) int fd; if (keysize <= 0 || keysize > MAX_KEY_SIZE) { - log_err(_("Invalid key size.\n")); + log_err(_("Invalid key size.")); return -EINVAL; } @@ -75,11 +75,11 @@ static int _read_mk(const char *file, char **key, int keysize) fd = open(file, O_RDONLY); if (fd == -1) { - log_err(_("Cannot read keyfile %s.\n"), file); + log_err(_("Cannot read keyfile %s."), file); goto fail; } if ((read(fd, *key, keysize) != keysize)) { - log_err(_("Cannot read %d bytes from keyfile %s.\n"), keysize, file); + log_err(_("Cannot read %d bytes from keyfile %s."), keysize, file); close(fd); goto fail; } @@ -159,7 +159,7 @@ static int _wipe_data_device(struct crypt_device *cd, const char *integrity_key) r = crypt_wipe(cd, tmp_path, CRYPT_WIPE_ZERO, 0, 0, DEFAULT_WIPE_BLOCK, 0, &tools_wipe_progress, NULL); if (crypt_deactivate(cd, tmp_name)) - log_err(_("Cannot deactivate temporary device %s.\n"), tmp_path); + log_err(_("Cannot deactivate temporary device %s."), tmp_path); set_int_block(0); return r; @@ -184,7 +184,7 @@ static int action_format(int arg) if (opt_integrity) { r = crypt_parse_hash_integrity_mode(opt_integrity, integrity); if (r < 0) { - log_err(_("No known integrity specification pattern detected.\n")); + log_err(_("No known integrity specification pattern detected.")); return r; } params.integrity = integrity; @@ -193,7 +193,7 @@ static int action_format(int arg) if (opt_journal_integrity) { r = crypt_parse_hash_integrity_mode(opt_journal_integrity, journal_integrity); if (r < 0) { - log_err(_("No known integrity specification pattern detected.\n")); + log_err(_("No known integrity specification pattern detected.")); return r; } params.journal_integrity = journal_integrity; @@ -202,7 +202,7 @@ static int action_format(int arg) if (opt_journal_crypt) { r = crypt_parse_hash_integrity_mode(opt_journal_crypt, journal_crypt); if (r < 0) { - log_err(_("No known integrity specification pattern detected.\n")); + log_err(_("No known integrity specification pattern detected.")); return r; } params.journal_crypt = journal_crypt; @@ -249,7 +249,7 @@ static int action_open(int arg) if (opt_integrity) { r = crypt_parse_hash_integrity_mode(opt_integrity, integrity); if (r < 0) { - log_err(_("No known integrity specification pattern detected.\n")); + log_err(_("No known integrity specification pattern detected.")); return r; } params.integrity = integrity; @@ -258,7 +258,7 @@ static int action_open(int arg) if (opt_journal_integrity) { r = crypt_parse_hash_integrity_mode(opt_journal_integrity, journal_integrity); if (r < 0) { - log_err(_("No known integrity specification pattern detected.\n")); + log_err(_("No known integrity specification pattern detected.")); return r; } @@ -268,7 +268,7 @@ static int action_open(int arg) if (opt_journal_crypt) { r = crypt_parse_hash_integrity_mode(opt_journal_crypt, journal_crypt); if (r < 0) { - log_err(_("No known integrity specification pattern detected.\n")); + log_err(_("No known integrity specification pattern detected.")); return r; } params.journal_crypt = journal_crypt; diff --git a/src/utils_password.c b/src/utils_password.c index 065849bd..4c336019 100644 --- a/src/utils_password.c +++ b/src/utils_password.c @@ -40,7 +40,7 @@ static int tools_check_pwquality(const char *password) r = pwquality_read_config(pwq, NULL, &auxerror); if (r) { - log_err(_("Cannot check password quality: %s\n"), + log_err(_("Cannot check password quality: %s"), pwquality_strerror(NULL, 0, r, auxerror)); pwquality_free_settings(pwq); return -EINVAL; @@ -48,7 +48,7 @@ static int tools_check_pwquality(const char *password) r = pwquality_check(pwq, password, NULL, NULL, &auxerror); if (r < 0) { - log_err(_("Password quality check failed:\n %s\n"), + log_err(_("Password quality check failed:\n %s"), pwquality_strerror(NULL, 0, r, auxerror)); r = -EPERM; } else { @@ -72,7 +72,7 @@ static int tools_check_pwquality(const char *password) passwdqc_params_reset(¶ms); if (*config && passwdqc_params_load(¶ms, &parse_reason, config)) { - log_err(_("Cannot check password quality: %s\n"), + log_err(_("Cannot check password quality: %s"), (parse_reason ? parse_reason : "Out of memory")); free(parse_reason); return -EINVAL; @@ -80,7 +80,7 @@ static int tools_check_pwquality(const char *password) check_reason = passwdqc_check(¶ms.qc, password, NULL, NULL); if (check_reason) { - log_err(_("Password quality check failed: Bad passphrase (%s)\n"), + log_err(_("Password quality check failed: Bad passphrase (%s)"), check_reason); return -EPERM; } @@ -204,12 +204,12 @@ static int crypt_get_key_tty(const char *prompt, pass = crypt_safe_alloc(key_size_max + 1); if (!pass) { - log_err( _("Out of memory while reading passphrase.\n")); + log_err( _("Out of memory while reading passphrase.")); return -ENOMEM; } if (interactive_pass(prompt, pass, key_size_max, timeout)) { - log_err(_("Error reading passphrase from terminal.\n")); + log_err(_("Error reading passphrase from terminal.")); goto out_err; } pass[key_size_max] = '\0'; @@ -217,19 +217,19 @@ static int crypt_get_key_tty(const char *prompt, if (verify) { pass_verify = crypt_safe_alloc(key_size_max); if (!pass_verify) { - log_err(_("Out of memory while reading passphrase.\n")); + log_err(_("Out of memory while reading passphrase.")); r = -ENOMEM; goto out_err; } if (interactive_pass(_("Verify passphrase: "), pass_verify, key_size_max, timeout)) { - log_err(_("Error reading passphrase from terminal.\n")); + log_err(_("Error reading passphrase from terminal.")); goto out_err; } if (strncmp(pass, pass_verify, key_size_max)) { - log_err(_("Passphrases do not match.\n")); + log_err(_("Passphrases do not match.")); r = -EPERM; goto out_err; } @@ -266,7 +266,7 @@ int tools_get_key(const char *prompt, if (tools_is_stdin(key_file)) { if (isatty(STDIN_FILENO)) { if (keyfile_offset) { - log_err(_("Cannot use offset with terminal input.\n")); + log_err(_("Cannot use offset with terminal input.")); } else { if (!prompt && !crypt_get_device_name(cd)) snprintf(tmp, sizeof(tmp), _("Enter passphrase: ")); @@ -301,7 +301,7 @@ int tools_get_key(const char *prompt, void tools_passphrase_msg(int r) { if (r == -EPERM) - log_err(_("No key available with this passphrase.\n")); + log_err(_("No key available with this passphrase.")); } int tools_read_mk(const char *file, char **key, int keysize) @@ -314,11 +314,11 @@ int tools_read_mk(const char *file, char **key, int keysize) fd = open(file, O_RDONLY); if (fd == -1) { - log_err(_("Cannot read keyfile %s.\n"), file); + log_err(_("Cannot read keyfile %s."), file); goto fail; } if ((read(fd, *key, keysize) != keysize)) { - log_err(_("Cannot read %d bytes from keyfile %s.\n"), keysize, file); + log_err(_("Cannot read %d bytes from keyfile %s."), keysize, file); close(fd); goto fail; } @@ -336,14 +336,14 @@ int tools_write_mk(const char *file, const char *key, int keysize) fd = open(file, O_WRONLY); if (fd < 0) { - log_err(_("Cannot open keyfile %s for write.\n"), file); + log_err(_("Cannot open keyfile %s for write."), file); return r; } if (write_buffer(fd, key, keysize) == keysize) r = 0; else - log_err(_("Cannot write to keyfile %s.\n"), file); + log_err(_("Cannot write to keyfile %s."), file); close(fd); return r; diff --git a/src/utils_tools.c b/src/utils_tools.c index eeeee0e3..e43ee935 100644 --- a/src/utils_tools.c +++ b/src/utils_tools.c @@ -99,6 +99,10 @@ void clogger(struct crypt_device *cd, int level, const char *file, int line, va_end(argp); free(target); + + /* All verbose and error messages in tools end with EOL. */ + if (level == CRYPT_LOG_VERBOSE || level == CRYPT_LOG_ERROR) + crypt_log(cd, level, "\n"); } void tool_log(int level, const char *msg, void *usrptr __attribute__((unused))) @@ -151,7 +155,7 @@ int yesDialog(const char *msg, void *usrptr) r = 0; /* Aborted by signal */ if (!quit) - log_err(_("Error reading response from terminal.\n")); + log_err(_("Error reading response from terminal.")); else log_dbg("Query interrupted on signal."); } else if (strcmp(answer, "YES\n")) { @@ -230,7 +234,7 @@ __attribute__ ((noreturn)) void usage(poptContext popt_context, { poptPrintUsage(popt_context, stderr, 0); if (error) - log_err("%s: %s\n", more, error); + log_err("%s: %s", more, error); poptFreeContext(popt_context); exit(exitcode); } @@ -419,7 +423,7 @@ int tools_wipe_progress(uint64_t size, uint64_t offset, void *usrptr) check_signal(&r); if (r) { tools_clear_line(); - log_err("\nWipe interrupted.\n"); + log_err("\nWipe interrupted."); } return r; diff --git a/src/veritysetup.c b/src/veritysetup.c index 880551c1..b4e49c5e 100644 --- a/src/veritysetup.c +++ b/src/veritysetup.c @@ -64,7 +64,7 @@ static int _prepare_format(struct crypt_params_verity *params, } else if (salt_string) { len = crypt_hex_to_bytes(salt_string, &salt, 0); if (len < 0) { - log_err(_("Invalid salt string specified.\n")); + log_err(_("Invalid salt string specified.")); return -EINVAL; } params->salt_size = len; @@ -95,7 +95,7 @@ static int action_format(int arg) /* Try to create hash image if doesn't exist */ r = open(action_argv[1], O_WRONLY | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR); if (r < 0 && errno != EEXIST) { - log_err(_("Cannot create hash image %s for writing.\n"), action_argv[1]); + log_err(_("Cannot create hash image %s for writing."), action_argv[1]); return -EINVAL; } else if (r >= 0) { log_dbg("Created hash image %s.", action_argv[1]); @@ -105,7 +105,7 @@ static int action_format(int arg) if (fec_device) { r = open(fec_device, O_WRONLY | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR); if (r < 0 && errno != EEXIST) { - log_err(_("Cannot create FEC image %s for writing.\n"), fec_device); + log_err(_("Cannot create FEC image %s for writing."), fec_device); return -EINVAL; } else if (r >= 0) { log_dbg("Created FEC image %s.", fec_device); @@ -178,7 +178,7 @@ static int _activate(const char *dm_device, hash_size = crypt_get_volume_key_size(cd); if (crypt_hex_to_bytes(root_hash, &root_hash_bytes, 0) != hash_size) { - log_err(_("Invalid root hash string specified.\n")); + log_err(_("Invalid root hash string specified.")); r = -EINVAL; goto out; }