X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tfcrypt.c;h=c8664cca99aad14cbc4cb9e84c4bb964483f5b4a;hb=347d23692d3a723b69b022d0e2f6cd9ecb388d1c;hp=df62420769d0b07b0db2a72a424cb72f6885d081;hpb=a7a8ae5408eed270854e69adf40ccaf3a401f830;p=tfcrypt.git diff --git a/tfcrypt.c b/tfcrypt.c index df62420..c8664cc 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -62,9 +62,22 @@ int main(int argc, char **argv) if (!isatty(2)) do_statline_dynamic = NO; + s = (char *)srcblk; + d = getenv("HOME"); + if (!d) d = ""; + n = PATH_MAX > sizeof(srcblk) ? sizeof(srcblk) : PATH_MAX; + if (xstrlcpy(s, d, n) >= n) goto _baddfname; + if (xstrlcat(s, "/.tfcrypt.defs", n) >= n) goto _baddfname; + read_defaults(s, YES); +_baddfname: + memset(s, 0, n); + opterr = 0; - while ((c = getopt(argc, argv, "s:aU:C:r:K:t:TPkzxc:l:qedn:vV:pwE:O:S:AmM:R:Z:WHD:")) != -1) { + while ((c = getopt(argc, argv, "L:s:aU:C:r:K:t:TPkzxc:l:qedn:vV:pwE:O:S:AmM:R:Z:WHD:")) != -1) { switch (c) { + case 'L': + read_defaults(optarg, NO); + break; case 's': saltf = optarg; break; @@ -171,6 +184,10 @@ int main(int argc, char **argv) catch_all_errors = YES; break; } + if (!strcmp(optarg, "xseek")) { + ignore_seek_errors = YES; + break; + } if (!strcmp(optarg, "exit")) error_action = TFC_ERRACT_EXIT; else if (!strncmp(optarg, "cont", 4)) @@ -695,7 +712,7 @@ _ctrskip1: if (counter_opt == TFC_CTR_HEAD && ctr_mode != TFC_MODE_ECB) iseek += ctrsz; if (lseek(sfd, iseek, SEEK_SET) == -1) - xerror(YES, NO, NO, "%s: seek failed", srcfname); + xerror(ignore_seek_errors, NO, NO, "%s: seek failed", srcfname); } if (ctr_mode == TFC_MODE_PLAIN) goto _plain; @@ -899,11 +916,12 @@ _xts2genkey: if (xwrite(krfd, pblk, TF_FROM_BITS(TFC_KEY_BITS)) == NOSIZE) xerro if (!tweakf) skein(key+TF_FROM_BITS(TF_MAX_BITS)+TF_SIZE_UNIT, 2*TF_UNIT_BITS, NULL, key, TF_FROM_BITS(TFC_KEY_BITS)); tf_key_tweak_compat(key); } - if (ctr_mode == TFC_MODE_STREAM) tfe_init_iv(&tfe, key, ctr); if (ctr_mode == TFC_MODE_ECB) goto _ctrskip2; tfc_data_to_words64(&iseek_blocks, sizeof(iseek_blocks)); tf_ctr_set(ctr, &iseek_blocks, sizeof(iseek_blocks)); + if (ctr_mode == TFC_MODE_STREAM) tfe_init_iv(&tfe, key, ctr); + switch (counter_opt) { case TFC_CTR_SHOW: switch (do_outfmt) { @@ -938,7 +956,7 @@ _plain: if (oseek) { if (lseek(dfd, oseek, SEEK_SET) == -1) - xerror(YES, NO, NO, "%s: seek failed", dstfname); + xerror(ignore_seek_errors, NO, NO, "%s: seek failed", dstfname); } for (x = 1; x < NSIG; x++) signal(x, SIG_IGN);