summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-12-16 14:50:05 +0100
committerErich Eckner <git@eckner.net>2016-12-16 14:50:05 +0100
commitc17a255d63566d8f92bc824eaf8a4768831ce724 (patch)
tree447d228e73a4b18b7e2028ca9e43e5db5ead145e /core
parente954094ad3464f5748d44d316262ff356ffef722 (diff)
downloadcrux-patches-c17a255d63566d8f92bc824eaf8a4768831ce724.tar.xz
coreutils: shred: keep hard linked files from being shredded (option -h to disable)
Diffstat (limited to 'core')
-rw-r--r--core/coreutils/Pkgfile.patch4
-rw-r--r--core/coreutils/coreutils-shred.patch.new67
2 files changed, 70 insertions, 1 deletions
diff --git a/core/coreutils/Pkgfile.patch b/core/coreutils/Pkgfile.patch
index d4886a0..6544681 100644
--- a/core/coreutils/Pkgfile.patch
+++ b/core/coreutils/Pkgfile.patch
@@ -1,16 +1,18 @@
--- Pkgfile 2016-01-21 19:54:43.219280408 +0100
+++ Pkgfile 2016-10-05 21:31:50.026261183 +0200
-@@ -7,12 +7,14 @@
+@@ -7,12 +7,16 @@
version=8.26
release=1
source=(http://ftp.gnu.org/pub/gnu/$name/$name-$version.tar.xz
- coreutils-uname.patch)
++ coreutils-shred.patch
+ coreutils-uname.patch
+ coreutils-uniq.patch)
build() {
cd $name-$version
++ patch -p1 -i $SRC/coreutils-shred.patch
patch -p1 -i $SRC/coreutils-uname.patch
+ patch -p1 -i $SRC/coreutils-uniq.patch
export FORCE_UNSAFE_CONFIGURE=1
diff --git a/core/coreutils/coreutils-shred.patch.new b/core/coreutils/coreutils-shred.patch.new
new file mode 100644
index 0000000..fe08175
--- /dev/null
+++ b/core/coreutils/coreutils-shred.patch.new
@@ -0,0 +1,67 @@
+--- old/src/shred.c 2016-12-16 14:36:58.819399157 +0100
++++ new/src/shred.c 2016-12-16 14:35:27.590639035 +0100
+@@ -129,6 +129,7 @@
+ struct Options
+ {
+ bool force; /* -f flag: chmod files if necessary */
++ bool shred_hard_links; /* -h flag: also shred file if nlink > 1 */
+ size_t n_iterations; /* -n flag: Number of iterations */
+ off_t size; /* -s flag: size of file */
+ enum remove_method remove_file; /* -u flag: remove file after shredding */
+@@ -148,6 +149,7 @@
+ {
+ {"exact", no_argument, NULL, 'x'},
+ {"force", no_argument, NULL, 'f'},
++ {"keep-hard-links", no_argument, NULL, 'h'},
+ {"iterations", required_argument, NULL, 'n'},
+ {"size", required_argument, NULL, 's'},
+ {"random-source", required_argument, NULL, RANDOM_SOURCE_OPTION},
+@@ -180,6 +182,7 @@
+
+ printf (_("\
+ -f, --force change permissions to allow writing if necessary\n\
++ -h, --keep-hard-links do not shred hard linked files\n\
+ -n, --iterations=N overwrite N times instead of the default (%d)\n\
+ --random-source=FILE get random bytes from FILE\n\
+ -s, --size=N shred this many bytes (suffixes like K, M, G accepted)\n\
+@@ -891,6 +894,11 @@
+ error (0, 0, _("%s: file has negative size"), qname);
+ return false;
+ }
++ else if (st.st_nlink > 1 && ! flags->shred_hard_links)
++ {
++ error (0, 0, _("%s: file has %d > 1 hard links, use -h to shred anyway"), qname, st.st_nlink);
++ return false;
++ }
+
+ /* Allocate pass array */
+ passarray = xnmalloc (flags->n_iterations, sizeof *passarray);
+@@ -1218,7 +1226,7 @@
+ main (int argc, char **argv)
+ {
+ bool ok = true;
+- struct Options flags = { 0, };
++ struct Options flags = { 0, 0, };
+ char **file;
+ int n_files;
+ int c;
+@@ -1236,7 +1244,7 @@
+ flags.n_iterations = DEFAULT_PASSES;
+ flags.size = -1;
+
+- while ((c = getopt_long (argc, argv, "fn:s:uvxz", long_opts, NULL)) != -1)
++ while ((c = getopt_long (argc, argv, "fhn:s:uvxz", long_opts, NULL)) != -1)
+ {
+ switch (c)
+ {
+@@ -1244,6 +1252,10 @@
+ flags.force = true;
+ break;
+
++ case 'h':
++ flags.shred_hard_links = true;
++ break;
++
+ case 'n':
+ flags.n_iterations = xdectoumax (optarg, 0,
+ MIN (ULONG_MAX,