From 7b1a5b98a73ef6921f251363ae159038b779d03a Mon Sep 17 00:00:00 2001 From: louib Date: Sat, 2 Nov 2019 18:33:36 -0400 Subject: [PATCH 1/6] Fix typos in README and comments. --- README | 4 ++-- README.md | 7 +++---- src/device.c | 2 +- src/options.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README b/README index 10803e5..daed97f 100644 --- a/README +++ b/README @@ -10,7 +10,7 @@ parted Debian & Ubuntu prerequisites ============================ -If you compiling nwipe from source the following will need to be installed first +If you are compiling nwipe from source the following will need to be installed first sudo apt install build-essential sudo apt install pkg-config @@ -52,7 +52,7 @@ this can be done using the alternate compile commands make make install -The '-O0 -g' flags disable optimisations, this is required if your debugging with +The '-O0 -g' flags disable optimisations, this is required if you're 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. diff --git a/README.md b/README.md index 64d9e3a..f69ba1c 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,8 @@ allow its use with any host distribution, thus giving better hardware support. To use from the git repository, first create all the autoconf files with -./init.sh +`./init.sh` -Then do the standard ./configure --prefix=/usr && make && make install - -For developer & release notes please see the [README file](README) +Then do the standard `./configure --prefix=/usr && make && make install` +For developers & release notes please see the [README file](README) diff --git a/src/device.c b/src/device.c index d27dabc..98aef6a 100644 --- a/src/device.c +++ b/src/device.c @@ -44,7 +44,7 @@ char *trim(char *str); int nwipe_device_scan( nwipe_context_t*** c ) { /** - * Scans the the filesystem for storage device names. + * Scans the filesystem for storage device names. * * @parameter device_names A reference to a null array pointer. * @modifies device_names Populates device_names with an array of nwipe_contect_t diff --git a/src/options.c b/src/options.c index 5446b44..d5152d4 100644 --- a/src/options.c +++ b/src/options.c @@ -280,7 +280,7 @@ int nwipe_options_parse( int argc, char** argv ) break; - case 'V': /* Rounds option. */ + case 'V': /* Version option. */ printf ( "%s version %s\n", program_name, version_string ); exit( EXIT_SUCCESS ); From 7c025040b48f6948f3ca2bb6d31d8f1f0937f37c Mon Sep 17 00:00:00 2001 From: louib Date: Sat, 2 Nov 2019 19:14:59 -0400 Subject: [PATCH 2/6] Fix AutoConf deprecated warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following AC warning: ``` configure.ac:6: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see: configure.ac:6: https://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation ``` As per the deprecation notice, using `AM_INIT_AUTOMAKE` for setting the version is mostly obsolete because the package and version can be obtained from Autoconf’s `AC_INIT` macro. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 54426e1..82582eb 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.64]) -AC_INIT(nwipe, 0.26, git@brumit.nl) -AM_INIT_AUTOMAKE(nwipe, 0.26) +AC_INIT([nwipe], [0.26], [git@brumit.nl]) +AM_INIT_AUTOMAKE AC_OUTPUT(Makefile src/Makefile man/Makefile) AC_CONFIG_SRCDIR([src/nwipe.c]) AC_CONFIG_HEADERS([config.h]) From 766d8020c605a464f694aa67f2432b53b43e29c2 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Mon, 4 Nov 2019 22:39:20 +0000 Subject: [PATCH 3/6] Fix error reporting when accessing dmidecode. This fix allows nwipe to log an error, specifically the exit code of dmidecode if the exit code is not 0. For instance if dmidecode is not installed on a system, then dmidecode reports the following [2019/11/04 22:12:50] nwipe: info: nwipe_log_sysinfo: dmidecode failed, "dmidecode -s bios-version" exit status = 127 nwipe does not abort on this error but does log the error and continue. --- src/logging.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/logging.c b/src/logging.c index 6fd2528..6a1dad1 100644 --- a/src/logging.c +++ b/src/logging.c @@ -327,6 +327,7 @@ int nwipe_log_sysinfo() char path[256]; char cmd[50]; int len; + int r; /* A result buffer. */ /* 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 @@ -359,13 +360,13 @@ int nwipe_log_sysinfo() keywords_idx = 0; - /* Run the dmidecode command to retrieve system serial number */ + /* Run the dmidecode command to retrieve each dmidecode keyword, one at a time */ 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 ); + nwipe_log( NWIPE_LOG_INFO, "nwipe_log_sysinfo: Failed to create stream to %s", cmd ); return 1; } /* Read the output a line at a time - output it. */ @@ -379,7 +380,12 @@ int nwipe_log_sysinfo() nwipe_log( NWIPE_LOG_INFO, "%s = %s", &dmidecode_keywords[keywords_idx][0], path ); } /* close */ - pclose(fp); + r = pclose(fp); + if( r > 0 ) + { + nwipe_log( NWIPE_LOG_INFO, "nwipe_log_sysinfo(): dmidecode failed, \"%s\" exit status = %u", cmd, WEXITSTATUS( r )); + return 1; + } keywords_idx++; } return 0; From d04ae940b6e52f6805922f90cb5ad6966aabbee6 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Tue, 5 Nov 2019 22:56:58 +0000 Subject: [PATCH 4/6] Limit help text line length to 80 characters 1. When running nwipe in a 80x24 terminal such as ALT-F2 or shredos the line length needs to limited to 80 characters otherwise the text looks misaligned. 2. Added a line between each option to make it more legible. --- src/options.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/src/options.c b/src/options.c index 82f04cd..99bcd26 100644 --- a/src/options.c +++ b/src/options.c @@ -428,35 +428,45 @@ display_help() { printf("Usage: %s [options] [device1] [device2] ...\n", program_name); printf("Options:\n" ); - puts(" -V, --version Prints the version number"); - puts(" -h, --help Prints this help"); - puts(" --autonuke If no devices have been specified on the command line, starts wiping all"); - puts(" devices immediately. If devices have been specified, starts wiping only"); - puts(" those specified devices immediately."); - puts(" --sync Open devices in sync mode"); - puts(" --verify=TYPE Whether to perform verification of erasure (default: last)"); + /* Limit line length to a maximum of 80 characters so it looks good in 80x25 terminals i.e shredos */ + /* ___12345678901234567890123456789012345678901234567890123456789012345678901234567890< Do not exceed */ + puts(" -V, --version Prints the version number\n"); + puts(" -h, --help Prints this help\n"); + puts(" --autonuke If no devices have been specified on the command line,"); + puts(" starts wiping all devices immediately. If devices have"); + puts(" been specified, starts wiping only those specified"); + puts(" devices immediately.\n"); + puts(" --sync Open devices in sync mode\n"); + puts(" --verify=TYPE Whether to perform verification of erasure"); + puts(" (default: last)"); puts(" off - Do not verify"); puts(" last - Verify after the last pass"); - puts(" all - Verify every pass"); - puts(" -m, --method=METHOD The wiping method (default: dodshort). See man page for more details."); + puts(" all - Verify every pass\n"); + puts(" -m, --method=METHOD The wiping method. See man page for more details."); + puts(" (default: dodshort)"); puts(" dod522022m / dod - 7 pass DOD 5220.22-M method"); puts(" dodshort / dod3pass - 3 pass DOD method"); puts(" gutmann - Peter Gutmann's Algorithm"); puts(" ops2 - RCMP TSSIT OPS-II"); puts(" random / prng / stream - PRNG Stream"); - puts(" zero / quick - Overwrite with zeros"); - puts(" -l, --logfile=FILE Filename to log to. Default is STDOUT"); - puts(" -p, --prng=METHOD PRNG option (mersenne|twister|isaac)" ); - 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(" zero / quick - Overwrite with zeros\n"); + puts(" -l, --logfile=FILE Filename to log to. Default is STDOUT\n"); + puts(" -p, --prng=METHOD PRNG option (mersenne|twister|isaac)\n"); + puts(" -r, --rounds=NUM Number of times to wipe the device using the selected"); + puts(" method (default: 1)\n" ); + puts(" --noblank Do not blank disk after wipe"); + puts(" (default is to complete a final blank pass)\n" ); + puts(" --nowait Do not wait for a key before exiting"); + puts(" (default is to wait)\n" ); + puts(" --nosignals Do not allow signals to interrupt a wipe"); + puts(" (default is to allow)\n" ); + puts(" --nogui Do not show the GUI interface. Automatically invokes" ); + puts(" the nowait option. Must be used with the --autonuke"); + puts(" option. Send SIGUSR1 to log current stats\n"); + puts(" -e, --exclude=DEVICES Up to ten comma separted devices to be excluded"); puts(" --exclude=/dev/sdc"); puts(" --exclude=/dev/sdc,/dev/sdd"); - puts(" --exclude=/dev/sdc,/dev/sdd,/dev/mapper/cryptswap1"); + puts(" --exclude=/dev/sdc,/dev/sdd,/dev/mapper/cryptswap1\n"); puts(""); exit( EXIT_SUCCESS ); } From f6c1cab28a3b0128a458974387941e17c6617f8d Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Wed, 6 Nov 2019 14:13:33 +0000 Subject: [PATCH 5/6] Have nwipe continue with following devices even if one fails --- src/device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 9244fad..5dac189 100644 --- a/src/device.c +++ b/src/device.c @@ -90,7 +90,10 @@ int nwipe_device_get( nwipe_context_t*** c, char **devnamelist, int ndevnames ) dev = ped_device_get(devnamelist[i]); if (!dev) - break; + { + nwipe_log( NWIPE_LOG_WARNING, "Device %s not found", devnamelist[i] ); + continue; + } if (check_device(c, dev, dcount)) dcount++; From 5199fb1793a00fe4812054381e80e871617496d9 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Wed, 6 Nov 2019 20:03:39 +0000 Subject: [PATCH 6/6] Fix wipe status saying Success when it never even started. Capitalise success and failure messages in GUI and log to make them stand out --- src/device.c | 1 + src/gui.c | 6 +++--- src/nwipe.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/device.c b/src/device.c index 5dac189..ccd695d 100644 --- a/src/device.c +++ b/src/device.c @@ -151,6 +151,7 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount ) 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); + next_device->result = -2; /* Attempt to get serial number of device. */ if ( (fd = open ( next_device->device_name = dev->path, O_RDONLY)) == ERR ) { diff --git a/src/gui.c b/src/gui.c index 8205c71..147113b 100644 --- a/src/gui.c +++ b/src/gui.c @@ -1839,9 +1839,9 @@ void *nwipe_gui_status( void *ptr ) else { - if( c[i]->result == 0 ) { mvwprintw( main_window, yy++, 4, "(success) " ); } - else if( c[i]->signal ) { mvwprintw( main_window, yy++, 4, "(failure, signal %i) ", c[i]->signal ); } - else { mvwprintw( main_window, yy++, 4, "(failure, code %i) ", c[i]->result ); } + if( c[i]->result == 0 ) { mvwprintw( main_window, yy++, 4, "(SUCCESS!) " ); } + else if( c[i]->signal ) { mvwprintw( main_window, yy++, 4, "(>>> FAILURE! <<<, signal %i) ", c[i]->signal ); } + else { mvwprintw( main_window, yy++, 4, "(>>>FAILURE!<<<, code %i) ", c[i]->result ); } } /* child returned */ diff --git a/src/nwipe.c b/src/nwipe.c index c7586fd..d92dfa1 100644 --- a/src/nwipe.c +++ b/src/nwipe.c @@ -565,8 +565,8 @@ void *signal_hand(void *ptr) else { if( c[i]->result == 0 ) { nwipe_log( NWIPE_LOG_INFO, "%s: Success", c[i]->device_name ); } - else if( c[i]->signal ) { nwipe_log( NWIPE_LOG_INFO, "%s: Failure: signal %i", c[i]->device_name, c[i]->signal ); } - else { nwipe_log( NWIPE_LOG_INFO, "%s: Failure: code %i", c[i]->device_name, c[i]->result ); } + else if( c[i]->signal ) { nwipe_log( NWIPE_LOG_INFO, "%s: >>> FAILURE! <<<: signal %i", c[i]->device_name, c[i]->signal ); } + else { nwipe_log( NWIPE_LOG_INFO, "%s: >>> FAILURE! <<<: code %i", c[i]->device_name, c[i]->result ); } } }