Hello community, here is the log from the commit of package srm for openSUSE:Factory checked in at 2015-03-27 09:41:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/srm (Old) and /work/SRC/openSUSE:Factory/.srm.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "srm" Changes: -------- --- /work/SRC/openSUSE:Factory/srm/srm.changes 2014-09-03 08:30:25.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.srm.new/srm.changes 2015-03-27 09:41:52.000000000 +0100 @@ -1,0 +2,11 @@ +Thu Mar 26 23:19:01 UTC 2015 - [email protected] + +- Update to version 1.2.15 + * fix handling of files > 2GB on Windows. + * fix handling of symlinks to files owned by root. +- Changes from version 1.2.14 + * fix fill() function, this fixes DoE and Gutmann modes. + * new --rcmp mode. + * use simple mode by default and not Gutmann 35 pass. + +------------------------------------------------------------------- Old: ---- srm-1.2.13.tar.gz New: ---- srm-1.2.15.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ srm.spec ++++++ --- /var/tmp/diff_new_pack.RUVATM/_old 2015-03-27 09:41:52.000000000 +0100 +++ /var/tmp/diff_new_pack.RUVATM/_new 2015-03-27 09:41:52.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package srm # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,14 +17,14 @@ Name: srm -Version: 1.2.13 +Version: 1.2.15 Release: 0 # COPYING file has the MIT license, but also a extra no-advertising clause Summary: A secure replacement for rm License: SUSE-SGI-FreeB-2.0 Group: Hardware/Other Url: http://srm.sf.net -Source0: http://sourceforge.net/projects/srm/files/1.2.13/srm-1.2.13.tar.gz +Source0: http://sourceforge.net/projects/srm/files/%{version}/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -45,6 +45,7 @@ %files %defattr(-, root, root) %doc COPYING +%{_bindir}/fill_test %{_bindir}/%{name} %{_mandir}/man?/%{name}* ++++++ srm-1.2.13.tar.gz -> srm-1.2.15.tar.gz ++++++ ++++ 1701 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/AUTHORS new/srm-1.2.15/AUTHORS --- old/srm-1.2.13/AUTHORS 2014-01-12 20:14:22.000000000 +0100 +++ new/srm-1.2.15/AUTHORS 2015-02-26 17:12:03.000000000 +0100 @@ -25,3 +25,5 @@ OsX ressource fork handling in 1.2.9 Dirk Jagdmann - misc bugfixes and general maintenance starting with 1.2.9 + +Pieter de Boer - fixed symlink problem in 1.2.15 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/Makefile.am new/srm-1.2.15/Makefile.am --- old/srm-1.2.13/Makefile.am 2014-01-13 21:50:00.000000000 +0100 +++ new/srm-1.2.15/Makefile.am 2015-02-26 17:12:03.000000000 +0100 @@ -1,5 +1,5 @@ EXTRA_DIST = ChangeLog AUTHORS COPYING INSTALL NEWS README TODO srm.spec.in test.sh srm.sln srm.vcxproj srmtest.sh test.bat -SUBDIRS = lib src doc win +SUBDIRS = lib src doc win test rpm: dist rpmbuild -tb $(distdir).tar.gz diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/NEWS new/srm-1.2.15/NEWS --- old/srm-1.2.13/NEWS 2014-03-18 08:27:36.000000000 +0100 +++ new/srm-1.2.15/NEWS 2015-02-26 17:12:03.000000000 +0100 @@ -1,5 +1,14 @@ This is a summary of user visible changes in srm. +release 1.2.15 + fix handling of files > 2GB on Windows. + fix handling of symlinks to files owned by root. + +release 1.2.14 + fix fill() function, this fixes DoE and Gutmann modes. + new --rcmp mode. + use simple mode by default and not Gutmann 35 pass. + release 1.2.13 fix handling of OsX resource forks. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/TODO new/srm-1.2.15/TODO --- old/srm-1.2.13/TODO 2014-01-12 20:14:22.000000000 +0100 +++ new/srm-1.2.15/TODO 2015-02-26 17:12:02.000000000 +0100 @@ -25,8 +25,6 @@ write to /proc filesystem. - research if special erase commands for SSD are available to userspace + http://en.wikipedia.org/wiki/Trim_%28computing%29 -- HPux test -- Solaris test -- AIX test -- whatever POSIX platform test +- bash completion diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/configure.ac new/srm-1.2.15/configure.ac --- old/srm-1.2.13/configure.ac 2014-01-13 22:25:18.000000000 +0100 +++ new/srm-1.2.15/configure.ac 2015-02-26 17:12:02.000000000 +0100 @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT(srm, 1.2.13) +AC_INIT(srm, 1.2.15) AC_CONFIG_SRCDIR([src/rename_unlink.c]) AM_INIT_AUTOMAKE AC_CONFIG_HEADER(config.h) @@ -21,7 +21,7 @@ #include <linux/fs.h> #endif ]]) - + dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_DIAGNOSE([obsolete],[AC_STRUCT_ST_BLKSIZE: @@ -49,5 +49,5 @@ AC_MSG_RESULT(no) fi -AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile lib/Makefile win/Makefile srm.spec doc/srm.1]) +AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile lib/Makefile win/Makefile srm.spec doc/srm.1 test/Makefile]) AC_OUTPUT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/doc/Makefile.am new/srm-1.2.15/doc/Makefile.am --- old/srm-1.2.13/doc/Makefile.am 2014-01-12 21:29:12.000000000 +0100 +++ new/srm-1.2.15/doc/Makefile.am 2015-02-26 17:12:03.000000000 +0100 @@ -9,4 +9,4 @@ cp $< ../../www/ clean-local: - $(RM) srm.html + rm -f srm.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/doc/srm.1 new/srm-1.2.15/doc/srm.1 --- old/srm-1.2.13/doc/srm.1 2014-03-18 08:28:19.000000000 +0100 +++ new/srm-1.2.15/doc/srm.1 2015-02-26 17:12:27.000000000 +0100 @@ -1,4 +1,4 @@ -.TH "srm" "1" "1.2.13" "Matt Gauthier, Dirk Jagdmann" "" +.TH "srm" "1" "1.2.15" "Matt Gauthier, Dirk Jagdmann" "" .SH "NAME" srm \- securely remove files or directories .SH "SYNOPSIS" @@ -10,13 +10,14 @@ removes each specified file by overwriting, renaming, and truncating it before unlinking. This prevents other people from undeleting or recovering any information about the file from the command line. -By default srm uses 35 passes to overwrite the file's contents. -If this seems overkill you can use use the +By default srm uses the simple mode to overwrite the file's contents. +You can choose a different overwrite mode with \fB\-\-dod\fR, \fB\-\-doe\fR, \fB\-\-openbsd\fR, -\fB\-\-simple\fR option which use less passes. -If you specify more than one option (of those listed above) they are executed in the order shown above. +\fB\-\-rcmp\fR, +\fB\-\-gutmann\fR. +If you specify more than one mode option, the last option is used. .P You can use .B srm @@ -56,11 +57,12 @@ argument. (Not supported on Windows) .TP \fB\-s\fR, \fB\-\-simple\fR -only overwrite the file with a single pass of zero bytes +Overwrite the file with a single pass of 0x00 bytes. +This is the default mode. .TP \fB\-P\fR, \fB\-\-openbsd\fR OpenBSD compatible rm. Files are overwritten three times, first with the byte -0xff, then 0x00, and then 0xff again, before they are deleted. +0xFF, then 0x00, and then 0xFF again, before they are deleted. .TP \fB\-D\fR, \fB\-\-dod\fR US Dod compliant 7\-pass overwrite. @@ -70,17 +72,24 @@ See http://cio.energy.gov/CS\-11_Clearing_and_Media_Sanitization_Guidance.pdf for details. .TP \fB\-G\fR, \fB\-\-gutmann\fR -Use the 35\-pass Gutmann method. This is the default and slowest overwrite mode. +Use the 35\-pass Gutmann method. See http://en.wikipedia.org/wiki/Gutmann_method for details. .TP +\fB\-C\fR, \fB\-\-rcmp\fR +Royal Canadian Mounted Police compliant 3\-pass overwrite. +First pass writes 0x00 bytes. +Second pass writes 0xFF bytes. +Third pass writes "RCMP". +See https://www.cse-cst.gc.ca/en/node/270/html/10572 for details. +.TP \fB\-v\fR, \fB\-\-verbose\fR explain what is being done. Specify this option multiple times to increase verbosity. .TP \fB\-h\fR, \fB\-\-help\fR -display this help and exit +display this help and exit. .TP \fB\-V\fR, \fB\-\-version\fR -output version information and exit +output version information and exit. .SH "SIGNALS" .TP \fBSIGINFO, SIGUSR2\fR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/doc/srm.1.in new/srm-1.2.15/doc/srm.1.in --- old/srm-1.2.13/doc/srm.1.in 2014-01-12 21:43:19.000000000 +0100 +++ new/srm-1.2.15/doc/srm.1.in 2015-02-26 17:12:03.000000000 +0100 @@ -10,13 +10,14 @@ removes each specified file by overwriting, renaming, and truncating it before unlinking. This prevents other people from undeleting or recovering any information about the file from the command line. -By default srm uses 35 passes to overwrite the file's contents. -If this seems overkill you can use use the +By default srm uses the simple mode to overwrite the file's contents. +You can choose a different overwrite mode with \fB\-\-dod\fR, \fB\-\-doe\fR, \fB\-\-openbsd\fR, -\fB\-\-simple\fR option which use less passes. -If you specify more than one option (of those listed above) they are executed in the order shown above. +\fB\-\-rcmp\fR, +\fB\-\-gutmann\fR. +If you specify more than one mode option, the last option is used. .P You can use .B srm @@ -56,11 +57,12 @@ argument. (Not supported on Windows) .TP \fB\-s\fR, \fB\-\-simple\fR -only overwrite the file with a single pass of zero bytes +Overwrite the file with a single pass of 0x00 bytes. +This is the default mode. .TP \fB\-P\fR, \fB\-\-openbsd\fR OpenBSD compatible rm. Files are overwritten three times, first with the byte -0xff, then 0x00, and then 0xff again, before they are deleted. +0xFF, then 0x00, and then 0xFF again, before they are deleted. .TP \fB\-D\fR, \fB\-\-dod\fR US Dod compliant 7\-pass overwrite. @@ -70,17 +72,24 @@ See http://cio.energy.gov/CS\-11_Clearing_and_Media_Sanitization_Guidance.pdf for details. .TP \fB\-G\fR, \fB\-\-gutmann\fR -Use the 35\-pass Gutmann method. This is the default and slowest overwrite mode. +Use the 35\-pass Gutmann method. See http://en.wikipedia.org/wiki/Gutmann_method for details. .TP +\fB\-C\fR, \fB\-\-rcmp\fR +Royal Canadian Mounted Police compliant 3\-pass overwrite. +First pass writes 0x00 bytes. +Second pass writes 0xFF bytes. +Third pass writes "RCMP". +See https://www.cse-cst.gc.ca/en/node/270/html/10572 for details. +.TP \fB\-v\fR, \fB\-\-verbose\fR explain what is being done. Specify this option multiple times to increase verbosity. .TP \fB\-h\fR, \fB\-\-help\fR -display this help and exit +display this help and exit. .TP \fB\-V\fR, \fB\-\-version\fR -output version information and exit +output version information and exit. .SH "SIGNALS" .TP \fBSIGINFO, SIGUSR2\fR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/src/Makefile.am new/srm-1.2.15/src/Makefile.am --- old/srm-1.2.13/src/Makefile.am 2014-01-12 20:14:21.000000000 +0100 +++ new/srm-1.2.15/src/Makefile.am 2015-02-26 17:12:02.000000000 +0100 @@ -1,7 +1,7 @@ AM_CPPFLAGS = -I../lib bin_PROGRAMS = srm -srm_SOURCES = error.c main.c random.c rename_unlink.c sunlink.c tree_walker.c srm.h impl.h +srm_SOURCES = error.c main.c random.c rename_unlink.c sunlink.c tree_walker.c srm.h impl.h fill.c srm_LDADD = ../lib/libsrm.a AM_CFLAGS = -Wall diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/src/fill.c new/srm-1.2.15/src/fill.c --- old/srm-1.2.13/src/fill.c 1970-01-01 01:00:00.000000000 +0100 +++ new/srm-1.2.15/src/fill.c 2015-02-26 17:12:02.000000000 +0100 @@ -0,0 +1,14 @@ +/* this file is part of srm http://srm.sourceforge.net/ + It is licensed under the MIT/X11 license */ + +void fill(unsigned char *dst, unsigned dst_len, const unsigned char *src, const unsigned src_len) +{ + unsigned i = 0; + while(dst_len > 0) { + *dst++ = src[i]; + if (++i == src_len) { + i = 0; + } + --dst_len; + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/src/impl.h new/srm-1.2.15/src/impl.h --- old/srm-1.2.13/src/impl.h 2014-01-12 20:14:21.000000000 +0100 +++ new/srm-1.2.15/src/impl.h 2015-02-26 17:12:02.000000000 +0100 @@ -46,6 +46,7 @@ void init_random(const unsigned int seed); unsigned char random_char(void); int randomize_buffer(unsigned char *buffer, int length); +void fill(unsigned char *dst, unsigned dst_len, const unsigned char *src, const unsigned src_len); #ifdef __cplusplus } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/src/main.c new/srm-1.2.15/src/main.c --- old/srm-1.2.13/src/main.c 2014-01-13 21:48:56.000000000 +0100 +++ new/srm-1.2.15/src/main.c 2015-02-26 17:12:02.000000000 +0100 @@ -35,6 +35,7 @@ { "dod", no_argument, NULL, 'D'}, { "doe", no_argument, NULL, 'E'}, { "gutmann", no_argument, NULL, 'G'}, + { "rcmp", no_argument, NULL, 'C'}, { "verbose", no_argument, NULL, 'v' }, { "help", no_argument, &show_help, 'h' }, { "version", no_argument, &show_version, 'V' }, @@ -44,14 +45,14 @@ int main(int argc, char *argv[]) { int opt, q; char* *trees; - int options = SRM_MODE_35; + int options = SRM_MODE_SIMPLE; if ( (program_name = strrchr(argv[0], SRM_DIRSEP)) != NULL) program_name++; else program_name = argv[0]; - while ((opt = getopt_long(argc, argv, "dDEfGhirRPsvVx", longopts, NULL)) != -1) + while ((opt = getopt_long(argc, argv, "CdDEfGhirRPsvVx", longopts, NULL)) != -1) { switch (opt) { @@ -73,6 +74,7 @@ case 'D': options &= ~SRM_MODE_MASK; options |= SRM_MODE_DOD; break; case 'E': options &= ~SRM_MODE_MASK; options |= SRM_MODE_DOE; break; case 'G': options &= ~SRM_MODE_MASK; options |= SRM_MODE_35; break; + case 'C': options &= ~SRM_MODE_MASK; options |= SRM_MODE_RCMP; break; case 'V': show_version=1; break; case 'v': if((options & SRM_OPT_V) < SRM_OPT_V) @@ -95,11 +97,12 @@ #ifndef _MSC_VER " -x, --one-file-system do not cross file system boundaries\n" #endif - " -s, --simple overwrite with single pass using 0x00\n" + " -s, --simple overwrite with single pass using 0x00 (default)\n" " -P, --openbsd overwrite with three passes like OpenBSD rm\n" " -D, --dod overwrite with 7 US DoD compliant passes\n" " -E, --doe overwrite with 3 US DoE compliant passes\n" - " -G, --gutmann overwrite with 35-pass Gutmann method (default)\n" + " -G, --gutmann overwrite with 35-pass Gutmann method\n" + " -C, --rcmp overwrite with Royal Canadian Mounted Police passes\n" " -r, -R, --recursive remove the contents of directories\n" " -v, --verbose explain what is being done\n" " -h, --help display this help and exit\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/src/srm.h new/srm-1.2.15/src/srm.h --- old/srm-1.2.13/src/srm.h 2014-01-12 20:14:21.000000000 +0100 +++ new/srm-1.2.15/src/srm.h 2015-02-26 17:12:02.000000000 +0100 @@ -24,9 +24,11 @@ #define SRM_MODE_DOE (1 << 19) /** 35-pass overwrite mode */ #define SRM_MODE_35 (1 << 20) +/** RCMP overwrite mode */ +#define SRM_MODE_RCMP (1 << 21) /** bitmask of overwrite modes */ -#define SRM_MODE_MASK (SRM_MODE_SIMPLE|SRM_MODE_OPENBSD|SRM_MODE_DOD|SRM_MODE_DOE|SRM_MODE_35) +#define SRM_MODE_MASK (SRM_MODE_SIMPLE|SRM_MODE_OPENBSD|SRM_MODE_DOD|SRM_MODE_DOE|SRM_MODE_35|SRM_MODE_RCMP) #ifdef __cplusplus extern "C" { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/src/sunlink.c new/srm-1.2.15/src/sunlink.c --- old/srm-1.2.13/src/sunlink.c 2014-03-18 08:27:36.000000000 +0100 +++ new/srm-1.2.15/src/sunlink.c 2015-02-26 17:12:02.000000000 +0100 @@ -75,20 +75,25 @@ #ifndef O_SYNC #define O_SYNC 0 #endif +#ifndef _O_BINARY +#define _O_BINARY 0 +#endif #define KiB 1024 #define MiB (KiB*KiB) #define GiB (KiB*KiB*KiB) +#ifdef _MSC_VER +typedef long long my_off_t; +#else +typedef off_t my_off_t; +#endif + struct srm_target { int fd; const char* file_name; -#ifdef _MSC_VER - long long file_size; -#else - off_t file_size; -#endif + my_off_t file_size; unsigned char *buffer; unsigned buffer_size; int options; @@ -187,18 +192,7 @@ #endif } -static void fill(unsigned char *dst, unsigned dst_len, const unsigned char *src, const unsigned src_len) -{ - unsigned i = 0; - while(dst_len > 0) { - *dst = src[i]; - if (++i == src_len) { - i = 0; - } - --dst_len; - } -} - +#if defined(HAVE_ATTR_XATTR_H) || defined(HAVE_SYS_XATTR_H) || defined(HAVE_SYS_EXTATTR_H) static int extattr_overwrite(struct srm_target *srm, const int pass, const int attrnamespace) { char *list = NULL; @@ -243,9 +237,9 @@ /* iterate list of attributes */ for(i = 0; i < len; i += key_len + 1) { - int ret; - ssize_t val_len; - char *key; + int ret = 0; + ssize_t val_len = 0; + char *key = NULL; #if defined(HAVE_ATTR_XATTR_H) || defined(HAVE_SYS_XATTR_H) key = list + i; key_len = strlen(key); @@ -263,11 +257,11 @@ val_len = extattr_get_fd(srm->fd, attrnamespace, key, NULL, 0); #endif if ( ((srm->options & SRM_OPT_V) > 1) && pass == 1) { - char *namespace=""; + char *name_space=""; #if defined(HAVE_SYS_EXTATTR_H) extattr_namespace_to_string(attrnamespace, &namespace); #endif - error("found extended attribute %s %s of %i bytes", namespace, key, (int)val_len); + error("found extended attribute %s %s of %i bytes", name_space, key, (int)val_len); } if (val_len > (ssize_t)value_size) { value_size = val_len; @@ -290,15 +284,15 @@ } } -#ifdef _MSC_VER (void)attrnamespace; -#endif return 0; } +#endif static int overwrite(struct srm_target *srm, const int pass) { - off_t i = 0; + unsigned last_val = ~0u; + my_off_t i = 0; ssize_t w; if(!srm) return -1; @@ -325,7 +319,7 @@ return -1; } - if(srm->file_size < (off_t)(srm->buffer_size)) + if(srm->file_size < (my_off_t)(srm->buffer_size)) { w=writen(srm->fd, srm->buffer, srm->file_size); if(w != srm->file_size) @@ -333,21 +327,34 @@ } else { - while (i < srm->file_size - (off_t)srm->buffer_size) + while (i < srm->file_size - (my_off_t)srm->buffer_size) { w=writen(srm->fd, srm->buffer, srm->buffer_size); if(w != (ssize_t)(srm->buffer_size)) return -1; i += w; - if((srm->options & SRM_OPT_V) > 1 || SIGINT_received) - { - if(srm->file_size < MiB) - printf("\rpass %i %uKiB/%uKiB ", pass, (unsigned)(i/KiB), (unsigned)(srm->file_size/KiB)); - else if(srm->file_size < GiB) - printf("\rpass %i %uMiB/%uMiB ", pass, (unsigned)(i/MiB), (unsigned)(srm->file_size/MiB)); - else - printf("\rpass %i %uGiB/%uGiB ", pass, (unsigned)(i/GiB), (unsigned)(srm->file_size/GiB)); + if ((srm->options & SRM_OPT_V) > 1 || SIGINT_received) { + unsigned val = 0, file_size = 0; + char c = '.'; + if (srm->file_size < MiB) { + val = i / KiB; + file_size = (unsigned)(srm->file_size/KiB); + c = 'K'; + } else if(srm->file_size < GiB) { + val = i / MiB; + file_size = (unsigned)(srm->file_size/MiB); + c = 'M'; + } else { + val = i / GiB; + file_size = (unsigned)(srm->file_size/GiB); + c = 'G'; + } + if (val != last_val) { + printf("\rpass %i %u%ciB/%u%ciB ", pass, val, c, file_size, c); + fflush(stdout); + last_val = val; + } if(SIGINT_received) { @@ -356,8 +363,8 @@ else putchar('\n'); SIGINT_received=0; + fflush(stdout); } - fflush(stdout); } } w=writen(srm->fd, srm->buffer, srm->file_size - i); @@ -424,6 +431,17 @@ return overwrite(srm, pass); } +static int overwrite_string(struct srm_target *srm, const int pass, const char *str) +{ + if(!srm) return -1; + if(!srm->buffer) return -1; + if(srm->buffer_size < 1) return -1; + if (!str) return -1; + + fill(srm->buffer, srm->buffer_size, (const unsigned char*)str, strlen(str)); + return overwrite(srm, pass); +} + static int overwrite_selector(struct srm_target *srm) { if(!srm) return -1; @@ -472,6 +490,14 @@ error("Simple mode"); if(overwrite_byte(srm, 1, 0x00) < 0) return -1; } + else if(srm->options & SRM_MODE_RCMP) + { + if((srm->options&SRM_OPT_V) > 1) + error("RCMP mode"); + if(overwrite_byte(srm, 1, 0x00) < 0) return -1; + if(overwrite_byte(srm, 2, 0xFF) < 0) return -1; + if(overwrite_string(srm, 3, "RCMP") < 0) return -1; + } else { if(! (srm->options & SRM_MODE_35)) @@ -518,11 +544,11 @@ } #ifdef _MSC_VER -static long long getFileSize(WCHAR *fn) +static my_off_t getFileSize(WCHAR *fn) { /* it's a pain, but it seems that the only way to get the size of an alternate data stream is to read it once. */ #if 1 - long long size = 0, r; + my_off_t size = 0, r; int fd = _wopen(fn, O_RDONLY); if (fd < 0) return 0; do { @@ -566,24 +592,40 @@ int sunlink_impl(const char *path, const int options) { - const int oflags = O_WRONLY|O_SYNC; + const int oflags = O_WRONLY|O_SYNC|_O_BINARY; struct srm_target srm; +#if defined(_MSC_VER) + struct __stat64 statbuf; +#else struct stat statbuf; -#ifdef __unix__ +#endif +#if defined(__unix__) || defined(__APPLE__) struct flock flock; #endif /* check function arguments */ if(!path) return -1; + memset(&srm, 0, sizeof(srm)); srm.file_name = path; srm.options = options; /* check if path exists */ - if (lstat(path, &statbuf) < 0) +#if defined(_MSC_VER) + if (_stat64(path, &statbuf) < 0) { return -1; + } +#else + if (lstat(path, &statbuf) < 0) { + return -1; + } +#endif srm.file_size = statbuf.st_size; + if (srm.file_size < 0) { + error("%s : file size: %lli, can not work with negative values", path, (long long)srm.file_size); + return -1; + } #ifdef _MSC_VER srm.buffer_size = 4096; #else @@ -607,7 +649,7 @@ if(ioctl(srm.fd, BLKSSZGET, &secsize) < 0) { perror("could not ioctl(BLKSSZGET)"); - return 1; + return -1; } if((options&SRM_OPT_V) > 2) error("sector size %i bytes", secsize); @@ -615,7 +657,7 @@ if(ioctl(srm.fd, BLKGETSIZE, &blocks) < 0) { perror("could not ioctl(BLKGETSIZE)"); - return 1; + return -1; } if((options&SRM_OPT_V) > 2) error("BLKGETSIZE %i blocks", (int)blocks); @@ -623,7 +665,7 @@ if(ioctl(srm.fd, BLKGETSIZE64, &u) < 0) { perror("could not ioctl(BLKGETSIZE64)"); - return 1; + return -1; } if((options&SRM_OPT_V) > 2) error("BLKGETSIZE64 %llu bytes", (unsigned long long)u); @@ -772,9 +814,21 @@ if ( (srm.fd = open(srm.file_name, oflags)) < 0) return -1; -#ifdef __unix__ - if (fcntl(srm.fd, F_WRLCK, &flock) < 0) { +#if defined(__unix__) || defined(__APPLE__) + flock.l_type = F_WRLCK; + flock.l_whence = SEEK_SET; + flock.l_start = 0; + flock.l_len = 0; + if (fcntl(srm.fd, F_SETLK, &flock) < 0) { int e=errno; + flock.l_type = F_WRLCK; + flock.l_whence = SEEK_SET; + flock.l_start = 0; + flock.l_len = 0; + flock.l_pid = 0; + if (fcntl(srm.fd, F_GETLK, &flock) == 0 && flock.l_pid > 0) { + error("can't unlink %s, locked by process %i", srm.file_name, flock.l_pid); + } close(srm.fd); errno=e; return -1; @@ -875,6 +929,26 @@ } #endif /* HAVE_CHFLAGS */ + /* check that the srm struct contains useful values */ + if (srm.file_name == 0) { + error("internal error: srm.file_name is NULL"); + close(srm.fd); + errno = ENOSYS; + return -1; + } + if (srm.file_size == 0) { + error("internal error: srm.file_size is 0"); + close(srm.fd); + errno = ENOSYS; + return -1; + } + if (srm.buffer_size == 0) { + error("internal error: srm.buffer_size is 0"); + close(srm.fd); + errno = ENOSYS; + return -1; + } + if(overwrite_selector(&srm) < 0) { int e=errno; @@ -935,7 +1009,11 @@ goto rsrc_fork_failed; } - if (fcntl(rsrc.fd, F_WRLCK, &flock) == -1) + flock.l_type = F_WRLCK; + flock.l_whence = SEEK_SET; + flock.l_start = 0; + flock.l_len = 0; + if (fcntl(rsrc.fd, F_SETLK, &flock) == -1) { close(rsrc.fd); goto rsrc_fork_failed; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/src/tree_walker.c new/srm-1.2.15/src/tree_walker.c --- old/srm-1.2.13/src/tree_walker.c 2014-01-12 20:14:21.000000000 +0100 +++ new/srm-1.2.15/src/tree_walker.c 2015-02-26 17:12:02.000000000 +0100 @@ -66,12 +66,22 @@ static int check_perms(const char *path) { int fd=-1; +#ifdef _MSC_VER + struct __stat64 statbuf; +#else struct stat statbuf; +#endif if(!path) return 0; - if( (stat(path, &statbuf) < 0) && (lstat(path, &statbuf) < 0) ) - return 0; +#ifdef _MSC_VER + if (_stat64(path, &statbuf) < 0) +#else + if (lstat(path, &statbuf) < 0) +#endif + { + return 0; + } if ( S_ISREG(statbuf.st_mode) && ((fd = open(path, O_WRONLY)) < 0) && (errno == EACCES) ) { @@ -95,7 +105,11 @@ static int prompt_file(const char *path, const int options) { int fd=-1, return_value=1; +#ifdef _MSC_VER + struct __stat64 statbuf; +#else struct stat statbuf; +#endif if(!path) return 0; @@ -106,7 +120,11 @@ return check_perms(path); } - if( (stat(path, &statbuf) < 0) && (lstat(path, &statbuf) < 0) ) +#ifdef _MSC_VER + if (_stat64(path, &statbuf) < 0) +#else + if (lstat(path, &statbuf) < 0) +#endif { errorp("could not stat %s", path); return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/srm.sln new/srm-1.2.15/srm.sln --- old/srm-1.2.13/srm.sln 2014-01-12 20:14:22.000000000 +0100 +++ new/srm-1.2.15/srm.sln 2015-02-26 17:12:03.000000000 +0100 @@ -3,11 +3,14 @@ # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "srm", "srm.vcxproj", "{BD29D4C0-86D8-4D9F-9C16-EC1055D4DCAB}" ProjectSection(ProjectDependencies) = postProject + {C319806D-A54B-422C-884D-A5AA93A51FB0} = {C319806D-A54B-422C-884D-A5AA93A51FB0} {1A35BAA0-B234-4061-9BDB-138E20F9E3FD} = {1A35BAA0-B234-4061-9BDB-138E20F9E3FD} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ln", "ln\ln.vcxproj", "{1A35BAA0-B234-4061-9BDB-138E20F9E3FD}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "createfile", "createfile\createfile.vcxproj", "{C319806D-A54B-422C-884D-A5AA93A51FB0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -22,6 +25,10 @@ {1A35BAA0-B234-4061-9BDB-138E20F9E3FD}.Debug|Win32.Build.0 = Debug|Win32 {1A35BAA0-B234-4061-9BDB-138E20F9E3FD}.Release|Win32.ActiveCfg = Release|Win32 {1A35BAA0-B234-4061-9BDB-138E20F9E3FD}.Release|Win32.Build.0 = Release|Win32 + {C319806D-A54B-422C-884D-A5AA93A51FB0}.Debug|Win32.ActiveCfg = Debug|Win32 + {C319806D-A54B-422C-884D-A5AA93A51FB0}.Debug|Win32.Build.0 = Debug|Win32 + {C319806D-A54B-422C-884D-A5AA93A51FB0}.Release|Win32.ActiveCfg = Release|Win32 + {C319806D-A54B-422C-884D-A5AA93A51FB0}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/srm.vcxproj new/srm-1.2.15/srm.vcxproj --- old/srm-1.2.13/srm.vcxproj 2014-01-12 20:14:22.000000000 +0100 +++ new/srm-1.2.15/srm.vcxproj 2015-02-26 17:12:02.000000000 +0100 @@ -120,6 +120,7 @@ <ClCompile Include="src\error.c" /> <ClCompile Include="lib\getopt.c" /> <ClCompile Include="lib\getopt1.c" /> + <ClCompile Include="src\fill.c" /> <ClCompile Include="src\main.c" /> <ClCompile Include="src\random.c" /> <ClCompile Include="src\rename_unlink.c" /> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/test/Makefile.am new/srm-1.2.15/test/Makefile.am --- old/srm-1.2.13/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/srm-1.2.15/test/Makefile.am 2015-02-26 17:12:03.000000000 +0100 @@ -0,0 +1,5 @@ +AM_CPPFLAGS = -I../lib -I../src +AM_CFLAGS = -Wall + +bin_PROGRAMS = fill_test +fill_test_SOURCES = ../src/fill.c fill_test.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/test/fill_test.c new/srm-1.2.15/test/fill_test.c --- old/srm-1.2.13/test/fill_test.c 1970-01-01 01:00:00.000000000 +0100 +++ new/srm-1.2.15/test/fill_test.c 2015-02-26 17:12:02.000000000 +0100 @@ -0,0 +1,82 @@ +#undef NDEBUG +#include "impl.h" +#include <assert.h> +#include <string.h> +#include <stdio.h> +int main() +{ + unsigned char src[3]; + src[0] = 1; + src[1] = 2; + src[2] = 3; + + unsigned char dst[10]; + + memset(dst, 0, sizeof(dst)); + fill(dst, 0, src, sizeof(src)); + assert(dst[0] == 0); + assert(dst[1] == 0); + assert(dst[2] == 0); + assert(dst[3] == 0); + assert(dst[4] == 0); + assert(dst[5] == 0); + assert(dst[6] == 0); + assert(dst[7] == 0); + assert(dst[8] == 0); + assert(dst[9] == 0); + + memset(dst, 0, sizeof(dst)); + fill(dst, 1, src, sizeof(src)); + assert(dst[0] == 1); + assert(dst[1] == 0); + assert(dst[2] == 0); + assert(dst[3] == 0); + assert(dst[4] == 0); + assert(dst[5] == 0); + assert(dst[6] == 0); + assert(dst[7] == 0); + assert(dst[8] == 0); + assert(dst[9] == 0); + + memset(dst, 0, sizeof(dst)); + fill(dst, 3, src, sizeof(src)); + assert(dst[0] == 1); + assert(dst[1] == 2); + assert(dst[2] == 3); + assert(dst[3] == 0); + assert(dst[4] == 0); + assert(dst[5] == 0); + assert(dst[6] == 0); + assert(dst[7] == 0); + assert(dst[8] == 0); + assert(dst[9] == 0); + + memset(dst, 0, sizeof(dst)); + fill(dst, 4, src, sizeof(src)); + assert(dst[0] == 1); + assert(dst[1] == 2); + assert(dst[2] == 3); + assert(dst[3] == 1); + assert(dst[4] == 0); + assert(dst[5] == 0); + assert(dst[6] == 0); + assert(dst[7] == 0); + assert(dst[8] == 0); + assert(dst[9] == 0); + + memset(dst, 0, sizeof(dst)); + fill(dst, sizeof(dst), src, sizeof(src)); + assert(dst[0] == 1); + assert(dst[1] == 2); + assert(dst[2] == 3); + assert(dst[3] == 1); + assert(dst[4] == 2); + assert(dst[5] == 3); + assert(dst[6] == 1); + assert(dst[7] == 2); + assert(dst[8] == 3); + assert(dst[9] == 1); + + puts("fill() test passed."); + return 0; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/test.bat new/srm-1.2.15/test.bat --- old/srm-1.2.13/test.bat 2014-01-13 21:48:56.000000000 +0100 +++ new/srm-1.2.15/test.bat 2015-02-26 17:12:02.000000000 +0100 @@ -6,7 +6,7 @@ echo "the remove test" > test.txt echo "first alternate" > test.txt:first echo "and the 2nd alternate data stream" > test.txt:second -%1\srm.exe -vvvs test.txt +%1\srm.exe -vvv test.txt IF EXIST test.txt ( echo could not remove test.txt in ads test! exit @@ -15,8 +15,8 @@ echo "The hard link test" > test2.txt del link.txt %1\ln.exe link.txt test2.txt -%1\srm.exe -vvvs test2.txt -%1\srm.exe -vvvs link.txt +%1\srm.exe -vvv test2.txt +%1\srm.exe -vvv link.txt IF EXIST test2.txt ( echo could not remove test2.txt in hard link test! exit @@ -29,7 +29,8 @@ echo "The wildcard test" > test1.txt echo "Another test file" > test2.txt echo "and a 4rd" > test3.txt -%1\srm.exe -vvvs test*.txt +%1\srm.exe -vvv test*.txt +echo "" IF EXIST test1.txt ( echo could not remove test1.txt in wildcard test! exit @@ -43,6 +44,16 @@ exit ) -echo -echo +rem don't run test with large file by default +IF "a" == "b" ( + echo "Test a 2.1GB file" + %1\createfile.exe big.txt 2100 + %1\srm.exe -svvv big.txt + IF EXIST big.txt ( + echo "could not remove big.txt" + exit + ) +) + +echo "" echo *** all Windows tests successful. *** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/test.sh new/srm-1.2.15/test.sh --- old/srm-1.2.13/test.sh 2014-03-18 08:27:36.000000000 +0100 +++ new/srm-1.2.15/test.sh 2015-02-26 17:12:02.000000000 +0100 @@ -4,6 +4,7 @@ set -e # exit if any commands fail make +test/fill_test SRM="src/srm -vvvvvvv" @@ -19,6 +20,8 @@ } # symlink +echo "testing symlinks..." +rm -f test.symlink echo "TEST" > test.file if [ ! -f test.file ] ; then echo could not create test file @@ -32,12 +35,29 @@ fi testremove test.symlink -# attributes +I=`whoami` +if [ "$I" != root ] ; then + echo "testing symlink to root's files..." + ln -s /etc/fstab test.symlink + if [ ! -L test.symlink ] ; then + echo could not create symlink + exit 1 + fi + testremove test.symlink +else + echo "can not test symlink to root's files, test.sh is run by root." +fi + +# permissions +echo +echo "testing file permissions..." echo "TEST" > test.file2 chmod 000 test.file2 testremove test.file2 # recursing into directories +echo +echo "testing recursing into directories..." rm -rf test.dir mkdir test.dir if [ ! -d test.dir ] ; then @@ -57,8 +77,9 @@ testremove test.dir # device nodes -I=`whoami` +echo if [ "$I" = root ] ; then + echo "testing device nodes..." mkdir test.dir2 echo "TEST" > test.dir2/test.file @@ -80,9 +101,13 @@ fi testremove test.block +else + echo "not running test.sh as root, not testing device nodes" fi # FIFO special file +echo +echo "testing FIFO..." mkfifo test.fifo if [ ! -p test.fifo ] ; then echo could not create fifo @@ -91,6 +116,8 @@ testremove test.fifo # hard links +echo +echo "testing hard links..." echo "the hard link" > test.file cp -f test.file test2.file ln test.file test3.file @@ -120,6 +147,8 @@ fi # test directory symlink +echo +echo "testing directory symlinks..." mkdir test.dir cd test.dir echo test > test.file @@ -137,13 +166,18 @@ # test return code if remove fails if [ "$USER" = doj -a "$HOST" = cubicle.cubic.org ] ; then cp -f /etc/fstab "/tmp/$USER.fstab" + set +e if $SRM -f /etc/fstab ; then echo "removing /etc/fstab as user should not work" exit 1 fi + set -e fi # test extended attributes +if [ 1 = 2 ] ; then +echo +echo "test extended attributes..." DIR=test.test mkdir -p $DIR chmod +t $DIR @@ -162,10 +196,10 @@ fi $SRM $FN rmdir $DIR +fi # test file sizes -SRM="$SRM -s" BS=123 SRC=/dev/zero # /dev/urandom @@ -180,7 +214,6 @@ echo failed to create $F exit 1 fi - ls -l $F if ! $SRM $F ; then echo failed to secure remove $F exit 1 @@ -198,10 +231,13 @@ # test until ~5GiB for i in 1 22 333 4444 55555 666666 7777777 44444444 do + echo + echo + echo "test file of $(($i * $BS / 1024)) KB..." F="$i.tst" dd if=$SRC of=$F bs=$BS count=$i 2> /dev/null testsrm done -echo all tests successful +echo "all tests successful." exit 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/srm-1.2.13/win/config.h new/srm-1.2.15/win/config.h --- old/srm-1.2.13/win/config.h 2014-01-13 22:25:09.000000000 +0100 +++ new/srm-1.2.15/win/config.h 2015-02-26 17:12:02.000000000 +0100 @@ -4,7 +4,7 @@ /* configuration for Win32 compilation */ #define PACKAGE "srm" -#define VERSION "1.2.13" +#define VERSION "1.2.15" #define HAVE_STRING_H 1 #define _CRT_SECURE_NO_WARNINGS 1 -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
