Compare commits

..

No commits in common. "c8s" and "c9s" have entirely different histories.
c8s ... c9s

10 changed files with 601 additions and 1642 deletions

5
.gitignore vendored
View File

@ -1,2 +1,5 @@
SOURCES/scrub-2.5.2.tar.bz2
scrub-2.2.tar.bz2
/scrub-2.4.tar.bz2
/scrub-2.4.1.tar.gz
/scrub-2.5.2.tar.bz2
/scrub-2.6.1.tar.gz

View File

@ -1,6 +1,6 @@
--- !Policy
product_versions:
- rhel-8
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

File diff suppressed because it is too large Load Diff

View File

@ -1,77 +0,0 @@
--- scrub-2.5.2.ori/src/scrub.c 2012-06-21 00:00:27.000000000 +0200
+++ scrub-2.5.2/src/scrub.c 2021-08-09 18:25:00.355142963 +0200
@@ -283,8 +283,8 @@
}
scrub_disk(filename, sopt, seq, bopt, Sopt, Topt);
break;
- case FILE_LINK:
- if (Lopt) {
+ case FILE_REGULAR:
+ if (is_symlink(filename) && Lopt) {
if (ropt) {
printf("%s: unlinking %s\n", prog, filename);
if (unlink(filename) != 0) {
@@ -295,7 +295,6 @@
}
break;
}
- case FILE_REGULAR:
if (access(filename, R_OK|W_OK) < 0) {
fprintf(stderr, "%s: no rw access to %s\n", prog, filename);
exit(1);
@@ -570,7 +570,7 @@
struct stat sb;
filetype_t ftype = filetype(path);
- assert(ftype == FILE_REGULAR || ftype == FILE_LINK);
+ assert(ftype == FILE_REGULAR);
if (stat(path, &sb) < 0) {
fprintf(stderr, "%s: stat %s: %s\n", prog, path, strerror(errno));
--- scrub-2.5.2.ori/src/util.c 2012-06-21 00:00:27.000000000 +0200
+++ scrub-2.5.2/src/util.c 2021-08-10 15:38:26.748107704 +0200
@@ -72,6 +72,15 @@
return n;
}
+/* Indicates whether the file represented by 'path' is a symlink.
+ */
+int
+is_symlink(char *path)
+{
+ struct stat sb;
+ return lstat(path, &sb) == 0 && S_ISLNK(sb.st_mode);
+}
+
/* Return the type of file represented by 'path'.
*/
filetype_t
@@ -90,10 +90,6 @@
filetype_t res = FILE_NOEXIST;
- if (lstat(path, &sb) == 0 && S_ISLNK(sb.st_mode)) {
- return FILE_LINK;
- }
-
if (stat(path, &sb) == 0) {
if (S_ISREG(sb.st_mode))
res = FILE_REGULAR;
--- scrub-2.5.2.ori/src/util.h 2012-06-21 00:00:27.000000000 +0200
+++ scrub-2.5.2/src/util.h 2021-08-16 16:12:25.306572001 +0200
@@ -35,7 +35,6 @@
FILE_REGULAR,
FILE_CHAR,
FILE_BLOCK,
- FILE_LINK,
FILE_OTHER,
} filetype_t;
@@ -43,6 +42,7 @@
int read_all(int fd, unsigned char *buf, int count);
int write_all(int fd, const unsigned char *buf, int count);
+int is_symlink(char *path);
filetype_t filetype(char *path);
off_t blkalign(off_t offset, int blocksize, round_t rtype);
void * alloc_buffer(int bufsize);

View File

@ -0,0 +1,31 @@
diff -up scrub-2.6.1/src/fillfile.c.analyzer-fixes scrub-2.6.1/src/fillfile.c
--- scrub-2.6.1/src/fillfile.c.analyzer-fixes 2021-03-18 10:42:37.201845461 -0400
+++ scrub-2.6.1/src/fillfile.c 2021-03-18 10:43:38.358151439 -0400
@@ -131,10 +131,13 @@ refill_init(struct memstruct **mpp, refi
if (!(mp = malloc(sizeof(struct memstruct))))
goto nomem;
- if (!(mp->buf = malloc(memsize)))
+ if (!(mp->buf = malloc(memsize))) {
+ free(mp);
goto nomem;
+ }
mp->size = memsize;
mp->refill = refill;
+ mp->thd = 0;
#if WITH_PTHREADS
if (!no_threads) {
if ((mp->err = pthread_create(&mp->thd, NULL, refill_thread, mp))) {
diff -up scrub-2.6.1/src/scrub.c.analyzer-fixes scrub-2.6.1/src/scrub.c
diff -up scrub-2.6.1/src/sig.c.analyzer-fixes scrub-2.6.1/src/sig.c
--- scrub-2.6.1/src/sig.c.analyzer-fixes 2021-03-18 10:44:20.715363360 -0400
+++ scrub-2.6.1/src/sig.c 2021-03-18 10:44:54.319531489 -0400
@@ -74,7 +74,7 @@ writesig(char *path)
goto nomem;
if ((fd = open(path, O_RDWR)) < 0)
goto error;
- if ((n = read_all(fd, buf, blocksize)) < 0)
+ if (read_all(fd, buf, blocksize) < 0)
goto error;
memcpy(buf, SCRUB_MAGIC, sizeof(SCRUB_MAGIC));
if (lseek(fd, 0, SEEK_SET) < 0)

View File

@ -1,26 +1,6 @@
From 1dd2a8b9226594ae834e639e00abdf2f47ac4acc Mon Sep 17 00:00:00 2001
From: Daniel Kopecek <dkopecek@redhat.com>
Date: Tue, 16 Jul 2019 13:21:06 +0200
Subject: [PATCH] scrub allocated extent only
---
libscrub/Makefile.am | 1 +
man/scrub.1.in | 7 ++
src/Makefile.am | 2 +
src/fextent_apply.c | 142 ++++++++++++++++++++++++++
src/fextent_apply.h | 30 ++++++
src/fillfile.c | 231 +++++++++++++++++++++++++++++++++----------
src/fillfile.h | 4 +-
src/genrand.c | 2 +-
src/scrub.c | 36 ++++---
9 files changed, 383 insertions(+), 72 deletions(-)
create mode 100644 src/fextent_apply.c
create mode 100644 src/fextent_apply.h
diff --git a/libscrub/Makefile.am b/libscrub/Makefile.am
index 477c866..d88cd48 100644
--- a/libscrub/Makefile.am
+++ b/libscrub/Makefile.am
diff -up scrub-2.6.1/libscrub/Makefile.am.extent-only scrub-2.6.1/libscrub/Makefile.am
--- scrub-2.6.1/libscrub/Makefile.am.extent-only 2014-08-20 17:33:43.000000000 -0400
+++ scrub-2.6.1/libscrub/Makefile.am 2021-02-22 14:24:32.439635010 -0500
@@ -13,6 +13,7 @@ libscrub_la_SOURCES = \
libscrub.c \
scrub.h \
@ -29,11 +9,10 @@ index 477c866..d88cd48 100644
../src/filldentry.c \
../src/fillfile.c \
../src/genrand.c \
diff --git a/man/scrub.1.in b/man/scrub.1.in
index a1c260a..72b114f 100644
--- a/man/scrub.1.in
+++ b/man/scrub.1.in
@@ -106,6 +106,13 @@ Don't generate random data in parallel with I/O.
diff -up scrub-2.6.1/man/scrub.1.in.extent-only scrub-2.6.1/man/scrub.1.in
--- scrub-2.6.1/man/scrub.1.in.extent-only 2014-08-20 17:33:43.000000000 -0400
+++ scrub-2.6.1/man/scrub.1.in 2021-02-22 14:24:32.439635010 -0500
@@ -110,6 +110,13 @@ Do everything but write to targets.
.TP
\fI-h\fR, \fI--help\fR
Print a summary of command line options on stderr.
@ -47,42 +26,27 @@ index a1c260a..72b114f 100644
.SH SCRUB METHODS
.TP
.I "nnsa"
diff --git a/src/Makefile.am b/src/Makefile.am
index 0cbd8f7..5de0b68 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,6 +3,8 @@ bin_PROGRAMS = scrub
scrub_SOURCES = \
aes.c \
aes.h \
+ fextent_apply.c \
+ fextent_apply.h \
filldentry.c \
filldentry.h \
fillfile.c \
diff --git a/src/fextent_apply.c b/src/fextent_apply.c
new file mode 100644
index 0000000..31d3210
--- /dev/null
+++ b/src/fextent_apply.c
diff -up scrub-2.6.1/src/fextent_apply.c.extent-only scrub-2.6.1/src/fextent_apply.c
--- scrub-2.6.1/src/fextent_apply.c.extent-only 2021-02-22 14:24:32.439635010 -0500
+++ scrub-2.6.1/src/fextent_apply.c 2021-02-22 14:25:20.590843156 -0500
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2012 Red Hat Inc., Durham, North Carolina.
+ * Copyright 2021 Red Hat, Inc.
+ * All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see:
+ * <https://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Daniel Kopecek <dkopecek@redhat.com>
@ -103,10 +67,10 @@ index 0000000..31d3210
+#include <linux/fiemap.h>
+
+#ifndef NDEBUG
+# define dP(...) \
+ do { int __tmp_errno = errno; \
+ fprintf(stderr, "DEBUG: "__VA_ARGS__); \
+ errno = __tmp_errno; \
+# define dP(...) \
+ do { int __tmp_errno = errno; \
+ fprintf(stderr, "DEBUG: "__VA_ARGS__); \
+ errno = __tmp_errno; \
+ } while(0)
+#else
+# define dP(...) while(0)
@ -121,26 +85,26 @@ index 0000000..31d3210
+
+ // lock, sync, stat
+ if (flock(fd, LOCK_EX) != 0) {
+ dP("flock(%d, LOCK_EX) failed: %s, %d.\n", fd, strerror(errno), errno);
+ return -1;
+ dP("flock(%d, LOCK_EX) failed: %s, %d.\n", fd, strerror(errno), errno);
+ return -1;
+ }
+ if (fsync(fd) != 0) {
+ dP("fsync(%d) failed: %s, %d.\n", fd, strerror(errno), errno);
+ goto exit_1;
+ dP("fsync(%d) failed: %s, %d.\n", fd, strerror(errno), errno);
+ goto exit_1;
+ }
+ if (fstat(fd, &st) != 0) {
+ dP("fstat(%d) failed: %s, %d.\n", fd, strerror(errno), errno);
+ goto exit_1;
+ dP("fstat(%d) failed: %s, %d.\n", fd, strerror(errno), errno);
+ goto exit_1;
+ }
+
+
+ /*
+ * fiemap => get extent count
+ */
+ em = malloc(sizeof(struct fiemap));
+
+ if (em == NULL) {
+ dP("malloc(%zu) returned NULL!\n", sizeof(struct fiemap));
+ goto exit_1;
+ dP("malloc(%zu) returned NULL!\n", sizeof(struct fiemap));
+ goto exit_1;
+ }
+
+ memset(em, 0, sizeof(struct fiemap));
@ -152,8 +116,8 @@ index 0000000..31d3210
+ em->fm_flags = 0;
+
+ if (ioctl(fd, FS_IOC_FIEMAP, em) != 0) {
+ dP("FS_IOC_FIEMAP: %s, %d.\n", strerror(errno), errno);
+ goto exit_0;
+ dP("FS_IOC_FIEMAP: %s, %d.\n", strerror(errno), errno);
+ goto exit_0;
+ }
+
+ extent_count = em->fm_mapped_extents;
@ -163,16 +127,16 @@ index 0000000..31d3210
+ * fiemap => get extents
+ */
+ em = malloc (sizeof(struct fiemap)
+ + (sizeof(struct fiemap_extent) * extent_count));
+ + (sizeof(struct fiemap_extent) * extent_count));
+
+ if (em == NULL) {
+ dP("malloc(%zu) returned NULL!\n", sizeof(struct fiemap)
+ + (sizeof (struct fiemap_extent) * extent_count));
+ goto exit_0;
+ dP("malloc(%zu) returned NULL!\n", sizeof(struct fiemap)
+ + (sizeof (struct fiemap_extent) * extent_count));
+ goto exit_0;
+ }
+
+ memset(em, 0, sizeof(struct fiemap)
+ + (sizeof(struct fiemap_extent) * extent_count));
+ + (sizeof(struct fiemap_extent) * extent_count));
+
+ em[0].fm_start = 0;
+ em[0].fm_length = st.st_size;
@ -180,21 +144,21 @@ index 0000000..31d3210
+ em[0].fm_flags = 0;
+
+ if (ioctl(fd, FS_IOC_FIEMAP, em) != 0) {
+ dP("FS_IOC_FIEMAP: %s, %d.\n", strerror(errno), errno);
+ goto exit_0;
+ dP("FS_IOC_FIEMAP: %s, %d.\n", strerror(errno), errno);
+ goto exit_0;
+ }
+
+ for (i = 0; i < extent_count; ++i) {
+ // seek to extent start
+ if (lseek(fd, em->fm_extents[i].fe_logical, SEEK_SET) == (off_t)-1) {
+ dP("lseek(%d, %llu, SET) failed: %s, %d.\n",
+ fd, em->fm_extents[i].fe_logical, strerror(errno), errno);
+ goto exit_0;
+ }
+
+ ret = function(fd, em->fm_extents + i, arg);
+ if (ret != 0)
+ goto exit_0;
+ for (i = 0; i < extent_count; ++i) {
+ // seek to extent start
+ if (lseek(fd, em->fm_extents[i].fe_logical, SEEK_SET) == (off_t)-1) {
+ dP("lseek(%d, %llu, SET) failed: %s, %d.\n",
+ fd, em->fm_extents[i].fe_logical, strerror(errno), errno);
+ goto exit_0;
+ }
+
+ ret = function(fd, em->fm_extents + i, arg);
+ if (ret != 0)
+ goto exit_0;
+ }
+
+ ret = 0;
@ -204,33 +168,31 @@ index 0000000..31d3210
+ exit_1:
+ // unlock
+ if (flock(fd, LOCK_UN) != 0)
+ ret = -1;
+ ret = -1;
+
+ return ret;
+}
diff --git a/src/fextent_apply.h b/src/fextent_apply.h
new file mode 100644
index 0000000..40a54ec
--- /dev/null
+++ b/src/fextent_apply.h
diff -up scrub-2.6.1/src/fextent_apply.h.extent-only scrub-2.6.1/src/fextent_apply.h
--- scrub-2.6.1/src/fextent_apply.h.extent-only 2021-02-22 14:24:32.439635010 -0500
+++ scrub-2.6.1/src/fextent_apply.h 2021-02-22 14:24:32.439635010 -0500
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Red Hat Inc., Durham, North Carolina.
+ * Copyright 2021 Red Hat, Inc.
+ * All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see:
+ * <https://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Daniel Kopecek <dkopecek@redhat.com>
@ -244,11 +206,10 @@ index 0000000..40a54ec
+int fextent_apply(int fd, int (*function)(int, struct fiemap_extent *, void *), void *arg);
+
+#endif /* FEXTENT_APPLY_H */
diff --git a/src/fillfile.c b/src/fillfile.c
index e0f67b6..a77367f 100644
--- a/src/fillfile.c
+++ b/src/fillfile.c
@@ -42,6 +42,7 @@
diff -up scrub-2.6.1/src/fillfile.c.extent-only scrub-2.6.1/src/fillfile.c
--- scrub-2.6.1/src/fillfile.c.extent-only 2014-08-20 17:33:43.000000000 -0400
+++ scrub-2.6.1/src/fillfile.c 2021-02-22 14:24:32.439635010 -0500
@@ -41,6 +41,7 @@
#include "util.h"
#include "fillfile.h"
@ -256,7 +217,7 @@ index e0f67b6..a77367f 100644
static int no_threads = 0;
@@ -57,6 +58,20 @@ struct memstruct {
@@ -56,6 +57,20 @@ struct memstruct {
extern char *prog;
@ -277,11 +238,11 @@ index e0f67b6..a77367f 100644
#if defined(O_DIRECT) && (defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN))
# define MY_O_DIRECT O_DIRECT
#else
@@ -155,11 +170,12 @@ refill_fini(struct memstruct *mp)
@@ -154,11 +169,12 @@ refill_fini(struct memstruct *mp)
* If 'sparse' is true, only scrub first and last blocks (for testing).
* The number of bytes written is returned.
* If 'creat' is true, open with O_CREAT and allow ENOSPC to be non-fatal.
+ * IF 'extentonly' is true, fill only file extents with the given pattern
+ * If 'extentonly' is true, fill only file extents with the given pattern.
*/
off_t
fillfile(char *path, off_t filesize, unsigned char *mem, int memsize,
@ -291,7 +252,7 @@ index e0f67b6..a77367f 100644
{
int fd = -1;
off_t n;
@@ -179,34 +195,58 @@ fillfile(char *path, off_t filesize, unsigned char *mem, int memsize,
@@ -178,34 +194,52 @@ fillfile(char *path, off_t filesize, uns
}
if (fd < 0)
goto error;
@ -342,31 +303,25 @@ index e0f67b6..a77367f 100644
+ if (written + memsize > filesize)
+ memsize = filesize - written;
+ if (refill && !sparse) {
+ if (!mp) {
+ if (refill_init(&mp, refill, memsize) < 0) {
+ if (!mp)
+ if (refill_init(&mp, refill, memsize) < 0)
+ goto error;
+ }
+ }
+ if (refill_memcpy(mp, mem, memsize, filesize, written) < 0) {
+ if (refill_memcpy(mp, mem, memsize, filesize, written) < 0)
+ goto error;
+ }
+ }
+ if (sparse && !(written == 0) && !(written + memsize == filesize)) {
+ if (lseek(fd, memsize, SEEK_CUR) < 0) {
+ if (lseek(fd, memsize, SEEK_CUR) < 0)
+ goto error;
+ }
+ written += memsize;
+ } else {
+ n = write_all(fd, mem, memsize);
+ if (creat && n < 0 && errno == ENOSPC)
+ break;
+ if (n == 0) {
+ errno = EINVAL;
+ errno = EINVAL; /* write past end of device? */
+ goto error;
+ }
+ else if (n < 0) {
+ } else if (n < 0)
+ goto error;
+ }
+ written += n;
+ }
+ if (progress)
@ -374,10 +329,10 @@ index e0f67b6..a77367f 100644
+ } while (written < filesize);
+ }
+
if (fsync(fd) < 0)
goto error;
#if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
@@ -230,7 +270,7 @@ error:
if (fsync(fd) < 0) {
if (errno != EINVAL)
goto error;
@@ -232,7 +266,7 @@ error:
*/
off_t
checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
@ -386,7 +341,7 @@ index e0f67b6..a77367f 100644
{
int fd = -1;
off_t n;
@@ -238,8 +278,6 @@ checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
@@ -240,8 +274,6 @@ checkfile(char *path, off_t filesize, un
unsigned char *buf = NULL;
int openflags = O_RDONLY;
@ -395,7 +350,7 @@ index e0f67b6..a77367f 100644
if (filetype(path) != FILE_CHAR)
openflags |= MY_O_DIRECT;
fd = open(path, openflags);
@@ -250,32 +288,60 @@ checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
@@ -252,32 +284,58 @@ checkfile(char *path, off_t filesize, un
}
if (fd < 0)
goto error;
@ -447,21 +402,19 @@ index e0f67b6..a77367f 100644
+ if (verified + memsize > filesize)
+ memsize = filesize - verified;
+ if (sparse && !(verified == 0) && !(verified + memsize == filesize)) {
+ if (lseek(fd, memsize, SEEK_CUR) < 0) {
+ if (lseek(fd, memsize, SEEK_CUR) < 0)
+ goto error;
+ }
+ verified += memsize;
+ } else {
+ n = read_all(fd, buf, memsize);
+ if (n < 0) {
+ if (n < 0)
+ goto error;
+ }
+ if (n == 0) {
+ errno = EINVAL; /* early EOF */
+ goto error;
+ }
+ if (memcmp(mem, buf, memsize) != 0) {
+ break;
+ break; /* return < filesize means verification failure */
+ }
+ verified += n;
+ }
@ -469,7 +422,7 @@ index e0f67b6..a77367f 100644
+ progress(arg, (double)verified/filesize);
+ } while (verified < filesize);
+ }
+
+
if (close(fd) < 0)
goto error;
- free(buf);
@ -479,7 +432,7 @@ index e0f67b6..a77367f 100644
return verified;
nomem:
errno = ENOMEM;
@@ -293,6 +359,63 @@ disable_threads(void)
@@ -295,6 +353,63 @@ disable_threads(void)
no_threads = 1;
}
@ -543,11 +496,10 @@ index e0f67b6..a77367f 100644
/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/
diff --git a/src/fillfile.h b/src/fillfile.h
index b9ef951..2fc917d 100644
--- a/src/fillfile.h
+++ b/src/fillfile.h
@@ -29,7 +29,7 @@ typedef void (*refill_t) (unsigned char *mem, int memsize);
diff -up scrub-2.6.1/src/fillfile.h.extent-only scrub-2.6.1/src/fillfile.h
--- scrub-2.6.1/src/fillfile.h.extent-only 2014-08-20 17:33:43.000000000 -0400
+++ scrub-2.6.1/src/fillfile.h 2021-02-22 14:24:32.440635014 -0500
@@ -3,9 +3,9 @@ typedef void (*refill_t) (unsigned char
off_t fillfile(char *path, off_t filesize, unsigned char *mem, int memsize,
progress_t progress, void *arg, refill_t refill,
@ -557,48 +509,46 @@ index b9ef951..2fc917d 100644
- progress_t progress, void *arg, bool sparse);
+ progress_t progress, void *arg, bool sparse, bool extentonly);
void disable_threads(void);
diff --git a/src/genrand.c b/src/genrand.c
index 820c898..ecfd382 100644
--- a/src/genrand.c
+++ b/src/genrand.c
@@ -106,7 +106,7 @@ genrandraw(unsigned char *buf, int buflen)
buf[n] = result;
}
#endif
- return;
+ return 0;
}
}
diff --git a/src/scrub.c b/src/scrub.c
index dec71f3..b0eb1f7 100644
--- a/src/scrub.c
+++ b/src/scrub.c
@@ -58,12 +58,12 @@
#define BUFSIZE (4*1024*1024) /* default blocksize */
/*
diff -up scrub-2.6.1/src/Makefile.am.extent-only scrub-2.6.1/src/Makefile.am
--- scrub-2.6.1/src/Makefile.am.extent-only 2021-02-22 14:24:32.438635006 -0500
+++ scrub-2.6.1/src/Makefile.am 2021-02-22 14:24:32.440635014 -0500
@@ -1,6 +1,8 @@
bin_PROGRAMS = scrub
scrub_SOURCES = \
+ fextent_apply.c \
+ fextent_apply.h \
filldentry.c \
filldentry.h \
fillfile.c \
diff -up scrub-2.6.1/src/scrub.c.extent-only scrub-2.6.1/src/scrub.c
--- scrub-2.6.1/src/scrub.c.extent-only 2021-02-22 14:24:32.438635006 -0500
+++ scrub-2.6.1/src/scrub.c 2021-02-22 14:24:32.440635014 -0500
@@ -68,10 +68,11 @@ struct opt_struct {
bool nofollow;
bool nohwrand;
bool nothreads;
+ bool extentonly;
};
static bool scrub(char *path, off_t size, const sequence_t *seq,
- int bufsize, bool Sopt, bool sparse, bool enospc);
+ int bufsize, bool Sopt, bool sparse, bool enospc, bool extentonly);
static void scrub_free(char *path, off_t size, const sequence_t *seq,
int bufsize, bool Sopt);
static void scrub_dirent(char *path, char *newpath);
static void scrub_file(char *path, off_t size, const sequence_t *seq,
- int bufsize, bool Sopt, bool sparse);
+ int bufsize, bool Sopt, bool sparse, bool extentonly);
#if __APPLE__
static void scrub_resfork(char *path, const sequence_t *seq,
int bufsize);
@@ -71,7 +71,7 @@ static void scrub_resfork(char *path, const sequence_t *seq,
static void scrub_disk(char *path, off_t size, const sequence_t *seq,
int bufsize, bool Sopt, bool sparse);
- int bufsize, bool nosig, bool sparse, bool enospc);
+ int bufsize, bool nosig, bool sparse, bool enospc, bool extentonly);
static void scrub_free(char *path, const struct opt_struct *opt);
static void scrub_dirent(char *path, const struct opt_struct *opt);
static void scrub_file(char *path, const struct opt_struct *opt);
@@ -82,7 +83,7 @@ static void scrub_disk(char *path,
static int scrub_object(char *path, const struct opt_struct *opt,
bool noexec, bool dryrun);
-#define OPTIONS "p:D:Xb:s:fSrvTLRth"
+#define OPTIONS "p:D:Xb:s:fSrvTELRth"
-#define OPTIONS "p:D:Xb:s:fSrvTLRthn"
+#define OPTIONS "p:D:Xb:s:fSrvTELRthn"
#if HAVE_GETOPT_LONG
#define GETOPT(ac,av,opt,lopt) getopt_long(ac,av,opt,lopt,NULL)
static struct option longopts[] = {
@@ -85,6 +85,7 @@ static struct option longopts[] = {
@@ -96,6 +97,7 @@ static struct option longopts[] = {
{"remove", no_argument, 0, 'r'},
{"version", no_argument, 0, 'v'},
{"test-sparse", no_argument, 0, 'T'},
@ -606,7 +556,7 @@ index dec71f3..b0eb1f7 100644
{"no-link", no_argument, 0, 'L'},
{"no-hwrand", no_argument, 0, 'R'},
{"no-threads", no_argument, 0, 't'},
@@ -111,6 +112,7 @@ usage(void)
@@ -123,6 +125,7 @@ usage(void)
" -f, --force scrub despite signature from previous scrub\n"
" -S, --no-signature do not write scrub signature after scrub\n"
" -r, --remove remove file after scrub\n"
@ -614,39 +564,22 @@ index dec71f3..b0eb1f7 100644
" -L, --no-link do not scrub link target\n"
" -R, --no-hwrand do not use a hardware random number generator\n"
" -t, --no-threads do not compute random data in a parallel thread\n"
@@ -139,6 +141,7 @@ main(int argc, char *argv[])
bool Lopt = false;
bool Ropt = false;
bool topt = false;
+ bool Eopt = false;
extern int optind;
extern char *optarg;
int c;
@@ -207,6 +210,9 @@ main(int argc, char *argv[])
@@ -212,6 +215,9 @@ main(int argc, char *argv[])
case 'T': /* --test-sparse */
Topt = true;
opt.sparse = true;
break;
+ case 'E': /* --extent-only */
+ Eopt = true;
+ opt.extentonly = true;
+ break;
case 'L': /* --no-link */
Lopt = true;
opt.nofollow = true;
break;
@@ -315,7 +321,7 @@ main(int argc, char *argv[])
prog, Dopt, filename);
exit(1);
}
- scrub_file(filename, sopt, seq, bopt, Sopt, Topt);
+ scrub_file(filename, sopt, seq, bopt, Sopt, Topt, Eopt);
#if __APPLE__
scrub_resfork(filename, seq, bopt);
#endif
@@ -346,14 +352,14 @@ done:
@@ -430,14 +436,14 @@ static int progress_col (const sequence_
*/
static bool
scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
- bool Sopt, bool sparse, bool enospc)
+ bool Sopt, bool sparse, bool enospc, bool extentonly)
- bool nosig, bool sparse, bool enospc)
+ bool nosig, bool sparse, bool enospc, bool extentonly)
{
unsigned char *buf;
int i;
@ -655,11 +588,11 @@ index dec71f3..b0eb1f7 100644
bool isfull = false;
- off_t written, checked;
+ off_t written = (off_t)-1, checked = (off_t)-1;
int pcol = progress_col(seq);
if (!(buf = alloc_buffer(bufsize))) {
fprintf(stderr, "%s: out of memory\n", prog);
@@ -381,7 +387,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
}
@@ -468,7 +474,7 @@ scrub(char *path, off_t size, const sequ
#endif /* HAVE_LIBGCRYPT. */
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
- (refill_t)genrand, sparse, enospc);
@ -667,7 +600,7 @@ index dec71f3..b0eb1f7 100644
if (written == (off_t)-1) {
fprintf(stderr, "%s: %s: %s\n", prog, path,
strerror(errno));
@@ -395,7 +401,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
@@ -482,7 +488,7 @@ scrub(char *path, off_t size, const sequ
memset_pat(buf, seq->pat[i], bufsize);
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
@ -676,7 +609,7 @@ index dec71f3..b0eb1f7 100644
if (written == (off_t)-1) {
fprintf(stderr, "%s: %s: %s\n", prog, path,
strerror(errno));
@@ -409,7 +415,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
@@ -496,7 +502,7 @@ scrub(char *path, off_t size, const sequ
memset_pat(buf, seq->pat[i], bufsize);
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
@ -685,60 +618,48 @@ index dec71f3..b0eb1f7 100644
if (written == (off_t)-1) {
fprintf(stderr, "%s: %s: %s\n", prog, path,
strerror(errno));
@@ -419,7 +425,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
@@ -506,7 +512,7 @@ scrub(char *path, off_t size, const sequ
printf("%s: %-8s", prog, "verify");
progress_create(&p, 50);
progress_create(&p, pcol);
checked = checkfile(path, written, buf, bufsize,
- (progress_t)progress_update, p, sparse);
+ (progress_t)progress_update, p, sparse, extentonly);
if (checked == (off_t)-1) {
fprintf(stderr, "%s: %s: %s\n", prog, path,
strerror(errno));
@@ -513,7 +519,7 @@ scrub_free(char *dirpath, off_t size, const sequence_t *seq,
size = blkalign(size, sb.st_blksize, DOWN);
@@ -600,7 +606,7 @@ scrub_free(char *dirpath, const struct o
do {
snprintf(path, sizeof(path), "%s/scrub.%.3d", dirpath, fileno++);
- isfull = scrub(path, size, seq, bufsize, Sopt, false, true);
+ isfull = scrub(path, size, seq, bufsize, Sopt, false, true, false);
isfull = scrub(path, size, opt->seq, opt->blocksize, opt->nosig,
- false, true);
+ false, true, false);
} while (!isfull);
while (--fileno >= 0) {
snprintf(path, sizeof(path), "%s/scrub.%.3d", dirpath, fileno);
@@ -565,7 +571,7 @@ scrub_dirent(char *path, char *newpath)
*/
static void
scrub_file(char *path, off_t size, const sequence_t *seq,
- int bufsize, bool Sopt, bool sparse)
+ int bufsize, bool Sopt, bool sparse, bool extentonly)
{
struct stat sb;
filetype_t ftype = filetype(path);
@@ -590,7 +596,7 @@ scrub_file(char *path, off_t size, const sequence_t *seq,
@@ -678,7 +684,7 @@ scrub_file(char *path, const struct opt_
prog, path, (int)(size - sb.st_size));
}
}
- scrub(path, size, seq, bufsize, Sopt, sparse, false);
+ scrub(path, size, seq, bufsize, Sopt, sparse, false, extentonly);
- scrub(path, size, opt->seq, opt->blocksize, opt->nosig, opt->sparse, false);
+ scrub(path, size, opt->seq, opt->blocksize, opt->nosig, opt->sparse, false, opt->extentonly);
}
/* Scrub apple resource fork component of file.
@@ -618,7 +624,7 @@ scrub_resfork(char *path, const sequence_t *seq, int bufsize)
@@ -706,7 +712,7 @@ scrub_resfork(char *path, const struct o
printf("%s: padding %s with %d bytes to fill last fs block\n",
prog, rpath, (int)(rsize - rsb.st_size));
}
- scrub(rpath, rsize, seq, bufsize, false, false, false);
+ scrub(rpath, rsize, seq, bufsize, false, false, false, false);
- scrub(rpath, rsize, opt->seq, opt->blocksize, false, false, false);
+ scrub(rpath, rsize, opt->seq, opt->blocksize, false, false, false, false);
}
#endif
@@ -639,7 +645,7 @@ scrub_disk(char *path, off_t size, const sequence_t *seq, int bufsize,
}
@@ -728,7 +734,7 @@ scrub_disk(char *path, const struct opt_
printf("%s: please verify that device size below is correct!\n", prog);
}
- scrub(path, size, seq, bufsize, Sopt, sparse, false);
+ scrub(path, size, seq, bufsize, Sopt, sparse, false, false);
scrub(path, devsize, opt->seq, opt->blocksize, opt->nosig, opt->sparse,
- false);
+ false, false);
}
/*
--
2.20.1

View File

@ -0,0 +1,122 @@
From 499a491c21b5a18be79334282dfa11fd4f408c49 Mon Sep 17 00:00:00 2001
From: Sergio Correia <scorreia@redhat.com>
Date: Wed, 27 Jan 2021 09:42:15 -0300
Subject: [PATCH] scrub should work for symlinks pointing to block devices
In [1] (add -L option to avoid scrubbing symlink target [Tim
Boronczyk]), scrub introduced a -L (--no-link) option so that it would
not scrub the target, if it was a link and this new option was set.
A side-effect of that change is that scrub stopped working for links
pointing to a block device, whereas it would still work for links
pointing to regular files -- it is not clear from the commit changelog
and the added documentation for this new option that this was an
intended change.
In this commit we fix this regression, and scrub works again for links
pointing to block devices. -L/--no-link option also works for these
links.
[1] https://github.com/chaos/scrub/commit/01915c442288b4b274261fa07e42e116fb9d6b60
---
src/scrub.c | 13 ++++++++-----
src/util.c | 13 +++++++++----
src/util.h | 2 +-
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/scrub.c b/src/scrub.c
index 1dada28..178dfe7 100644
--- a/src/scrub.c
+++ b/src/scrub.c
@@ -334,6 +334,10 @@ static int scrub_object(char *filename, const struct opt_struct *opt,
fprintf(stderr, "%s: %s already scrubbed? (-f to force)\n",
prog, filename);
errcount++;
+ } else if (is_symlink(filename) && opt->nofollow) {
+ fprintf(stderr, "%s: skipping symlink %s because --no-link (-L) option was set\n",
+ prog, filename);
+ errcount++;
} else if (!noexec) {
if (dryrun) {
printf("%s: (dryrun) scrub special file %s\n",
@@ -343,8 +347,8 @@ static int scrub_object(char *filename, const struct opt_struct *opt,
}
}
break;
- case FILE_LINK:
- if (opt->nofollow) {
+ case FILE_REGULAR:
+ if (is_symlink(filename) && opt->nofollow) {
if (opt->remove && !noexec) {
if (dryrun) {
printf("%s: (dryrun) unlink %s\n", prog, filename);
@@ -359,8 +363,7 @@ static int scrub_object(char *filename, const struct opt_struct *opt,
}
break;
}
- /* FALL THRU */
- case FILE_REGULAR:
+
if (access(filename, R_OK|W_OK) < 0) {
fprintf(stderr, "%s: no rw access to %s\n", prog, filename);
errcount++;
@@ -670,7 +673,7 @@ scrub_file(char *path, const struct opt_struct *opt)
filetype_t ftype = filetype(path);
off_t size = opt->devsize;
- assert(ftype == FILE_REGULAR || ftype == FILE_LINK);
+ assert(ftype == FILE_REGULAR);
if (stat(path, &sb) < 0) {
fprintf(stderr, "%s: stat %s: %s\n", prog, path, strerror(errno));
diff --git a/src/util.c b/src/util.c
index 96dd59b..fb85368 100644
--- a/src/util.c
+++ b/src/util.c
@@ -71,6 +71,15 @@ write_all(int fd, const unsigned char *buf, int count)
return n;
}
+/* Indicates whether the file represented by 'path' is a symlink.
+ */
+int
+is_symlink(char *path)
+{
+ struct stat sb;
+ return lstat(path, &sb) == 0 && S_ISLNK(sb.st_mode);
+}
+
/* Return the type of file represented by 'path'.
*/
filetype_t
@@ -80,10 +89,6 @@ filetype(char *path)
filetype_t res = FILE_NOEXIST;
- if (lstat(path, &sb) == 0 && S_ISLNK(sb.st_mode)) {
- return FILE_LINK;
- }
-
if (stat(path, &sb) == 0) {
if (S_ISREG(sb.st_mode))
res = FILE_REGULAR;
diff --git a/src/util.h b/src/util.h
index 513ae48..04246df 100644
--- a/src/util.h
+++ b/src/util.h
@@ -13,7 +13,6 @@ typedef enum {
FILE_REGULAR,
FILE_CHAR,
FILE_BLOCK,
- FILE_LINK,
FILE_OTHER,
} filetype_t;
@@ -21,6 +20,7 @@ typedef enum { UP, DOWN } round_t;
int read_all(int fd, unsigned char *buf, int count);
int write_all(int fd, const unsigned char *buf, int count);
+int is_symlink(char *path);
filetype_t filetype(char *path);
off_t blkalign(off_t offset, int blocksize, round_t rtype);
void * alloc_buffer(int bufsize);

View File

@ -0,0 +1,229 @@
diff -up scrub-2.6.1/configure.ac.libgcrypt scrub-2.6.1/configure.ac
--- scrub-2.6.1/configure.ac.libgcrypt 2014-08-26 14:15:12.000000000 -0400
+++ scrub-2.6.1/configure.ac 2021-02-22 13:42:48.489217200 -0500
@@ -70,6 +70,25 @@ AC_CHECK_FUNCS( \
X_AC_CHECK_PTHREADS
##
+# gcrypt library
+##
+have_libgcrypt=no
+AC_ARG_WITH(libgcrypt, AS_HELP_STRING([--without-libgcrypt], [build without libgcrypt;
+ fallback to custom AES implementation]))
+AS_IF([test "x$with_libgcrypt" != "xno"],
+ [AM_PATH_LIBGCRYPT([1.5.0],
+ [AC_DEFINE([HAVE_LIBGCRYPT], [1], [libgcrypt API available])
+ gcrypt_CFLAGS="$LIBGCRYPT_CFLAGS"
+ gcrypt_LIBS="$LIBGCRYPT_LIBS"
+ have_libgcrypt=yes
+ ]
+ )]
+)
+AM_CONDITIONAL([LIBGCRYPT], [test "$have_libgcrypt" = "yes"])
+AC_SUBST([gcrypt_CFLAGS])
+AC_SUBST([gcrypt_LIBS])
+
+##
# Arrange for large file support
##
AC_SYS_LARGEFILE
diff -up scrub-2.6.1/src/genrand.c.libgcrypt scrub-2.6.1/src/genrand.c
--- scrub-2.6.1/src/genrand.c.libgcrypt 2014-08-20 17:33:43.000000000 -0400
+++ scrub-2.6.1/src/genrand.c 2021-02-22 13:42:48.490217204 -0500
@@ -37,21 +37,27 @@
#include <assert.h>
#include <libgen.h>
-#include "aes.h"
#include "util.h"
#include "genrand.h"
#include "hwrand.h"
-#define PATH_URANDOM "/dev/urandom"
-
-#define PAYLOAD_SZ 16
-#define KEY_SZ 16
+#ifdef HAVE_LIBGCRYPT
+#include <gcrypt.h>
+#else
+#include "aes.h"
+#endif /* HAVE_LIBGCRYPT. */
extern char *prog;
static bool no_hwrand = false;
static hwrand_t gen_hwrand;
+#ifndef HAVE_LIBGCRYPT
+#define PATH_URANDOM "/dev/urandom"
+
+#define PAYLOAD_SZ 16
+#define KEY_SZ 16
+
static aes_context ctx;
static unsigned char ctr[PAYLOAD_SZ];
@@ -140,17 +146,26 @@ churnrand(void)
error:
return -1;
}
+#endif /* HAVE_LIBGCRYPT. */
/* Initialize the module.
*/
int
initrand(void)
{
+#ifndef HAVE_LIBGCRYPT
struct timeval tv;
+#else
+ if (!gcry_check_version(GCRYPT_VERSION)) {
+ goto error;
+ }
+ gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+#endif /* HAVE_LIBGCRYPT */
if (!no_hwrand)
gen_hwrand = init_hwrand();
+#ifndef HAVE_LIBGCRYPT
/* Always initialize the software random number generator as backup */
if (gettimeofday(&tv, NULL) < 0)
@@ -163,6 +178,7 @@ initrand(void)
#endif
if (churnrand() < 0)
goto error;
+#endif /* HAVE_LIBGCRYPT. */
return 0;
error:
return -1;
@@ -173,9 +189,11 @@ error:
void
genrand(unsigned char *buf, int buflen)
{
+#ifndef HAVE_LIBGCRYPT
int i;
unsigned char out[PAYLOAD_SZ];
int cpylen = PAYLOAD_SZ;
+#endif /* HAVE_LIBGCRYPT. */
if (gen_hwrand) {
bool hwok = gen_hwrand(buf, buflen);
@@ -183,6 +201,7 @@ genrand(unsigned char *buf, int buflen)
return;
}
+#ifndef HAVE_LIBGCRYPT
for (i = 0; i < buflen; i += cpylen) {
aes_encrypt(&ctx, ctr, out);
incr128(ctr);
@@ -191,6 +210,9 @@ genrand(unsigned char *buf, int buflen)
memcpy(&buf[i], out, cpylen);
}
assert(i == buflen);
+#else
+ gcry_randomize(buf, buflen, GCRY_STRONG_RANDOM);
+#endif /* HAVE_LIBGCRYPT. */
}
/*
diff -up scrub-2.6.1/src/genrand.h.libgcrypt scrub-2.6.1/src/genrand.h
--- scrub-2.6.1/src/genrand.h.libgcrypt 2014-08-20 17:33:43.000000000 -0400
+++ scrub-2.6.1/src/genrand.h 2021-02-22 13:42:48.490217204 -0500
@@ -1,8 +1,14 @@
+#include "config.h"
+
void disable_hwrand(void);
int initrand(void);
-int churnrand(void);
void genrand(unsigned char *buf, int buflen);
+#ifndef HAVE_LIBGCRYPT
+int churnrand(void);
+#endif /* HAVE_LIBGCRYPT. */
+
+
/*
* vi:tabstop=4 shiftwidth=4 expandtab
*/
diff -up scrub-2.6.1/src/Makefile.am.libgcrypt scrub-2.6.1/src/Makefile.am
--- scrub-2.6.1/src/Makefile.am.libgcrypt 2014-08-20 17:33:43.000000000 -0400
+++ scrub-2.6.1/src/Makefile.am 2021-02-22 13:43:47.008492696 -0500
@@ -1,8 +1,6 @@
bin_PROGRAMS = scrub
scrub_SOURCES = \
- aes.c \
- aes.h \
filldentry.c \
filldentry.h \
fillfile.c \
@@ -24,3 +22,9 @@ scrub_SOURCES = \
util.h
scrub_LDADD = $(LIBPTHREAD)
+
+if LIBGCRYPT
+scrub_LDADD += $(gcrypt_LIBS)
+else
+scrub_SOURCES += aes.c aes.h
+endif
diff -up scrub-2.6.1/src/scrub.c.libgcrypt scrub-2.6.1/src/scrub.c
--- scrub-2.6.1/src/scrub.c.libgcrypt 2021-02-22 13:42:48.488217195 -0500
+++ scrub-2.6.1/src/scrub.c 2021-02-22 13:42:48.490217204 -0500
@@ -459,11 +459,13 @@ scrub(char *path, off_t size, const sequ
case PAT_RANDOM:
printf("%s: %-8s", prog, "random");
progress_create(&p, pcol);
+#ifndef HAVE_LIBGCRYPT
if (churnrand() < 0) {
fprintf(stderr, "%s: churnrand: %s\n", prog,
strerror(errno));
exit(1);
}
+#endif /* HAVE_LIBGCRYPT. */
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
(refill_t)genrand, sparse, enospc);
diff -up scrub-2.6.1/test/Makefile.am.libgcrypt scrub-2.6.1/test/Makefile.am
--- scrub-2.6.1/test/Makefile.am.libgcrypt 2014-08-26 14:11:14.000000000 -0400
+++ scrub-2.6.1/test/Makefile.am 2021-02-22 13:44:59.301833042 -0500
@@ -1,8 +1,8 @@
-check_PROGRAMS = pad trand aestest tprogress tgetsize tsig tsize pat
+check_PROGRAMS = pad trand tprogress tgetsize tsig tsize pat
TESTS_ENVIRONMENT = env
TESTS_ENVIRONMENT += "PATH_SCRUB=$(top_builddir)/src/scrub"
-TESTS = t00 t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \
+TESTS = t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \
t17 t18 t19 t20 t21 t22
CLEANFILES = *.out *.diff testfile
@@ -13,17 +13,24 @@ common_sources = \
$(top_srcdir)/src/getsize.c \
$(top_srcdir)/src/genrand.c \
$(top_srcdir)/src/hwrand.c \
- $(top_srcdir)/src/aes.c \
$(top_srcdir)/src/util.c \
$(top_srcdir)/src/progress.c \
$(top_srcdir)/src/sig.c
pad_SOURCES = pad.c $(common_sources)
trand_SOURCES = trand.c $(common_sources)
-aestest_SOURCES = aestest.c $(common_sources)
tprogress_SOURCES = tprogress.c $(common_sources)
tgetsize_SOURCES = tgetsize.c $(common_sources)
tsig_SOURCES = tsig.c $(common_sources)
pat_SOURCES = pat.c $(common_sources)
+if LIBGCRYPT
+AM_LDFLAGS = $(gcrypt_LIBS)
+else
+check_PROGRAMS += aestest
+TESTS += t00
+common_sources += $(top_srcdir)/src/aes.c
+aestest_SOURCES = aestest.c $(common_sources)
+endif
+
EXTRA_DIST = $(TESTS) $(TESTS:%=%.exp)

View File

@ -1,21 +1,22 @@
%bcond_without check
Name: scrub
Version: 2.5.2
Release: 16%{?dist}
Version: 2.6.1
Release: 4%{?dist}
Summary: Disk scrubbing program
License: GPLv2+
Group: System Environment/Base
URL: http://code.google.com/p/diskscrub/
Source0: http://diskscrub.googlecode.com/files/%{name}-%{version}.tar.bz2
BuildRequires: autoconf automake libtool
BuildRequires: libgcrypt-devel
Patch0: scrub-2.5.2-extentonly.patch
Patch1: scrub-2.5.2-remove-aes-implementation.patch
Patch2: scrub-2.5.2-test-use-power-2-filesizes.patch
Patch3: scrub-2.5.2-symlinkresolve.patch
URL: https://github.com/chaos/scrub/
Source0: https://github.com/chaos/scrub/releases/download/%{version}/scrub-%{version}.tar.gz
# https://github.com/chaos/scrub/commit/b90fcb2330d00dbd1e9aeaa2e1a9807f8b80b922.patch
Patch0: scrub-2.6.1-symlinks-to-block-device.patch
# https://github.com/chaos/scrub/commit/27f6452a658f057e3ba6bf9dfda070b6dffc6798.patch
Patch1: scrub-2.6.1-use-libgcrypt.patch
Patch2: scrub-2.6.1-extentonly.patch
Patch3: scrub-2.5.2-test-use-power-2-filesizes.patch
# https://github.com/chaos/scrub/commit/864a454f16ac3e47103064b0e4fe3a9111593e49
Patch4: scrub-2.6.1-analyzer-fixes.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: libgcrypt-devel
BuildRequires: autoconf, automake, libtool
%description
Scrub writes patterns on files or disk devices to make
@ -28,46 +29,60 @@ the file system is full, then scrubbed as in 2).
%prep
%setup -q
%patch0 -p1 -b .extent-only
%patch1 -p1 -b .remove-aes
%patch2 -p1 -b .test-use-power-2-filesizes
%patch3 -p1 -b .symlinkresolve
%patch0 -p1 -b .symlinks-to-block-devices
%patch1 -p1 -b .libgcrypt
%patch2 -p1 -b .extent-only
%patch3 -p1 -b .test-use-power-2-filesizes
%patch4 -p1 -b .analyzer-fixes
autoreconf -ifv --include=config
%build
./autogen.sh
%configure
make %{?_smp_mflags}
%if %{with check}
%check
make check
%endif
%{make_build}
%install
make DESTDIR=%{buildroot} install
%{make_install}
%files
%doc DISCLAIMER COPYING
%license COPYING
%doc DISCLAIMER
%doc README ChangeLog
%{_bindir}/scrub
%{_mandir}/man1/scrub.1*
%changelog
* Mon Aug 16 2021 Sergio Arroutbi <sarroutb@redhat.com> - 2.5.2-16
- Fix covscan issues introduced in previous version
Resolves: rhbz#1920252
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 2.6.1-4
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Thu Aug 12 2021 Sergio Arroutbi <sarroutb@redhat.com> - 2.5.2-15
- Fix for symbolic link resolution
Resolves: rhbz#1920252
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.6.1-3
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jul 16 2019 Daniel Kopecek <dkopecek@redhat.com> - 2.5.2-14
Resolves: rhbz#1689897 - Missing '--extent-only' patch
Resolves: rhbz#1630298 - Removal of component scrub or its crypto from RHEL
* Thu Mar 18 2021 Tom Callaway <spot@fedoraproject.org> - 2.6.1-2
- apply analyzer fixes from upstream
* Tue May 14 2019 Daniel Kopecek <dkopecek@redhat.com> - 2.5.2-13
- spec: added check phase (conditional, enabled by default)
* Wed Feb 24 2021 Tom Callaway <spot@fedoraproject.org> - 2.6.1-1
- update to 2.6.1
- update URLs
- merge patches from Red Hat and upstream
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.2-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (scrub-2.5.2.tar.bz2) = 23815831a356b3a7c6a75354134c49912dc97f9e54130acaa9ee8e80cf839e18238bf69cf6d5aaf79dbbc3dc4195ca78cb6f0d5aca11972726956040fcc424e7
SHA512 (scrub-2.6.1.tar.gz) = 6e434b9d81c5ac473188c37af790c808771204203b3f04a5ca316c6a890f872d1beb73ce4713546e14ae91287d7adaf2fbfa44a30af634c2b3af890e2a0e8640