mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-03-04 20:02:11 +00:00
Merge pull request #239 from PartialVolume/add_no_usb_option
Add --nousb option.
This commit is contained in:
@@ -17,6 +17,7 @@ other items in 0.29 are proposed and yet to be implemented.
|
||||
- [DONE] Add serial number display for USB to IDE/SATA adapters. This only works if the USB to IDE/SATA adapter supports ATA pass through. See #149 for further details (Thanks PartialVolume)
|
||||
- [DONE] Fix disk capacity nomenclature, width and padding on drive selection screen. See #237 (Thanks PartialVolume)
|
||||
- [DONE] Add bus type, ATA or USB, amongst others to drive selection and wipe windows. (Thanks PartialVolume)
|
||||
- [DONE] Add --nousb option. If you use the option --nousb, all USB devices will be ignored. They won't show up in the GUI and they won't be wiped if you use the --nogui --autonuke command. They will even be ignored if you specifically name them on the command line.
|
||||
- Add enhancement fibre channel wiping of non 512 bytes/sector drives such as 524/528 bytes/sector etc (work in progress by PartialVolume)
|
||||
- HPA/DCO detection and adjustment to wipe full drive. (work in progress by PartialVolume)
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ Do not wait for a key before exiting (default is to wait).
|
||||
\fB\-\-nosignals\fR
|
||||
Do not allow signals to interrupt a wipe (default is to allow).
|
||||
.TP
|
||||
\fB\-\-nousb\fR
|
||||
Do not show or wipe any USB devices, whether in GUI, --nogui or autonuke
|
||||
mode. (default is to allow USB devices to be shown and wiped).
|
||||
.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.
|
||||
|
||||
56
src/device.c
56
src/device.c
@@ -47,6 +47,8 @@
|
||||
int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount );
|
||||
char* trim( char* str );
|
||||
|
||||
extern int terminate_signal;
|
||||
|
||||
int nwipe_device_scan( nwipe_context_t*** c )
|
||||
{
|
||||
/**
|
||||
@@ -67,6 +69,13 @@ int nwipe_device_scan( nwipe_context_t*** c )
|
||||
{
|
||||
if( check_device( c, dev, dcount ) )
|
||||
dcount++;
|
||||
|
||||
/* Don't bother scanning drives if the terminate signal is active ! as in the case of
|
||||
* the readlink program missing which is required if the --nousb option has been specified */
|
||||
if( terminate_signal == 1 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the number of devices that were found. */
|
||||
@@ -104,6 +113,13 @@ int nwipe_device_get( nwipe_context_t*** c, char** devnamelist, int ndevnames )
|
||||
|
||||
if( check_device( c, dev, dcount ) )
|
||||
dcount++;
|
||||
|
||||
/* Don't bother scanning drives if the terminate signal is active ! as in the case of
|
||||
* the readlink program missing which is required if the --nousb option has been specified */
|
||||
if( terminate_signal == 1 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the number of devices that were found. */
|
||||
@@ -119,6 +135,9 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
|
||||
int idx;
|
||||
int r;
|
||||
char tmp_serial[21];
|
||||
nwipe_device_t bus;
|
||||
|
||||
bus = 0;
|
||||
|
||||
/* Check whether this drive is on the excluded drive list ? */
|
||||
idx = 0;
|
||||
@@ -131,6 +150,35 @@ int check_device( nwipe_context_t*** c, PedDevice* dev, int dcount )
|
||||
}
|
||||
}
|
||||
|
||||
/* Check whether the user has specified using the --nousb option
|
||||
* that all USB devices should not be displayed or wiped whether
|
||||
* in GUI, --nogui or --autonuke modes */
|
||||
|
||||
if( nwipe_options.nousb )
|
||||
{
|
||||
/* retrieve bus and drive serial number, HOWEVER we are only interested in the bus at this time */
|
||||
r = nwipe_get_device_bus_type_and_serialno( dev->path, &bus, tmp_serial );
|
||||
|
||||
if( r == 0 || r == 5 )
|
||||
{
|
||||
if( bus == NWIPE_DEVICE_USB )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Device %s ignored as per command line option --nousb", dev->path );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( r == 2 )
|
||||
{
|
||||
nwipe_log(
|
||||
NWIPE_LOG_NOTICE, "--nousb requires the 'readlink' program, please install readlink", dev->path );
|
||||
terminate_signal = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Try opening the device to see if it's valid. Close on completion. */
|
||||
if( !ped_device_open( dev ) )
|
||||
{
|
||||
@@ -403,6 +451,13 @@ int nwipe_get_device_bus_type_and_serialno( char* device, nwipe_device_t* bus, c
|
||||
if( system( "which /usr/bin/readlink > /dev/null 2>&1" ) )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install readlink !" );
|
||||
set_return_value = 2;
|
||||
|
||||
/* Return immediatley if --nousb specified. Readlink is a requirment for this option. */
|
||||
if( nwipe_options.nousb )
|
||||
{
|
||||
return set_return_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -481,6 +536,7 @@ int nwipe_get_device_bus_type_and_serialno( char* device, nwipe_device_t* bus, c
|
||||
}
|
||||
|
||||
set_return_value = 2;
|
||||
return set_return_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,12 @@ int main( int argc, char** argv )
|
||||
}
|
||||
}
|
||||
|
||||
if( terminate_signal == 1 )
|
||||
{
|
||||
cleanup();
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
/* Log the System information */
|
||||
nwipe_log_sysinfo();
|
||||
|
||||
|
||||
@@ -84,6 +84,9 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
/* Whether to blank the disk after wiping. */
|
||||
{"noblank", no_argument, 0, 0},
|
||||
|
||||
/* Whether to ignore all USB devices. */
|
||||
{"nousb", no_argument, 0, 0},
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{"nowait", no_argument, 0, 0},
|
||||
|
||||
@@ -115,6 +118,7 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
nwipe_options.prng = &nwipe_twister;
|
||||
nwipe_options.rounds = 1;
|
||||
nwipe_options.noblank = 0;
|
||||
nwipe_options.nousb = 0;
|
||||
nwipe_options.nowait = 0;
|
||||
nwipe_options.nosignals = 0;
|
||||
nwipe_options.nogui = 0;
|
||||
@@ -163,6 +167,12 @@ int nwipe_options_parse( int argc, char** argv )
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nousb" ) == 0 )
|
||||
{
|
||||
nwipe_options.nousb = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nowait" ) == 0 )
|
||||
{
|
||||
nwipe_options.nowait = 1;
|
||||
@@ -509,6 +519,8 @@ void display_help()
|
||||
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( " --nousb Do show or wipe any USB devices whether in GUI" );
|
||||
puts( " mode, --nogui or --autonuke modes.\n" );
|
||||
puts( " -e, --exclude=DEVICES Up to ten comma separated devices to be excluded" );
|
||||
puts( " --exclude=/dev/sdc" );
|
||||
puts( " --exclude=/dev/sdc,/dev/sdd" );
|
||||
|
||||
@@ -50,6 +50,7 @@ typedef struct
|
||||
int autonuke; // Do not prompt the user for confirmation when set.
|
||||
int autopoweroff; // Power off on completion of wipe
|
||||
int noblank; // Do not perform a final blanking pass.
|
||||
int nousb; // Do not show or wipe any USB devices.
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user