125 Commits
v0.15 ... v0.26

Author SHA1 Message Date
Martijn van Brummelen
37dfb1a2b6 new release 0.26 2019-09-04 08:51:37 +02:00
Martijn van Brummelen
55783c0b8d Update configure.ac 2019-09-04 08:21:10 +02:00
Martijn van Brummelen
52d0508b23 Update nwipe.1 2019-09-04 08:20:37 +02:00
Martijn van Brummelen
d2a66e0047 Merge pull request #99 from PartialVolume/log_system_info
Log system's hardware as described in the system BIOS according to th…
2019-09-04 08:18:47 +02:00
Martijn van Brummelen
11ed6b1472 Merge pull request #71 from PartialVolume/exclude-drive-181116
Enhancement: Add exclude drive option
2019-09-04 08:18:32 +02:00
PartialVolume
0fec3a1213 Log system's hardware as described in the system BIOS according to the SMBIOS/DMI standard.
Uses dmidecode with search keywords arguments. dmidecode -s to see available keywords.
2019-08-31 09:55:08 +01:00
Martijn van Brummelen
b341d1dab0 Merge pull request #93 from PartialVolume/Fedora_package_update_to_readme
Update readme with Fedora package requirements
2018-11-28 12:26:24 +01:00
Nick Law
c92a87860d Update readme with Fedora package requirements 2018-11-28 11:08:03 +00:00
Martijn van Brummelen
545491940e Merge pull request #92 from PartialVolume/update_readme_and_readme.md
Update Readme with package requirements
2018-11-28 08:43:39 +01:00
Nick Law
cd16c2e86b Update Readme with package requirements 2018-11-27 21:56:14 +00:00
Martijn van Brummelen
00469644d8 Merge pull request #89 from PartialVolume/Fix_segfault_that_shows_up_in_Fedora32bit_on_exit
Fix segfault on immediate CNTRL-C exit, shows in Fedora32 bit
2018-11-27 10:08:09 +01:00
Martijn van Brummelen
ac680b4225 Merge pull request #90 from PartialVolume/Update_Fedora_workaround
Update Fedora workaround
2018-11-27 10:07:38 +01:00
Nick Law
c58ab04ff6 Update Fedora workaround 2018-11-25 23:55:11 +00:00
Nick Law
bb91f093a3 Fix segfault on immediate CNTRL-C exit, shows in Fedora32 bit 2018-11-25 21:53:21 +00:00
Martijn van Brummelen
025a02e87c Merge pull request #86 from PartialVolume/netinet_header_removal
Use stdint.h, ncurses.h and panel.h instead of netinet/in.h
2018-11-25 20:53:24 +01:00
Martijn van Brummelen
68cad1b640 Merge pull request #84 from PartialVolume/va_list_ap_was_opened_but_not_closed_by_va_end
Close va_list 'ap' using (va_end( ap ) on failures
2018-11-25 20:52:47 +01:00
Martijn van Brummelen
54f643559f Merge pull request #83 from PartialVolume/warning_variable_wy_set_but_not_used_in_nwipe_gui_title
(void) unused wy, to silence compiler warning
2018-11-25 20:52:16 +01:00
Nick Law
cd3716f260 Use stdint.h, ncurses.h and panel.h instead of netinet/in.h 2018-11-24 23:32:20 +00:00
Nick Law
43172a9741 Close va_list 'ap' using (va_end( ap ) on failures 2018-11-24 13:29:11 +00:00
Nick Law
10221fb2a9 (void) unused wy, to silence compiler warning 2018-11-23 21:09:24 +00:00
Martijn van Brummelen
9b821292ea Merge pull request #82 from PartialVolume/Unused_variables_in_NWIPE_PRNG_READ_SIGNATURE_in_prng.c
(void) unused variables in func.nwipe_isaac_read()
2018-11-23 19:45:22 +01:00
Nick Law
6b350a2348 (void) unused variables in func.nwipe_isaac_read() 2018-11-23 17:13:14 +00:00
Martijn van Brummelen
6ec7826692 Merge pull request #80 from PartialVolume/nwipe.h_is_not_guarded_against_multiple_inclusions
Put Function prototypes inside #ifndef/#define/#endif macro guard
2018-11-23 16:20:51 +01:00
Nick Law
00e9350dd6 Put Function prototypes inside #ifndef/#define/#endif macro guard 2018-11-23 12:56:20 +00:00
Martijn van Brummelen
c46e0c8ba4 Merge pull request #79 from PartialVolume/deallocate_memory_used_by_logging.c
De-allocate memory used by the log functions
2018-11-23 10:38:38 +01:00
Nick Law
af1b470456 De-allocate memory used by the log functions 2018-11-22 20:33:47 +00:00
Martijn van Brummelen
ae51d548d4 Merge pull request #78 from PartialVolume/reduce_log_allocation_memory_requirements
Fix log message buffer overflow & reduce memory requirements.
2018-11-22 07:06:29 +01:00
Nick Law
5f712f3b0c Fix log message buffer overflow, reduce memory requirements. 2018-11-22 02:01:11 +00:00
Martijn van Brummelen
99778f187d Merge pull request #76 from PartialVolume/return_status_of_malloc_not_checked
Malloc return status not checked in nwipe_log()
2018-11-21 18:21:25 +01:00
Nick Law
528bb9fd6a Malloc return status not checked in nwipe_log() 2018-11-21 17:14:29 +00:00
Martijn van Brummelen
08215f3fb2 Merge pull request #72 from PartialVolume/common_realloc_mistake_causing_memory_leak
Common realloc mistake: nulled but not freed
2018-11-21 07:31:49 +01:00
Nick Law
f20e7c6b74 Common realloc mistake: nulled but not freed 2018-11-21 00:27:12 +00:00
Nick Law
27bb409efa Enhancement: Add exclude drive option 2018-11-20 16:03:32 +00:00
Martijn van Brummelen
cfd75a918c Merge pull request #68 from PartialVolume/Fixes_implicit_declaration_of_function_fileno
Fixes implicit declaration of function fileno()
2018-11-20 16:15:33 +01:00
Martijn van Brummelen
f56977930a Merge pull request #70 from PartialVolume/memory_leak_b_in_pass.c
Memory leak:b in pass.c
2018-11-20 16:14:58 +01:00
Nick Law
fa0d72cbaf Memory leak:b in pass.c 2018-11-20 14:14:29 +00:00
Nick Law
42a114abc0 Fixes implicit declaration of function fileno() 2018-11-19 23:38:12 +00:00
Martijn van Brummelen
58d4733273 Merge pull request #65 from PartialVolume/Fixes-uninitialized-variable-warning
Fix uninitialized variable 'keystroke' in nwipe_gui_verify()
2018-11-17 11:23:03 +01:00
Martijn van Brummelen
fe4fdaee93 Merge pull request #66 from PartialVolume/Fixes-uninitialized-variable-keystroke-in-nwipe-gui-prng
Fixes uninitialized variable 'keystroke' in nwipe_gui_prng
2018-11-17 11:21:58 +01:00
Nick Law
157797c1ca Fixes uninitialized variable 'keystroke' in nwipe_gui_prng 2018-11-16 22:35:52 +00:00
Nick Law
396896e16c Fix uninitialized variable 'keystroke' in nwipe_gui_verify() 2018-11-16 22:16:17 +00:00
Martijn van Brummelen
5cb6003fc0 Fixes spurious character at the end of serial no string. 2018-11-16 22:35:32 +01:00
Martijn van Brummelen
b2bee8ac83 Fixes uninitialized variable warning 2018-11-16 22:20:48 +01:00
Martijn van Brummelen
4606834286 Variable 'keystroke' is used uninitialized 2018-11-16 21:27:42 +01:00
Martijn van Brummelen
ed5ca0fce7 Merge pull request #64 from PartialVolume/Fix-serial-numbers-for-ATA-SCSI-devices
Fix non display of serial numbers for ATA/SCSI devices
2018-11-16 21:14:49 +01:00
Nick Law
9c69bc0e1a Fix non display of serial numbers for ATA/SCSI devices 2018-11-16 11:13:49 +00:00
Martijn van Brummelen
a049c871b6 Merge pull request #63 from PartialVolume/NL-patch-1-pointer-d-undeclared
Pointer d undeclared
2018-11-13 11:46:02 +01:00
Nick Law
f960da3f4a Pointer d undeclared
The statment free(d), should not be in nwipe_random_pass().
2018-11-03 09:47:43 +00:00
Martijn van Brummelen
81850bde42 Fixes uninitialized variable 2018-10-05 23:23:16 +02:00
Martijn van Brummelen
e92ac3a870 fix cast/serial number 2018-10-05 23:11:30 +02:00
Martijn van Brummelen
0ecc90786d fix cast 2018-10-05 23:07:06 +02:00
Martijn van Brummelen
5912d0f57a check right pointer 2018-10-05 23:02:19 +02:00
Martijn van Brummelen
e16da663a1 fix more memory leaks 2018-10-05 22:58:58 +02:00
Martijn van Brummelen
a9ed8a091a fix memory leaks 2018-10-05 22:53:05 +02:00
Martijn van Brummelen
dd74c429b0 fix segfault by initializing nwipe_gui_thread 2018-10-05 22:35:41 +02:00
Martijn van Brummelen
baab603809 Version 0.25(change footer) 2018-10-05 22:20:09 +02:00
Martijn van Brummelen
0fa21d4c04 Merge pull request #43 from infrastation/master
fix a couple minor issues in the man page
2018-08-08 10:15:16 +02:00
Denis Ovsienko
3bc0235d38 fix a couple minor issues in the man page 2018-07-07 23:57:52 +01:00
Martijn van Brummelen
533fa56de8 change version to 0.24 2017-12-06 20:44:12 +01:00
Martijn van Brummelen
011901b28e remove tar ball. 2017-12-06 20:33:17 +01:00
Martijn van Brummelen
b47fe001b3 add autoconf tarball 2017-12-06 20:29:58 +01:00
Martijn van Brummelen
3638eae8d4 change version number and add friendly throughput 2017-12-06 20:28:09 +01:00
Martijn van Brummelen
b0bc174d32 pre-0.24 2017-12-06 20:09:47 +01:00
Martijn van Brummelen
8f5c05506f v0.23 2017-12-05 20:07:30 +01:00
Martijn van Brummelen
23c69f34c1 Merge pull request #35 from kelderek/kelderek-patch4
added #include <sys/ioctl.h> so it can get device name
2017-12-05 20:01:22 +01:00
kelderek
0b1cb83013 added #include <sys/ioctl.h> so it can get device name 2017-12-04 17:33:09 -05:00
martijn
17f23ba03b remove unused variable 2017-12-03 20:28:09 +01:00
martijn
22665fa781 include version.h 2017-12-03 19:31:17 +01:00
martijn
95dc8abcf3 fix 32bit issues 2017-12-03 19:07:31 +01:00
Martijn van Brummelen
fd55f48267 add gitignore file 2017-12-02 20:18:53 +01:00
Martijn van Brummelen
d9ba357722 add friendly disk size 2017-12-02 19:46:38 +01:00
Martijn
8a85d7e96f remove testfile 2017-12-02 18:31:02 +01:00
Martijn
cac9b17f9b update version in manpage 2017-12-02 18:27:29 +01:00
Martijn
37109daae7 change spelling fixes github bug #31 2017-12-02 18:03:39 +01:00
Martijn
052852d475 change version year to 2017 2017-12-02 18:02:34 +01:00
Martijn
4b20e7ca76 add test file 2017-12-02 17:58:06 +01:00
Martijn van Brummelen
c8a5a16108 place files in normal location 2017-02-21 22:31:11 +01:00
Martijn van Brummelen
4e64cab3c3 use localtime instead of gmtime for logging 2017-02-13 13:40:00 +01:00
Martijn van Brummelen
5f65683f63 Merge branch 'master' of ssh://github.com/martijnvanbrummelen/nwipe 2017-02-12 23:00:51 +01:00
Martijn van Brummelen
7b170bb444 Revert "Revert "bump version to 0.19""
This reverts commit b808b8402c.
2017-02-12 23:00:24 +01:00
Martijn van Brummelen
464bf788c5 Oops 2017-02-12 22:30:00 +01:00
Martijn van Brummelen
16e78b8523 disable "Kill the GUI thread" 2017-02-12 22:23:28 +01:00
Martijn van Brummelen
f71b23afc4 Merge branch 'master' of ssh://github.com/martijnvanbrummelen/nwipe 2017-02-12 21:20:18 +01:00
Martijn van Brummelen
e7d9ff73fe remove unused netinet/in.h 2017-02-12 20:14:55 +01:00
Martijn van Brummelen
1fce0eb936 make code more readable 2017-02-12 19:53:32 +01:00
Martijn van Brummelen
72c5cd8a0f forgot to include version.h in gui.c 2017-02-12 19:23:26 +01:00
Martijn van Brummelen
0f06e91ce5 forgot ; 2017-02-12 19:20:06 +01:00
Martijn van Brummelen
0f26c8ea68 use banner and update manpage 2017-02-12 19:05:36 +01:00
Martijn van Brummelen
9c63eef565 Version 0.21 2016-08-24 15:21:30 +02:00
Martijn van Brummelen
db9e7ef1aa Merge pull request #22 from nbassler/master
Fix ETA not updating properly and bad total throughput display
2016-08-24 15:58:56 +02:00
Niels Bassler
7039f381af Fix total throughtput display, which showed cummulative throughput, and not current througput. Fix also ETA, which would never decrease. 2016-08-21 19:48:54 +02:00
Martijn van Brummelen
b808b8402c Revert "bump version to 0.19"
This reverts commit 263d5d161f.
2016-08-04 10:55:42 +02:00
Martijn van Brummelen
c6fa743f15 Update README/Version 2016-08-04 09:27:48 +02:00
Martijn van Brummelen
61e8e4663f Merge branch 'vuntz-panel-headers' 2016-08-04 09:14:52 +02:00
Martijn van Brummelen
ea198137de Merge branch 'panel-headers' of https://github.com/vuntz/nwipe into vuntz-panel-headers 2016-08-04 09:14:37 +02:00
Martijn van Brummelen
263d5d161f bump version to 0.19 2016-08-04 07:37:37 +02:00
Martijn van Brummelen
15c444e2eb Build on Fedora 2016-08-03 22:36:20 +02:00
Martijn van Brummelen
1e1eadbc0a version 19 2016-08-03 22:24:58 +02:00
martijn van brummelen
d01b00b4f8 Update Release 0.18 2016-07-27 09:33:17 +02:00
martijn van brummelen
3c0c8408f6 remove test file 2016-07-27 09:00:39 +02:00
martijn van brummelen
a619de6134 test 2016-07-27 08:52:42 +02:00
Martijn van Brummelen
3176688f3e Merge pull request #13 from charles-dyfis-net/issues/12
Add libintl, libuuid dependencies to allow parted static link (#12)
2016-07-27 08:07:03 +02:00
Martijn van Brummelen
b03f063e89 Merge pull request #6 from vuntz/kill-warnings
Remove more compiler warnings
2016-07-27 08:05:51 +02:00
Martijn van Brummelen
f9fd45f129 Merge pull request #9 from dmshaw/master
Add "--nosignals" option to nwipe
Automake needs the dist_ prefix to include man pages in 'make dist'
2016-07-27 08:04:50 +02:00
Martijn van Brummelen
d10dca3bed Merge pull request #14 from charles-dyfis-net/issues/11
Move from loff_t to off64_t for musl libc support (#11)
2016-07-27 08:03:26 +02:00
Martijn van Brummelen
8fa0d8c1f4 Merge pull request #18 from TheSqrtMinus1/master
fixed grammar
2016-07-27 08:01:01 +02:00
gabe
47ff866968 fixed grammar 2016-03-15 10:48:13 -04:00
Charles Duffy
edfabad8a1 Add libintl, libuuid dependencies to allow parted static link (#12)
libparted requires libuuid; both require libintl. Static builds currently fail
with link errors due to these missing dependencies.
2015-10-17 15:18:16 -05:00
Charles Duffy
2f44978db4 Move from loff_t to off64_t for musl libc support (#11)
Using musl libc, the loff_t type is unavailable. This is only exported by the
kernel when building with GNU_SOURCE, so there's an argument to be made that
it's desired behavior; see http://www.openwall.com/lists/musl/2013/01/23/6 for
discussion on this point.
2015-10-17 15:15:54 -05:00
David Shaw
fbe6e9d150 Automake needs the dist_ prefix to include man pages in 'make dist' 2015-06-04 14:46:58 -04:00
David Shaw
3ba8d3814b Add "--nosignals" option to tell nwipe to ignore signals during a
wipe.  Intended for use inside scripts where we don't want users to be
able to kill a wipe partway through.
2015-06-04 14:36:36 -04:00
Martijn
8a9a718221 remove test file 2014-10-19 21:49:22 +02:00
Martijn
a86f366147 Missed if statement 2014-10-19 21:15:22 +02:00
Martijn
e1627b3dc5 Patch nwipe.c to fix Debian bug #755473 (thanks Mark Feenstra). 2014-10-19 14:38:15 +02:00
Martijn
167e4787b7 Change start key to S instead of F10. 2014-10-19 14:23:36 +02:00
Martijn
5a63140baf Update version to 0.17 2014-10-19 14:19:44 +02:00
Martijn
35009577ca Remove control reaches end of non-void function" warnings(Thanks Vincent Untz). 2014-10-19 14:04:36 +02:00
Martijn
2b65e93207 Remove unused variables (thanks Vincent Untz). 2014-10-19 13:56:44 +02:00
Martijn
69dda249c2 add test 2014-10-19 13:51:02 +02:00
Vincent Untz
124ec1e4a9 Do not use variable before we set it 2014-09-09 19:11:19 +02:00
Vincent Untz
57c14286db Ensure variable is initialized 2014-09-09 19:10:51 +02:00
Vincent Untz
ae5d2355cb Remove unused variables 2014-09-09 19:10:44 +02:00
Vincent Untz
51d33b9f61 Fix build when panel header is not in /usr/include
When there's no pkg-config file for the panel library, the build breaks
if the header is not in /usr/include.

At least in openSUSE, we have /usr/include/ncurses.h and
/usr/include/ncurses/panel.h.
2014-09-09 18:19:05 +02:00
Andrew Beverley
86b7b32e37 Update versioning info to v0.16 2014-05-15 09:25:26 +01:00
Andrew Beverley
ee99425d6d Allow building with clang compiler 2014-05-15 09:22:29 +01:00
23 changed files with 908 additions and 271 deletions

31
.gitignore vendored Normal file
View File

@@ -0,0 +1,31 @@
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
compile
config.h
config.h.in
config.log
config.status
configure
depcomp
install-sh
man/Makefile
man/Makefile.in
missing
src/.deps/
src/Makefile
src/Makefile.in
src/nwipe
src/nwipe-device.o
src/nwipe-gui.o
src/nwipe-isaac_rand.o
src/nwipe-logging.o
src/nwipe-method.o
src/nwipe-mt19937ar-cok.o
src/nwipe-nwipe.o
src/nwipe-options.o
src/nwipe-pass.o
src/nwipe-prng.o
src/nwipe-version.o
stamp-h1

129
README
View File

@@ -1,23 +1,136 @@
Installation
============
First bootstrap the source tree:
Compiling & Installing
======================
Nwipe requires the following libraries to be installed.
ncurses
pthreads
parted
Debian & Ubuntu prerequisites
============================
If you compiling nwipe from source the following will need to be installed first
sudo apt install build-essential
sudo apt install pkg-config
sudo apt install automake
sudo apt install libncurses5-dev
sudo apt install autotools-dev
sudo apt install libparted-dev
Fedora prerequisites
====================
sudo bash
dnf update
dnf groupinstall "Development Tools"
dnf groupinstall "C Development Tools and Libraries"
yum install ncurses-devel
yum install parted-devel
Compilation
===========
then create all the autoconf files:
./init.sh
The install using the standard:
Then compile & install using the standard: (Devs see below)
./configure
make
make install
The ncurses, pthreads and parted libraries are required for compiling.
For any problems, please use the Github page:
https://github.com/abeverley/nwipe
Developers !
==========
Andy Beverley
If you wish to submit pull requests to this code we would prefer you enable all warnings,
this can be done using the alternate compile commands
./configure --prefix=/usr CFLAGS='-O0 -g -Wall -Wextra'
make
make install
The '-O0 -g' flags disable optimisations, this is required if your debugging with
gdb in an IDE such as Kdevelop. Without these optimisations disabled you won't be
able to see the values of many variables in nwipe, not to mention the IDE won't step
through the code properly.
The -Wall & -Wextra flags enable all compiler warnings. Please submit code with zero warnings.
Once done with your coding then the released/patch/fixed code can be compiled with
./configure --prefix=/usr && make && make install
complete with all it's optimisations.
For any problems, please use the Github page:
https://github.com/martijnvanbrummelen/nwipe
Martijn van Brummelen
RELEASE NOTES
=============
v0.26
- New release
- Add exclude drive option(Thanks PartialVolume)
- Log hardware (Thanks PartialVolume)
v0.25
- Correct J=Up K=Down in footer(Thanks PartialVolume)
- Fix segfault initialize nwipe_gui_thread (Thanks PartialVolume)
- Fix memory leaks (Thanks PartialVolume)
- Check right pointer (Thanks PartialVolume)
- Fix casting problem (Thanks PartialVolume)
- Fix serial number
- Fixes uninitialized variable warning ( Thanks PartialVolume)
v0.24
- use include values for version 0.17
- display throughput value more friendly(Thanks Kelderek)
v0.23
- make serial visible again on 32Bit machines
v0.22
- Update manpage
- use long long for device size
- Use ped_unit_format_byte function to display(friendly) size of device
v0.21
- Fix ETA not updating properly and bad total throughput display. Thanks (Niels Bassler).
v0.20
- Fix build when panel header is not in /usr/include (Thanks Vincent Untz).
v0.19
- Fix building on Fedora(Unknown off64_t) bug #19.
- Use PRNG instead of zero's bug #7. Thanks xambroz.
v0.18
=====
- Fixed grammar.
- Move from loff_t to off64_t for musl libc support.
- Add "--nosignals" option.
- Automake needs the dist_ prefix to include man pages in 'make dist'.
- Remove more compiler warnings.
- Add libintl, libuuid dependencies to allow parted static link
v0.17
=====
- Remove control reaches end of non-void function" warnings(Thanks Vincent
Untz).
- Remove unused variables (thanks Vincent Untz).
- Change start key to 'S' instead of F10 (closes debian bug #755474).
- Fix problem with unusable device (Closes debian bug #755473).
v0.16
=====
- Fix problems building with clang compiler (thanks Martijn van Brummelen)
v0.15
=====
- Add more detailed information to status page when wiping

View File

@@ -1,6 +1,6 @@
nwipe is a command that will securely erase disks using a variety of
recognised methods. It is a fork of the dwipe command used by
Darik's Boot and Nuke (dban). nwipe is included with partedmagic if
Darik's Boot and Nuke (dban). nwipe is included with partedmagic if you
want a quick and easy bootable CD version. nwipe was created out of
a need to run the DBAN dwipe command outside of DBAN, in order to
allow its use with any host distribution, thus giving better hardware
@@ -11,5 +11,5 @@ To use from the git repository, first create all the autoconf files with
Then do the standard ./configure --prefix=/usr && make && make install
For release notes please see the [README file](README)
For developer & release notes please see the [README file](README)

View File

@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.64])
AC_INIT(nwipe, 0.15, andy@andybev.com)
AM_INIT_AUTOMAKE(nwipe, 0.15)
AC_INIT(nwipe, 0.26, git@brumit.nl)
AM_INIT_AUTOMAKE(nwipe, 0.26)
AC_OUTPUT(Makefile src/Makefile man/Makefile)
AC_CONFIG_SRCDIR([src/nwipe.c])
AC_CONFIG_HEADERS([config.h])
@@ -21,7 +21,14 @@ PKG_CHECK_MODULES(
CFLAGS="${CFLAGS} ${PANEL_CFLAGS}"
LIBS="${LIBS} ${PANEL_LIBS}"
],
[AC_CHECK_LIB([panel], [main], ,[AC_MSG_ERROR([ncurses panel library not found])])]
[AC_CHECK_LIB([panel], [main], [
LIBS="-lpanel $LIBS"
AC_CHECK_HEADERS(panel.h,, [
AC_CHECK_HEADERS(ncurses/panel.h, [
AC_DEFINE([PANEL_IN_SUBDIR], [ncurses/], [Look for ncurses headers in subdir])
], [AC_MSG_ERROR([ncurses panel headers not found])])
])
], [AC_MSG_ERROR([ncurses panel library not found])])]
)
PKG_CHECK_MODULES(
@@ -42,7 +49,9 @@ PKG_CHECK_MODULES(
)]
)
AC_CHECK_LIB([parted], [ped_device_probe_all], ,[AC_MSG_ERROR([parted development library not found])])
AC_CHECK_LIB([intl], [libintl_dgettext]) # needed to statically link libparted, but not given in its pkgconfig file
AC_CHECK_LIB([uuid], [uuid_generate]) # needed to statically link libparted, but not given in its pkgconfig file
PKG_CHECK_MODULES([PARTED], [libparted])
AC_CHECK_LIB([pthread], [main], ,[AC_MSG_ERROR([pthread development library not found])])
# Checks for header files.

View File

@@ -1 +1 @@
man_MANS = nwipe.1
dist_man_MANS = nwipe.1

View File

@@ -1,4 +1,4 @@
.TH NWIPE "1" "March 2014" "nwipe version 0.15" "User Commands"
.TH NWIPE "1" "September 2019" "nwipe version 0.26" "User Commands"
.SH NAME
nwipe \- securely erase disks
.SH SYNOPSIS
@@ -7,7 +7,7 @@ nwipe \- securely erase disks
.SH DESCRIPTION
nwipe is a command that will securely erase disks using a variety of
recognised methods. It is a fork of the dwipe command used by Darik's Boot
and Nuke (dban). nwipe is included with partedmagic if want a quick and
and Nuke (dban). nwipe is included with partedmagic if you want a quick and
easy bootable CD version. nwipe was created out of a need to run the DBAN
dwipe command outside of DBAN, in order to allow its use with any host
distribution, thus giving better hardware support. It is essentially the
@@ -40,6 +40,9 @@ Open devices in sync mode
\fB\-\-nowait\fR
Do not wait for a key before exiting (default is to wait).
.TP
\fB\-\-nosignals\fR
Do not allow signals to interrupt a wipe (default is to allow).
.TP
\fB\-\-nogui\fR
Do not show the GUI interface. Can only be used with the autonuke option.
Nowait option is automatically invoked with the nogui option.
@@ -75,11 +78,10 @@ PRNG option (mersenne|twister|isaac)
\fB\-r\fR, \fB\-\-rounds\fR=\fINUM\fR
Number of times to wipe the device using the selected method (default: 1)
.SH BUGS
Please see the sourceforge site for the latest list
(http://nwipe.sourceforge.net)
Please see the GitHub site for the latest list
(https://github.com/martijnvanbrummelen/nwipe/issues)
.SH AUTHOR
Nwipe was released by Andy Beverley <andy@andybev.com>
as modified version of dwipe from DBAN by Darik Horn <dajhorn-dban@vanadac.com>.
Nwipe is developed by Martijn van Brummelen <github@brumit.nl>
.SH "SEE ALSO"
.BR shred (1),
.BR dwipe (1),

View File

@@ -7,3 +7,5 @@ AM_LDFLAGS =
# the previous manual Makefile
bin_PROGRAMS = nwipe
nwipe_SOURCES = context.h isaac_rand.c logging.h options.h prng.h nwipe.c gui.c isaac_rand.h method.h pass.c device.c gui.h isaac_standard.h mt19937ar-cok.c nwipe.h mt19937ar-cok.h pass.h device.h logging.c method.c options.c prng.c version.c version.h
nwipe_CFLAGS = $(PARTED_CFLAGS)
nwipe_LDADD = $(PARTED_LIBS)

View File

@@ -72,48 +72,53 @@ typedef struct nwipe_speedring_t_
typedef struct nwipe_context_t_
{
int block_size; /* The soft block size reported the device. */
int device_bus; /* The device bus number. */
int device_fd; /* The file descriptor of the device file being wiped. */
int device_host; /* The host number. */
struct hd_driveid device_id; /* The WIN_IDENTIFY data for IDE drives. */
int device_lun; /* The device logical unit number. */
int device_major; /* The major device number. */
int device_minor; /* The minor device number. */
int device_part; /* The device partition or slice number. */
char* device_name; /* The device file name. */
loff_t device_size; /* The device size in bytes. */
struct stat device_stat; /* The device file state from fstat(). */
nwipe_device_t device_type; /* Indicates an IDE, SCSI, or Compaq SMART device. */
int device_target; /* The device target. */
u64 eta; /* The estimated number of seconds until method completion. */
int entropy_fd; /* The entropy source. Usually /dev/urandom. */
char* label; /* The string that we will show the user. */
int pass_count; /* The number of passes performed by the working wipe method. */
u64 pass_done; /* The number of bytes that have already been i/o'd in this pass. */
u64 pass_errors; /* The number of errors across all passes. */
u64 pass_size; /* The total number of i/o bytes across all passes. */
nwipe_pass_t pass_type; /* The type of the current working pass. */
int pass_working; /* The current working pass. */
nwipe_prng_t* prng; /* The PRNG implementation. */
nwipe_entropy_t prng_seed; /* The random data that is used to seed the PRNG. */
void* prng_state; /* The private internal state of the PRNG. */
int result; /* The process return value. */
int round_count; /* The number of rounds performed by the working wipe method. */
u64 round_done; /* The number of bytes that have already been i/o'd. */
u64 round_errors; /* The number of errors across all rounds. */
u64 round_size; /* The total number of i/o bytes across all rounds. */
double round_percent; /* The percentage complete across all rounds. */
int round_working; /* The current working round. */
int sector_size; /* The hard sector size reported by the device. */
nwipe_select_t select; /* Indicates whether this device should be wiped. */
int signal; /* Set when the child is killed by a signal. */
nwipe_speedring_t speedring; /* Ring buffer for computing the rolling throughput average. */
short sync_status; /* A flag to indicate when the method is syncing. */
pthread_t thread; /* The ID of the thread. */
u64 throughput; /* Average throughput in bytes per second. */
u64 verify_errors; /* The number of verification errors across all passes. */
struct hd_driveid identity; /* The serial number of the drive (where applicable) */
int block_size; /* The soft block size reported the device. */
int device_bus; /* The device bus number. */
int device_fd; /* The file descriptor of the device file being wiped. */
int device_host; /* The host number. */
struct hd_driveid device_id; /* The WIN_IDENTIFY data for IDE drives. */
int device_lun; /* The device logical unit number. */
int device_major; /* The major device number. */
int device_minor; /* The minor device number. */
int device_part; /* The device partition or slice number. */
char* device_name; /* The device file name. */
long long device_size; /* The device size in bytes. */
char* device_size_text; /* The device size in a more (human)readable format. */
struct stat device_stat; /* The device file state from fstat(). */
nwipe_device_t device_type; /* Indicates an IDE, SCSI, or Compaq SMART device. */
int device_target; /* The device target. */
u64 eta; /* The estimated number of seconds until method completion. */
int entropy_fd; /* The entropy source. Usually /dev/urandom. */
char* label; /* The string that we will show the user. */
int pass_count; /* The number of passes performed by the working wipe method. */
u64 pass_done; /* The number of bytes that have already been i/o'd in this pass. */
u64 pass_errors; /* The number of errors across all passes. */
u64 pass_size; /* The total number of i/o bytes across all passes. */
nwipe_pass_t pass_type; /* The type of the current working pass. */
int pass_working; /* The current working pass. */
nwipe_prng_t* prng; /* The PRNG implementation. */
nwipe_entropy_t prng_seed; /* The random data that is used to seed the PRNG. */
void* prng_state; /* The private internal state of the PRNG. */
int result; /* The process return value. */
int round_count; /* The number of rounds performed by the working wipe method. */
u64 round_done; /* The number of bytes that have already been i/o'd. */
u64 round_errors; /* The number of errors across all rounds. */
u64 round_size; /* The total number of i/o bytes across all rounds. */
double round_percent; /* The percentage complete across all rounds. */
int round_working; /* The current working round. */
int sector_size; /* The hard sector size reported by the device. */
nwipe_select_t select; /* Indicates whether this device should be wiped. */
int signal; /* Set when the child is killed by a signal. */
nwipe_speedring_t speedring; /* Ring buffer for computing the rolling throughput average. */
short sync_status; /* A flag to indicate when the method is syncing. */
pthread_t thread; /* The ID of the thread. */
u64 throughput; /* Average throughput in bytes per second. */
u64 verify_errors; /* The number of verification errors across all passes. */
char serial_no[21]; /* Serial number(processed), 20 characters, plus null termination */
struct hd_driveid identity; /* Identity contains the raw serial number of the drive */
/* (where applicable), however, for use within nwipe use the */
/* processed serial_no[21] string above. To access serial no. use */
/* c[i]->serial_no) and not c[i]->identity.serial_no); */
} nwipe_context_t;

View File

@@ -20,19 +20,26 @@
*
*/
/* Why is this needed? Segfaults without it */
#include <netinet/in.h>
#include <stdint.h>
#include "nwipe.h"
#include "context.h"
#include "method.h"
#include "options.h"
#include "logging.h"
#include <sys/ioctl.h>
#include <linux/hdreg.h> //Drive specific defs
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
#include <parted/parted.h>
#include <parted/debug.h>
#include <parted/debug.h>
int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount );
char *trim(char *str);
int nwipe_device_scan( nwipe_context_t*** c )
{
@@ -85,8 +92,8 @@ int nwipe_device_get( nwipe_context_t*** c, char **devnamelist, int ndevnames )
if (!dev)
break;
if (check_device(c, dev, dcount))
dcount++;
if (check_device(c, dev, dcount))
dcount++;
}
/* Return the number of devices that were found. */
@@ -98,38 +105,114 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
{
/* Populate this struct, then assign it to overall array of structs. */
nwipe_context_t* next_device;
int fd;
int idx;
/* Try opening the device to see if it's valid. Close on completion. */
if (!ped_device_open(dev))
return 0;
ped_device_close(dev);
/* Check whether this drive is on the excluded drive list ? */
idx=0;
while ( idx < 10 )
{
if ( !strcmp( dev->path, nwipe_options.exclude[idx++] ))
{
nwipe_log( NWIPE_LOG_NOTICE, "Device %s excluded as per command line option -e", dev->path );
return 0;
}
}
/* Try opening the device to see if it's valid. Close on completion. */
if (!ped_device_open(dev))
{
nwipe_log( NWIPE_LOG_FATAL, "Unable to open device" );
return 0;
}
ped_device_close(dev);
/* New device, reallocate memory for additional struct pointer */
*c = realloc (*c, (dcount+1) * sizeof(nwipe_context_t *));
/* New device, reallocate memory for additional struct pointer */
*c = realloc (*c, (dcount+1) * sizeof(nwipe_context_t *));
next_device = malloc (sizeof(nwipe_context_t));
next_device = malloc (sizeof(nwipe_context_t));
/* Check the allocation. */
if( ! next_device )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to create the array of enumeration contexts." );
return 0;
}
/* Check the allocation. */
if( ! next_device )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to create the array of enumeration contexts." );
return 0;
}
/* Zero the allocation. */
memset( next_device , 0, sizeof( nwipe_context_t ) );
/* Zero the allocation. */
memset( next_device , 0, sizeof( nwipe_context_t ) );
/* Get device information */
next_device->label = dev->model;
next_device->device_name = dev->path;
next_device->device_size = dev->length * dev->sector_size;
/* Attempt to get serial number of device. */
ioctl(next_device->device_fd, HDIO_GET_IDENTITY, &next_device->identity);
/* Get device information */
next_device->label = dev->model;
next_device->device_name = dev->path;
next_device->device_size = dev->length * dev->sector_size;
next_device->device_size_text = ped_unit_format_byte(dev, dev->length * dev->sector_size);
/* Attempt to get serial number of device. */
if ( (fd = open ( next_device->device_name = dev->path, O_RDONLY)) == ERR )
{
nwipe_log( NWIPE_LOG_WARNING, "Unable to open device %s to obtain serial number", next_device->device_name );
}
/* We don't check the ioctl return status because there are plenty of situations where a serial number may not be
* returned by ioctl such as USB drives, logical volumes, encryted volumes, so the log file would have multiple
* benign ioctl errors reported which isn't necessarily a problem.
*/
ioctl(fd, HDIO_GET_IDENTITY, &next_device->identity);
close( fd );
(*c)[dcount] = next_device;
for (idx=0; idx<20; idx++) next_device->serial_no[idx]=next_device->identity.serial_no[idx];
next_device->serial_no[20]=0; /* terminate the string */
trim ( (char*) next_device->serial_no ); /* Remove leading/training whitespace from serial number and left justify */
nwipe_log( NWIPE_LOG_INFO,"Found drive model=\"%s\", device path=\"%s\", size=\"%s\", serial number=\"%s\"", next_device->label, next_device->device_name, next_device->device_size_text, next_device->serial_no);
(*c)[dcount] = next_device;
return 1;
return 1;
}
/* Remove leading/training whitespace from a string and left justify result */
char *trim(char *str)
{
size_t len = 0;
char *frontp = str;
char *endp = NULL;
if( str == NULL )
{
return NULL;
}
if( str[0] == '\0' )
{
return str;
}
len = strlen(str);
endp = str + len;
/* Move the front and back pointers to address the first non-whitespace
* characters from each end.
*/
while( isspace((unsigned char) *frontp) ) { ++frontp; }
if( endp != frontp )
{
while( isspace((unsigned char) *(--endp)) && endp != frontp ) {}
}
if( str + len - 1 != endp )
*(endp + 1) = '\0';
else if( frontp != str && endp == frontp )
*str = '\0';
/* Shift the string so that it starts at str so that if it's dynamically
* allocated, we can still free it on the returned pointer. Note the reuse
* of endp to mean the front of the string buffer now.
*/
endp = str;
if( frontp != str )
{
while( *frontp ) { *endp++ = *frontp++; }
*endp = '\0';
}
return str;
}
/* eof */

View File

@@ -29,9 +29,9 @@
* and things like ncurses libmenu are not worth the storage overhead.
*
*/
/* Why is this needed? Segfaults without it */
#include <netinet/in.h>
#include <ncurses.h>
#include <panel.h>
#include <stdint.h>
#include "nwipe.h"
#include "context.h"
@@ -41,6 +41,8 @@
#include "gui.h"
#include "pass.h"
#include "logging.h"
#include "version.h"
#define NWIPE_GUI_PANE 8
@@ -123,8 +125,8 @@ const char* options_title = " Options ";
const char* stats_title = " Statistics ";
/* Footer labels. */
const char* nwipe_buttons1 = "Ctrl-C=Quit F10=Start M=Method P=PRNG V=Verify R=Rounds B=Blanking-pass Space=Select";
const char* nwipe_buttons2 = " J=Up K=Down Space=Select";
const char* nwipe_buttons1 = "Ctrl-C=Quit S=Start M=Method P=PRNG V=Verify R=Rounds B=Blanking-pass Space=Select";
const char* nwipe_buttons2 = " J=Down K=Up Space=Select";
const char* nwipe_buttons3 = " B=Blank screen, ctrl-c=Quit";
@@ -138,6 +140,7 @@ void nwipe_gui_title( WINDOW* w, const char* s )
/* The number of lines in the window. (Not used.) */
int wy;
(void) wy; /* flag wy not used to the compiler, to silence warning */
/* The number of columns in the window. */
int wx;
@@ -229,7 +232,7 @@ void nwipe_gui_init( void )
wclear( header_window );
/* Print the product banner. */
nwipe_gui_title( header_window, nwipe_options.banner );
nwipe_gui_title( header_window, banner );
/* Create the footer window. */
footer_window = newwin( NWIPE_GUI_FOOTER_H, NWIPE_GUI_FOOTER_W, NWIPE_GUI_FOOTER_Y, NWIPE_GUI_FOOTER_X );
@@ -446,40 +449,40 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
{
case NWIPE_SELECT_TRUE:
wprintw( main_window, " [wipe] %i. %s - %s %s (%lld bytes)", (i + offset + 1),
wprintw( main_window, " [wipe] %i. %s - %s %s (%s)", (i + offset + 1),
c[i+offset]->device_name,
c[i+offset]->label,
c[i+offset]->identity.serial_no,
c[i+offset]->device_size );
c[i+offset]->serial_no,
c[i+offset]->device_size_text );
break;
case NWIPE_SELECT_FALSE:
/* Print an element that is not selected. */
wprintw( main_window, " [ ] %i. %s - %s %s (%lld bytes)", (i + offset +1),
wprintw( main_window, " [ ] %i. %s - %s %s (%s)", (i + offset +1),
c[i+offset]->device_name,
c[i+offset]->label,
c[i+offset]->identity.serial_no,
c[i+offset]->device_size );
c[i+offset]->serial_no,
c[i+offset]->device_size_text );
break;
case NWIPE_SELECT_TRUE_PARENT:
/* This element will be wiped when its parent is wiped. */
wprintw( main_window, " [****] %i. %s - %s %s (%lld bytes)", (i + offset +1),
wprintw( main_window, " [****] %i. %s - %s %s (%s)", (i + offset +1),
c[i+offset]->device_name,
c[i+offset]->label,
c[i+offset]->identity.serial_no,
c[i+offset]->device_size );
c[i+offset]->serial_no,
c[i+offset]->device_size_text );
break;
case NWIPE_SELECT_FALSE_CHILD:
/* We can't wipe this element because it has a child that is being wiped. */
wprintw( main_window, " [----] %i. %s - %s %s (%lld bytes)", (i + offset +1),
wprintw( main_window, " [----] %i. %s - %s %s (%s)", (i + offset +1),
c[i+offset]->device_name,
c[i+offset]->label,
c[i+offset]->identity.serial_no,
c[i+offset]->device_size );
c[i+offset]->serial_no,
c[i+offset]->device_size_text );
break;
case NWIPE_SELECT_DISABLED:
@@ -750,7 +753,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c )
} /* keystroke switch */
} while( keystroke != KEY_F(10) && keystroke != ERR );
} while( keystroke != 'S' && keystroke != ERR );
/* Clear the main window. */
werase( main_window );
@@ -994,7 +997,7 @@ void nwipe_gui_prng( void )
if( nwipe_options.prng == &nwipe_isaac ) { focus = 1; }
while( keystroke != ERR )
do
{
/* Clear the main window. */
werase( main_window );
@@ -1084,7 +1087,8 @@ void nwipe_gui_prng( void )
} /* switch */
} /* while */
}
while( keystroke != ERR );
} /* nwipe_gui_prng */
@@ -1123,7 +1127,7 @@ void nwipe_gui_verify( void )
nwipe_gui_title( footer_window, nwipe_buttons2 );
wrefresh( footer_window );
while( keystroke != ERR )
do
{
/* Clear the main window. */
werase( main_window );
@@ -1218,7 +1222,8 @@ void nwipe_gui_verify( void )
} /* switch */
} /* while */
}
while( keystroke != ERR );
} /* nwipe_gui_verify */
@@ -1256,7 +1261,7 @@ void nwipe_gui_noblank( void )
nwipe_gui_title( footer_window, nwipe_buttons2 );
wrefresh( footer_window );
while( keystroke != ERR )
do
{
/* Clear the main window. */
werase( main_window );
@@ -1338,8 +1343,9 @@ void nwipe_gui_noblank( void )
} /* switch */
} /* while */
}
while( keystroke != ERR );
} /* nwipe_gui_noblank */
@@ -1811,11 +1817,11 @@ void *nwipe_gui_status( void *ptr )
for( i = offset ; i < offset + slots && i < count ; i++ )
{
/* Print the context label. */
if ( strlen(c[i]->identity.serial_no) )
if ( strlen((const char*)c[i]->serial_no) )
{
mvwprintw( main_window, yy++, 2, "%s - %s (%s)", c[i]->device_name,
c[i]->label,
c[i]->identity.serial_no);
c[i]->serial_no);
}
else {
mvwprintw( main_window, yy++, 2, "%s - %s", c[i]->device_name,
@@ -1867,13 +1873,13 @@ void *nwipe_gui_status( void *ptr )
if( c[i]->sync_status ) { wprintw( main_window, "[syncing] " ); }
if( c[i]->throughput >= INT64_C( 1000000000000000 ) )
if( c[i]->throughput >= INT64_C( 1000000000000 ) )
{ wprintw( main_window, "[%llu TB/s] ", c[i]->throughput / INT64_C( 1000000000000 ) ); }
else if( c[i]->throughput >= INT64_C( 1000000000000 ) )
{ wprintw( main_window, "[%llu GB/s] ", c[i]->throughput / INT64_C( 1000000000 ) ); }
else if( c[i]->throughput >= INT64_C( 1000000000 ) )
{ wprintw( main_window, "[%llu MB/s] ", c[i]->throughput / INT64_C( 1000000 ) ); }
{ wprintw( main_window, "[%llu GB/s] ", c[i]->throughput / INT64_C( 1000000000 ) ); }
else if( c[i]->throughput >= INT64_C( 1000000 ) )
{ wprintw( main_window, "[%llu MB/s] ", c[i]->throughput / INT64_C( 1000000 ) ); }
else if( c[i]->throughput >= INT64_C( 1000 ) )
{ wprintw( main_window, "[%llu KB/s] ", c[i]->throughput / INT64_C( 1000 ) ); }
else
{ wprintw( main_window, "[%llu B/s] ", c[i]->throughput / INT64_C( 1 ) ); }
@@ -1908,13 +1914,13 @@ void *nwipe_gui_status( void *ptr )
u64 nwipe_throughput = nwipe_misc_thread_data->throughput;
if( nwipe_throughput >= INT64_C( 1000000000000000 ) )
if( nwipe_throughput >= INT64_C( 1000000000000 ) )
{ nwipe_throughput /= INT64_C( 1000000000000 ); nwipe_format = nwipe_tera; }
else if( nwipe_throughput >= INT64_C( 1000000000000 ) )
{ nwipe_throughput /= INT64_C( 1000000000 ); nwipe_format = nwipe_giga; }
else if( nwipe_throughput >= INT64_C( 1000000000 ) )
{ nwipe_throughput /= INT64_C( 1000000 ); nwipe_format = nwipe_mega; }
{ nwipe_throughput /= INT64_C( 1000000000 ); nwipe_format = nwipe_giga; }
else if( nwipe_throughput >= INT64_C( 1000000 ) )
{ nwipe_throughput /= INT64_C( 1000000 ); nwipe_format = nwipe_mega; }
else if( nwipe_throughput >= INT64_C( 1000 ) )
{ nwipe_throughput /= INT64_C( 1000 ); nwipe_format = nwipe_kilo; }
else
{ nwipe_throughput /= INT64_C( 1 ); nwipe_format = nwipe_unit; }
@@ -2017,6 +2023,7 @@ void *nwipe_gui_status( void *ptr )
wrefresh( footer_window );
nwipe_misc_thread_data->gui_thread = 0;
return NULL;
} /* nwipe_gui_status */
int compute_stats(void *ptr)
@@ -2035,6 +2042,9 @@ int compute_stats(void *ptr)
int i;
time_t nwipe_time_now = time( NULL );
nwipe_misc_thread_data->throughput = 0;
nwipe_misc_thread_data->maxeta = 0;
/* Enumerate all contexts to compute statistics. */
for( i = 0 ; i < count ; i++ )

View File

@@ -29,8 +29,10 @@ void isaac(ctx)
randctx *ctx;
{
register ub4 a,b,x,y,*m,*mm,*m2,*r,*mend;
mm=ctx->randmem; r=ctx->randrsl;
a = ctx->randa; b = ctx->randb + (++ctx->randc);
mm=ctx->randmem;
r=ctx->randrsl;
a = ctx->randa;
b = ctx->randb + (++ctx->randc);
for (m = mm, mend = m2 = m+(RANDSIZ/2); m<mend; )
{
rngstep( a<<13, a, b, mm, m, m2, r, x);
@@ -84,20 +86,44 @@ word flag;
/* initialize using the contents of r[] as the seed */
for (i=0; i<RANDSIZ; i+=8)
{
a+=r[i ]; b+=r[i+1]; c+=r[i+2]; d+=r[i+3];
e+=r[i+4]; f+=r[i+5]; g+=r[i+6]; h+=r[i+7];
a+=r[i ];
b+=r[i+1];
c+=r[i+2];
d+=r[i+3];
e+=r[i+4];
f+=r[i+5];
g+=r[i+6];
h+=r[i+7];
mix(a,b,c,d,e,f,g,h);
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
m[i ]=a;
m[i+1]=b;
m[i+2]=c;
m[i+3]=d;
m[i+4]=e;
m[i+5]=f;
m[i+6]=g;
m[i+7]=h;
}
/* do a second pass to make all of the seed affect all of m */
for (i=0; i<RANDSIZ; i+=8)
{
a+=m[i ]; b+=m[i+1]; c+=m[i+2]; d+=m[i+3];
e+=m[i+4]; f+=m[i+5]; g+=m[i+6]; h+=m[i+7];
a+=m[i ];
b+=m[i+1];
c+=m[i+2];
d+=m[i+3];
e+=m[i+4];
f+=m[i+5];
g+=m[i+6];
h+=m[i+7];
mix(a,b,c,d,e,f,g,h);
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
m[i ]=a;
m[i+1]=b;
m[i+2]=c;
m[i+3]=d;
m[i+4]=e;
m[i+5]=f;
m[i+6]=g;
m[i+7]=h;
}
}
else
@@ -106,8 +132,14 @@ word flag;
for (i=0; i<RANDSIZ; i+=8)
{
mix(a,b,c,d,e,f,g,h);
m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d;
m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h;
m[i ]=a;
m[i+1]=b;
m[i+2]=c;
m[i+3]=d;
m[i+4]=e;
m[i+5]=f;
m[i+6]=g;
m[i+7]=h;
}
}

View File

@@ -18,7 +18,11 @@
*
*/
#define _POSIX_SOURCE
#define _DEFAULT_SOURCE
#include "stdio.h"
#include "stdlib.h"
#include "nwipe.h"
#include "context.h"
#include "method.h"
@@ -26,8 +30,6 @@
#include "options.h"
#include "logging.h"
int const MAX_LOG_LINE_CHARS = 512;
/* Global array to hold log values to print when logging to STDOUT */
char **log_lines;
int log_current_element = 0;
@@ -41,6 +43,12 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
*
*/
char **result;
char *malloc_result;
char message_buffer[MAX_LOG_LINE_CHARS * sizeof(char)];
int chars_written;
int message_buffer_length;
/* A time buffer. */
time_t t;
@@ -50,63 +58,105 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
/* Get the current time. */
t = time( NULL );
p = gmtime( &t );
p = localtime( &t );
pthread_mutex_lock( &mutex1 );
/* Increase the current log element pointer - we will write here */
if (log_current_element == log_elements_allocated) {
log_elements_allocated++;
log_lines = (char **) realloc (log_lines, (log_elements_allocated) * sizeof(char *));
log_lines[log_current_element] = malloc(MAX_LOG_LINE_CHARS * sizeof(char));
}
/* Position of writing to current log string */
int line_current_pos = 0;
/* Print the date. The rc script uses the same format. */
line_current_pos = snprintf( log_lines[log_current_element], MAX_LOG_LINE_CHARS, "[%i/%02i/%02i %02i:%02i:%02i] nwipe: ", \
chars_written = snprintf( message_buffer, MAX_LOG_LINE_CHARS, "[%i/%02i/%02i %02i:%02i:%02i] nwipe: ", \
1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec );
/* Has the end of the buffer been reached ?, snprintf returns the number of characters that would have been
* written if MAX_LOG_LINE_CHARS had not been reached, it does not return the actual characters written in
* all circumstances, hence why we need to check whether it's greater than MAX_LOG_LINE_CHARS and if so set
* it to MAX_LOG_LINE_CHARS, preventing a buffer overrun further down this function.
*/
switch( level )
/* check if there was a complete failure to write this part of the message, in which case return */
if ( chars_written < 0 )
{
fprintf( stderr, "nwipe_log: snprintf error when writing log line to memory.\n" );
pthread_mutex_unlock( &mutex1 );
return;
}
else
{
if ( (line_current_pos + chars_written) > MAX_LOG_LINE_CHARS )
{
fprintf( stderr, "nwipe_log: Warning! The log line has been truncated as it exceeded %i characters\n", MAX_LOG_LINE_CHARS );
line_current_pos = MAX_LOG_LINE_CHARS;
}
else
{
line_current_pos += chars_written;
}
}
case NWIPE_LOG_NONE:
/* Do nothing. */
break;
if ( line_current_pos < MAX_LOG_LINE_CHARS )
{
switch( level )
{
case NWIPE_LOG_DEBUG:
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "debug: " );
break;
case NWIPE_LOG_NONE:
/* Do nothing. */
break;
case NWIPE_LOG_INFO:
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "info: " );
break;
case NWIPE_LOG_DEBUG:
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "debug: " );
break;
case NWIPE_LOG_NOTICE:
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "notice: " );
break;
case NWIPE_LOG_INFO:
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "info: " );
break;
case NWIPE_LOG_WARNING:
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "warning: " );
break;
case NWIPE_LOG_NOTICE:
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "notice: " );
break;
case NWIPE_LOG_ERROR:
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "error: " );
break;
case NWIPE_LOG_WARNING:
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "warning: " );
break;
case NWIPE_LOG_FATAL:
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "fatal: " );
break;
case NWIPE_LOG_ERROR:
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "error: " );
break;
case NWIPE_LOG_SANITY:
/* TODO: Request that the user report the log. */
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "sanity: " );
break;
case NWIPE_LOG_FATAL:
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "fatal: " );
break;
default:
line_current_pos += snprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, "level %i: ", level );
case NWIPE_LOG_SANITY:
/* TODO: Request that the user report the log. */
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "sanity: " );
break;
default:
chars_written = snprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos, "level %i: ", level );
}
/* Has the end of the buffer been reached ?
*/
if ( chars_written < 0 )
{
fprintf( stderr, "nwipe_log: snprintf error when writing log line to memory.\n" );
pthread_mutex_unlock( &mutex1 );
return;
}
else
{
if ( (line_current_pos + chars_written) > MAX_LOG_LINE_CHARS )
{
fprintf( stderr, "nwipe_log: Warning! The log line has been truncated as it exceeded %i characters\n", MAX_LOG_LINE_CHARS );
line_current_pos = MAX_LOG_LINE_CHARS;
}
else
{
line_current_pos += chars_written;
}
}
}
/* The variable argument pointer. */
@@ -114,9 +164,61 @@ void nwipe_log( nwipe_log_t level, const char* format, ... )
/* Fetch the argument list. */
va_start( ap, format );
/* Print the event. */
line_current_pos += vsnprintf( log_lines[log_current_element] + line_current_pos, MAX_LOG_LINE_CHARS, format, ap );
if ( line_current_pos < MAX_LOG_LINE_CHARS )
{
chars_written = vsnprintf( message_buffer + line_current_pos, MAX_LOG_LINE_CHARS - line_current_pos -1, format, ap );
if ( chars_written < 0 )
{
fprintf( stderr, "nwipe_log: snprintf error when writing log line to memory.\n" );
pthread_mutex_unlock( &mutex1 );
va_end( ap );
return;
}
else
{
if ( (line_current_pos + chars_written) > MAX_LOG_LINE_CHARS )
{
fprintf( stderr, "nwipe_log: Warning! The log line has been truncated as it exceeded %i characters\n", MAX_LOG_LINE_CHARS );
line_current_pos = MAX_LOG_LINE_CHARS;
}
else
{
line_current_pos += chars_written;
}
}
}
/* Increase the current log element pointer - we will write here, deallocation is done in cleanup() in nwipe.c */
if (log_current_element == log_elements_allocated) {
log_elements_allocated++;
result = realloc (log_lines, (log_elements_allocated) * sizeof(char *));
if ( result == NULL )
{
fprintf( stderr, "nwipe_log: realloc failed when adding a log line.\n" );
pthread_mutex_unlock( &mutex1 );
va_end( ap );
return;
}
log_lines = result;
/* Allocate memory for storing a single log message, deallocation is done in cleanup() in nwipe.c */
message_buffer_length = strlen( message_buffer ) * sizeof(char);
malloc_result = malloc((message_buffer_length + 1) * sizeof(char));
if (malloc_result == NULL)
{
fprintf( stderr, "nwipe_log: malloc failed when adding a log line.\n" );
pthread_mutex_unlock( &mutex1 );
va_end( ap );
return;
}
log_lines[log_current_element] = malloc_result;
}
strcpy ( log_lines[log_current_element], message_buffer );
/*
if( level >= NWIPE_LOG_WARNING )
@@ -219,4 +321,69 @@ void nwipe_perror( int nwipe_errno, const char* f, const char* s )
} /* nwipe_perror */
int nwipe_log_sysinfo()
{
FILE *fp;
char path[256];
char cmd[50];
int len;
/* Remove or add keywords to be searched, depending on what information is to
be logged, making sure the last entry in the array is a NULL string. To remove
an entry simply comment out the keyword with // */
char dmidecode_keywords[][24] = {
"bios-version",
"bios-release-date",
"system-manufacturer",
"system-product-name",
"system-version",
"system-serial-number",
"system-uuid",
"baseboard-manufacturer",
"baseboard-product-name",
"baseboard-version",
"baseboard-serial-number",
"baseboard-asset-tag",
"chassis-manufacturer",
"chassis-type",
"chassis-version",
"chassis-serial-number",
"chassis-asset-tag",
"processor-family",
"processor-manufacturer",
"processor-version",
"processor-frequency",
"" //terminates the keyword array. DO NOT REMOVE
};
unsigned int keywords_idx;
keywords_idx = 0;
/* Run the dmidecode command to retrieve system serial number */
while ( dmidecode_keywords[keywords_idx][0] != 0 )
{
sprintf(cmd,"dmidecode -s %s", &dmidecode_keywords[keywords_idx][0] );
fp = popen(cmd, "r");
if (fp == NULL ) {
nwipe_log( NWIPE_LOG_INFO, "Failed to run command dmidecode -s %s", &dmidecode_keywords[keywords_idx][0], path );
return 1;
}
/* Read the output a line at a time - output it. */
while (fgets(path, sizeof(path)-1, fp) != NULL)
{
/* Remove any trailing return from the string, as nwipe_log automatically adds a return */
len = strlen(path);
if( path[len-1] == '\n' ) {
path[len-1] = 0;
}
nwipe_log( NWIPE_LOG_INFO, "%s = %s", &dmidecode_keywords[keywords_idx][0], path );
}
/* close */
pclose(fp);
keywords_idx++;
}
return 0;
}
/* eof */

View File

@@ -22,6 +22,9 @@
#ifndef LOGGING_H_
#define LOGGING_H_
/* Maximum size a log message can be */
#define MAX_LOG_LINE_CHARS 512
typedef enum nwipe_log_t_
{
NWIPE_LOG_NONE = 0,
@@ -36,6 +39,7 @@ typedef enum nwipe_log_t_
void nwipe_log( nwipe_log_t level, const char* format, ... );
void nwipe_perror( int nwipe_errno, const char* f, const char* s );
int nwipe_log_sysinfo();
/* Global array to hold log values to print when logging to STDOUT */
//extern char **log_lines;

View File

@@ -38,8 +38,7 @@
*
*/
/* Why is this needed? Segfaults without it */
#include <netinet/in.h>
#include <stdint.h>
#include "nwipe.h"
#include "context.h"
@@ -111,6 +110,7 @@ void *nwipe_zero( void *ptr )
/* Finished. Set the thread ID to 0 so that the GUI knows */
c->thread = 0;
return NULL;
} /* nwipe_zero */
@@ -156,8 +156,8 @@ void *nwipe_dod522022m( void *ptr )
nwipe_log( NWIPE_LOG_FATAL, "Unable to seed the %s method.", nwipe_dod522022m_label );
/* Ensure a negative return. */
if( r < 0 ) { c->result = r; return; }
else { c->result = -1; return; }
if( r < 0 ) { c->result = r; return NULL; }
else { c->result = -1; return NULL; }
}
@@ -173,6 +173,7 @@ void *nwipe_dod522022m( void *ptr )
/* Finished. Set the thread ID to 0 so that the GUI knows */
c->thread = 0;
return NULL;
} /* nwipe_dod522022m */
@@ -215,8 +216,8 @@ void *nwipe_dodshort( void *ptr )
nwipe_log( NWIPE_LOG_FATAL, "Unable to seed the %s method.", nwipe_dodshort_label );
/* Ensure a negative return. */
if( r < 0 ) { c->result = r; return; }
else { c->result = -1; return; }
if( r < 0 ) { c->result = r; return NULL; }
else { c->result = -1; return NULL; }
}
@@ -229,6 +230,7 @@ void *nwipe_dodshort( void *ptr )
/* Finished. Set the thread ID to 0 so that the GUI knows */
c->thread = 0;
return NULL;
} /* nwipe_dodshort */
@@ -312,8 +314,8 @@ void *nwipe_gutmann( void *ptr )
nwipe_log( NWIPE_LOG_FATAL, "Unable to seed the %s method.", nwipe_gutmann_label );
/* Ensure a negative return. */
if( r < 0 ) { c->result = r; return; }
else { c->result = -1; return; }
if( r < 0 ) { c->result = r; return NULL; }
else { c->result = -1; return NULL; }
}
@@ -355,6 +357,7 @@ void *nwipe_gutmann( void *ptr )
/* Finished. Set the thread ID to 0 so that the GUI knows */
c->thread = 0;
return NULL;
} /* nwipe_gutmann */
@@ -406,18 +409,19 @@ void *nwipe_ops2( void *ptr )
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate the random character array." );
c->result = -1;
return;
return NULL;
}
/* Allocate the array of complement characters. */
t = malloc( sizeof( char ) * u );
if( s == NULL )
if( t == NULL )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate the complement character array." );
c->result = -1;
return;
free(s);
return NULL;
}
@@ -432,7 +436,9 @@ void *nwipe_ops2( void *ptr )
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate the pattern array." );
c->result = -1;
return;
free(s);
free(t);
return NULL;
}
@@ -444,10 +450,24 @@ void *nwipe_ops2( void *ptr )
r = errno;
nwipe_perror( r, __FUNCTION__, "read" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to seed the %s method.", nwipe_ops2_label );
/* Ensure a negative return. */
if( r < 0 ) { c->result = r; return; }
else { c->result = -1; return; }
if( r < 0 )
{
c->result = r;
free(s);
free(t);
free(patterns);
return NULL;
}
else
{
c->result = -1;
free(s);
free(t);
free(patterns);
return NULL;
}
}
@@ -506,6 +526,7 @@ void *nwipe_ops2( void *ptr )
/* Finished. Set the thread ID to 0 so that the GUI knows */
c->thread = 0;
return NULL;
} /* nwipe_ops2 */
@@ -534,6 +555,7 @@ void *nwipe_random( void *ptr )
/* Finished. Set the thread ID to 0 so that the GUI knows */
c->thread = 0;
return NULL;
} /* nwipe_random */

View File

@@ -20,10 +20,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#define _POSIX_SOURCE
#include <netinet/in.h>
#include <stdint.h>
#include <time.h>
#include <signal.h>
#include <pthread.h>
#include <bits/pthreadtypes.h>
#include <bits/sigthread.h>
#include "nwipe.h"
#include "context.h"
@@ -48,18 +52,9 @@ int main( int argc, char** argv )
int nwipe_enumerated; /* The number of contexts that have been enumerated. */
int nwipe_error = 0; /* An error counter. */
int nwipe_selected = 0; /* The number of contexts that have been selected. */
int nwipe_shmid; /* A shared memory handle for the context array. */
int nwipe_wait = 0; /* The number of child processes that have returned. */
pthread_t nwipe_gui_thread; /* The thread ID of the GUI thread. */
pthread_t nwipe_gui_thread = 0; /* The thread ID of the GUI thread. */
pthread_t nwipe_sigint_thread; /* The thread ID of the sigint handler. */
/* The list of device filenames. */
char** nwipe_names = NULL;
/* Used to write-out the result file. */
char nwipe_result_file [FILENAME_MAX];
FILE* nwipe_result_fp;
/* The entropy source file handle. */
int nwipe_entropy;
@@ -78,9 +73,6 @@ int main( int argc, char** argv )
/* Initialised and populated in device scan. */
nwipe_context_t **c1 = 0;
/* The array of pointers to contexts that will actually be wiped. */
nwipe_context_t **c2 = (nwipe_context_t **)malloc(nwipe_enumerated * sizeof(nwipe_context_t *));
/* Parse command line options. */
nwipe_optind = nwipe_options_parse( argc, argv );
@@ -104,13 +96,24 @@ int main( int argc, char** argv )
else
{
argv += nwipe_optind;
argv += nwipe_optind;
argc -= nwipe_optind;
nwipe_enumerated = nwipe_device_get( &c1, argv, argc );
}
if ( nwipe_enumerated == 0 )
{
cleanup();
exit(1);
}
}
/* Log the System information */
nwipe_log_sysinfo();
/* The array of pointers to contexts that will actually be wiped. */
nwipe_context_t **c2 = (nwipe_context_t **)malloc(nwipe_enumerated * sizeof(nwipe_context_t *));
/* Open the entropy source. */
nwipe_entropy = open( NWIPE_KNOB_ENTROPY, O_RDONLY );
@@ -147,16 +150,19 @@ int main( int argc, char** argv )
nwipe_thread_data_ptr.c = c2;
nwipe_misc_thread_data.nwipe_enumerated = nwipe_enumerated;
nwipe_misc_thread_data.nwipe_selected = 0;
if( !nwipe_options.nogui )
nwipe_misc_thread_data.gui_thread = &nwipe_gui_thread;
nwipe_thread_data_ptr.nwipe_misc_thread_data = &nwipe_misc_thread_data;
pthread_attr_t pthread_attr;
pthread_attr_init(&pthread_attr);
pthread_attr_setdetachstate(&pthread_attr, PTHREAD_CREATE_DETACHED);
pthread_create( &nwipe_sigint_thread, &pthread_attr, signal_hand, &nwipe_thread_data_ptr);
if( !nwipe_options.nosignals )
{
pthread_attr_t pthread_attr;
pthread_attr_init(&pthread_attr);
pthread_attr_setdetachstate(&pthread_attr, PTHREAD_CREATE_DETACHED);
pthread_create( &nwipe_sigint_thread, &pthread_attr, signal_hand, &nwipe_thread_data_ptr);
}
/* A context struct for each device has already been created. */
/* Now set specific nwipe options */
@@ -208,6 +214,7 @@ int main( int argc, char** argv )
if( nwipe_options.nogui )
{
printf("--nogui option must be used with autonuke option\n");
cleanup();
exit(1);
}
else
@@ -289,8 +296,8 @@ int main( int argc, char** argv )
*/
/* Print serial number of device if it exists. */
if ( strlen(c2[i]->identity.serial_no) ) {
nwipe_log( NWIPE_LOG_INFO, "Device %s has serial number %s", c2[i]->device_name, c2[i]->identity.serial_no);
if ( strlen((const char*)c2[i]->serial_no) ) {
nwipe_log( NWIPE_LOG_INFO, "Device %s has serial number %s", c2[i]->device_name, c2[i]->serial_no);
}
@@ -358,7 +365,7 @@ int main( int argc, char** argv )
}
if( c2[i]->device_size == (loff_t)-1 )
if( c2[i]->device_size == (long long)-1 )
{
/* We cannot determine the size of this device. */
nwipe_perror( errno, __FUNCTION__, "lseek" );
@@ -371,7 +378,7 @@ int main( int argc, char** argv )
/* Reset the file pointer. */
r = lseek( c2[i]->device_fd, 0, SEEK_SET );
if( r == (loff_t)-1 )
if( r == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to reset the '%s' file offset.", c2[i]->device_name );
@@ -479,6 +486,8 @@ int main( int argc, char** argv )
printf("%s\n", log_lines[i]);
}
cleanup();
/* Success. */
return 0;
@@ -527,7 +536,7 @@ void *signal_hand(void *ptr)
if ( c[i]->thread )
{
char *status;
char *status = "";
switch( c[i]->pass_type )
{
case NWIPE_PASS_FINAL_BLANK:
@@ -569,12 +578,14 @@ void *signal_hand(void *ptr)
case SIGQUIT :
case SIGTERM :
{
nwipe_log( NWIPE_LOG_INFO, "nwipe_selected = %lu", nwipe_misc_thread_data->nwipe_selected );
for( i = 0; i < nwipe_misc_thread_data->nwipe_selected; i++ )
{
if ( c[i]->thread )
{
nwipe_log( NWIPE_LOG_INFO, "Cancelling thread for %s", c[i]->device_name );
pthread_cancel( c[i]->thread );
}
}
@@ -582,7 +593,7 @@ void *signal_hand(void *ptr)
// Kill the GUI thread
if( !nwipe_options.nogui )
{
if ( nwipe_misc_thread_data->gui_thread )
if ( *nwipe_misc_thread_data->gui_thread )
{
pthread_cancel( *nwipe_misc_thread_data->gui_thread );
*nwipe_misc_thread_data->gui_thread = 0;
@@ -600,8 +611,7 @@ void *signal_hand(void *ptr)
printf("Program interrupted (caught signal %d)\n", sig);
// Cleanup
// TODO: All other cleanup required
cleanup();
exit(0);
@@ -615,5 +625,20 @@ void *signal_hand(void *ptr)
} /* end of signal_hand */
int cleanup()
{
/* Deallocate memory used by logging */
int idx;
for ( idx=0; idx < log_elements_allocated; idx++ )
{
free ( log_lines[idx] );
}
log_elements_allocated=0; /* zeroed just in case cleanup is called twice */
free ( log_lines );
/* TODO: All other cleanup required */
return 0;
}
/* eof */

View File

@@ -20,9 +20,13 @@
*
*/
#ifndef NWIPE_H_
#define NWIPE_H_
/* Function prototypes */
int cleanup();
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
@@ -31,6 +35,15 @@
#define _FILE_OFFSET_BITS 64
#endif
/* workaround for Fedora */
#ifndef off64_t
#ifndef off_t
#define off64_t int64_t
#else
#define off64_t off_t
#endif
#endif
/* Busybox headers. */
#ifdef BB_VER
#include "busybox.h"
@@ -65,12 +78,15 @@ extern int log_current_element;
extern int log_elements_allocated;
extern pthread_mutex_t mutex1;
/* Ncurses headers. Assume panel.h is in same place.*/
/* Ncurses headers. */
#ifdef NCURSES_IN_SUBDIR
#include <ncurses/ncurses.h>
#include <ncurses/panel.h>
#else
#include <ncurses.h>
#endif
#ifdef PANEL_IN_SUBDIR
#include <ncurses/panel.h>
#else
#include <panel.h>
#endif

View File

@@ -42,17 +42,19 @@ int nwipe_options_parse( int argc, char** argv )
extern nwipe_prng_t nwipe_twister;
extern nwipe_prng_t nwipe_isaac;
/* The maximum banner size, including the null. */
const int nwipe_banner_size = 81;
/* The getopt() result holder. */
int nwipe_opt;
/* Excluded drive indexes */
int idx_drive_chr;
int idx_optarg;
int idx_drive;
/* Array index variable. */
int i;
/* The list of acceptable short options. */
char nwipe_options_short [] = "Vhl:hm:p:r:";
char nwipe_options_short [] = "Vhl:hm:p:r:e:";
/* The list of acceptable long options. */
static struct option nwipe_options_long [] =
@@ -68,6 +70,9 @@ int nwipe_options_parse( int argc, char** argv )
/* Log file. Corresponds to the 'l' short option. */
{ "logfile", required_argument, 0, 'l' },
/* Exclude devices, comma separated list */
{ "exclude", required_argument, 0, 'e' },
/* The Pseudo Random Number Generator. */
{ "prng", required_argument, 0, 'p' },
@@ -81,6 +86,9 @@ int nwipe_options_parse( int argc, char** argv )
/* Whether to exit after wiping or wait for a keypress. */
{ "nowait", no_argument, 0, 0 },
/* Whether to allow signals to interrupt a wipe. */
{ "nosignals", no_argument, 0, 0 },
/* Whether to exit after wiping or wait for a keypress. */
{ "nogui", no_argument, 0, 0 },
@@ -97,15 +105,6 @@ int nwipe_options_parse( int argc, char** argv )
{ 0, 0, 0, 0 }
};
/* Note that COLS isn't available until ncurses is initialized. */
nwipe_options.banner = malloc( nwipe_banner_size );
/* Set the default product banner. */
/* TODO: Add version constant. */
strncpy ( nwipe_options.banner, program_name, nwipe_banner_size);
strncat ( nwipe_options.banner, " ", nwipe_banner_size - strlen (nwipe_options.banner) - 1);
strncat ( nwipe_options.banner, version_string, nwipe_banner_size - strlen (nwipe_options.banner) - 1);
strncat ( nwipe_options.banner, " (based on DBAN's dwipe - Darik's Wipe)", nwipe_banner_size - strlen (nwipe_options.banner) - 1);
/* Set default options. */
nwipe_options.autonuke = 0;
@@ -114,11 +113,17 @@ int nwipe_options_parse( int argc, char** argv )
nwipe_options.rounds = 1;
nwipe_options.noblank = 0;
nwipe_options.nowait = 0;
nwipe_options.nosignals= 0;
nwipe_options.nogui = 0;
nwipe_options.sync = 0;
nwipe_options.verify = NWIPE_VERIFY_LAST;
memset( nwipe_options.logfile, '\0', sizeof(nwipe_options.logfile) );
/* Initialise each of the strings in the excluded drives array */
for ( i=0; i < MAX_NUMBER_EXCLUDED_DRIVES; i++ )
{
nwipe_options.exclude[i][0]=0;
}
/* Parse command line options. */
while( 1 )
@@ -151,6 +156,12 @@ int nwipe_options_parse( int argc, char** argv )
break;
}
if( strcmp( nwipe_options_long[i].name, "nosignals" ) == 0 )
{
nwipe_options.nosignals = 1;
break;
}
if( strcmp( nwipe_options_long[i].name, "nogui" ) == 0 )
{
nwipe_options.nogui = 1;
@@ -244,6 +255,46 @@ int nwipe_options_parse( int argc, char** argv )
strncpy(nwipe_options.logfile, optarg, sizeof(nwipe_options.logfile));
break;
case 'e': /* exclude drives option */
idx_drive_chr=0;
idx_optarg=0;
idx_drive=0;
/* Create an array of excluded drives from the comma separated string */
while ( optarg[idx_optarg] != 0 && idx_drive<MAX_NUMBER_EXCLUDED_DRIVES )
{
/* drop the leading '=' character if used */
if ( optarg[idx_optarg] == '=' && idx_optarg == 0 )
{ idx_optarg++;
continue;
}
if ( optarg[idx_optarg] == ',' )
{
/* terminate string and move onto next drive */
nwipe_options.exclude[idx_drive++][idx_drive_chr]=0;
idx_drive_chr=0;
idx_optarg++;
}
else
{
if ( idx_drive_chr < MAX_DRIVE_PATH_LENGTH )
{
nwipe_options.exclude[idx_drive][idx_drive_chr++]=optarg[idx_optarg++];
}
else
{ /* This section deals with file names that exceed MAX_DRIVE_PATH_LENGTH */
nwipe_options.exclude[idx_drive][idx_drive_chr]=0;
while ( optarg[idx_optarg] != 0 || optarg[idx_optarg] != ',' )
{
idx_optarg++;
}
}
}
}
break;
case 'h': /* Display help. */
display_help();
@@ -276,7 +327,7 @@ int nwipe_options_parse( int argc, char** argv )
|| nwipe_options.rounds < 1
)
{
fprintf( stderr, "Error: The rounds argument must be a postive integer.\n" );
fprintf( stderr, "Error: The rounds argument must be a positive integer.\n" );
exit( EINVAL );
}
@@ -332,12 +383,17 @@ void nwipe_options_log( void )
nwipe_log( NWIPE_LOG_NOTICE, " do not wait for a key before exiting" );
}
if( nwipe_options.nosignals )
{
nwipe_log( NWIPE_LOG_NOTICE, " do not allow signals to interrupt a wipe" );
}
if( nwipe_options.nogui )
{
nwipe_log( NWIPE_LOG_NOTICE, " do not show GUI interface" );
}
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", nwipe_options.banner );
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", banner );
nwipe_log( NWIPE_LOG_NOTICE, " method = %s", nwipe_method_label( nwipe_options.method ) );
nwipe_log( NWIPE_LOG_NOTICE, " rounds = %i", nwipe_options.rounds );
nwipe_log( NWIPE_LOG_NOTICE, " sync = %i", nwipe_options.sync );
@@ -394,8 +450,13 @@ display_help()
puts(" -r, --rounds=NUM Number of times to wipe the device using the selected method (default: 1)" );
puts(" --noblank Do not blank disk after wipe (default is to complete a final blank pass)" );
puts(" --nowait Do not wait for a key before exiting (default is to wait)" );
puts(" --nosignals Do not allow signals to interrupt a wipe (default is to allow)" );
puts(" --nogui Do not show the GUI interface. Automatically invokes the nowait option" );
puts(" Must be used with --autonuke option. Send SIGUSR1 to log current stats");
puts(" -e, --exclude=DEVICES Up to ten comma separted devices to be excluded, examples:");
puts(" --exclude=/dev/sdc");
puts(" --exclude=/dev/sdc,/dev/sdd");
puts(" --exclude=/dev/sdc,/dev/sdd,/dev/mapper/cryptswap1");
puts("");
exit( EXIT_SUCCESS );
}

View File

@@ -36,6 +36,8 @@
#define NWIPE_KNOB_SCSI "/proc/scsi/scsi"
#define NWIPE_KNOB_SLEEP 1
#define NWIPE_KNOB_STAT "/proc/stat"
#define MAX_NUMBER_EXCLUDED_DRIVES 10
#define MAX_DRIVE_PATH_LENGTH 200 /* e.g. /dev/sda is only 8 characters long, so 200 should be plenty*/
/* Function prototypes for loading options from the environment and command line. */
int nwipe_options_parse( int argc, char** argv );
@@ -48,12 +50,14 @@ typedef struct /* nwipe_options_t */
{
int autonuke; /* Do not prompt the user for confirmation when set. */
int noblank; /* Do not perform a final blanking pass. */
int nowait; /* Do not wait for a final key before exiting. */
int nogui ; /* Do not show the GUI. */
int nowait; /* Do not wait for a final key before exiting. */
int nosignals; /* Do not allow signals to interrupt a wipe. */
int nogui ; /* Do not show the GUI. */
char* banner; /* The product banner shown on the top line of the screen. */
// nwipe_method_t method; /* A function pointer to the wipe method that will be used. */
void* method; /* A function pointer to the wipe method that will be used. */
char logfile[FILENAME_MAX]; /* The filename to log the output to */
char exclude[MAX_NUMBER_EXCLUDED_DRIVES][MAX_DRIVE_PATH_LENGTH]; /* Drives excluded from the search */
nwipe_prng_t* prng; /* The pseudo random number generator implementation. */
int rounds; /* The number of times that the wipe method should be called. */
int sync; /* A flag to indicate whether writes should be sync'd. */

View File

@@ -20,9 +20,8 @@
*
*/
/* Why is this needed? Segfaults without it */
#include <netinet/in.h>
#include <stdint.h>
#include "nwipe.h"
#include "context.h"
#include "method.h"
@@ -46,7 +45,7 @@ int nwipe_random_verify( nwipe_context_t* c )
size_t blocksize;
/* The result buffer for calls to lseek. */
loff_t offset;
off64_t offset;
/* The input buffer. */
char* b;
@@ -89,6 +88,7 @@ int nwipe_random_verify( nwipe_context_t* c )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate memory for the pattern buffer." );
free(b);
return -1;
}
@@ -98,10 +98,12 @@ int nwipe_random_verify( nwipe_context_t* c )
/* Reset the pass byte counter. */
c->pass_done = 0;
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
free(b);
free(d);
return -1;
}
@@ -109,6 +111,8 @@ int nwipe_random_verify( nwipe_context_t* c )
{
/* This is system insanity. */
nwipe_log( NWIPE_LOG_SANITY, "lseek() returned a bogus offset on '%s'.", c->device_name );
free(b);
free(d);
return -1;
}
@@ -177,7 +181,7 @@ int nwipe_random_verify( nwipe_context_t* c )
/* Bump the file pointer to the next block. */
offset = lseek( c->device_fd, s, SEEK_CUR );
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial read.", c->device_name );
@@ -225,7 +229,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
size_t blocksize;
/* The result buffer for calls to lseek. */
loff_t offset;
off64_t offset;
/* The output buffer. */
char* b;
@@ -267,10 +271,11 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
/* Reset the pass byte counter. */
c->pass_done = 0;
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
free(b);
return -1;
}
@@ -278,6 +283,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
{
/* This is system insanity. */
nwipe_log( NWIPE_LOG_SANITY, "__FUNCTION__: lseek() returned a bogus offset on '%s'.", c->device_name );
free(b);
return -1;
}
@@ -328,7 +334,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE )
/* Bump the file pointer to the next block. */
offset = lseek( c->device_fd, s, SEEK_CUR );
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial write.", c->device_name );
@@ -388,7 +394,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
size_t blocksize;
/* The result buffer for calls to lseek. */
loff_t offset;
off64_t offset;
/* The input buffer. */
char* b;
@@ -438,6 +444,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate memory for the pattern buffer." );
free(b);
return -1;
}
@@ -470,10 +477,11 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
/* Reset the pass byte counter. */
c->pass_done = 0;
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
free(b);
return -1;
}
@@ -481,6 +489,8 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
{
/* This is system insanity. */
nwipe_log( NWIPE_LOG_SANITY, "nwipe_static_verify: lseek() returned a bogus offset on '%s'.", c->device_name );
free(b);
free(d);
return -1;
}
@@ -534,7 +544,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
/* Bump the file pointer to the next block. */
offset = lseek( c->device_fd, s, SEEK_CUR );
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial read.", c->device_name );
@@ -587,7 +597,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
size_t blocksize;
/* The result buffer for calls to lseek. */
loff_t offset;
off64_t offset;
/* The output buffer. */
char* b;
@@ -638,7 +648,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
/* Reset the pass byte counter. */
c->pass_done = 0;
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name );
@@ -697,7 +707,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern )
/* Bump the file pointer to the next block. */
offset = lseek( c->device_fd, s, SEEK_CUR );
if( offset == (loff_t)-1 )
if( offset == (off64_t)-1 )
{
nwipe_perror( errno, __FUNCTION__, "lseek" );
nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial write.", c->device_name );

View File

@@ -25,6 +25,7 @@
#include "mt19937ar-cok.h"
#include "isaac_rand.h"
nwipe_prng_t nwipe_twister =
{
"Mersenne Twister (mt19937ar-cok)",
@@ -40,6 +41,25 @@ nwipe_prng_t nwipe_isaac =
};
/* Print given number of bytes from unsigned integer number to a byte stream buffer starting with low-endian*/
int nwipe_u32tobuffer(u8 *buffer, u32 rand, int len)
{
int i;
u8 c; //single char
if (len > sizeof(u32))
{
nwipe_log( NWIPE_LOG_FATAL, "Tried to print longer number than the value passed." );
len = sizeof(u32);
}
for (i=0 ; i < len; i++)
{
c=rand & 0xFFUL;
rand = rand >> 8;
buffer[i]=c;
}
return 0;
}
int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
{
@@ -54,21 +74,23 @@ int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE )
{
u32 i=0;
u32 ii;
u32 words = count / sizeof( u32 );
u32 remain = count % sizeof( u32 );
u32 words = count / SIZE_OF_TWISTER ; // the values of twister_genrand_int32 is strictly 4 bytes
u32 remain = count % SIZE_OF_TWISTER ; // the values of twister_genrand_int32 is strictly 4 bytes
/* Twister returns 4-bytes per call, so cast the buffer into words. */
/* Twister returns 4-bytes per call, so progress by 4 bytes. */
for( ii = 0; ii < words; ++ii )
{
((u32*)buffer)[ii] = twister_genrand_int32( (twister_state_t*)*state );
nwipe_u32tobuffer((u8*)(buffer+i), twister_genrand_int32( (twister_state_t*)*state ), SIZE_OF_TWISTER) ;
i = i + SIZE_OF_TWISTER;
}
/* Fill the buffer tail if the count is not evenly divided by the size of u32. */
for( ii = 1; ii <= remain; ++ii )
/* If there is some remainder copy only relevant number of bytes to not
* overflow the buffer. */
if ( remain > 0 )
{
/* Notice how three bytes are discarded by doing this. */
((u8*)buffer)[count-ii] = twister_genrand_int32( (twister_state_t*)*state );
nwipe_u32tobuffer((u8*)(buffer+i), twister_genrand_int32( (twister_state_t*)*state ), remain) ;
}
return 0;
@@ -127,6 +149,19 @@ int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE )
int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE )
{
/* The purpose of this function is unclear, as it does not do anything except immediately return !
* Because the variables in the macro NWIPE_PRNG_READ_SIGNATURE were then unused this throws
* up a handful of compiler warnings, related to variables being unused. To stop the compiler warnings
* I've simply put in a (void) var so that compiler sees the variable are supposed to be unused.
*
* As this code works, I thought it best not to remove this function, just in case it servers
* some purpose or is there for future use.
*/
(void) state;
(void) buffer;
(void) count;
return 0;
}

View File

@@ -51,6 +51,10 @@ int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE );
int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE );
int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE );
/* Size of the twister is not derived from the architecture, but it is strictly 4 bytes */
#define SIZE_OF_TWISTER 4
#endif /* PRNG_H_ */
/* eof */

View File

@@ -4,13 +4,14 @@
* used by configure to dynamically assign those values
* to documentation files.
*/
const char *version_string = "0.15";
const char *version_string = "0.26";
const char *program_name = "nwipe";
const char *author_name = "Andy Beverley";
const char *email_address = "andy@andybev.com";
const char *years = "2012";
const char *author_name = "Martijn van Brummelen";
const char *email_address = "git@brumit.nl";
const char *years = "2019";
const char *copyright = "Copyright Darik Horn <dajhorn-dban@vanadac.com>\n\
Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
FOR A PARTICULAR PURPOSE.\n";
const char *banner = "nwipe 0.26 (based on DBAN's dwipe - Darik's Wipe)";

View File

@@ -6,5 +6,6 @@ extern char *program_name;
extern char *author_name;
extern char *email_address;
extern char *copyright;
extern char *banner;
#endif/*__VERSION_H*/