added -P option for PDFreportpath

This commit is contained in:
Gerold Gruber
2023-10-02 20:28:49 +02:00
parent c1e943d283
commit 8124e6b3d5
7 changed files with 43 additions and 5 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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 */

View File

@@ -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. */

View File

@@ -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" );

View File

@@ -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