Accepting request 597860 from home:garloff:branches:Base:System

- ddr_1998-alg-caseindep.diff:
  * Use case-independent matching for algorithm names (hash, crypt).
- ddr_1998-check-nofail-noxattr.diff:
  * Make testsuite succeed for builds w/o xattr support.

OBS-URL: https://build.opensuse.org/request/show/597860
OBS-URL: https://build.opensuse.org/package/show/Base:System/dd_rescue?expand=0&rev=41
This commit is contained in:
Kurt Garloff 2018-04-18 18:10:36 +00:00 committed by Git OBS Bridge
parent 82cd7ff52b
commit 71d6014956
4 changed files with 221 additions and 3 deletions

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Apr 17 15:46:16 CEST 2018 - kurt@garloff.de
- ddr_1998-alg-caseindep.diff:
* Use case-independent matching for algorithm names (hash, crypt).
- ddr_1998-check-nofail-noxattr.diff:
* Make testsuite succeed for builds w/o xattr support.
-------------------------------------------------------------------
Sun Dec 3 22:11:29 CET 2017 - kurt@garloff.de

View File

@ -1,7 +1,7 @@
#
# spec file for package dd_rescue
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -27,6 +27,8 @@ Source0: http://garloff.de/kurt/linux/ddrescue/%{name}-%{version}.tar.bz2
Source1: http://garloff.de/kurt/linux/ddrescue/%{name}-%{version}.tar.bz2.asc
Source2: %{name}.keyring
Source99: %{name}.changes
Patch1: ddr_1998-alg-caseindep.diff
Patch2: ddr_1998-check-nofail-noxattr.diff
BuildRequires: autoconf
BuildRequires: libattr-devel
%if 0%{?is_opensuse}
@ -48,7 +50,7 @@ Provides: ddrescue = %{version}
Obsoletes: ddrescue < %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
#BuildRequires: pkgconfig(libcrypto)
BuildRequires: libopenssl-devel
BuildRequires: libopenssl-devel
%description
dd_rescue helps when nothing else can: your disk has crashed and you
@ -113,7 +115,8 @@ data to the decompressor; the plugin is still young and might expose bugs.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
# Remove build time references so build-compare can do its work
FAKE_BUILDTIME=$(LC_ALL=C date -u -r %{SOURCE99} '+%%H:%%M')
FAKE_BUILDDATE=$(LC_ALL=C date -u -r %{SOURCE99} '+%%b %%e %%Y')

122
ddr_1998-alg-caseindep.diff Normal file
View File

@ -0,0 +1,122 @@
commit 604e57678ed50ee88ea20d82c98bf7ba53db76c1
Author: Kurt Garloff <kurt@garloff.de>
Date: Thu Feb 8 10:41:25 2018 +0100
Case insensitivity for crypt algos, help, debug.
This makes it a bit easier to specify things correctly.
diff --git a/aes.c b/aes.c
index 33906b0..2784006 100644
--- a/aes.c
+++ b/aes.c
@@ -449,7 +449,7 @@ ciph_desc_t *findalg(ciph_desc_t* list, const char* nm, const char probe)
{
ciph_desc_t* alg = list;
while (alg->name) {
- if (!strcmp(alg->name, nm)) {
+ if (!strcasecmp(alg->name, nm)) {
if (!probe || !alg->probe)
return alg;
return (alg->probe()? NULL: alg);
diff --git a/libddr_crypt.c b/libddr_crypt.c
index 0d2e77f..1d9d4a0 100644
--- a/libddr_crypt.c
+++ b/libddr_crypt.c
@@ -158,7 +158,7 @@ int set_alg(crypt_state* state, const char* algnm)
FPLOG(FATAL, "Don't understand option (alg?) %s\n", algnm);
return -1;
}
- if (!strcmp(algnm, "help")) {
+ if (!strcasecmp(algnm, "help")) {
FPLOG(INFO, "Crypto algorithms:", NULL);
ciph_desc_t *alg;
for (alg = state->engine; alg->name != NULL; ++alg)
@@ -218,28 +218,28 @@ int crypt_plug_init(void **stat, char* param, int seq, const opt_t *opt)
param = next;
continue;
}
- if (!strcmp(param, "help")) {
+ if (!strcasecmp(param, "help")) {
FPLOG(INFO, "%s", crypt_help);
return -1;
- } else if (!strcmp(param, "debug"))
+ } else if (!strcasecmp(param, "debug"))
state->debug = 1;
else if (!strcmp(param, "encrypt") || !strcmp(param, "enc"))
state->enc = 1;
else if (!strcmp(param, "decrypt") || !strcmp(param, "dec"))
state->enc = 0;
else if (!memcmp(param, "engine=", 7)) {
- if (!strcmp(param+7, "aes_c"))
+ if (!strcasecmp(param+7, "aes_c"))
state->engine = AES_C_Methods;
#ifdef HAVE_AES_ARM64
- else if (!strcmp(param+7, "aesarm64"))
+ else if (!strcasecmp(param+7, "aesarm64"))
state->engine = AES_ARM8_Methods;
#endif
#ifdef HAVE_AESNI
- else if (!strcmp(param+7, "aesni"))
+ else if (!strcasecmp(param+7, "aesni"))
state->engine = AESNI_Methods;
#endif
#ifdef HAVE_LIBCRYPTO
- else if (!strcmp(param+7, "openssl"))
+ else if (!strcasecmp(param+7, "openssl"))
state->engine = AES_OSSL_Methods;
#endif
else {
@@ -257,11 +257,11 @@ int crypt_plug_init(void **stat, char* param, int seq, const opt_t *opt)
else if (!memcmp(param, "alg=", 4))
err += set_alg(state, param+4);
else if (!memcmp(param, "pad=", 4)) {
- if (!strcmp(param+4, "zero"))
+ if (!strcasecmp(param+4, "zero"))
state->pad = PAD_ZERO;
- else if (!strcmp(param+4, "always"))
+ else if (!strcasecmp(param+4, "always"))
state->pad = PAD_ALWAYS;
- else if (!strcmp(param+4, "asneeded"))
+ else if (!strcasecmp(param+4, "asneeded"))
state->pad = PAD_ASNEEDED;
else {
FPLOG(FATAL, "Illegal padding %s: Specify zero/always/asneeded!\n",
@@ -401,8 +401,10 @@ int crypt_plug_init(void **stat, char* param, int seq, const opt_t *opt)
}
/* 1st: Set engine: Default: aesni/aes_c: Done */
/* 2nd: Set alg: Already done if set explicitly */
- if (!err && !state->alg)
+ if (!err && !state->alg) {
state->alg = findalg(state->engine, "AES192-CTR", 0);
+ FPLOG(INFO, "Using default algorithm AES192-CTR\n", NULL);
+ }
if (!state->alg)
return -1;
diff --git a/libddr_hash.c b/libddr_hash.c
index 7c8cdf8..b6634ff 100644
--- a/libddr_hash.c
+++ b/libddr_hash.c
@@ -120,7 +120,7 @@ static loff_t readint(const char* const ptr)
hashalg_t *get_hashalg(hash_state *state, const char* nm)
{
unsigned int i;
- const char help = !strcmp(nm, "help");
+ const char help = !strcasecmp(nm, "help");
if (help)
FPLOG(INFO, "Supported algorithms:");
for (i = 0; i < sizeof(hashes)/sizeof(hashalg_t); ++i) {
@@ -154,10 +154,10 @@ int hash_plug_init(void **stat, char* param, int seq, const opt_t *opt)
char* next = strchr(param, ':');
if (next)
*next++ = 0;
- if (!strcmp(param, "help"))
+ if (!strcasecmp(param, "help"))
FPLOG(INFO, "%s", hash_help);
- else if (!strcmp(param, "debug"))
+ else if (!strcasecmp(param, "debug"))
state->debug = 1;
else if (!strcmp(param, "output"))
state->outfd = 1;

View File

@ -0,0 +1,85 @@
commit 7944395ea224067e54f1a094ee91b20b93f5ef65
Author: Kurt Garloff <kurt@garloff.de>
Date: Sun Apr 15 11:58:59 2018 +0200
Avoid check fail if dd_rescue was built w/o xattr support.
diff --git a/Makefile b/Makefile
index 6c9f958..5d81353 100644
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,12 @@ else
HAVE_OPENSSL=0
endif
+ifeq ($(shell grep 'HAVE_ATTR_XATTR_H 1' config.h >/dev/null 2>&1 && echo 1), 1)
+ HAVE_XATTR=1
+else
+ HAVE_XATTR=0
+endif
+
ifeq ($(CC),wcl386)
CFLAGS = "-ox -wx $(EXTRA_CFLAGS)"
DEFINES = -dMISS_STRSIGNAL -dMISS_PREAD -dVERSION=\"$(VERSION)\" -d__COMPILER__="\"$(COMPILER)\""
@@ -493,15 +499,9 @@ check: $(TARGETS) find_nonzero md5 sha1 sha256 sha512 fmt_no
#if test $(HAVE_LZO) = 1; then $(MAKE) check_lzo_test; fi
if test $(HAVE_LZO) = 1; then $(MAKE) check_lzo_fuzz; fi
# Tests for libddr_null
- $(VG) ./dd_rescue -L ./libddr_null.so=debug dd_rescue /dev/null
- # Tests with hash set_xattr and chk_xattr (with fallback as not all filesystems support xattrs ...)
- $(VG) ./dd_rescue -tL ./libddr_hash.so=sha256:set_xattr:fallback dd_rescue /tmp/dd_rescue
- $(VG) ./dd_rescue -L ./libddr_hash.so=sha256:chk_xattr:fallback /tmp/dd_rescue /dev/null
- rm -f /tmp/dd_rescue CHECKSUMS.sha256
- # Tests with prepend and append
- $(VG) ./dd_rescue -tL ./libddr_hash.so=sha512:set_xattr:fallback:prepend=abc:append=xyz dd_rescue /tmp/dd_rescue
- $(VG) ./dd_rescue -L ./libddr_hash.so=sha512:chk_xattr:fallback /tmp/dd_rescue /dev/null && false || true
- $(VG) ./dd_rescue -L ./libddr_hash.so=sha512:chk_xattr:fallback:prepend=abc:append=xyz /tmp/dd_rescue /dev/null
+ $(VG) ./dd_rescue -L ./libddr_null.so=debug dd_rescue /dev/null
+ # Hash tests with set_xattr and chk_xattr
+ if test $(HAVE_XATTR) = 1; then $(MAKE) check_xattr_storehash; fi
# Extra xattrs (should be preserved)
#make check_xattr_copy
# Tests with HMAC
@@ -514,6 +514,15 @@ check: $(TARGETS) find_nonzero md5 sha1 sha256 sha512 fmt_no
#$(MAKE) check_aes
$(MAKE) check_crypt
+check_xattr_storehash: $(TARGETS)
+ # Tests with hash set_xattr and chk_xattr (with fallback as not all filesystems support xattrs ...)
+ $(VG) ./dd_rescue -tL ./libddr_hash.so=sha256:set_xattr:fallback dd_rescue /tmp/dd_rescue
+ $(VG) ./dd_rescue -L ./libddr_hash.so=sha256:chk_xattr:fallback /tmp/dd_rescue /dev/null
+ rm -f /tmp/dd_rescue CHECKSUMS.sha256
+ # Tests with prepend and append
+ $(VG) ./dd_rescue -tL ./libddr_hash.so=sha512:set_xattr:fallback:prepend=abc:append=xyz dd_rescue /tmp/dd_rescue
+ $(VG) ./dd_rescue -L ./libddr_hash.so=sha512:chk_xattr:fallback /tmp/dd_rescue /dev/null && false || true
+ $(VG) ./dd_rescue -L ./libddr_hash.so=sha512:chk_xattr:fallback:prepend=abc:append=xyz /tmp/dd_rescue /dev/null
# FIXME: This fails on filesystems without xattr support - disabled until we know how to handle this
check_xattr_copy: $(TARGETS)
commit 919323921daed3afc339079378d1af58f0252840
Author: Kurt Garloff <kurt@garloff.de>
Date: Sun Apr 15 17:04:03 2018 +0200
Also avoid xattr usage in test_crypt.sh if not supported.
diff --git a/test_crypt.sh b/test_crypt.sh
index 0aef640..47f1fc9 100755
--- a/test_crypt.sh
+++ b/test_crypt.sh
@@ -170,10 +170,12 @@ done
echo "*** Salt and XAttrs ***"
# Use random numbers and write to binary file
enc_dec_compare dd_rescue AES192-CTR saltgen pass=PWD_:pbkdf2:saltfile=SALT
-# Use random numbers and write to xattr, fall back to saltsfile
-enc_dec_compare dd_rescue AES192-CTR saltgen pass=PSWD:pbkdf2:saltxattr:sxfallback
-# Save key and IV to xattrs
-enc_dec_compare dd_rescue AES192-CTR keygen:ivgen keyxattr:kxfallb:ivxattr:ixfallb
+if grep 'define HAVE_ATTR_XATTR_H 1' config.h >/dev/null 2>&1 ; then
+ # Use random numbers and write to xattr, fall back to saltsfile
+ enc_dec_compare dd_rescue AES192-CTR saltgen pass=PSWD:pbkdf2:saltxattr:sxfallback
+ # Save key and IV to xattrs
+ enc_dec_compare dd_rescue AES192-CTR keygen:ivgen keyxattr:kxfallb:ivxattr:ixfallb
+fi
HAVE_AESNI=`grep " sse4" /proc/cpuinfo 2>/dev/null | grep " aes " 2>/dev/null`
HAVE_AESARM=`grep " pmull " /proc/cpuinfo 2>/dev/null`