mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-02-20 22:15:41 +00:00
@@ -1,10 +1,11 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.64])
|
||||
AC_INIT([nwipe], [0.34], [git@brumit.nl])
|
||||
AC_PREREQ([2.71])
|
||||
AC_INIT([nwipe],[0.34],[git@brumit.nl])
|
||||
AM_INIT_AUTOMAKE(foreign subdir-objects)
|
||||
AC_OUTPUT(Makefile src/Makefile man/Makefile)
|
||||
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
|
||||
AC_OUTPUT
|
||||
AC_CONFIG_SRCDIR([src/nwipe.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ devices immediately. If devices have been specified, starts wiping only
|
||||
those specified devices immediately.
|
||||
.TP
|
||||
\fB\-\-autopoweroff\fR
|
||||
Power off system on completion of wipe delayed for for one minute. During
|
||||
Power off system on completion of wipe delayed for one minute. During
|
||||
this one minute delay you can abort the shutdown by typing sudo shutdown -c
|
||||
.TP
|
||||
\fB\-\-sync\fR=\fINUM\fR
|
||||
@@ -111,6 +111,11 @@ is5enh \- HMG IS5 enhanced
|
||||
\fB\-l\fR, \fB\-\-logfile\fR=\fIFILE\fR
|
||||
Filename to log to. Default is STDOUT
|
||||
.TP
|
||||
\fB\-P\fR, \fB\-\-PDFreportpath\fR=\fIDIR\fR
|
||||
Directory to write the PDF nwipe reports/certificates to.
|
||||
Defaults to ".".
|
||||
If \fIDIR\fR is set to \fInoPDF\fR no report PDF files are written.
|
||||
.TP
|
||||
\fB\-p\fR, \fB\-\-prng\fR=\fIMETHOD\fR
|
||||
PRNG option (mersenne|twister|isaac|isaac64)
|
||||
.TP
|
||||
|
||||
@@ -70,7 +70,7 @@ typedef struct nwipe_speedring_t_
|
||||
} nwipe_speedring_t;
|
||||
|
||||
#define NWIPE_DEVICE_LABEL_LENGTH 200
|
||||
#define NWIPE_DEVICE_SIZE_TXT_LENGTH 7
|
||||
#define NWIPE_DEVICE_SIZE_TXT_LENGTH 8
|
||||
|
||||
// Arbitrary length, so far most paths don't exceed about 25 characters
|
||||
#define MAX_HWMON_PATH_LENGTH 100
|
||||
@@ -157,7 +157,7 @@ typedef struct nwipe_context_t_
|
||||
time_t start_time; // Start time of wipe
|
||||
time_t end_time; // End time of wipe
|
||||
u64 fsyncdata_errors; // The number of fsyncdata errors across all passes.
|
||||
char PDF_filename[256]; // The filename of the PDF certificate/report.
|
||||
char PDF_filename[FILENAME_MAX]; // The filename of the PDF certificate/report.
|
||||
int HPA_status; // 0 = No HPA found/disabled, 1 = HPA detected, 2 = Unknown, unable to checked,
|
||||
// 3 = Not applicable to this device
|
||||
u64 HPA_reported_set; // the 'HPA set' value reported hdparm -N, i.e the first value of n/n
|
||||
|
||||
@@ -841,7 +841,8 @@ int create_pdf( nwipe_context_t* ptr )
|
||||
replace_non_alphanumeric( c->device_serial_no, '_' );
|
||||
snprintf( c->PDF_filename,
|
||||
sizeof( c->PDF_filename ),
|
||||
"nwipe_report_%s_Model_%s_Serial_%s.pdf",
|
||||
"%s/nwipe_report_%s_Model_%s_Serial_%s.pdf",
|
||||
nwipe_options.PDFreportpath,
|
||||
end_time_text,
|
||||
c->device_model,
|
||||
c->device_serial_no );
|
||||
@@ -960,6 +961,7 @@ int nwipe_get_smart_data( char* device )
|
||||
}
|
||||
}
|
||||
|
||||
pdf_set_font( pdf, "Courier" );
|
||||
pdf_add_text( pdf, page_2, result, 6, x, y, PDF_BLACK );
|
||||
y -= 9;
|
||||
}
|
||||
|
||||
11
src/device.c
11
src/device.c
@@ -244,11 +244,18 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
|
||||
|
||||
for( idx = 0; idx < 20; idx++ )
|
||||
{
|
||||
next_device->device_serial_no[idx] = next_device->identity.serial_no[idx];
|
||||
if( isascii( next_device->identity.serial_no[idx] ) && !iscntrl( next_device->identity.serial_no[idx] ) )
|
||||
{
|
||||
next_device->device_serial_no[idx] = next_device->identity.serial_no[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Terminate the string.
|
||||
next_device->device_serial_no[20] = 0;
|
||||
next_device->device_serial_no[idx] = 0;
|
||||
|
||||
// Remove leading/trailing whitespace from serial number and left justify.
|
||||
trim( (char*) next_device->device_serial_no );
|
||||
|
||||
@@ -890,8 +890,13 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
|
||||
model,
|
||||
serial_no );
|
||||
|
||||
/* Create the PDF certificate */
|
||||
create_pdf( c[i] );
|
||||
/* Create the PDF report/certificate */
|
||||
if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) != 0 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTIMESTAMP, "Creating PDF report in %s\n", nwipe_options.PDFreportpath );
|
||||
printf( "Creating PDF report in %s\n", nwipe_options.PDFreportpath );
|
||||
create_pdf( c[i] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine the size of throughput so that the correct nomenclature can be used */
|
||||
|
||||
@@ -159,25 +159,25 @@ void Determine_C_B_nomenclature( u64 qty, char* result, int result_array_size )
|
||||
}
|
||||
|
||||
/* Determine the size of throughput so that the correct nomenclature can be used */
|
||||
if( qty >= INT64_C( 1000000000000 ) )
|
||||
if( qty >= INT64_C( 10000000000000 ) )
|
||||
{
|
||||
snprintf( result, result_array_size, "%3llu TB", qty / INT64_C( 1000000000000 ) );
|
||||
snprintf( result, result_array_size, "%4llu TB", qty / INT64_C( 1000000000000 ) );
|
||||
}
|
||||
else if( qty >= INT64_C( 1000000000 ) )
|
||||
else if( qty >= INT64_C( 10000000000 ) )
|
||||
{
|
||||
snprintf( result, result_array_size, "%3llu GB", qty / INT64_C( 1000000000 ) );
|
||||
snprintf( result, result_array_size, "%4llu GB", qty / INT64_C( 1000000000 ) );
|
||||
}
|
||||
else if( qty >= INT64_C( 1000000 ) )
|
||||
else if( qty >= INT64_C( 10000000 ) )
|
||||
{
|
||||
snprintf( result, result_array_size, "%3llu MB", qty / INT64_C( 1000000 ) );
|
||||
snprintf( result, result_array_size, "%4llu MB", qty / INT64_C( 1000000 ) );
|
||||
}
|
||||
else if( qty >= INT64_C( 1000 ) )
|
||||
else if( qty >= INT64_C( 10000 ) )
|
||||
{
|
||||
snprintf( result, result_array_size, "%3llu KB", qty / INT64_C( 1000 ) );
|
||||
snprintf( result, result_array_size, "%4llu KB", qty / INT64_C( 1000 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( result, result_array_size, "%3llu B", qty / INT64_C( 1 ) );
|
||||
snprintf( result, result_array_size, "%4llu B", qty / INT64_C( 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
src/nwipe.c
12
src/nwipe.c
@@ -32,6 +32,7 @@
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nwipe.h"
|
||||
#include "context.h"
|
||||
@@ -154,6 +155,17 @@ int main( int argc, char** argv )
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the given path for PDF reports is a writeable directory */
|
||||
if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) != 0 )
|
||||
{
|
||||
if( access( nwipe_options.PDFreportpath, W_OK ) != 0 )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_ERROR, "PDFreportpath %s is not a writeable directory.", nwipe_options.PDFreportpath );
|
||||
cleanup();
|
||||
exit( 2 );
|
||||
}
|
||||
}
|
||||
|
||||
if( nwipe_optind == argc )
|
||||
{
|
||||
/* File names were not given by the user. Scan for devices. */
|
||||
|
||||
@@ -54,7 +54,7 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
int i;
|
||||
|
||||
/* The list of acceptable short options. */
|
||||
char nwipe_options_short[] = "Vvhl:m:p:qr:e:";
|
||||
char nwipe_options_short[] = "Vvhl:P:m:p:qr:e:";
|
||||
|
||||
/* The list of acceptable long options. */
|
||||
static struct option nwipe_options_long[] = {
|
||||
@@ -73,6 +73,9 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
/* Log file. Corresponds to the 'l' short option. */
|
||||
{ "logfile", required_argument, 0, 'l' },
|
||||
|
||||
/* PDFreport path. Corresponds to the 'P' short option. */
|
||||
{ "PDFreportpath", required_argument, 0, 'P' },
|
||||
|
||||
/* Exclude devices, comma separated list */
|
||||
{ "exclude", required_argument, 0, 'e' },
|
||||
|
||||
@@ -131,6 +134,8 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
nwipe_options.verbose = 0;
|
||||
nwipe_options.verify = NWIPE_VERIFY_LAST;
|
||||
memset( nwipe_options.logfile, '\0', sizeof( nwipe_options.logfile ) );
|
||||
memset( nwipe_options.PDFreportpath, '\0', sizeof( nwipe_options.PDFreportpath ) );
|
||||
strncpy( nwipe_options.PDFreportpath, ".", 2 );
|
||||
|
||||
/* Initialise each of the strings in the excluded drives array */
|
||||
for( i = 0; i < MAX_NUMBER_EXCLUDED_DRIVES; i++ )
|
||||
@@ -315,6 +320,12 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
strncpy( nwipe_options.logfile, optarg, sizeof( nwipe_options.logfile ) );
|
||||
break;
|
||||
|
||||
case 'P': /* PDFreport path option. */
|
||||
|
||||
nwipe_options.PDFreportpath[strlen( optarg )] = '\0';
|
||||
strncpy( nwipe_options.PDFreportpath, optarg, sizeof( nwipe_options.PDFreportpath ) );
|
||||
break;
|
||||
|
||||
case 'e': /* exclude drives option */
|
||||
|
||||
idx_drive_chr = 0;
|
||||
@@ -570,6 +581,8 @@ void display_help()
|
||||
puts( " verify_zero - Verifies disk is zero filled" );
|
||||
puts( " verify_one - Verifies disk is 0xFF filled\n" );
|
||||
puts( " -l, --logfile=FILE Filename to log to. Default is STDOUT\n" );
|
||||
puts( " -P, --PDFreportpath=PATH Path to write PDF reports to. Default is \".\"" );
|
||||
puts( " If set to \"noPDF\" no PDF reports are written.\n" );
|
||||
puts( " -p, --prng=METHOD PRNG option (mersenne|twister|isaac|isaac64)\n" );
|
||||
puts( " -q, --quiet Anonymize logs and the GUI by removing unique data, i.e." );
|
||||
puts( " serial numbers, LU WWN Device ID, and SMBIOS/DMI data" );
|
||||
|
||||
@@ -58,6 +58,7 @@ typedef struct
|
||||
char* banner; // The product banner shown on the top line of the screen.
|
||||
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 PDFreportpath[FILENAME_MAX]; // The path to write the PDF report 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. pointer to the function.
|
||||
int quiet; // Anonymize serial numbers
|
||||
|
||||
Reference in New Issue
Block a user