878 Commits
0.20 ... v0.36

Author SHA1 Message Date
PartialVolume
cb595e139c Update README.md 2024-02-20 21:19:54 +00:00
PartialVolume
08f68f14d9 Merge pull request #549 from PartialVolume/Bump_version_to_0.36
Bump version to 0.36
2024-02-20 20:53:14 +00:00
PartialVolume
f17845c54b Updated CHANGELOG.md 2024-02-20 20:43:54 +00:00
PartialVolume
230e7f524a Bump to v0.36 2024-02-20 19:52:25 +00:00
PartialVolume
de077211e6 Merge pull request #548 from PartialVolume/Fix_some_strcpy_warnings_for_Debian
Fix some strcpy compiler warnings
2024-02-17 17:23:30 +00:00
PartialVolume
07a7c0ab0c Fix some strcpy compiler warnings
Replace three strcpy commands with strncpy,
bump minor version ready for more testing.
2024-02-17 17:00:37 +00:00
PartialVolume
2fae6ea5f5 Merge pull request #546 from PartialVolume/Determine_block_sizes_before_hidden_sector_detection
Populates device block size before hidden sector
2024-02-15 23:21:50 +00:00
PartialVolume
d6f7238cb3 Populates device block size before hidden sector
Now populates the block size (physical) before
the hidden sector determination function runs.

The naming of block/sector can be very confusing in
nwipe. So I have created a device_phy_sector_size
in the drive context, so we have

->device_sector_size // logical sector size
->device_phys_sector_size // physical sector size
->device_block_size // Usually the same as logical
size but could be increased by nwipe to encompass
multiple logical sectors, i.e a block of sectors
2024-02-15 23:11:09 +00:00
PartialVolume
c007d0f2ab Update version.c
Bump minor version from 0.35.6 to 0.35.7
2024-02-15 11:51:45 +00:00
PartialVolume
161054269c Merge pull request #543 from PartialVolume/Fix_incorrect_HS_status_for_4096_sectors_as_reported_by_libata
Fix hidden sector detection for logical 4096 size
2024-02-03 22:34:47 +00:00
PartialVolume
dd7ffab816 Fix hidden sector detection for logical 4096 size
This fixes an issue where nwipe detects a discrepancy
between the number of sectors reported by hdparm and
nwipe's own HPA/DCO functions that were reporting the
same values, using number of sectors based on 512 byte
sectors but disagreed with the number of sectors
generated from libata which was reporting the number of
sectors based on 4096 byte sectors.

This has been fixed by always calculating the number
of sectors returned by libata using 512 bytes per sector
so a direct comparison can be made to data from hdparm
& nwipe's HPA/DCO functions.
2024-02-03 20:20:39 +00:00
PartialVolume
9edebde20d Merge pull request #538 from PartialVolume/Make_footer_text_more_informative_at_end_of_all_wipes
Make completion footer more informative
2023-12-20 21:10:34 +00:00
PartialVolume
807eed0ffc Make completion footer more informative
These changes solve three issues. The first
issue was that it wasn't obvious that the
PDFs are only created once you press return
to exit after all the wipes have finished. It
is now explicitly stated in the footer message if
PDFs are enabled.

It also now specifies the logfile name on the
footer if the user has specified a log file as a
command line option. If no logfile is specified
then STDOUT is displayed.

If the user specified --PDFreportpath=noPDF on the
command line, prior to this commit it had no affect.
This is now fixed so that it disables PDF's irrespective
of what is in nwipe.conf. i.e command line options
override the entries in nwipe.conf

If the user has specified a --PDFreportpath=noPDF=/some/path
then PDF's are enabled irrespective of the value in nwipe.conf
2023-12-20 20:53:43 +00:00
PartialVolume
78f3a26795 Merge pull request #536 from PartialVolume/Bump_minor_version
Bump version from 0.35.3 to 0.35.4
2023-12-16 19:14:47 +00:00
PartialVolume
dbe7103fe9 Bump version from 0.35.3 to 0.35.4 2023-12-16 19:12:23 +00:00
PartialVolume
eef25e829e Merge pull request #535 from PartialVolume/Fix_incorrect_footer_on_return_to_preview
Fix incorrect footer on return to preview
2023-12-16 18:57:59 +00:00
PartialVolume
43bfb3a08e Fix incorrect footer on return to preview
This fixes incorrect footer text being displayed when
Enable customer/company preview is enabled and the user
select a field to be edited, completes the editing and
returns to the preview to select A for accept. Only
problem was A=Accept wasn't listed on the footer.
2023-12-16 18:50:33 +00:00
PartialVolume
fd6cca7010 Merge pull request #534 from PartialVolume/Fix_spacing_between_temperature_and_model
Place a space between temperature and model
2023-11-29 22:23:44 +00:00
PartialVolume
1220eca2ef Place a space between temperature and model
eg [36C] ST3500... and not [36C]ST3500..
2023-11-29 22:21:01 +00:00
PartialVolume
32321f49fa Merge pull request #533 from PartialVolume/Fix_config_key_shortcuts_help_text
Fix the config help messages.

Some of the config help messages that show the purpose of the keys were inconsistent or not updating correctly when going back to the previous menu. Now fixed.
2023-11-29 19:51:02 +00:00
PartialVolume
cca93f845d Fix the config help messages
Some of the help messages that show the
purpose of the keys were inconsistent or
not updated when going back. Now fixed.
2023-11-29 19:40:47 +00:00
PartialVolume
789aa134a0 Merge pull request #532 from PartialVolume/Fix_PDF_page_titles
Make smart page titles consistent with page 1

Should now read
Page 1 - Erasure Status
Page 2 - Smart Data
Page 3 - Smart Data

and not as previously
Page 1 - Erasure Status
Smart Data - Page 2
Smart Data - Page 3
2023-11-28 21:25:52 +00:00
PartialVolume
c24e248055 Make smart page titles consistent with page 1
Should now read
Page 1 - Erasure Status
Page 2 - Smart Data
Page 3 - Smart Data

and not as previously
Page 1 - Erasure Status
Smart Data - Page 2
Smart Data - Page 3
2023-11-28 21:21:48 +00:00
PartialVolume
3f78d76bac Merge pull request #531 from PartialVolume/Fix_no_auto_exit_in_non_gui_mode
Fix nwipe not auto exiting on completion in non gui mode.
2023-11-28 00:52:54 +00:00
PartialVolume
626ca3826c Fix nwipe not auto exiting on completion in non gui mode. 2023-11-27 23:39:50 +00:00
PartialVolume
f61b593093 Merge pull request #529 from PartialVolume/Fix_autopoweroff_and_nowait_when_screen_blank
Fix autopoweroff and nowait when screen blank
2023-11-24 01:14:31 +00:00
PartialVolume
7f39d81548 Fix autopoweroff and nowait when screen blank
If the user had blanked the screen, the autopoweroff
and nowait options did not work. Instead they paused
nwipe on completion of the wipe/s waiting for the b
key to be pressed which reactivated compute_stats()
function who's output indicates whether any wipes were
still active.

This was fixed so that compute_stats() is always
active while wipes are in progress, so that the
nwipe_gui_status() function will exit when all wipe
threads have completed even if the screen has been
blanked.
2023-11-24 01:06:29 +00:00
PartialVolume
d0a53f57be Merge pull request #527 from ggruber/SerialGarbage
fix: again garbage after serial number
2023-11-20 00:15:03 +00:00
Gerold Gruber
811c36b65a again garbage after serial number 2023-11-20 00:14:05 +01:00
PartialVolume
2ff23eb02c Update version.c
Bump minor version from 0.35 to 0.35.1
2023-11-17 12:04:48 +00:00
PartialVolume
7a4709da55 Merge pull request #526 from PartialVolume/Identify_mmcblk_devices
Added mmcblk device type MMC

Changed log message from "USB bridge, no pass-through support" to "Smart data unavailable" as no smart data could be caused by a non USB device such as mmcblk as well as USB devices with no ATA pass through and other devices that smartctl does not detect.
2023-11-16 20:00:13 +00:00
PartialVolume
9ee5193673 Added mmcblk device type MMC
Added the abbreviation MMC for mmcblk devices such as SD and
microSD cards and some low budget laptops.

Changed log message from "USB bridge, no pass-through support"
to "Smart data unavailable" as no smart data could be caused by
a non USB device such as mmcblk as well as USB devices with no ATA
pass through and other devices that smartctl does not detect.
2023-11-16 19:35:07 +00:00
PartialVolume
9270eda8d0 Merge pull request #523 from ggruber/master
modified disk sorting for more than 26 disks
2023-11-05 16:07:30 +00:00
Gerold Gruber
470672bc3a modified disk sorting for more than 26 disks 2023-11-05 02:02:39 +01:00
PartialVolume
d14c3da26b Merge pull request #520 from xambroz/patch-4
move the include of time.h
2023-11-04 21:29:34 +00:00
PartialVolume
4bf06d136c Merge pull request #517 from xambroz/patch-3
lower the build requirements
2023-11-04 21:22:03 +00:00
PartialVolume
2abe4975f2 Merge pull request #516 from xambroz/patch-2
move the define off64_t
2023-11-04 21:10:00 +00:00
PartialVolume
2a30ae92af Merge pull request #521 from ggruber/master
fix MAX_NUMBER_EXCLUDED_DRIVES, handle exceeding the limit, +README.md
2023-11-04 20:58:08 +00:00
Gerold Gruber
e77164f710 fix MAX_NUMBER_EXCLUDED_DRIVES, handle exceeding the limit, +README.md 2023-11-04 21:14:05 +01:00
PartialVolume
e463b10d28 Merge pull request #518 from ggruber/master
progress dots added
2023-11-04 18:36:11 +00:00
Michal Ambroz
4747ce65c6 move the include of time.h
The definition of the newly used _POSIX_SOURCE affects preprocessing of the time.h. As result on RHEL7 (possibly 6 as well) the timespec structure is not defined.
2023-11-04 15:59:38 +01:00
Gerold Gruber
28a9c70abc formatting fix 2023-11-04 13:55:11 +01:00
Gerold Gruber
2ac6ebe7ea progress dots added 2023-11-04 13:53:26 +01:00
Michal Ambroz
a70fa15bac lower the build requirements
Hello,
please lower the requirements to autoconf allowing to build rhel7/8 packages (possibly rhel6, not tested).
Thank you
Michal Ambroz
2023-11-03 22:51:59 +01:00
Michal Ambroz
398b03a11a move the define off64_t
Move the definition of the off64_t using int64_t  bellow the include stdint.h, which is actually defining it.

Without change wrong order is breaking the build on RHEL7/8/9.
2023-11-03 22:47:29 +01:00
PartialVolume
63c64b91e4 Merge pull request #514 from PartialVolume/Add_check_for_root_execution
Add_check_for_root_execution
2023-11-02 20:19:21 +00:00
PartialVolume
edfd982037 Add_check_for_root_execution 2023-11-02 20:14:52 +00:00
PartialVolume
cad05c685a Merge pull request #513 from PartialVolume/Fix_segfault_on_first_run_as_non_root
Fix_segfault_on_first_run_as_non_root
2023-11-02 19:55:47 +00:00
PartialVolume
499ad925ae Fix_segfault_on_first_run_as_non_root
Incorrectly trying to close a uninitialised file
pointer stream when the file could not be opened.
2023-11-02 19:47:53 +00:00
PartialVolume
2c17e32189 Update CHANGELOG.md
Added info about temperature thread in 0.35
2023-11-02 17:36:21 +00:00
PartialVolume
68561873ba Update README.md
Updates to README.md for version 0.35
2023-11-02 17:30:50 +00:00
PartialVolume
a30f92425c Merge pull request #512 from PartialVolume/master
Updates to CHANGELOG.md
2023-11-01 23:12:18 +00:00
PartialVolume
cb7d3d1664 Update CHANGELOG.md
Added further information about HPA/DCO
2023-11-01 23:09:22 +00:00
PartialVolume
869804f6c1 Update CHANGELOG.md
Correct some typos in CHANGELOG.md
2023-11-01 23:04:10 +00:00
PartialVolume
61cca3141e Update CHANGELOG.md
Change version number to header format ( Large, bold)
2023-11-01 23:02:22 +00:00
PartialVolume
07b83f053b Merge pull request #511 from PartialVolume/Add_changes_to_CHANGELOG.md_for_0.35_release
Update CHANGELOG.md for 0.35 release
2023-11-01 22:55:53 +00:00
PartialVolume
fd3bbd8523 Update CHANGELOG.md for 0.35 release 2023-11-01 22:52:51 +00:00
PartialVolume
1b37bcef84 Merge pull request #510 from PartialVolume/Bump_version_to_0.35
Bump version to 0.35
2023-11-01 20:13:48 +00:00
PartialVolume
f3179cf748 Bump version to 0.35 2023-11-01 20:07:33 +00:00
PartialVolume
fba63312ad Merge pull request #509 from PartialVolume/Create_PDF_Certificate_Group
Create_PDF_Certificate_Group
2023-11-01 19:52:03 +00:00
PartialVolume
1b9a376186 Create_PDF_Certificate_Group
The code that handles nwipe.conf now checks
an existing nwipe.conf for the correct default
groups. This allows future additions to the
nwipe.conf file to be added to an existing nwipe.conf
file. This makes the code more robust.

The code that handles creation of groups, settings and
values has been made into a function so any future additions
to nwipe.conf can be added with a single call to this function.

i.e
nwipe_conf_populate( "Default_Wipe.Method", "PRNG" );

The code can now handle creation of groups to a arbitrary
depth of four levels, however currently we only use a
group depth of 1.

i.e
CCC :
{
 XXX :
 {
   YYY :
   {
     ZZZ :
     {
     };
     TTT :
     {
     };
   };
 };
};
2023-11-01 19:39:43 +00:00
PartialVolume
eaa7603aaf Merge pull request #508 from PartialVolume/Fix_warning_directive_output_may_be_truncated
Fix_warning_directive_output_may_be_truncated

Fixed the following warning:

create_pdf.c:795:18: warning: ‘/nwipe_report_’ directive output may be truncated writing 14 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]
2023-10-24 20:30:30 +01:00
PartialVolume
26ae763379 Fix_warning_directive_output_may_be_truncated
Fixed the following warning:

create_pdf.c:795:18: warning: ‘/nwipe_report_’ directive
output may be truncated writing 14 bytes into a region of
size between 1 and 4096 [-Wformat-truncation=]
2023-10-24 20:22:23 +01:00
PartialVolume
95021ef0c3 Merge pull request #507 from PartialVolume/Fix_message_Creating_PDF_report_in
The message that logs which directory the nwipe PDF certificate is being saved, was being printed multiple times in the middle of the erasure summary table.

This was corrected so that it only prints once at the end of the table
2023-10-23 22:15:49 +01:00
PartialVolume
8ce7b077bf Fix_message_creating_PDF_in
The message that displays where the nwipe PDF certificate
is being saved was being printed multiple times in the
middle of the erasure summary table.

This was corrected so that it only prints once at the end
of the table.
2023-10-23 22:08:23 +01:00
PartialVolume
603716e990 Merge pull request #505 from ggruber/master
sort the device list
2023-10-22 00:47:07 +01:00
PartialVolume
7fb2a77c7a Merge pull request #506 from PartialVolume/temperature_thread
Temperature Thread
2023-10-22 00:45:59 +01:00
PartialVolume
28068ebf97 Temperature Thread
Due to significant delays in obtaining drive temperature
from some drives especially SAS which was causing a noticeable
freeze of a second or two or more in the GUI wipe status
screen, being made worse the more drives that were being
simultaneously wiped.

The temperature update code was separated from the GUI code
by placing the temperature update in it's own thread.
2023-10-22 00:25:01 +01:00
Gerold Gruber
539a023fd7 sort the device list 2023-10-20 18:43:46 +02:00
PartialVolume
04dae6da32 Merge pull request #504 from ggruber/master
fixed min/max wrong set
2023-10-20 09:15:17 +01:00
Gerold Gruber
dcef86fb0b fixed min/max wrong set 2023-10-20 00:56:35 +02:00
PartialVolume
193cc8f0b2 Merge pull request #503 from PartialVolume/Fix_temperature_colour_part2
Fix_temperature_colour_part2
2023-10-17 19:43:39 +01:00
PartialVolume
1ee1bb1966 Fix_temperature_colour_part2
Reverted change in wprintw_temperature()
as that was not causing the red temperature
character.
2023-10-17 19:38:22 +01:00
PartialVolume
d9785d2b84 Merge pull request #502 from PartialVolume/red_temperature_fix
Fix red text on temperature
2023-10-17 18:12:13 +01:00
PartialVolume
c02dbe42ce Fix red text on temperature
This was due to incorrectly changing temperature
colour based on historical highest and lowest values.

Also removed some debug nwipe_log code
2023-10-17 18:03:39 +01:00
PartialVolume
7ce28ce61a Merge pull request #498 from ggruber/master
improved SCSI disk handling
2023-10-17 12:43:39 +01:00
PartialVolume
7d2517a120 Merge pull request #501 from PartialVolume/Change_HPA_message_to_stop_flashing_move_to_end_of_line
Change_HPA_message_to_stop_flashing_&_move_to_end_of_line
2023-10-17 11:24:41 +01:00
PartialVolume
725c79b9d0 Change_HPA_message_to_stop_flashing_&_move_to_end_of_line
The HPA message alternating with the drive model serial
number made reading the serial number quite a challenge
and made the display far too messy looking when displaying
20+ drives or even 10+ drives with differing HPA statuses.

Removed, alternating appearance.
Reduced size of message.
Placed after temperature, before drive model/serial in display.
2023-10-17 09:46:11 +01:00
PartialVolume
ab9d269bb1 Merge pull request #500 from PartialVolume/PDF_Gen37_single_column_smart_data
PDF_Gen37_single_column_smart_data
2023-10-15 23:22:16 +01:00
PartialVolume
508a6d2a62 PDF_Gen37_single_column_smart_data
Previously smart data was completely located
on page 2 in two columns using a variable width font.
This had two issues. The font size had to be very small
to fit on the page which made it difficult to read
and variable width fonts were used because the smart
attribute table took up too much width when all the data
was displayed in two newspaper type columns. This made the
smart attribute table look messy.

This patch now displays the smart data over page two and three
in mono spaced font and with a larger font size so it's easier
to read and the columns with the smart attribute table are now
aligned correctly.

In terms of the code, I placed the header and footer creation
code in it's own function as this is called multiple times
and will make it easier to add additional information pages
in the future.
2023-10-15 23:16:14 +01:00
PartialVolume
0bb9ee33c9 Merge pull request #499 from PartialVolume/PDFGen36_Add_Optional_Org_Customer_Preview_Prior_To_Drive_Selection
PDFGen36_Add_Optional_Org_Customer_Preview_Prior_To_Drive_Selection.
2023-10-14 22:43:14 +01:00
PartialVolume
f12ee921b8 PDFGen36_Add_Optional_Org_Customer_Preview_Prior_To_Drive_Selection.
Added new options in GUI config menu to display preview of
organisation, customer, date/time at startup prior to drive
selection. This preview is disabled as default but can be
enabled in the config menu.

The purpose of the preview is to allow the user to check &
update as required the organisation details, customer &
current date/time so that the details provided on the PDF
certificate/report are correct.
2023-10-14 22:22:14 +01:00
Gerold Gruber
53d91f4b8b fix lowest 2023-10-13 07:44:56 +02:00
Gerold Gruber
de887ea6ee get better timing information for temperature retrieval 2023-10-12 22:15:18 +02:00
Gerold Gruber
b6f97454f1 more temperatur limit fake for SAS disks 2023-10-12 21:44:51 +02:00
Gerold Gruber
6a92755cf2 detect and display if disk is a SSD 2023-10-12 21:15:31 +02:00
Gerold Gruber
68a6002ff1 temp statistics for SAS drives 2023-10-12 12:37:32 +02:00
Gerold Gruber
47112c4de2 some code cleaning, time debugging added 2023-10-11 00:05:57 +02:00
Gerold Gruber
97efd12b93 fixes 2023-10-10 14:32:32 +02:00
Gerold Gruber
3bc3de37ae included hddtemp code for SCSI disk temperatures 2023-10-10 14:01:20 +02:00
PartialVolume
525cf037c5 Merge pull request #496 from ggruber/master
bustype detection with smartctl works (again?)
2023-10-06 20:38:57 +01:00
Gerold Gruber
f764c39390 bustype detection with smartctl works (again?) 2023-10-06 00:45:44 +02:00
PartialVolume
c6ff341f7e Merge pull request #494 from PartialVolume/fix_endian_model_name
fix_endian_model_name
2023-10-02 22:48:45 +01:00
PartialVolume
948368bc28 Merge pull request #493 from ggruber/master
fix for issue #492
2023-10-02 22:48:22 +01:00
PartialVolume
59d73107f6 fix_endian_model_name
Some IDE USB adapter chipsets get the endian wrong for model name
This fix identifies a endian swapped model name and corrects it.

The function currently only includes Samsung but I'll add more IDE
drive manufacturers as I come across them.

This is peculiar to some USB IDE adapters. I've never seen this
issue with SATA, ATA drives connected directly to the motherboard.
2023-10-02 22:37:54 +01:00
Gerold Gruber
8124e6b3d5 added -P option for PDFreportpath 2023-10-02 20:28:49 +02:00
Gerold Gruber
c1e943d283 improved formatted fix for issue #492 2023-10-02 17:30:28 +02:00
Gerold Gruber
8124d2d493 improved fix for issue #492 2023-10-02 16:42:41 +02:00
Gerold Gruber
7c9939e228 possible solution for issue #418 2023-10-02 00:21:49 +02:00
Gerold Gruber
4675a17693 manpage typo 2023-10-01 23:52:38 +02:00
Gerold Gruber
bbcb4fc219 fix for issue #492 2023-10-01 23:45:48 +02:00
PartialVolume
65a3a45a38 Merge pull request #491 from PartialVolume/Fix_segfault_on_logfile_write_permissions
Fix intermittent segfault when --logfile specified without insufficient permissions to write to directory
2023-09-29 21:22:20 +01:00
PartialVolume
f1fe7d6bd7 Fix intermittent segfault when --logfile specified
Under the following conditions a segfault will
occur upon starting nwipe.

Run nwipe with --logfile option AND run nwipe in a directory that does
not have write permissions so the logfile can't be created AND run nwipe
without sudo or root or as as a user without sufficient privileges so
you don't have permissions to write to the directory.
2023-09-29 21:05:31 +01:00
PartialVolume
50951dff03 Merge pull request #490 from PartialVolume/PDFGen35
PDFGen35 Complete Date & time functions
2023-09-28 22:31:58 +01:00
PartialVolume
2d730eac2e PDFGen35 Complete Date & time functions
Add functions:
nwipe_gui_set_system_day()
nwipe_gui_set_system_hour()
nwipe_gui_set_system_minute()
2023-09-28 22:15:52 +01:00
PartialVolume
16b87cc2bd Merge pull request #489 from PartialVolume/PDFGen34
Created further date/time functions.
2023-09-14 22:16:34 +01:00
PartialVolume
ea1c2019cd Created further date/time functions.
write_system_datetime() and
nwipe_gui_set_system_month()
2023-09-14 22:07:37 +01:00
PartialVolume
c5b4e58cee Merge pull request #487 from PartialVolume/PDFGen33
Create function read_system_datetime()
2023-09-05 19:09:49 +01:00
PartialVolume
8a46658820 Create function read_system_datetime()
The purpose of this is to read year, month, day, hours
minutes and seconds into variables for updating in the GUI
prior to writing back to the system.

For systems isolated from the internet this will allow the
user to update system date/time from the nwipe GUI rather than
having to drop into the command line.

To complete this feature next will be to create the write_system_datetime
function.
2023-09-05 19:01:08 +01:00
PartialVolume
1e50f2fd2c Merge pull request #485 from PartialVolume/PDFGen32
PDFGen32 Create Set Date/Time window in GUI
2023-08-14 22:01:19 +01:00
PartialVolume
60d38a80e4 PDFGen32 Create Set Date/Time window in GUI
Created a window where you can edit the systems
date and time. To be completed.
2023-08-14 21:53:10 +01:00
PartialVolume
c72f740587 Merge pull request #484 from PartialVolume/PDFGen31
PDFGen31 Created truncate string function
2023-08-11 22:29:58 +01:00
PartialVolume
ba4c4c51f1 PDFGen31 Created truncate string function
Created a function that truncates a string that is printed
to a window if the string should exceed the window width.

This prevents the line wrap that occurs with mvwprintw
when the window width is not wide enough. This mainly
occurs with a 4:3 ratio monitor, 80 columns wide.
2023-08-11 21:41:48 +01:00
PartialVolume
86d71d0858 Update README.md
Removed the download link to the build script. As it's only a short script it can be copied and pasted from the github page.
2023-08-08 11:12:24 +01:00
PartialVolume
bb0cd2258d Update README.md - Add libconfig-dev libconfig++-dev
Added libconfig-dev libconfig++-dev to the build script
2023-08-08 11:03:26 +01:00
PartialVolume
4c703a6922 Merge pull request #483 from PartialVolume/PDFGen30
PDFGen30 Added org, customer & date/time preview
2023-08-05 23:26:32 +01:00
PartialVolume
9f92ec1b29 PDFGen30 Added org, customer & date/time preview
Created a window that shows a preview of organisational,
customer and date time information that will be added to
the PDF report. Items within the preview can be selected
which takes you to the relevant window for editing the
data. This can be optionally displayed before the drive
selection window is displayed.

To complete this I need to add a further entry in the
config window to allow editing date & time. Plus a
function needs to be added to truncate the strings
based on window width as some address strings could
be wider than the window and mess up the display as
they wrap to the next line.
2023-08-05 23:13:41 +01:00
PartialVolume
17a391f971 Merge pull request #482 from PartialVolume/PDFGen29
PDFGen29 Fix incorrect customer deletion/selection
2023-08-04 17:29:14 +01:00
PartialVolume
b40563ab22 PDFGen29 Fix incorrect customer deletion/selection
When using backspace or esc to abort customer deletion,
first customer in list would incorrectly be deleted.
Corrected by this fix.

Also when aborting customer selection, first customer
in list would be automatically selected. Also corrected
by this fix.
2023-08-04 17:14:39 +01:00
PartialVolume
7fc4325d69 Merge pull request #481 from PartialVolume/PDFGen28
PDFGen28 Completed customer delete feature.
2023-08-03 00:15:57 +01:00
PartialVolume
c137736997 PDFGen28 Completed customer delete feature. 2023-08-02 23:54:35 +01:00
PartialVolume
1a3e7eb23e Merge pull request #480 from PartialVolume/PDFGen27
PDFGen27 Cleaned up customer selection list
2023-07-27 23:47:15 +01:00
PartialVolume
e6034cf94e PDFGen27 Cleaned up customer selection list
Removed the csv field double quotes from the customer
selection list as displayed on screen. The double quotes will
still obviously exist in the csv file and are required
for the code to work correctly in various places. However, for
human readable text they are removed before displaying the
customer details line on the selection screen as it makes the
list look less 'busy' on screen hopefully.

I also fixed a issue where spaces were incorrectly being removed
from the customer details when filtering for printable characters
only.
2023-07-27 23:36:11 +01:00
PartialVolume
ce628e5c17 Merge pull request #479 from PartialVolume/PDFGen26
PDFGen26 Completed the code that adds a customer
2023-07-27 02:51:00 +01:00
PartialVolume
3dcc40c0e7 PDFGen26 Completed the code that adds a customer
Completed the code that adds a customer and saves
in /etc/nwipe.customers.csv so they can be selected
for display on the PDF report.
2023-07-27 02:46:09 +01:00
PartialVolume
1582f8c224 Merge pull request #477 from PartialVolume/PDFGen25
PDFGen25 Continuation of add customer csv
2023-07-25 22:24:57 +01:00
PartialVolume
a3fd0b71ca PDFGen25 Continuation of add customer csv
Continuation of add a customer entry to the
customers.csv file.

Plus a few corrections to earlier code.
2023-07-25 22:16:42 +01:00
PartialVolume
580429a371 Merge pull request #476 from PartialVolume/PDFGen24
PDFGen24 Created dialogs for adding a customer
2023-07-24 23:09:46 +01:00
PartialVolume
b46575cd63 PDFGen24 Created dialogs for adding a customer 2023-07-24 22:56:42 +01:00
PartialVolume
0d403a20a3 Merge pull request #475 from PartialVolume/PDFGen23
Completed the code that writes the user selected customer to nwipe's config file
2023-07-19 01:12:05 +01:00
PartialVolume
baefd77605 Completed code that writes selected customer to nwipe's config file /etc/nwipe/nwipe.conf 2023-07-19 01:03:49 +01:00
PartialVolume
9f8aecaa52 Merge pull request #473 from PartialVolume/PDFGen22
PDFGen22 Further work completed on customer selection and deletion
2023-07-18 02:10:43 +01:00
PartialVolume
0948596559 PDFGen22 Further work completed on customer selection and deletion dialogs 2023-07-18 02:06:33 +01:00
PartialVolume
2630edbea1 Merge pull request #472 from PartialVolume/PDFGen21
PDFGen21 Completed all GUI dialog boxes for entering organisational data.
2023-07-14 23:12:33 +01:00
PartialVolume
e74ae252ef PDFGen21 Completed all GUI dialog boxes for entering organisational data. Confirmed the data is correctly saved to /etc/nwipe/nwipe.conf and read back for automatic entry into the PDF erasure report. Further work is required to create dialog entry screens for customer details.. to be continued. 2023-07-14 23:00:17 +01:00
PartialVolume
2ebea57008 Merge pull request #471 from PartialVolume/PDFGen20
PDFGen20 Started creating new GUI dialogs.  A Configuration dialog and sub dialogs for allowing the user to enter business and customer details. Further dialog windows and code to be added...
2023-07-13 22:34:31 +01:00
PartialVolume
247cf3031b PDFGen20 Started creating new GUI dialogs. A Configuration Dialog and sub dialogs for allowing the user to enter business and customer details. Further dialog windows and code to be added... 2023-07-13 22:28:23 +01:00
PartialVolume
a05784f05a Merge pull request #470 from PartialVolume/PDFGen19
PDFGen19 Completed data extraction from nwipe.conf
2023-07-12 20:45:09 +01:00
PartialVolume
6f453967f6 PDFGen19 Completed the code the extracts the organisation and selected customer details from the nwipe.conf configuration file and populates the business and customer details boxes on the PDF report. 2023-07-12 20:37:08 +01:00
PartialVolume
0649f1c606 Merge pull request #469 from PartialVolume/PDFGen18
PDFGen18 - further work on PDF certificate
2023-07-11 23:36:26 +01:00
PartialVolume
174072db2e PDFGen18 - further work on PDF certificate, basic construction & format of the nwipe.conf file for PDF organisation and customer details 2023-07-11 23:30:03 +01:00
PartialVolume
60385f479a Update README.md
Remove old 16.04 badge
2023-07-03 01:25:02 +01:00
PartialVolume
49d82eebc9 Merge pull request #467 from PartialVolume/Fix_intermittent_exit_when_sizing_console
Fix the premature exit when sizing konsole
2023-06-30 23:57:36 +01:00
PartialVolume
d7b1fdf2ce Fix the premature exit when sizing konsole
If you are running nwipe within the KDE konsole
terminal and you resize the window by pulling on
the corners, occasionally nwipe will exit with the
error message:

"GUI.c,nwipe_gui_select(), loop runaway,
did you close the terminal without exiting nwipe?
Initiating shutdown now"

The loop runaway detection has been made less sensitive,
i.e 32 iterations per second of the GUI update can now
be completed before a loop runaway is detected. previously
it was 8. In practise when sizing the konsole window,
anywhere between 1 and 17 iterations will occur.
2023-06-30 23:40:23 +01:00
PartialVolume
21ef97e355 Merge pull request #465 from PartialVolume/HPA_DCO_013
HPA_DCO_013 Continuation of HPA/DCO integration
2023-04-12 23:34:46 +01:00
PartialVolume
447c4eddf7 HPA_DCO_013 Continuation of HPA/DCO integration
Fixes to apparent and real disc size fields in PDF based on use
of c->Calculated_real_max_size_in_bytes.

Minor changes to HPA status messages for consistent messaging.

When HPA and DCO sector information cannot be obtained display the
message "HPA/DCO data unavailable, can not determine hidden sector
status" in the information field on the PDF.

Determine human readable size for the c->Calculated_real_max_size_in_bytes
as used in the PDF real disc size field.

Instead of >>FAILURE!<< -1 when a I/O error occurs display >>IOERROR!<< -1
in the GUI.
2023-04-12 23:29:13 +01:00
PartialVolume
3a9ff16d29 Merge pull request #464 from PartialVolume/HPA_DCO_012
HPA_DCO_012 Continuation of HPA/DCO integration
2023-04-11 22:47:31 +01:00
PartialVolume
d981159f04 HPA_DCO_012 Continuation of HPA/DCO integration
Simplified the code that determines whether a HPA/DCO
is present and in the process fixed some related bugs
to do with the HPA/DCO fields in the PDF document
displaying incorrect information in some drive specific
cases.
2023-04-11 22:42:16 +01:00
PartialVolume
3d2ba87967 Merge pull request #463 from PartialVolume/HPA_DCO_011
HPA_DCO_011 Continuation of HPA/DCO integration.
2023-04-05 22:58:02 +01:00
PartialVolume
e7fca73970 HPA_DCO_011 Continuation of HPA/DCO integration.
Fixed a issue that occurs when a drive is attached via a USB adapter
that doesn't correctly pass the ATA commands for HPA/DCO determination.

It incorrectly set the HPA_status as enabled when in fact it should
have determined that DCO was accessible and a comparison against
the size as returned by libata and the real max sectors which in this
particular adapters case worked, was sufficient to correctly determine
whether there were hidden sectors or not.

Now fixed, so HPA status is now determined correctly even on some
less than ideal USB adapters.
2023-04-05 22:50:39 +01:00
PartialVolume
dfa78567e0 Merge pull request #462 from PartialVolume/HPA_DCO_010
HPA_DCO_010 Continuation of HPA/DCO integration.
2023-04-05 18:12:16 +01:00
PartialVolume
30997876a5 HPA_DCO_010 Continuation of HPA/DCO integration.
The Seagate EXOS family of drives don't support the ATA
drive configuration overlay (DCO) command, however they do
support host protected area (HPA). Therefore these drives
can have hidden sectors.

The code was changed to accommodate the slightly different
way these drives respond to a hdparm -N, that is, the
response is accessible max address enabled or
accessible max address disabled. The new code correctly
determines a the status of a drive in regards to
whether it has hidden sectors or not and what it's
apparent and real size is.
2023-04-05 18:05:54 +01:00
PartialVolume
0c41d895e2 Merge pull request #461 from PartialVolume/HPA_DCO_009
HPA_DCO_009 Continuation of HPA/DCO integration.
2023-04-04 23:58:42 +01:00
PartialVolume
776717a729 HPA_DCO_009 Continuation of HPA/DCO integration.
Changed the way percentage is calculated. As we
are dealing with large numbers and for some reason
printf prints a double that is 99.99999999999 as
100.00 when a precision of two is specified I wrote
a function that creates a percentage string such that
99.99999999999 is displayed as 99.99%. This is important
in the report as a disc with one hidden sector will now
correctly show as 99.99% erased and not 100.00% erased.
2023-04-04 23:52:40 +01:00
PartialVolume
a1e607dc02 Merge pull request #460 from PartialVolume/HPA_DCO_008
HPA_DCO_008 continuation of HPA/DCO integration.
2023-04-03 23:19:20 +01:00
PartialVolume
0b720b155c HPA_DCO_008 continuation of HPA/DCO integration.
Many changes related to DCO real max sectors and HPA set and real
sectors and how they are processed and used in the PDF creation
function. More testing is required until I'm happy this works
correctly with lots of different hardware including USB adapters
that don't support DCO/HPA and also drives that don't support
DCO/HPA such as the Seagate Enterprise EXOS drives.
2023-04-03 23:11:41 +01:00
PartialVolume
4fc1806880 Merge pull request #459 from PartialVolume/Fix_very_obscure_incorrect_percentage_on_fill_ones_only
Fix obscure incorrect percentage on completion.
2023-03-20 19:51:34 +00:00
PartialVolume
bbfaa0e9f7 Fix obscure incorrect percentage on completion.
This bug only applies to ones wipe and one or zero's
verification.

A very rare occurrence of a incorrect percentage on
completion. The actual wipe was completed correctly it
was just that the percentage calculation was wrong.

This was due to a variable that was initialised for
all methods except ones, & ones & zeros verification.

For those three method's the uninitialised variable
would have had to have the value 1 or 6 for the
incorrect percentage to be calculated, this is why
it was so rare.

Corrected by initialising the variable with a -1 so
that if no method was found in the array then no
extra calculations as regards the percentage are
performed.
2023-03-20 19:39:16 +00:00
PartialVolume
4f5c15ffad Merge pull request #458 from PartialVolume/nwipe_conf_001
nwipe_conf_001 Add /etc/nwipe/nwipe.conf
2023-03-17 23:23:54 +00:00
PartialVolume
dbde867974 nwipe_conf_001 Add /etc/nwipe/nwipe.conf
1. Started constructing the code we will use to access
and write to /etc/nwipe/nwipe.conf. The initial use of
the nwipe.conf file will be to hold information such
as organisation and technician details that will be used
on the PDF report certificate. We are using the libconfig
library enable us to read and write the conf file. libconfig
is very well documented so editing the conf file manually
should be pretty straight forward. Nwipe will build a basic
conf file to give the user an idea how it should be edited.

2. Updated the README.md, showing the libconfig-dev, libconfig++-dev
needs to be installed.

3. Added some information about the use of hdparm to detect hidden
sectors and also noted that as from v0.35 nwipe will detect hidden
sectors, and may well have an extra method to expose those hidden#
sectors by restoring the DCO.
2023-03-17 23:18:39 +00:00
PartialVolume
a51a9b3e2a Merge pull request #457 from PartialVolume/HPA_DCO_007
HPA_DCO_007 - Add HPA/DCO capability
2023-03-16 21:12:24 +00:00
PartialVolume
3d5fdd3f11 HPA_DCO_007 - Add HPA/DCO capability
1. Fix issue in PDF certificate where a drive that doesn't
support device configuration overlay, shows 512 bytes as the
disc size in the "Size(Real)" area on the certificate.

2. Fix a comment in the log that suggests you might be using a USB
adapter or memory stick and those device can cause an indeterminate
HPA/DCO status. This is now corrected so that we check the bus
is USB before we issue that message.

3. Changes to some GUI text, replaced 'area' with 'sectors'.

4. Aligned "HPA/DCO No hidden sectors detected" to the drive
model/serial text that it alternates with. One character left.

5. Nwipe's version and operating system information that is always
printed to the console on exit, was not appearing in the optional
log file, as optionally specified on the command line. This was
caused because those nwipe_log() calls were happening before the
command line options had been parsed. Essentially there was no log file.
Comments were made in the nwipe.c as a reminder to use nwipe_log()
calls with caution, prior to the options parser.

6. Made changes to the logic in the HPA_dco functions such that
a device that does not appear to support device configuration
overlay and host protected area is classified as HPA_NOT APPLICABLE
in regards to the hpa_status which is important for the PDF
certificate code so that the fields in the certificate are updated
appropriately.
2023-03-16 20:57:07 +00:00
PartialVolume
5051e5c7bf Merge pull request #456 from PartialVolume/Validate_temperatures_before_using_to_change_temperature_text_color
Validate temperatures.
2023-03-16 00:54:20 +00:00
PartialVolume
5d8c0cc4bf Validate temperatures.
Now validates temperatures rather than assuming the data
is valid.

1. Checks for 0 in high critical and max.
2. Copes with missing critical or max min data or
partially missing data.
3. Checks the high critical and max are the right way round
4. Checks the low critical and min are the right way round
5. Temperature is displayed in 5 different ways
i. white text on blue - temperature with spec. (or no spec available)
ii. red text on blue - max temperature reached.
iii. white text on red - critical high temperature reached.
iv. black text on blue - minimum temperature reached.
v. white text on black - critical low temperature reached.
2023-03-16 00:43:19 +00:00
PartialVolume
c79c8ad8f7 Merge pull request #455 from PartialVolume/add_min_max_temperatures_to_log
Added max, min drive temperatures to log
2023-03-14 23:57:09 +00:00
PartialVolume
79cedf47fc Added max, min drive temperatures to log
Added the max and min drive temperatures to the nwipe
log. We now have upto six temperatures that may be reported
for each drive. Whether all these fields are populated is
down to each drive manufacturer.
2023-03-14 23:53:21 +00:00
PartialVolume
08cba2ee5e Merge pull request #454 from PartialVolume/Fix_anomaly_when_temperature_changes_color
Fix anomaly with color change of temperature
2023-03-14 22:30:19 +00:00
PartialVolume
4368092d11 Fix anomaly with color change of temperature
Temperature text now changes red when it's exceeded
the high critical temperature and black when it's dropped below the low
critical temperature. See nwipes log for what those values actually are
as those critical temperature values are obtained from each drive.

When the drive temperature is within the drives specification the temperature
text will be white text on blue background.

The temperature text no longer flashes red or black.
2023-03-14 22:27:34 +00:00
PartialVolume
ac96c51120 Merge pull request #453 from PartialVolume/add_temperature_limits_to_log_info
Add temperature limits to nwipe log
2023-03-14 20:42:37 +00:00
PartialVolume
c4490a89d1 Add temperature limits to nwipe log
1. For each drive we now show the following temperature
limits that are obtained directly from the drive. These are
shown in the log under the INFO category. For a given drive
all it's limits are shown on a single line near the start of
the log.

Example:
Temperature limits for /dev/nvme0n1, critical=84c, highest=N/A, lowest=N/A, low critical=N/A.

High critical
Highest
Lowest
Low critical

Whether all these values contain data various between
manufacturer, for instance the Seagate SN570 only shows
the high critical value of 84 deg.C

2. Changed some wording in the GUI for a on screen
message to do with HPA/DCO.
2023-03-14 20:11:00 +00:00
PartialVolume
87d25cf752 Merge pull request #452 from PartialVolume/PDFGen17
PDFGen17 - further work on PDF certificate
2023-03-12 18:15:39 +00:00
PartialVolume
c3cd5011a2 PDFGen17 - further work on PDF certificate
1. I wasn't keen on my first attempt at the exclamation
icon so I redesigned it.I think this one looks better.
2023-03-12 16:34:43 +00:00
PartialVolume
1b3d03faad Merge pull request #451 from PartialVolume/PDFGen16
PDFGen16 - further work on PDF certificate
2023-03-11 22:45:31 +00:00
PartialVolume
f258872c67 PDFGen16 - further work on PDF certificate
1. Added a new icon, a yellow exclamation in a red circle
with the words "erased with a warning" inside the circle.
This is used instead of the green tick icon or red cross icon
when a disk is successfully erase as requested but the user
chose not to expose the hidden sectors by removing the HPA and/or
restoring the drive configuration overlay (DCO).

2. Expanded the size of the "Disk Erasure Details" section on
the certificate by 20 points to provide better spacing for warnings

3. Removed remapped sectors label, as that information already
appears on page 2 in the smart data.

4. Improvements to the logic in regards to text colour changes.

5. Added a additional red warning message in the information section
when the exposed sectors of the disc are erased but the hidden sectors
are not.

6. Added the original images in .xcf (gimp) and jpg formats that are
used to generate the embedded .c and .h files using bin2c.
2023-03-11 22:24:34 +00:00
PartialVolume
d231c863f7 Merge pull request #450 from PartialVolume/PDFGen15
PDFGen15 - further work on PDF certificate
2023-03-10 23:41:45 +00:00
PartialVolume
b35400b22a PDFGen15 - further work on PDF certificate
1. Added page 2 of the report which includes all
smart data as displayed by smartctl -a /dev/sdx

2. Did some more work on the logic, i.e. when certain
data on the certificate should be green and when it should be
red.

3. Made some changes to nwipe's log in regards to the way
it displays disc info right at the beginning of the log.
Separated the drive information by a blank line to make
each drive stand out from the rest.

4. Moved a string function from device.c to miscellaneous.c

more code to follow ..
2023-03-10 23:33:46 +00:00
PartialVolume
c52dfa3d8f Merge pull request #449 from PartialVolume/HPA_DCO_006
HPA_DCO_006 - Add HPA/DCO capability
2023-03-10 00:52:14 +00:00
PartialVolume
e6a9944a7a HPA_DCO_006 - Add HPA/DCO capability
1. If nwipe enumerates a USB bridge that does not support
ATA pass through or you are wiping a USB memory stick,
nwipe will show a message in the GUI that says
"HPA/DCO hidden area indeterminate". If you get this message
you know to either get yourself a better quality USB to SATA
adapter or in the case of a USB memory stick, i've never
come across one that supports HPA/DCO so either don't worry
about it and wipe it as normal or physically destroy it.

2.We now check for a nonsense "real max sectors" as produced
by the bug in hdparm. We use our own low level function to
issue a DCO identify command and retrieve the correct value.

3. Changed the dmidecode info at the start of the log from
a 'notice' classification to 'info'.

4. Made changes to the nwipe_log function so that any messages
logged that are classified as 'debug' will not be logged unless
the --verbose flag has been set on the command line options. I
send the hex data structures and hex sense data to the logs as debug
information and as they can take up a lot of space and make the
log look untidy they will only appear in --verbose mode.

5. I also extended the nwipe's log message length from 512 to 1024
as some of the sense data was being truncated in the log.
2023-03-10 00:28:31 +00:00
PartialVolume
9c0dd6a25a Merge pull request #448 from PartialVolume/HPA_DCO_005
HPA_DCO_005 - Add HPA/DCO capability
2023-03-08 23:37:46 +00:00
PartialVolume
67ca3b260d HPA_DCO_005 - Add HPA/DCO capability
1. Created the function nwipe_read_dco_real_max_sectors()
which directly accesses the disk drive sending a 0xB1
device configuration overlay identify command to the drive.
We read the returned data structure extracting the real max
sectors value. We do this if hdparm returns nonsense for the
real max sector (as it does in hdparm v9.60) for some larger
drives. This value is automatically sent to the nwipe log FYI.

2. Added a stdout & stderr pipe to the hdparm commands as verbose
data appears to be sent to stderr, as we are interested in that
data this pipe captures stderr as well as stdout.

3. Added headers "scsi/sg.h" and "scsi/scsi_ioctl.h" as we
are now sending low level commands to the drives.
2023-03-08 23:30:14 +00:00
PartialVolume
c97d1c9166 Merge pull request #447 from PartialVolume/HPA_DCO_004
HPA_DCO_004 - Add HPA/DCO Capability
2023-03-08 00:34:53 +00:00
PartialVolume
4b6399a93f HPA_DCO_004 - Add HPA/DCO Capability
1. In the GUI I switched the HPA/DCO status position
from overlaying the [drive size][temp] and instead
positioning the HPA/DCO status over the drive model
and serial number. HPA/DCO information and drive details
alternating every couple of seconds. This allowed me to
extend the length of the HPA message and make it more
meaningful to somebody that doesn't know the HPA/DCO
terminology. Therefore "HPA Enabled" is replaced with
"HPA/DCO Warning, hidden area detected"

2. Started adding bad/missing sense data detection ..

more code to follow ..
2023-03-08 00:20:22 +00:00
PartialVolume
518b8b536a Merge pull request #446 from PartialVolume/PDFGen14
PDFGen14 - further work on PDF certificate
2023-03-05 23:48:26 +00:00
PartialVolume
b79eea6c9f PDFGen14 - further work on PDF certificate
1. Changes to colour on some items under certain
conditions.

2. Changed the HPA labels to include DCO, and changed
the text from HPA enabled/disabled to something more
meaningful to a user, i.e Hidden area found, no hidden
area.

3. Added a new define "HPA_NOT_SUPPORTED_BY_DRIVE" for
recent SATA drives that no longer support HPA/DCO.
Further work needs to be done determining whether a drive
supports HPA/DCO or not in the hpa_dco.c functions.

more code to follow ..
2023-03-05 23:24:49 +00:00
PartialVolume
88cec08854 Merge pull request #445 from PartialVolume/PDFGen13
PDFGen13 - further work on PDF certificate
2023-03-05 00:49:34 +00:00
PartialVolume
dc6d76176a PDFGen13 - further work on PDF certificate
1. Reduced font size for data info.
2. Used a define for text point size to make it easier
to change size.
3. Started work on function to parse sense data for older
versions of hdparm (9.60) that fail to parse the real max
sectors correctly. (fixed in 9.65).
4. Miscellaneous changes.

More changes to follow ..
2023-03-05 00:42:37 +00:00
PartialVolume
3eb5a43a32 Merge pull request #443 from PartialVolume/HPA_DCO_003
HPA_DCO_003 - Add HPA,DCO capability
2023-02-28 23:55:46 +00:00
PartialVolume
8abab96a3e HPA_DCO_003 - Add HPA,DCO capability
1. For devices that support HPA/DCO (not NVMe) nwipe
displays the HPA status, it toggles every two seconds
the size and the temperature i.e "[  1TB][ 35C]" with
the HPA status such as [HPA disabled], [HPA ENABLED!],
[HPA unknown]. The HPA ENABLED is highlighted with red
text and a white background. HPA_disabled is standard
white text on blue background.

More code to follow, a new option to be added, HPA, disable/enable
which will disable the HPA and shut down the system. On manually
powering back up the HPA should be reported as disabled.

Then lots of testing.
2023-02-28 23:48:17 +00:00
PartialVolume
7ccb68675b Merge pull request #442 from PartialVolume/HPA_DCO_002
HPA_DCO_002 - Add HPA, DCO capability
2023-02-28 00:10:26 +00:00
PartialVolume
c7d17df7f8 HPA_DCO_002 - Add HPA, DCO capability
1. Further work was completed, putting the HPA status and HPA size into
the report/certificate.

2. Moved some general functions that may be used throughout nwipe
into miscellaneous.c These tend to be string processing functions.

3. Tested certificate HPA status. There are three possible states of the HPA
i. Enabled and HPA size is displayed on the certificate
ii. Disabled, the drive reports it's real size to the O.S.
iii. Unknown. Nwipe could not determine whether there is a HPA or not.
This may be caused by the use of a USB adapter or could be a bad drive,
or finally a change in hdparms format when displaying HPA information.

More code to follow, next on the list is to add the HPA status into the
drive selection screen in the GUI, so when you select the drive you can see
the status of HPA and choose to disable it.
2023-02-28 00:02:01 +00:00
PartialVolume
ea9d76132e Merge pull request #441 from PartialVolume/HPA_DCO_001
HPA_DCO_001 - Add HPA, DCO capability
2023-02-26 23:23:22 +00:00
PartialVolume
bba050fa71 HPA_DCO_1 - Add HPA, DCO capability
1. nwipe now reads the HPA set and real number of
sectors and the DSO real max sectors. It determines
from these values whether the HPA is enabled, disabled
or in a unknown state. The values are logged to nwipes
log and flags are set in the drives context.

More code will follow that adds this information to the PDF
certificate and to the drive selection window in the GUI.
2023-02-26 22:59:33 +00:00
PartialVolume
00e2053ab4 Merge pull request #440 from PartialVolume/HPA_DCO
HPA_DCO_1 - Add HPA, DCO capability
2023-02-23 22:52:38 +00:00
PartialVolume
ef84c65846 HPA_DCO_1 - Add HPA, DCO capability
1. debugging.
2023-02-23 22:30:18 +00:00
PartialVolume
09af2bc5a6 HPA_DCO_1 - Add HPA, DCO capability
1. More debugging.
2023-02-23 21:44:08 +00:00
PartialVolume
2747ab5d4f HPA_DCO_1 - Add HPA, DCO capability
1. More corrections to hdparm command
2023-02-23 21:22:21 +00:00
PartialVolume
a2d6735b89 HPA_DCO_1 - Add HPA, DCO capability
1. Corrections to hdparm command.
2023-02-23 21:14:48 +00:00
PartialVolume
e4ecd6a68e HPA_DCO_1 - Add HPA, DCO capability
1. Initial commit
2023-02-23 20:46:19 +00:00
PartialVolume
6f7ca938f4 Merge pull request #439 from PartialVolume/PDFGen12
PDFGen12 - further work on PDF certificate
2023-02-23 12:50:18 +00:00
PartialVolume
ecfc252015 PDFGen12 - further work on PDF certificate
1. Add information regarding how many pass, sync
and verify errors, if any.
2023-02-23 12:31:41 +00:00
PartialVolume
40f1e31225 Merge pull request #438 from PartialVolume/PDFGen11
PDFGen11 - further work on PDF certificate
2023-02-22 16:28:42 +00:00
PartialVolume
3b952d3f92 PDFGen11 - further work on PDF certificate
1. Fix a bug in the static and random pass code
where I unnecessarily moved the decrement of z (the
count of bytes remaining) to after the periodic sync
which meant every time it sync'ed z wasn't decremented due
to r being used as a general results variable for the
fdatasync function.

I prefer to just have a variable be responsible for just
one thing hence my assumption r wasn't used for two different
things.

Changed the position of the decrement of z, pass_done and
round_done to their original position prior to the periodic
sync.
2023-02-22 11:56:22 +00:00
PartialVolume
09e41d573f Merge pull request #437 from PartialVolume/PDFGen10
PDFGen10 - further work on PDF certificate
2023-02-22 00:31:51 +00:00
PartialVolume
8b827f9ea0 PDFGen10 - further work on PDF certificate
1. Fix rounds reported on abort or fail.
2023-02-22 00:06:28 +00:00
PartialVolume
c57e04005e PDFGen10 - further work on PDF certificate
1. remove some unnecessary code related to bytes_erased.
2023-02-21 23:39:22 +00:00
PartialVolume
04c409a665 PDFGen10 - further work on PDF certificate
1. Fix percentage for bytes erased on certificate.
2023-02-21 22:59:09 +00:00
PartialVolume
c5f9c1d6e9 PDFGen10 - further work on PDF certificate
1. Added the red cross icon located on the top right of
the certificate. This is displayed when the wipe is aborted
or failed to complete due to disc I/O errors etc. The
green tick icon is displayed on a successful wipe.

2. When the user manually aborts the wipe, the bytes so
far erased incorrectly displayed as zero. This change updates the
c->bytes_erased variable in the static pass and random
pass functions to correct this.
2023-02-21 21:33:19 +00:00
PartialVolume
d9fed5bcc6 Merge pull request #436 from PartialVolume/PDFGen9
PDFGen9 - further work on PDF certificate
2023-02-21 12:09:43 +00:00
PartialVolume
84048ba58b PDFGen9 - further work on PDF certificate
1. Added rounds requested & completed. Coloured
green if equal and red if not.
2. Fixed endtime sometimes not being recorded when
a wipe is aborted. This affected the creation of the
PDF filename. Now ok.
3. Added throughput using the appropriate nomenclature
such as KB/sec MB/sec, GB/sec etc
2023-02-21 11:51:36 +00:00
PartialVolume
f0b61a0bc1 Merge pull request #435 from PartialVolume/PDFGen8
PDFGen8 - further work on PDF certificate
2023-02-21 00:48:42 +00:00
PartialVolume
eda930f06d PDFGen8 - further work on PDF certificate
1. Added bytes erased including percentage, green
if equal to disc size and red if the drive hasn't been
fully erased at least once.
2. Added explanation of bytes erased to certificate.
3. Added throughput
2023-02-21 00:35:52 +00:00
PartialVolume
2320015841 Merge pull request #434 from PartialVolume/PDFGen7
PDFGen7 - further work on PDF certificate
2023-02-18 23:14:28 +00:00
PartialVolume
581e83e615 PDFGen7 - further work on PDF certificate
1. Change model/serial no in header to bold and move left
2. Create a filename for the report that identifies the
wipe uniquely ie:
nwipe_report_YY-MM-DD_HH-MM-SS_Model_XXXX_Serial_XXXX.pdf
3. Move size data 2 characters right to allow for up to two
space prefix on size string. So data doesn't get written over
the end of the 'Size:' label.
2023-02-18 23:04:28 +00:00
PartialVolume
eef866fa54 Merge pull request #433 from PartialVolume/PDFGen6
PDFGen6 - further work on PDF certificate
2023-02-18 00:20:54 +00:00
PartialVolume
a29cc3b543 PDFGen6 - further work on PDF certificate
1. Fix @param in pdfgen.h, committed and accepted upstream
2. Added size of disk in bytes
3. When NVME drive show message "Not applicable" for HPA, DCO
4. Highlight status ERASED, FAILED etc with coloured ellipse
5. Added function help for nwipe_log (shows in hints in IDE)
2023-02-18 00:13:56 +00:00
PartialVolume
630837b207 Merge pull request #431 from PartialVolume/PDFGen5
PDFGen5 - further work on PDF certificate
2023-02-16 21:00:11 +00:00
PartialVolume
b5eb549c59 PDFGen5 - further work on PDF certificate
1. Rearranged the layout so the Tech/ID signature
is at the bottom of the report.
2. Added start date/time
3. Added end date/time
4. Changed data from helvetica to helvetica-bold
5. Created a definition for PDF_DARK_GREEN text in
create_pdf.h and moved the previously created PDF_GRAY
to create_pdf.h, to keep pdfgen.h vanilla.
6. Added the erasure status, ERASED, FAILED, ABORTED.
ERASED in green and FAILED, ABORTED in red.

Further code to follow ..
2023-02-16 20:49:41 +00:00
PartialVolume
142a140ddf Merge pull request #430 from PartialVolume/PDFGen4
PDFGen4 - further work on PDF certificate
2023-02-16 00:06:36 +00:00
PartialVolume
ac6f14d86d PDFGen4 - further work on PDF certificate
1. Display unknown in serial number field for loopback device
2. Added device type, USB, SATA, VIRT etc
3. Added duration of wipe in hh:mm:ss
4. Added pseudo random number generator type, twister, isaac etc
5. Added final blanking pass type, none, zeros, ones
6. Added number of rounds
2023-02-15 23:52:17 +00:00
PartialVolume
e7797bf874 Merge pull request #429 from PartialVolume/PDFGen3
PDFGen3 - further work on PDF certificate
2023-02-15 01:28:53 +00:00
PartialVolume
40fdaf49a3 Formatted text .. I need to auto run make format! 2023-02-15 01:25:10 +00:00
PartialVolume
0c0e3f2930 PDFGen3 - further work on PDF certificate
1. Changed most titles in certificate to gray with
the data in black.

Started adding real data to template including:
Model, serial no., method, verify, size.

more code to follow...
2023-02-15 01:15:36 +00:00
PartialVolume
d5286a1965 Merge pull request #428 from PartialVolume/PDFGen2
Further updates to the PDF Erasure Report code
2023-02-14 01:54:11 +00:00
PartialVolume
cb129ffbc2 As usual, forgot to run make format ! 2023-02-14 01:48:16 +00:00
PartialVolume
8c7b1839f4 Embed PDF header images, plus font
1. Embed the images contained in the PDF into nwipes code
rather than use external image files.
2. Changed the font from Times New Roman to Helvetica
to give it a cleaner look.
2023-02-14 01:42:27 +00:00
PartialVolume
ac26aad3ac Merge pull request #427 from PartialVolume/PDFGen
Create PDF Disk Erasure Report for each drive wiped (Initial code, more to come)
2023-02-13 23:24:55 +00:00
PartialVolume
b41a84f5af Update workflow.
clang-format-7 missing from latest ubuntu so
modified to clang-format
2023-02-13 23:00:19 +00:00
PartialVolume
ed478f6dc0 Create Disk Erasure Report PDF template
This commits code that creates a erasure report
pdf file. Further to will follow that populates
the template.
2023-02-13 22:38:30 +00:00
PartialVolume
602b835aef Merge pull request #424 from sporqist/patch-1
Add grml to distros that ship nwipe
2022-09-14 16:12:42 +01:00
Marius Alwan Meyer
c2ab19a109 Update README.md with additional nwipe distro grml
I was searching for a DBAN alternative that runs in a normal Linux distro so I can hot-swap drives and not hale to reboot the system. When I found nwipe, I went to install it in a grml live system. Turns out, nwipe ships with grml by default as you can see in [grml's dpkg.list](https://packages.grml.org/files/grml64-small_2021.07/dpkg.list).

It's not exactly the most up-to-date version (0.30-1+b2 for amd64) because grml is close to Debian stable. It even comes with the the small live system image.
2022-09-14 16:56:59 +02:00
PartialVolume
9feea8b3cf Merge pull request #423 from DimitriPapadopoulos/ubuntu-18.04
The `ubuntu-18.04` runner image is being deprecated
2022-09-14 15:10:26 +01:00
Dimitri Papadopoulos
1b6ba8e8a2 The ubuntu-18.04 runner image is being deprecated
https://github.com/actions/runner-images/issues/6002
2022-09-14 16:01:47 +02:00
PartialVolume
b6d5388759 Merge pull request #421 from DimitriPapadopoulos/actions
Update GitHub Actions
2022-09-14 01:12:05 +01:00
PartialVolume
24fd407b43 Merge pull request #420 from DimitriPapadopoulos/codespell
Typos found by codespell
2022-09-14 01:07:19 +01:00
Dimitri Papadopoulos
53b5c020e0 Update GitHub Actions 2022-09-13 13:27:57 +02:00
Dimitri Papadopoulos
87f4b48705 Typos found by codespell 2022-09-13 13:24:39 +02:00
Martijn van Brummelen
099d380f3c bump 0.34 2022-07-08 13:18:18 +02:00
PartialVolume
f3ace2aa7c Merge pull request #417 from PartialVolume/Fix_zero_length_strings
Fixes a compiler warning -Wformat-zero-length string
2022-07-02 19:52:22 +01:00
PartialVolume
f6483ca055 Fixes a compiler warning -Wformat-zero-length string 2022-07-02 19:43:56 +01:00
PartialVolume
0a5dbeb5a4 Update README.md
Use Warning symbol markup
2022-05-29 17:01:45 +01:00
PartialVolume
cf57297953 Update README.md re HDA
Although reported in issues some time ago, make it clear nwipe doesn't support HDA and you will need to run hdparm in order to detect and if necessary correct the disks reported size prior to running nwipe.
2022-05-29 11:15:33 +01:00
PartialVolume
1d67d9e0d3 Merge pull request #411 from PartialVolume/Bump_to_0.33
Bump to v0.33
2022-03-20 14:15:05 +00:00
PartialVolume
f63862d042 Bump to v0.33
Updated:
CHANGELOG.md
configure.ac
man/nwipe.1
src/version.c
2022-03-20 14:11:46 +00:00
PartialVolume
65bc03da9a Merge pull request #410 from PartialVolume/fix_segfault_when_logfile_cannot_be_created_due_to_permissions
Fix obscure segfault when --logfile option used with a non writable directory.
2022-03-15 23:07:16 +00:00
PartialVolume
949f2b25e5 Bump version 2022-03-15 23:05:02 +00:00
PartialVolume
62e7876c74 Fix obscure segfault when --logfile option used.
If you use the --logfile option but specify a filename
that will be created in a directory that is not writable,
for instance, a system directory such as /proc/sys/ or
your current directory happens to be a system directory
that you are running nwipe from while not specifying a
writable path for the log file then nwipe would exit with
a segfault.

This is now fixed and if the logfile cannot be created
or opened then an appropriate message is displayed and
nwipe is aborted.
2022-03-15 19:58:13 +00:00
PartialVolume
648cad7645 Merge pull request #409 from PartialVolume/fix_nwipe_not_exiting_when_konsole_exited_before_nwipe_during_wipe
Fix_nwipe_not_exiting_when_using_konsole
2022-03-03 20:06:13 +00:00
PartialVolume
791c6f3975 Fix_nwipe_not_exiting_when_using_konsole
This fixes a issue related to konsole and terminals based on Konsole,
like cool retro terminal. If you exit the terminal before exiting nwipe,
nwipe will then continue running in the background but detached from any
terminals input/output. This causes a call to halfdelay()/getch() to
return immediately, thus removing the delay and causing the thread to
run at full speed causing 100% CPU in a core. This requires nwipe to
then be killed manually. This patch is related to the last patch in
that both patches do much the same thing but the previous patch fixes
the problem when nwipe is sitting at the drive selection screen, while
this patch fixes the problem during a wipe.

This problem would only be seen in specific KDE konsole related
terminals and only if you do not exit nwipe by using nwipe's control c
to abort or use the space bar on completion of the wipe.

Much like the same check we perform in the nwipe_gui_select() function,
here we check that we are not looping any faster than as defined by the
halfdelay() function, typically this loop runs at 10 times a second.
This check makes sure that if the loop runs faster than double this
value i.e 20 times a second then the program exits. This check is
therefore determining whether the getch() function is returning
immediately rather than blocking for the defined period of 100ms.
Why is this necessary? Some terminals (konsole & deriviatives) that are
exited while nwipe is still running fail to terminate nwipe this causes
the halfdelay()/getch() functions to immediately fail causing the loop
frequency to drastically increase. We detect that speed increase here
and therefore close down nwipe. This doesn't affect the use of the tmux
terminal by which you can detach and reattach to running nwipe
processes. The tmux terminal will still work correctly when a nwipe
session is detached.
2022-03-03 19:48:44 +00:00
PartialVolume
3f3ea5e04b Merge pull request #408 from PartialVolume/Fix_100%CPU_when_konsole_closed
Fixes a 100% CPU usage on Konsole based terminal
2022-03-02 19:39:54 +00:00
PartialVolume
175b246291 Fixes a 100% CPU usage on Konsole based terminal
when Konsole terminal exited while nwipe is sitting at the
drive selection screen.

To avoid 100% CPU usage, check for a runaway condition caused by the
function "keystroke = getch() that immediately returns an error
condition. We check for an error condition because getch() returns a
ERR value when the timeout value "timeout( 250 );" expires as well as
when a real error occurs. We can't differentiate from normal operation
and a failure of the getch function to block for the specified period
of timeout. So here we check the while loop hasn't exceeded the number
of expected iterations per second ie. a timeout(250) block value of
250ms means we should not see any more than (1000/250) = 4 iterations.
We double this to 8 to allow a little tolerance. Why is this necessary?
It's been found that in KDE konsole and other terminals based on the QT
terminal engine exiting the terminal without first existing nwipe
results in nwipe remaining running but detached from any interface
which causes getch to fail and its associated timeout. So the CPU or
CPU core rises to 100%. Here we detect that failure and exit nwipe
gracefully with the appropriate error. This does not affect use of
tmux for attaching or detaching from a running nwipe session when
sitting at the selection screen. All other terminals correctly
terminate nwipe when the terminal itself is exited.
2022-03-02 19:34:05 +00:00
PartialVolume
58576f8191 Merge pull request #407 from PartialVolume/Fix_temperature_update_in_drive_selection_window
Fix temperature update in drive selection window
2022-02-25 22:47:06 +00:00
PartialVolume
1384d8a6d7 Fix temperature update in drive selection window
This fixes a problem where the drive temperature is not updated
automatically in the drive selection window only. The temperature
is however updated every correctly every 60 seconds during a wipe in
the wipe status window.

This bug would probably never be noticed by most people as usually the
drive temperature changes slowly and only rises once a wipe has started.

The only time I imagine it would have been noticed would have been if
the drive temperature was already high and you were trying to reduce the
temperature by cooling before starting a wipe.

This has now been corrected so that the temperature in the drive
selection window is updated every 60 seconds.
2022-02-25 22:40:07 +00:00
PartialVolume
7f16dd3f74 Merge pull request #406 from PartialVolume/fix_spurious_message_on_abort_before_wipe_starts_control_c
Fix spurious message on abort before wipe.
2022-02-25 15:47:18 +00:00
PartialVolume
14f70661d8 Fix spurious message on abort before wipe.
This patch fixes a minor display issue that occurs when
a user aborts a wipe before a wipe has started. It only occurs
if the user had selected one or more drives for wipe and then
aborted before starting the wipe. The spurious message only
occurs in a virtual terminal, i.e. /dev/tty1, /dev/tty2, /dev/console
It does not occur in terminal applications such as konsole, xterm,
terminator etc.

The spurious message that appears in the main window, states that
"/dev/sdxyz 100% complete" along with garbage values in the statistics
window. The message appears for a fraction of a second before being
replaced with the textual log information that correctly states that
the user aborted and no wipe was started.

Basically the gui status information update function tries to update
the data when the wipe hasn't even started. The fix is to only update
the statistics information only if a wipe has started by checking the
'global_wipe_status' value which indicates whether any wipe started. '1'
indicates that a wipe has started, else '0' if no wipe has started.
2022-02-25 15:38:42 +00:00
PartialVolume
dcd1d100ca Merge pull request #404 from PartialVolume/master
Bump minor version to 0.32.023
2022-01-13 20:31:11 +00:00
PartialVolume
334bcadae1 Bump minor version 2022-01-13 20:20:58 +00:00
PartialVolume
dff450c49d Merge pull request #403 from martijnvanbrummelen/revert-402-revert-401-update_isaac64_command_line_options_help_and_man_page
Revert "Revert "Isaac64, update options, help and man page""
2022-01-13 20:05:43 +00:00
PartialVolume
40569ce1c0 Revert "Revert "Isaac64, update options, help and man page"" 2022-01-13 20:03:47 +00:00
PartialVolume
34fca0747a Merge pull request #402 from martijnvanbrummelen/revert-401-update_isaac64_command_line_options_help_and_man_page
Revert "Isaac64, update options, help and man page" Checks failed.
2022-01-13 19:32:36 +00:00
PartialVolume
110f62de00 Revert "Isaac64, update options, help and man page" 2022-01-13 19:30:10 +00:00
PartialVolume
1705b31ae8 Merge pull request #401 from PartialVolume/update_isaac64_command_line_options_help_and_man_page
Isaac64, update options, help and man page
2022-01-13 19:27:52 +00:00
PartialVolume
1e43f17650 Isaac64, update options, help and man page 2022-01-13 19:25:43 +00:00
PartialVolume
8313506ec5 Merge pull request #400 from PartialVolume/Fix_summary_table_on_specific_failure
Fix obscure incorrect summary table status
2022-01-12 21:14:22 +00:00
PartialVolume
978c4e9c8b Fix obscure incorrect summary table status
If the drive becomes non responsive during the wipe, the MB/s will
slowly drop towards 0MB/s and will display a FAILURE -1 error. The logs
will display errors and nwipe's return status will be non zero, however
the summary table may display erased rather than FAILURE, this is because
the wipe thread exited prematurely without setting the pass error.

This fixes the error by checking the context's result status, i.e non zero
on failure and if pass equals zero it makes pass equal to one. This is
then picked up by the summary table log code which then marks the status
correctly as FAILURE in the summary table.
2022-01-12 21:03:58 +00:00
PartialVolume
5ca7458b8c Bump version to 0.32.021 2022-01-09 15:18:32 +00:00
PartialVolume
0bc79f9feb Merge pull request #399 from chkboom/gutmann
Random passes in the Gutmann method should not be rearranged.
2022-01-09 15:16:05 +00:00
AK-47
0b959b62da Random passes in the Gutmann method should not be rearranged.
https://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html
"... random passes before and after the erase process, and by performing the deterministic passes in random order ..."
"The deterministic patterns between the random writes are permuted before the write is performed, ..."
2022-01-08 12:50:18 +11:00
PartialVolume
5e9ff6dfa5 Bumped version and year. 2022-01-06 23:37:02 +00:00
PartialVolume
d964c9245d Merge pull request #398 from chkboom/isaac64
Added ISAAC-64 PRNG for 64-bit systems.
2022-01-06 23:32:56 +00:00
AK-47
aa2c7727c4 Removed asserts and make "remain" const.
Attempt to fix formatting.
2022-01-07 00:28:39 +11:00
AK-47
3094fc2fa7 Leave the blanking setting alone when changing the verification setting. 2022-01-06 21:42:01 +11:00
AK-47
85fbba947a Select ISAAC-64 by default on a >=64-bit CPU.
Otherwise choose ISAAC instead of Mersenne Twister.
2022-01-06 20:57:18 +11:00
AK-47
6dff23d6b2 Significantly improved ISAAC and ISAAC-64 performance.
Each ISAAC call generates a block of integers, but only the first integer was used before the PRNG was called again.
This resulted in most of the random numbers being wasted and more calls to the PRNG than was necessary.
Also fixed some segmentation faults in ISAAC-64 code.
2022-01-06 13:55:00 +11:00
AK-47
76ca47f2cb Added ISAAC-64 PRNG for 64-bit systems.
Use RANDIZL=8 as recommended by ISAAC author.
Fixed possible buffer overflow in nwipe_isaac_read().
Slight performance improvement.
2022-01-06 01:36:12 +11:00
PartialVolume
fe9666bd41 Merge pull request #395 from Firminator/patch-2
Update README.md
2021-12-13 09:12:04 +00:00
Firminator
a19e07bd1b Update README.md
* remove redundant paragraphs and information especially regarding ShredOS
* move certain paragraphs around to streamline the readme and for better readability
* update links
* some minor changes
2021-12-13 00:33:30 -05:00
PartialVolume
c4430f149c Merge pull request #394 from PartialVolume/Mitigate_against_smartctls_inconsistent_use_of_case_in_labelling
Fix missing serial number on SAS drive. Fixes #384
2021-12-12 20:28:08 +00:00
PartialVolume
a83a27f8e5 Fix missing serial number on SAS drive
This was caused by inconsistent labeling of the
serial number by smartctl. In a majority of cases
smartctl would output serial number data using
the label "Serial Number:" however on a SAS
drive we found that smartctl output the label
as "Serial number:" i.e. differs with a lower
case 'n'. Unfortunately we were doing a case
sensitive search for "Serial Number" so the result
being the serial number was not found.

This patch converts both strings in the search
to lower case before searching.

In addition a new field was added to the
anonymize list, "logical unit id:" so when the
-q option is used "serial number", "lu wwn device id:"
and "logical unit id:" are all now anonymized in the
smartctl debug data.
2021-12-12 20:22:35 +00:00
PartialVolume
254a0efd2c Merge pull request #393 from PartialVolume/Improve_GUI_thread_cancellation_eror_handling
Improve GUI thread cancellation messaging
2021-12-08 23:47:38 +00:00
PartialVolume
323fc38631 Improve GUI thread cancellation messaging
If pthread_join failed, nwipe would report an error
but would also report that the thread had been
cancelled. This has been corrected so that only
the error message is displayed in a fault condition.
2021-12-08 23:43:01 +00:00
PartialVolume
7f547e7ccb Merge pull request #392 from PartialVolume/Improve_thread_cancellation_error_reporting
Improve thread cancellation error reporting
2021-12-07 23:17:25 +00:00
PartialVolume
c433326c9f Improve thread cancellation error reporting
Check for specific errors.
Add retry loop with timeout for pthread_join.
2021-12-07 23:10:20 +00:00
PartialVolume
4351b3db5d Merge pull request #391 from PartialVolume/Fix_use_of_modprobe_on_Debian_11_part2
Would help if I explicitly stated the paths ;-)
2021-12-02 22:51:48 +00:00
PartialVolume
5eb43855c7 Would help if I explicitly stated the paths :'-) 2021-12-02 22:47:48 +00:00
PartialVolume
86174b227d Merge pull request #390 from PartialVolume/Fix_use_of_modprobe_on_Debian_11
Check multiple paths for modprobe
Fixes #389
2021-12-02 22:34:09 +00:00
PartialVolume
acba2c8065 Check multiple paths for modprobe
Particularly relevant to Debian which when logged in as root
doesn't put /sbin in the $PATH environment setting.

This might have caused temperatures to not be available on Debian
systems, but not necessarily on distros based on Debian like
Ubuntu which would have worked ok.
2021-12-02 22:30:39 +00:00
PartialVolume
0d3e1af83d Merge pull request #388 from PartialVolume/Fix_second_occurence_of_incorrect_specifier
Fix 2nd occurrence of incorrect format specifier.
2021-12-01 19:45:20 +00:00
PartialVolume
981f666150 Fix 2nd occurrence of incorrect format specifier.
Causing incorrect sect/block/device size to be
printed in nwipe_log but only for 32 bit builds.
2021-12-01 19:42:28 +00:00
PartialVolume
4f531e65db Merge pull request #387 from PartialVolume/Fix_nwipe_log_format_specifier_incorrect
Fix nwipe log format specifier incorrect
2021-12-01 19:33:16 +00:00
PartialVolume
181ef543de nwipe_log format specifier doesn't match variable.
The format specifier didn't match the size of the variable that holds
c2[i]->device_sector_size which is an int. This didn't appear to cause
a problem with reporting in a 64 bit build. It does cause a problem in
a 32 bit build displaying a very large & incorrect number for sector,
block and device sizes.

This doesn't cause any issues with the overall function, simply
incorrect sector, block and device sizes in 32 bit builds as displayed
in the nwipe log.

I also changed the signed long long for c2[i]->device _size to a
unsigned long long as there is little point in a negative device size.
2021-12-01 19:20:34 +00:00
PartialVolume
aab863ea7d Update ShredOS link 2021-12-01 05:50:34 +00:00
PartialVolume
ef06fed886 Merge pull request #383 from Firminator/patch-1
Update options.c with additional infor for -q
2021-11-18 15:34:05 +00:00
Firminator
6396825eb6 Update options.c
* added additional info for -q, i.e. what data is being removed from GUI and logs
* removed superfluous new line break
2021-11-18 10:11:03 -05:00
PartialVolume
b35b14ba42 Merge pull request #382 from PartialVolume/Remove_trailing_character
Remove ')' character in nwipe_log message
2021-11-18 12:07:29 +00:00
PartialVolume
2b63fb74cb Remove ')' character in nwipe_log message 2021-11-18 12:02:35 +00:00
PartialVolume
fd11b9df35 Merge pull request #381 from PartialVolume/Update_hwmon_search_directories
Update temperature for some nvme devices
2021-11-18 11:29:27 +00:00
PartialVolume
0677cebe5b Update temperature
Add /sys/class/hwmon/hwmonX/device/ to the list
of directories to search for a given device.

Some nvme devices/controllers put the device name
in /sys/class/hwmon/hwmonX/device/ rather than
/sys/class/hwmon/hwmonX/device/nvme/nvme0/

Update debug messaging.
2021-11-18 11:25:44 +00:00
PartialVolume
6b930863a6 Update comment 2021-11-17 20:32:15 +00:00
PartialVolume
e07ae7e0ef Merge pull request #380 from PartialVolume/Update_NVME_temperature_code
Update nvme temperatures.
2021-11-17 19:30:39 +00:00
PartialVolume
1744d89692 Update nvme temperatures.
For sdX devices we look in
/sys/class/hwmon/hwmonX/block for the device
name.

However, for nvme we access the device name
by looking in ..
/sys/class/hwmon/hwmonX/device/nvme/nvme0

nvme0n1

Multiple nvme drives/controllers will need
to be tested.
2021-11-17 19:27:27 +00:00
PartialVolume
8b36b3d204 Merge pull request #379 from PartialVolume/Add_anonymized_label_to_banner
Make it clear we are in anonymized mode
2021-11-17 16:26:06 +00:00
PartialVolume
c0466c4850 Make it clear we are in anonymized mode
When selecting -q or --quiet as an nwipe
option, append " (ANONYMIZED)" to the nwipe
banner.
2021-11-17 16:14:28 +00:00
PartialVolume
bb7199adf6 Bump version to v0.32.010 2021-11-17 15:39:54 +00:00
PartialVolume
e2cd608741 Merge pull request #378 from PartialVolume/Add_VRFY_instead_of_WIPE_when_verify_ones_or_zeros_only_is_selected
Distinguish between a wipe & verify
2021-11-17 15:38:16 +00:00
PartialVolume
a4d2418597 Distinguish between a wipe & verify
In the drive selection window when you
select a drive, the drive is identified
as selected for wiping with the [wipe]
label, however if you then select a
verify only method such as 'verify with
ones' or 'verify with zeros' it still
says [wipe] which is technically a
contradiction.

This patch changes the [wipe] to a
[vrfy] when a verify only method is
selected. If a method is selected
that writes data to the disc then the
label is displayed as [wipe].
2021-11-17 15:27:45 +00:00
PartialVolume
40ae117db4 Merge pull request #377 from PartialVolume/add_temperature_support_to_nvme_drives
Add temperature support to NVME drives, patch #1 ready for checking @Firminator . Thanks
2021-11-17 14:44:53 +00:00
PartialVolume
4ef3dbc5dd Add temperature support to NVME drives
Patch #1 (first check)
2021-11-17 14:37:16 +00:00
PartialVolume
93fe596c04 Merge pull request #375 from PartialVolume/Dont_calculate_ETA_when_throughput_is_zero
Fixes ETA under fault condition
2021-11-17 11:53:38 +00:00
PartialVolume
dd44cc8176 Fixes ETA under fault condition
If a faulty drive fails mid wipe and it's
throughput drops until eventually reaching
zero. The ETA calculation grows to an enormously
high value.

This patch prevents the ETA being calculated if
the throughput for a given drive drops below
100,000 bytes per second. In this way we can still
see that something is wrong because the ETA is much
higher than normal but prevents the sort of calculation
that looks like this ! 90867213:29:12 i.e ..
90,867,213 hours, 29 minutes and 12 seconds, or put
another way, 3,786,133 days or 10,372 years.
2021-11-17 11:50:22 +00:00
PartialVolume
c6fda62558 Merge pull request #374 from PartialVolume/Make_verify_error_message_more_succinct_to_reduce_line_wrap_on_many_verification_errors
Make verify & pass error succinct
2021-11-17 10:45:10 +00:00
PartialVolume
87f63e1388 Make verify & pass error succinct
When many verification or pass errors are detected
the status line can wrap on a 80 column display.

This patch makes the error message more succinct
which will free up about 10 characters & prevents
the line wrapping.
2021-11-17 10:40:36 +00:00
PartialVolume
bfe5939e33 Merge pull request #373 from PartialVolume/Fix_intermittent_FAILED_message_instead_of_UABORTED_on_control-C
Fix summary table - Control-C
2021-11-17 10:03:45 +00:00
PartialVolume
fb6b47d12a Fix summary table - Control-C
If you used control-c during a wipe,
the summary table would report FAILED
rather than UABORTED, even though no
errors had occured and no errors were
reported in the error summary table.

The correct message on control-c abort
should be UABORTED if no errors on that
drive had so far been detected or FAILED
if errors had been detected.

nwipe reported correctly when letting
the wipe continue to it's natural completion.

This patch fixes that issue.
2021-11-17 09:59:20 +00:00
PartialVolume
5d0d0ecb8a Merge pull request #371 from PartialVolume/Add_LU_WWN_ID_to_the_list_of_items_that_can_be_anonymized
Anonymize 'LU WWN ID' when -q specified.
2021-11-16 17:54:11 +00:00
PartialVolume
5cb27e60ce Anonymize 'LU WWN ID' when -q specified.
Add 'LU WWN ID' to the list of data returned
by smartctl that should be anonymized when
-q or --quiet is specified.
2021-11-16 17:48:50 +00:00
PartialVolume
f3f5ab1cac Bump version 2021-11-15 22:00:57 +00:00
PartialVolume
357031ce54 Merge pull request #367 from PartialVolume/Anonymize_SMBIOS-DMI_data_in_log_when_q_option_used
Anonymize SMBIOS/DMI data if -q --quiet specified
2021-11-15 21:57:41 +00:00
PartialVolume
190dae3dec Anonymize SMBIOS/DMI data if -q --quiet specified 2021-11-15 21:46:20 +00:00
PartialVolume
b9cb2369d1 Merge pull request #366 from PartialVolume/Add_anonymize_serial_numbers_option
Add -q --quiet option - anonymize serial numbers
2021-11-15 18:41:03 +00:00
PartialVolume
e982ca5fee Add -q --quiet option - anonymize serial numbers
Anonymize the serial numbers in the gui, the
log and the summary table.

If a serial number was obtained from the device,
it is replaced with "XXXXXXXXXXXXXXX".

If the serial number could not be obtained from the
device, it's replaced with "???????????????".
2021-11-15 18:19:47 +00:00
PartialVolume
a074be7f87 Merge pull request #365 from PartialVolume/Remove_dev_prefix_for_long_device_names_for_gui
Remove /dev/ from gui for long filenames
2021-11-15 10:07:47 +00:00
PartialVolume
0960fd1259 Remove /dev/ from gui for long filenames
This fixes column alignment issues in the gui
with nvme drives i.e. nvme0n1 etc. If the drive
name including path exceeds 8 characters the
/dev/ is removed and prefixed with spaces to
a total max length of 8 characters.
2021-11-15 09:57:46 +00:00
PartialVolume
4aee9a2d28 Merge pull request #364 from PartialVolume/move_temperature
Moved the temperature readout
2021-11-13 22:06:41 +00:00
PartialVolume
8650b4838a Moved the temperature readout
In both selection and wipe status windows I
moved the temperature readout to the right
of the disk size column.

Also in the wipe status window, by moving to
the right of the disk size column the
temperature is no longer on the same line as
the disk pass progress. This reduces the line
length as I found that in tests if you had
many verification errors the temperature
being on the end of the line would disappear
of the right of the screen.
2021-11-13 21:55:48 +00:00
PartialVolume
07eac4d861 Merge pull request #363 from Firminator/patch-1
Update README.md
2021-11-13 17:07:10 +00:00
Firminator
20ea1bf251 Update README.md
rewording.
2021-11-13 11:25:08 -05:00
Firminator
673310ce6d Update README.md
added netboot.xyz
2021-11-13 11:21:08 -05:00
PartialVolume
a0e63c659b Merge pull request #361 from PartialVolume/temperature_on_select_screen
Added temperature to drive selection window
2021-11-12 23:39:55 +00:00
PartialVolume
90ed59fe06 Added temperature to drive selection window
Also removed 1. 2. etc from drive selection
to reduce the line length. Also removed the
space between > and [, ie "> [wipe]" becomes
">[wipe]" These changes remove 3 characters
and help to reduce the affect of the additional
temperature field [30C] which add 5 characters.
Therefore the line length overall, increased by
5-3 = 2 characters.

This helps to reduce line wrapping on 80
character terminals, when the drive model length
exceeds 24 characters.
2021-11-12 23:23:57 +00:00
PartialVolume
c38c9577bb Bump version 2021-11-10 23:32:38 +00:00
PartialVolume
584f70e3b0 Merge pull request #360 from PartialVolume/Add_drive_temperature
Add drive temperature monitoring
2021-11-10 23:28:04 +00:00
PartialVolume
588784a06b More additions to temperature feature
1. Changed a few nwipe log messages to improve
readability.

2. Added code so that the temperature changes from
- white text = (Temperature within spec)
- red text = max continuous temp reached
- red flashing text = critical upper temperature reached
- black text = minimum continuous temperature reached
- black flashing text = critical lower temperature reached.
2021-11-10 23:16:17 +00:00
PartialVolume
796d5e2294 More changes related to temperature feature
1. Changed gui format specifier to match signed
integer that we changed to in the previous commit.

2. Changed the format specifier in verbose nwipe logging of
the temperatures and moved the nwipe log message that prints
the hwmonX path to the log in order to remove
unnecessary printing to the log.
2021-11-10 19:09:12 +00:00
PartialVolume
e7237a7a75 Changes related to temperature feature
1. Changed u64 to int to support negative
temperature values, i.e. temp1_lcrit may
be as low as -40C

2. In gui surround temperature reading with
square brackets instead of round brackets to
be consistent with the rest of the drive status line
2021-11-10 18:40:42 +00:00
PartialVolume
1d5f2a7899 Stage 2 temperature monitor feature.
Stage 2 modifies the GUI to trigger a temperature
update every 60 seconds. Changes were made to the
drive progress line to include [ 30C ]. The drive
context structure had another variable added that
records the time of the temperature update.

Note. When the temperature data cannot be retrieved
from the hwmon (drivetemp) module the GUI displays
[ --C ]. USB devices, even those adapters that support
ATA pass through, don't seem to work with hwmon (drivetemp),
at least the adapters I have don't work with drivetemp
to monitor temperature.
2021-11-10 12:27:20 +00:00
PartialVolume
397f6fceb3 Stage 1 temperature monitor feature.
Stage 1 adds the additional variables to the drive
context and creates the temperature initialisation
function, which associates a hwmonX directory with
a block device. Also wrote the context update function,
that reads hwmon for each drive context and writes the
temperatures back to the context.

Stage 2 commit to follow which will make changes within
the GUI to call the update function every 60 seconds
and display the temperature information.
2021-11-10 01:27:52 +00:00
PartialVolume
74fa192efa Change message for unknown serial no.
Changed message from (No ATA pass-thru) to (S/N: unknown)
2021-11-07 00:10:38 +00:00
PartialVolume
aa196b9602 Merge pull request #356 from Firminator/patch-2
Update device.c
2021-11-07 00:05:19 +00:00
PartialVolume
4d59c31b8f Bump version to 0.32.002 2021-11-06 00:44:12 +00:00
PartialVolume
056b4745ba Merge pull request #358 from PartialVolume/add_SATA_to_smartctl
Check smartctl for unresolved bus types SATA
2021-11-05 23:47:53 +00:00
PartialVolume
366249b76a Check smartctl for unresolved bus types SATA
For some controllers/drivers the readlink method of
obtaining the bus type for GUI display does not work.

If we haven't already resolved the bus type, we then
also check smartctl for the transport protocol
for SATA.
2021-11-05 23:43:43 +00:00
Firminator
02c1fa4780 Update device.c
correct a few typos not found by codespell
2021-11-04 23:35:00 -04:00
PartialVolume
39de02db8c Merge pull request #353 from DimitriPapadopoulos/codespell_rc
Add a .codespellrc file to run codespell
2021-11-02 19:12:50 +00:00
PartialVolume
e4b033e566 Merge pull request #354 from DimitriPapadopoulos/typo
Typo not found by codespell
2021-11-02 11:28:54 +00:00
Dimitri Papadopoulos
4903f246c0 Typo not found by codespell
The it's → its typo is not detected bsy codespell. Both are valid.
A higher level analysis would be required to detect that kind of typo.
2021-11-02 12:20:59 +01:00
Dimitri Papadopoulos
009ccf294b Add a .codespellrc file to run codespell 2021-11-02 12:10:22 +01:00
PartialVolume
17609ecdcd Merge pull request #352 from DimitriPapadopoulos/spaces
Remove trailing spaces or empty lines
2021-11-02 09:34:37 +00:00
PartialVolume
9f58de6006 Merge pull request #351 from DimitriPapadopoulos/codespell
Typos found by codespell
2021-11-02 09:30:23 +00:00
Dimitri Papadopoulos
c545aa8447 Remove trailing spaces or empty lines 2021-11-02 08:21:34 +01:00
Dimitri Papadopoulos
b2c22d58cb Typos found by codespell 2021-11-02 08:13:48 +01:00
PartialVolume
2459b0a397 Merge pull request #350 from PartialVolume/Add_SAS_to_bus_type_for_GUI
Add SAS to GUI.
2021-11-01 23:02:34 +00:00
PartialVolume
3c4e51a1ff Add SAS to GUI.
For some controllers/drivers the readlink method of
obtaining the bus type for GUI display does not work.

If we haven't already resolved the bus type, we then
also check smartctl for the transport protocol
for SAS.
2021-11-01 22:54:55 +00:00
PartialVolume
0ee4099c64 Merge pull request #348 from PartialVolume/Fix_spaces_overwriting_first_two_chars_of_DOD
Fix slight screen corruption on 80 column display
2021-10-31 21:49:19 +00:00
PartialVolume
089c188b06 Fix slight screen corruption on 80 column display
When highlighting the verify ones option the first two
digits of DoD 5220 .20-M disappear. This patch fixes that
issue.
2021-10-31 21:30:20 +00:00
PartialVolume
154490e56f Merge pull request #347 from PartialVolume/update_ready_for_0.32_release
Update files for 0.32 release
2021-10-28 23:40:29 +01:00
PartialVolume
753e758b0a Update files for 0.32 release
Confirmed the following release files were/are updated.
configure.ac
CHANGELOG.md
nwipe.1
version.c
2021-10-28 23:34:46 +01:00
PartialVolume
7d58587eb0 Merge pull request #346 from PartialVolume/update_readme_with_new_ones_wipe_and_verification
Update README.md with new wipe methods
2021-10-28 22:18:14 +01:00
PartialVolume
996c6cbf02 Update README.md with new wipe methods
Updated with Ones wipe & Ones verification.
2021-10-28 22:16:37 +01:00
PartialVolume
7eba0aeb1b Merge pull request #345 from PartialVolume/add_verify_ones
Add ones (0xFF) verification method.
2021-10-28 21:55:50 +01:00
PartialVolume
a379329fca Add ones (0xFF) verification method. 2021-10-28 21:50:19 +01:00
PartialVolume
9196e7748b Merge pull request #344 from PartialVolume/update_help_and_man_pages_for_zeros_ones
Update help, man and options for the ones method
2021-10-28 10:46:56 +01:00
PartialVolume
f7730b9fea Update ones method, help, man and options 2021-10-28 10:44:09 +01:00
PartialVolume
bcb34f7a83 Merge pull request #343 from PartialVolume/Adjust_info_for_max_80_columns
Adjust method info for 80+ column display
2021-10-28 00:40:27 +01:00
PartialVolume
a8dbbd46ec Adjust method info for 80+ column display 2021-10-28 00:36:53 +01:00
PartialVolume
7a3f2f573f Merge pull request #342 from PartialVolume/add_wipe_with_ones_method
Add ones 0xFF method.
2021-10-27 23:42:15 +01:00
PartialVolume
8336653926 Add ones 0xFF method. 2021-10-27 23:40:30 +01:00
PartialVolume
e629d9b2d1 Merge pull request #341 from PartialVolume/Remove_syslinux.cfg_lines
Remove the old syslinux configuration hints.

Help on nwipe options is available from the command
line nwipe --help or man help.
2021-10-27 22:30:58 +01:00
PartialVolume
70c5383d97 Remove the old syslinux configuration hints.
Help on nwipe options is available from the command
line nwipe --help or man help.
2021-10-27 22:22:15 +01:00
PartialVolume
708c4e02c8 Merge pull request #340 from PartialVolume/Move_method_info
Move the method description
2021-10-27 21:12:16 +01:00
PartialVolume
8fcb314ed4 Move the method description
Move the method description to the right hand side
of the list of methods. This allows us to extend the
list of methods so that the info doesn't fall of the
terminal on a 80x24 system that is using the frame
buffer such as shredos.

Also updated the information, making it more
description in terms of describing the passes used
for each method.
2021-10-27 21:07:32 +01:00
PartialVolume
6497b43518 Merge pull request #339 from PartialVolume/add_fdata_sync_errors_to_summary_table
Add fdatasync errors to error summary table
2021-10-27 10:17:15 +01:00
PartialVolume
e6e6ed1e30 Add fdatasync errors to error summary table 2021-10-27 09:55:33 +01:00
PartialVolume
c821f3176b Merge pull request #337 from PartialVolume/change_color_theme
Toggle between dark/blank/default screens
2021-10-26 02:09:18 +01:00
PartialVolume
9db8ad854e Toggle between dark/blank/default screens
Using the 'b' key you can now toggle between
dark/blank/default screens during a wipe.

Added the dark option to prevent TFT/LCD image
persistence.

See:
https://en.wikipedia.org/wiki/Image_persistence
2021-10-26 02:03:58 +01:00
PartialVolume
6ce785c2f2 Update and rename ci_ubuntu_16.04.yml to ci_ubuntu_18.04.yml 2021-10-26 01:46:59 +01:00
PartialVolume
cb08dda2de Update README.md with distro info 2021-06-15 23:57:34 +01:00
PartialVolume
2fb882084d Update README.md 2021-06-15 13:36:47 +01:00
PartialVolume
64caac4b16 Update README.md 2021-06-15 13:30:15 +01:00
PartialVolume
47e523cf34 Update nwipe.1 with correct default sync rate 2021-06-08 23:25:17 +01:00
PartialVolume
cf3ae6a0f6 Merge pull request #328 from PartialVolume/update_to_0.31
Update to 0.31
2021-06-05 20:23:12 +01:00
PartialVolume
a88eeb9383 Update to 0.31 2021-06-05 19:40:00 +01:00
PartialVolume
a84894f317 Update CHANGELOG.md with version 0.31 changes
Update CHANGELOG.md with version 0.31 changes
2021-06-05 00:17:41 +01:00
PartialVolume
5c3eed8813 Merge pull request #326 from PartialVolume/Enable_verification_on_zero_pass_without_additional_blanking_pass
Allow Last Pass Verify to work without requiring final blanking (zero) pass.
2021-06-04 10:36:35 +01:00
PartialVolume
4b1c7007ff Various fixes to methods
1. Allows zero fill to be verified when blanking off.
Prior to this if you wanted to verify a zero pass,
blanking had to be on. This meant a zero pass, then a
blanking pass then a verify, effectively two zero passes
and a verify. This is now fixed so you can now do a zero
pass with verification without a blanking pass. This knocks
a third off the wipe time of a zero fill with verification.

This also means all other methods can have either all their
passes or just the last pass verified without blanking being
enabled.

2. OPS2 method requires the last pass to be random, the GUI
now disables the use of the blanking option for this message
and displays a warning message that a final blanking pass is
not allowed for OPS2. It never did a final blanking pass
anyway, even if it was selected, but this makes it clearer in
the GUI.

3. The caculate_round_size() function was improved by reducing
some duplicated code and bring the full calculation into this function.

4. On completion of each pass or verification the total number of
bytes written or read for each pass or verification is logged.
2021-06-04 10:20:23 +01:00
PartialVolume
970d74f0d5 Bump minor version number from 009 to 010 2021-06-01 02:36:51 +01:00
PartialVolume
c815235f7b Merge pull request #325 from PartialVolume/Add_count_of_fatal_non-fatal_and_verification_errors_to_summary_table
Add pass and verification summary table to log
2021-06-01 02:30:50 +01:00
PartialVolume
dcfa13a8db Add pass and verification summary table to log 2021-06-01 02:21:00 +01:00
PartialVolume
a1560de8b5 Merge pull request #324 from PartialVolume/Fixes_verify_status_message_not_shown_on_blanking_pass
Fix blanking pass verification status message
2021-05-31 23:44:41 +01:00
PartialVolume
18386f225e Fix blanking pass verification status message
Although the blanking pass verification is
completed correctly the GUI status message
did not show the status as 'Verifying', the
status message continued to say blanking.

This patch fixes the GUI message so if
verification and blanking pass are enabled,
then when blanking is complete and verification
starts the drive status message changes from
'blanking' to 'Verifying'.
2021-05-31 23:41:19 +01:00
PartialVolume
1f3b36f141 Merge pull request #323 from PartialVolume/Fix_mersenne_prng_always_being_used_even_when_user_selected_isaac
Fix the prng GUI selection
2021-05-30 23:09:01 +01:00
PartialVolume
962e1053dd Fix the prng GUI selection
This patch fixes the issue where irrespective
of whether the user selects mersenne or isaac
in the GUI, mersenne is always used without the
user being aware mersenne was being used instead
of isaac.
2021-05-30 23:05:47 +01:00
PartialVolume
93ea5f85d0 Merge pull request #322 from PartialVolume/populate_the_empty_isaac_read_function_with_some_actual_code
Fix non functional isaac prng
2021-05-30 22:34:36 +01:00
PartialVolume
76a7be696c Fix non functional isaac prng
Since at least 2013 (the initial nwipe commit),
isaac has never functioned. When the issac prng
was selected in the GUI, nwipe used the mersenne
twister prng instead. Not that you would ever
have known, as there were no log entries saying which
prng was being actively used.

However, I don't believe this was just an nwipe
issue, looking at the code for DBAN's dwipe the
same function nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE )
exists as it does in nwipe. In both cases the function
has no code that actually does anything.

This patch populates this function and brings isaac
back to life !

This bug was also responsible for verification errors
when the option prng=isaac was used on the command
line. Worse still, if you used prng=isaac on the
command line then wiped using method=prng, no verification
and no blanking you would expect to see random data. You
don't, instead you would see either all zeros or mainly
zeros because the uninitialised buffer that should have
contained random data instead contained initialised text
data such as partial log entries. This patch and previously
submitted patches fix all these problems related to the
isaac implementation.

A separate commit will fix the GUI prng selection which
was leading everybody to believe isaac was being used
when in fact it was mersenne all along.
2021-05-30 22:30:31 +01:00
PartialVolume
630d107558 Merge pull request #321 from PartialVolume/check_prng_is_generating_data
Check that the prng produces output.
2021-05-29 21:31:47 +01:00
PartialVolume
5adc34b9e3 Check that the prng produces output.
Additional log messages are produced and a failed prng
causes a wipe failure. The buffer that outputs prng data
to the disk is now initialised with zeros (calloc rather than malloc)
to avoid uninitialised memory leakage to the disk in the event of some
unforeseen bug. This initialised buffer is also required for the check
process.

Why do this check? At a future date more prng methods may be added. This
is a very basic check that they produce some output although the output
is not verified in terms of it's randomness. This check was also
implemented to show an existing bug in the Isaac implementation in nwipe.

See the example log below that shows a failed prng. This would be caused
by a bug in the prng implementation. See the last few messages after
pass 3/3 starts. 3/3 in DoD short is the prng pass.

[2021/05/29 20:30:27]  notice: Invoking method 'DoD Short' on /dev/loop29
[2021/05/29 20:30:27]  notice: Starting round 1 of 1 on /dev/loop29
[2021/05/29 20:30:27]  notice: Starting pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:39]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:30:39]  notice: Finished pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:39]  notice: Starting pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:30:58]  notice: Finished pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: Starting pass 3/3, round 1/1, on /dev/loop29
[2021/05/29 20:30:58]  notice: Initialising Isaac prng
[2021/05/29 20:30:58]   fatal: ERROR, prng wrote nothing to the buffer
[2021/05/29 20:30:58]  notice: 0 bytes written to /dev/loop29
[2021/05/29 20:31:03]   error: Nwipe exited with fatal errors on device = /dev/loop29

********************************************************************************
! Device | Status | Thru-put | HH:MM:SS | Model/Serial Number
--------------------------------------------------------------------------------
! loop29 |-FAILED-|  69 MB/s | 00:00:31 | Loopback device/
--------------------------------------------------------------------------------
[2021/05/29 20:31:03] Total Throughput  69 MB/s, DoD Short, 1R+NB+NV
********************************************************************************

A message is also shown for a successful prng output. i.e "prng is active"
See example below.

[2021/05/29 20:04:30]  notice: Invoking method 'DoD Short' on /dev/loop29
[2021/05/29 20:04:30]  notice: Starting round 1 of 1 on /dev/loop29
[2021/05/29 20:04:30]  notice: Starting pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:44]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:04:44]  notice: Finished pass 1/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:44]  notice: Starting pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: 1073741824 bytes written to /dev/loop29
[2021/05/29 20:04:59]  notice: Finished pass 2/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: Starting pass 3/3, round 1/1, on /dev/loop29
[2021/05/29 20:04:59]  notice: Initialising Mersenne Twister prng
[2021/05/29 20:04:59]  notice: prng stream is active
[2021/05/29 20:05:25]  notice: 1073741824 bytes written to /dev/loop29
2021-05-29 21:23:38 +01:00
PartialVolume
5bc61f2bdd Merge pull request #320 from PartialVolume/Log_intialisation_of_prng_method
Logs the specific prng that is initialised.
2021-05-28 19:54:49 +01:00
PartialVolume
b55b020a83 Log the initialisation of the prng type
Logs the specific prng that is initialised.
2021-05-28 19:45:19 +01:00
PartialVolume
b34c99b81b Bump banner & version minor version 2021-05-27 14:23:34 +01:00
PartialVolume
63d20dc4be Merge pull request #319 from PartialVolume/Add_details_of_wipe_to_log
log the nwipe options that the wipe/s is going to use.
2021-05-27 14:16:14 +01:00
PartialVolume
2111206fa3 Add nwipe options that have been selected.
The log now contains wipe configuration detail
such as method, prng, blanking, sync, rounds etc.
2021-05-27 14:06:57 +01:00
PartialVolume
5263a23cd6 Merge pull request #317 from PartialVolume/Fix_contradictory_log_messaging
Fixes contradictory log messages.
2021-05-27 08:18:29 +01:00
PartialVolume
a6b60bfd15 Fixes contradictory log messages.
1. The log reported verification errors while also
showing an entry in the log that said "[SUCCESS] Blanked /dev/...".
The blanked device message now shows [FAILURE] /dev/... may not be blanked"
if any verification errors are detected for a specific drive.

2. If a verification error occurred, the error would be correctly
shown in the GUI and in the logs but the summary table drive status
would show 'ERASED' not 'FAILED'. Now corrected so that the tables
drive status field shows 'FAILED' if any verification error is detected.
Prior to this it was marking the status as 'FAILED' only if the O.S
detected write errors. In practise most drive errors are detected
by the write I/O process on syncing but this will now detect errors not
recognised by the O.S. and found by the verification process. Despite
this the textual log and GUI correcty reported verification errors.

3. The final log message "Nwipe exited successfully" was checking for
fatal errors but ignoring non fatal errors despite being reported in
the log.

The final message now reads
either "Nwipe Exited Succesfully" if no fatal and non fatal errors were
detected. Alternatively it displays ...
"Nwipe exited with errors, check the log & summary table for individual drive status."
if any fatal OR non fatal errors are detected.
2021-05-27 08:07:20 +01:00
PartialVolume
d8d627dce3 Merge pull request #315 from PartialVolume/Fix_shutdown
Fix shutdown on buildroot based distros such as shredos 2020, while maintaining compatibility with Ubuntu/Debian etc.
2021-04-19 15:34:21 +01:00
PartialVolume
95d0b3f382 Fix shutdown on buildroot based distros
The shutdown command that nwipe currently uses is
"shutdown -P +1 "Broadcast shutdown message".
While the above command works works fine on Ubuntu 18.04 LTS it
does not work on the version of shutdown used in buildroot, failing
with the error:
"shutdown -H and -P flags can only be used along with -h flag"

Luckily there is a shutdown command with options that work correctly
on both buildroot (ShredOS) and Ubuntu 18.04 LTS, this is
shutdown -Ph +1 "Broadcast shutdown message". i.e. the option -h has been added.
2021-04-19 15:22:43 +01:00
PartialVolume
055d2e8b0c Bump minor revision 2021-03-17 21:28:29 +00:00
PartialVolume
9f0674b3b9 Merge pull request #314 from andrewvaughanj/code_formatting
Run 'make format'
2021-03-17 21:27:03 +00:00
PartialVolume
5f332a407d Merge pull request #313 from andrewvaughanj/fix_global_wipe_status
Correcting multiple definition of 'global_wipe_status'
2021-03-17 21:26:28 +00:00
Andrew V. Jones
543a880064 Run 'make format'
Signed-off-by: Andrew V. Jones <andrewvaughanj@gmail.com>
2021-03-17 17:41:32 +00:00
Andrew V. Jones
62c604bc0e Correcting multiple definition of 'global_wipe_status'
Signed-off-by: Andrew V. Jones <andrewvaughanj@gmail.com>
2021-03-17 16:07:37 +00:00
PartialVolume
2bc62a7217 Update README.md with link to gparted live 2021-02-17 21:16:55 +00:00
PartialVolume
7f5bc5aa34 Merge pull request #301 from ndowens/master
bits/sigthread.h is a glibc only and is not needed
2021-02-05 17:07:29 +00:00
PartialVolume
7fa5c98023 Merge pull request #312 from PartialVolume/fix_footer_corruption_on_resize_and_method_rounds_blanking_selection
Fixes footer bar corruption to the right of the message
2021-02-04 21:51:26 +00:00
PartialVolume
4e159a902c Merge branch 'master' into fix_footer_corruption_on_resize_and_method_rounds_blanking_selection 2021-02-04 21:50:06 +00:00
PartialVolume
3090b0682f Fixes footer bar corruption to the right of the message
This bug only occurs when you resize the terminal while
on the drive selection screen, then switch to method, rounds
or blanking. To the right of the message the text background
is now blue and not white and random box characters appear.

To me it seems to be a bug not in nwipe but in curses, however
placing double quotes around the message fixes the problem. I
also found that the contents of the message appeared to trigger
the problem, possibly the '=' symbol, however the fact that
the main selection text does not require the quotes is most odd.
Still, this simple fix seems to get rid of the problem.
2021-02-04 21:40:26 +00:00
PartialVolume
d2dff52407 Merge pull request #310 from Firminator/patch-1
Update gui.c - Add CTRL+A
2021-02-01 11:43:46 +00:00
PartialVolume
58a5184c88 Removed CTRL+A=SelectALL from help as it makes the help text greater than 80 characters required for system working with frame buffer displays using 80x25. I have a plan to make the help line responsive or multipage to overcome this limitation so more commands can be added. Secondly, one line needed to be formatted to pass CI format check. 2021-02-01 11:40:52 +00:00
PartialVolume
6dcaaa6920 Update README.md with make format
If submitting pull requests, you must `make format` prior to commiting code and submitting a pull request otherwise you pull request will fail the CI that checks formatting.
2021-01-31 00:17:35 +00:00
PartialVolume
8e9e2ae90f Update README.md with make format
If submitting pull requests, you must `make format` prior to commiting code and submitting a pull request otherwise you pull request will fail the CI that checks formatting.
2021-01-31 00:15:58 +00:00
PartialVolume
02e356e0ec Merge pull request #311 from PartialVolume/fix_uaborted_message_in_summary_table
Fixes to summary table & fix final status message Fixes #308
2021-01-30 19:17:15 +00:00
PartialVolume
12063ad954 Fixes to summary table & fix final status message
1. Prior to this fix, if a user aborted a multi drive using control-C,
and if some of the drives had completed their wipe either
successfully or with a I/O failures, the summary log would say
UABORTED for all drives. UABORTED is acceptable status for drives that
hadn't completed their wipe but for drives that had completed the wipe,
the summary table should have gave either a ERASED or FAILED status
message. This fix corrects the summary status when using control-c to
abort a multi drive wipe where some drives have completed and some have
not.

2. If I wipe was selected but not started and then the user used
control-C to abort nwipe, the summary table would possibly
intermittently be displayed showing the last drive wiped. The correct
behaviour is that no summary table is displayed if the wipe hasn't been
started yet. This fix corrects the behaviour of the summary table when
control-c is used and a drive has been selected for wiping but not
started, in this scenario the summary table is NOT displayed.

3. When nwipe exits it always prints the message "nwipe successfully
exited". To make this single line message more informative it now
reports a different message depending upon the wipe status.

These four messages are:

"Nwipe was aborted by the user. Check the summary table for the drive
status" -  When the user aborts during a wipe.

"Nwipe was aborted by the user prior to the wipe starting."

"Nwipe exited with fatal errors, check the summary table for individual
drive status." - When one or more drives failed.

"Nwipe successfully completed. See summary table for details." - When
selected drives were all erased without error.
2021-01-30 19:08:05 +00:00
Firminator
66d239c980 Update gui.c - Add CTRL+A
... and reduce confusion about lowercase and uppercase option. All options are now defaulting to show as lowercase in the GUI except Start which can only be invoked with SHIFT S to prevent accidental start of wipe. Unless someone enjoys pressing additionally SHIFT for B and R and V and all the other options I'd propose it might be time to remove unneeded code for this :)
2021-01-30 13:37:48 -05:00
PartialVolume
462777d92b Merge pull request #309 from Firminator/patch-1
Corrected --nousb
2021-01-30 09:14:50 +00:00
Firminator
69c9d7d6c5 Corrected --nousb
emphasized that no[gui,blank,wait,signals,usb] will ignore things
2021-01-29 21:13:37 -05:00
PartialVolume
fffee8bb34 Update README.md
Updated link to buildnwipe script
2021-01-08 23:35:07 +00:00
PartialVolume
b8a536a02f Merge pull request #303 from NoNameForMee/master
Correct one external link in README.md
2021-01-08 23:13:33 +00:00
NoNameForMee
0c542660ff Correct one external link in README.md
To official website of SystemRescue (also known as SystemRescueCd).
2021-01-08 20:35:45 +01:00
PartialVolume
412917ab17 Update README.md
Add link to repology with reference to nwipe. Information on which version of Nwipe is in which distro version.
2021-01-07 21:01:14 +00:00
Nathan Owens
f5501ccc45 bits/sigthread.h is a glibc only and is not needed 2020-12-21 12:23:53 -06:00
PartialVolume
d819330583 bump minor banner revision 2020-12-19 18:32:39 +00:00
PartialVolume
2061346ace Merge pull request #300 from andreasheil/update-man-and-help
Update man and help
2020-12-19 18:30:51 +00:00
Andreas Heil
69fed30dde fix typo and reformat 2020-12-18 10:14:06 +01:00
Andreas Heil
7cc1a68a89 updated manpage 2020-12-18 10:13:35 +01:00
PartialVolume
ab6c4c0014 Update version.c for 0.30 release 2020-12-09 17:28:14 +00:00
PartialVolume
22f596c228 Update nwipe.1 for 0.30 release 2020-12-09 17:27:03 +00:00
PartialVolume
be0de995f8 Update configure.ac for 0.30 release 2020-12-09 17:10:43 +00:00
PartialVolume
24a3eb5734 Update CHANGELOG.md for 0.30 release 2020-12-09 17:07:48 +00:00
PartialVolume
5f14819e65 Update CHANGELOG.md
Added nwipe version & OS info to log [#297](https://github.com/martijnvanbrummelen/nwipe/pull/297)
2020-12-05 01:00:48 +00:00
PartialVolume
e06db0702b Bump minor version from .010 to .011 2020-12-05 00:56:12 +00:00
PartialVolume
1e02b754ff Merge pull request #297 from PartialVolume/add_nwipe_version_and_OS_info_to_log
This commit adds nwipes banner version number and OS info derived from /proc/version to the nwipe log. This information may be useful when a user has an issue and submits a log file.
2020-12-05 00:43:17 +00:00
PartialVolume
4a1690be59 Added /proc/version info to log 2020-12-05 00:32:46 +00:00
PartialVolume
b826ce9fc5 Bump minor version number to .010 i.e 0.29.010 2020-12-03 22:08:40 +00:00
PartialVolume
9ebed56d43 Update CHANGELOG.md
Added ..
[DONE] Right Justify log labels to maintain column alignment [#280](https://github.com/martijnvanbrummelen/nwipe/issues/280)
2020-12-03 22:07:03 +00:00
PartialVolume
c03ec324ba Merge pull request #296 from PartialVolume/Right_justify_log_message_labels
Right justify log labels.
2020-12-03 21:59:52 +00:00
PartialVolume
fb27ab8d55 Right justify log labels.
Right justify log labels in order to maintain column alignment
2020-12-03 21:56:23 +00:00
PartialVolume
c7d486f776 Merge pull request #295 from PartialVolume/master
Use past tense of fix, i.e. Fixed.
2020-12-02 14:52:10 +00:00
PartialVolume
69b125ba4d Use past tense of fix, i.e. Fixed. 2020-12-02 14:48:13 +00:00
PartialVolume
3e15e6ef3c Update CHANGELOG.md with changes since 0.28 2020-12-02 14:30:45 +00:00
PartialVolume
2e7de74202 Bumped proposed Rev to 0.30 CHANGELOG.md
Skip 0.29 due to minor revs being used i.e 0.29.009 etc. When 0.30 is released, changes to the minor number in the master rev will be 0.30.001 etc
2020-12-02 14:16:01 +00:00
PartialVolume
21b5190fc4 Merge pull request #294 from PartialVolume/fix_musl_libc_compatibility
Fixes musl libc compatibility on NixOS issue #275
2020-12-02 13:07:58 +00:00
PartialVolume
d61b9005c3 Fixes musl libc compatibility on NixOS issue #275 2020-12-02 13:03:18 +00:00
PartialVolume
13ecd9d268 Bump minor rev to .009 2020-12-02 11:08:32 +00:00
PartialVolume
e24d7992ef Merge pull request #293 from PartialVolume/Add_sudo_message
Add sudo/su help message
2020-12-02 11:05:39 +00:00
PartialVolume
948813a692 Add sudo/su help message 2020-12-02 10:55:08 +00:00
PartialVolume
4abff9e287 Replace init.sh with autogen.sh 2020-12-01 21:56:15 +00:00
PartialVolume
2102301382 Merge pull request #279 from louib/ci_formatting
Moving formatting to a new GH action.
2020-12-01 21:33:11 +00:00
PartialVolume
9b2f71d4e7 Merge pull request #284 from louib/rename_init_script
Rename init.sh -> autogen.sh
2020-12-01 21:15:56 +00:00
PartialVolume
c54a1296aa bump minor version on banner 2020-12-01 21:02:57 +00:00
PartialVolume
e543f54029 Merge pull request #292 from PartialVolume/Changes_to_the_sync_section_in_help
Added some additional info to sync help
2020-12-01 20:57:01 +00:00
PartialVolume
d4261b8e37 Added some additional info to sync help 2020-12-01 20:48:32 +00:00
PartialVolume
a7982c8579 Merge pull request #285 from andreasheil/master
Fix --sync option
2020-12-01 19:13:09 +00:00
Andreas Heil
9f6e2de116 Added constant for DEFAULT_SYNC_RATE 2020-11-23 12:11:08 +01:00
PartialVolume
337223a126 Merge pull request #288 from PartialVolume/Fix_footer_message_during_wipe
Fix incorrect footer message during wipe
2020-10-03 22:42:52 +01:00
PartialVolume
496e51d84e Fix incorrect footer message during wipe 2020-10-03 22:34:31 +01:00
Andreas Heil
ca6b829687 Fix display_help() to reflect new default for --sync option. 2020-08-23 13:52:15 +02:00
Andreas Heil
2f1e87f09b Fix --sync option not allowing 0 as legal input. 2020-08-23 13:50:30 +02:00
louib
eb1297913a Rename init.sh -> autogen.sh 2020-07-13 19:10:12 -04:00
louib
7c10bc85a3 Remove apt-cache search from formatting job. 2020-07-12 13:11:32 -04:00
louib
d830db3c1c Bumping to clang-format-7 2020-07-12 13:11:32 -04:00
louib
4075b4b50e missing deps. 2020-07-12 13:11:32 -04:00
louib
69d6d9708c Moving formatting to a new GH action. 2020-07-12 13:11:32 -04:00
PartialVolume
cbe1d83801 Update README.md
With link to ShredOS 2020
2020-07-12 02:08:51 +01:00
PartialVolume
0df4678fbc Update README.md - fix broken link 2020-05-29 12:06:25 +01:00
PartialVolume
18e542bad7 Update README.md 2020-04-26 18:50:25 +01:00
PartialVolume
24d294cf6f Merge pull request #273 from PartialVolume/Update_example_gif
Update the example gif
2020-04-26 17:42:20 +00:00
PartialVolume
08c2b54a3f Update the example gif
Update the example gif and add some explanatory text
to README.md
2020-04-26 18:35:54 +01:00
PartialVolume
8d8e2e3191 Merge pull request #272 from PartialVolume/Fix_nwipes_behaviour_if_S_key_repeats
Fix nwipes behaviour with repeated S key
2020-04-24 22:11:02 +00:00
PartialVolume
86f01f0b36 Fix nwipes behaviour with repeated S key
Prior to this patch if S key held down keyboard would
be unresponsive for x seconds.
Where x = number of S keystrokes x 3.

Now keys are delayed for no longer than 3 seconds
while warning message is displayed, long enough for
the user to read the warning message.
2020-04-24 23:03:59 +01:00
PartialVolume
0e92a9ddee Merge pull request #271 from PartialVolume/Fix_memory_leak
Fix memory leak
2020-04-23 21:53:59 +00:00
PartialVolume
33690b9e37 Fix memory leak
Detected by cppcheck
2020-04-23 22:47:50 +01:00
PartialVolume
b29ca4c29e Update README.md 2020-04-20 21:46:25 +01:00
PartialVolume
cf3c6f148b Update README.md no downloads data in api 2020-04-19 23:40:46 +01:00
PartialVolume
65d6ab45b6 Update README.md install of download badges 2020-04-19 23:33:30 +01:00
PartialVolume
d76868617a Update CHANGELOG.md 2020-04-17 23:45:47 +01:00
PartialVolume
bd59f5ac98 Merge pull request #270 from PartialVolume/Fix_fatal_errors_reported_on_ctrl_C
Fix_error_reporting_on_ctrl_C before wipe starts
2020-04-17 23:35:45 +01:00
PartialVolume
af30da3cc2 Fix_error_reporting_on_ctrl_C before wipe starts
If you do a ctrl c to exit nwipe before you have
even started a wipe, it will be reported in the logs
that there are fatal or non fatal errors. This is
incorrect as no wipe has even been started.

This error is only relevant to when using ctrl c
before a wipe has started and not after a wipe has
started.

Basically the variables that hold the errors are
in an indeterminate state before wiping begins and
in the case of a user abort we mistakenly checked
those values and reported. They should only be used
after a thread has completed or failed when their
values are then valid.

Now if you exit nwipe before any wiping started
there are no fatal/non fatal errors reported.
2020-04-17 23:31:00 +01:00
PartialVolume
4cc8a34bbc Merge pull request #267 from PartialVolume/Add_ctrl_a_toggle_for_drive_selection
Add ctrl a to select/deselect wipe for ALL drives.
2020-04-17 15:17:02 +01:00
PartialVolume
b3def7c336 Add ctrl a to select/deselect wipe, all drives.
To select or deselect all drives for wiping you can
now type ctrl a.

Useful for users that are wiping many drives
simultaneously.
2020-04-17 15:13:07 +01:00
PartialVolume
dc012e46b2 Update README.md 2020-04-17 07:07:49 +01:00
PartialVolume
88e2adf6a2 Merge pull request #265 from PartialVolume/No_drives_selected_warning
Warn user if no drives are selected, when attempting to start a wipe
2020-04-16 20:13:08 +01:00
PartialVolume
ddb0ca8c35 Warn user about no drives selected
If a user attempts to start a wipe but hasn't yet
selected any drives for wiping, a warning message
will now appear for a few seconds suggesting
they select a drive.

Prior to this patch, if you tried to start a wipe
without selecting a drive, nwipe would immediately
display a message saying the wipe was complete
and press enter to exit. You had no choice but to
exit and restart nwipe.
2020-04-16 20:06:33 +01:00
PartialVolume
b185818732 Update README.md 2020-04-16 14:19:07 +01:00
PartialVolume
1335455d7e Update README.md 2020-04-16 13:14:01 +01:00
PartialVolume
cf75391b93 Update README.md
Make it clear right at the start of the readme, that the latest version of nwipe is available as a bootable USB flash image
2020-04-16 13:12:16 +01:00
PartialVolume
082a4e53d6 Merge pull request #263 from PartialVolume/Warn_user_if_the_press_lower_case_s
Warn user if they press 's' instead of 'S'
2020-04-15 22:26:32 +01:00
PartialVolume
a4d5164602 Warn user if they press 's' instead of 'S'
I have come across a new user that couldn't start a wipe, until it was
pointed out that to start a wipe you needed to type shift S. While this
is often true, shift S doesn't start a wipe if you have caps lock on. To
be precise you need to type a capital S. Confusing to a new user because
if they have been told to type shift S but their caps lock is on, then
nothing happens. Also how would you know you are supposed to type a
capital S when the key info puts all keys in caps.

The fix for this is to trap the lower case s and then print a message on
the status line that says "Use capital S to start a wipe". This message
could remain on the status line for 3 seconds then revert back to the
standard key info.

The use of capital S is to try to reduce the likelihood of an accidental
wipe you didn't mean to start, however, I've always thought that maybe
we should have a 'are you sure ?' after the user types 'S' .
A non issue once you're familiar with nwipe but probably irritating to
a new user.
2020-04-15 22:01:56 +01:00
PartialVolume
7d93a44f18 Update README.md with revised shredos info 2020-04-14 13:06:18 +01:00
PartialVolume
52df4390f7 Merge pull request #259 from PartialVolume/Fix_minor_error_in_disc_block_size_pertains_to_log_display_only
Fix minor error in reporting block size in log
2020-04-08 22:28:34 +01:00
PartialVolume
92a6a76c51 Fix minor error in reporting block size in log
Fix a minor error in the reporting of the
discs total number of blocks. This only
affects reporting to the log file and
does not affect the programs operation.
2020-04-08 22:24:09 +01:00
PartialVolume
68ef665b2d Merge pull request #258 from PartialVolume/Remove_unnecssary_ATA_that_prefixes_some_model_numbers
Remove redundant ATA prefix from the model number.
2020-04-08 17:10:07 +01:00
PartialVolume
fcd35ea910 Remove redundant ATA prefix from the model number.
We already determine the bus type,
ATA, USB, NVME, VIRT (loop) etc
and display the bus type on the GUI.
libparted prefixes the model number
with ATA which we don't need, especially
as we try to keep the drive display length
to a maximum of 80 characters.
2020-04-08 17:05:06 +01:00
PartialVolume
5aded13bf7 Merge pull request #257 from PartialVolume/Summary_table_FAILED_should_take_precedence_over_UABORTED
Fix summary table message precedence
2020-04-08 11:14:56 +01:00
PartialVolume
5cd00da2a6 Fix summary table message precedence
Previously if a drive failed during
a multiple drive wipe and the user
decided to abort nwipe to say remove
the drive and start over, the user would
use CONTROl-C to abort. This would be
reflected in the summary table as ALL drives
having been aborted including the drive that
failed. It makes more sense for a failed drive
to be marked as failed in the summary table
even though the user aborted the wipe.

This patch fixes that, so that if a drive failed
it reflects that drives status in the summary
even if the user aborts the wipe.
2020-04-08 10:59:09 +01:00
PartialVolume
3ee514c395 Merge pull request #255 from martijnvanbrummelen/Update-README.md-with-latest-ShredOS-details
Update README.md with latest ShredOS details
2020-04-05 18:58:08 +01:00
PartialVolume
fe93c77e22 Update README.md with latest ShredOS details
Recompiled ShredOS with support for Smartmontools, C++ V7.x support. Nwipe in this version of ShredOS, now supports the display of serial numbers for USB bridges that have chipsets that support ATA pass through functionality.
2020-04-05 18:49:35 +01:00
PartialVolume
d3ac79bb0e Update README.md update img link 2020-04-02 23:15:50 +01:00
PartialVolume
2322c690a4 Merge pull request #252 from martijnvanbrummelen/PartialVolume-patch-1
Update README.md Add link to nwipe bootable master
2020-04-02 18:51:49 +01:00
PartialVolume
243d8a5e81 Update README.md Add link to nwipe bootable master 2020-04-02 18:48:17 +01:00
PartialVolume
4596c5f06d Merge pull request #251 from martijnvanbrummelen/PartialVolume-patch-1
Update README.md ShredOS download with nwipe master
2020-04-02 18:39:54 +01:00
PartialVolume
e91721d06b Update README.md ShredOS download with nwipe master
Build of ShredOS and download link with the latest nwipe master.
2020-04-02 18:14:31 +01:00
PartialVolume
2a6d6e10df Update CHANGELOG.md spelling mistake 2020-04-02 04:43:38 +01:00
PartialVolume
73b6b2ef6d Merge pull request #249 from PartialVolume/Fix_--nousb_missing_a_USB_drive
Fix --nousb missing a drive
2020-04-01 21:35:15 +01:00
PartialVolume
0488138c43 Fix --nousb missing a drive
If a USB device generated a particular error
code from smartmontools, the --nousb option
incorrectly did not exclude it from the
enumerated drives.

This has now been corrected.
2020-04-01 21:29:08 +01:00
PartialVolume
57eeab2292 Update CHANGELOG.md Fixed obscure segfault 2020-04-01 20:22:07 +01:00
PartialVolume
c3756e0f53 Merge pull request #248 from PartialVolume/Fix_segfault_when_scrolling_drive_selection_window
Fix obscure segfault when resizing terminal
2020-04-01 20:00:26 +01:00
PartialVolume
d140feb94b Fix obscure segfault when resizing terminal
This was a very obscure segmentation fault I
stumbled across while testing the drive
selection window. I confirmed it exists
in all versions at least going back prior
to 0.24 and maybe a lot earlier.

It was a very tricky bug to track down as you
had to do some very specific things to cause it to
occur. Probably most people would not have seen
it, however for those that did, this was what you
needed to do to trigger it.

1. First you had to be wiping more than one drive.

2. Then you needed to scroll down to the bottom
drive in the list.

3. You then needed to minimise the vertical height
of the terminal so you could no longer see the
selected drive.

4. Then you needed to expand the vertical height
of the terminal. This last step would trigger a
segmentation fault and crash nwipe.

So, the theory. nwipe uses four variables to
allow you to scroll through multiple displayed
drives. These four variables are:

count = the number of enumerated drives.

slots = the number of available horizontal lines
        to display the drives. The number of slots
        varies depending upon vertical resizing
        of the terminal. So slots is calculated
        in real time.

focus = which drive the GUI '>' pointer is pointing to.

offset = A value between 0 and slots that describes
         what drives are displayed in the available
         slots.

offset is then used along with i in a for loop to index
the drive contexts. This is where the segfault
occurred.

The calculation failed to take correct account of a varying
number of slots so in the condition described above the
offset would create an index that was out of bounds.

So first I fixed the miss calculation and second I placed
an if statement that acts as a bounds checker so if
ever this code is changed by someone in the future and
they break the calculation the bounds checker 'if' statement
will log the details of the error and prevent a segfault which
is far easier to debug.
2020-04-01 19:50:04 +01:00
PartialVolume
62beaca8ac Merge pull request #247 from PartialVolume/Add_NVME_to_bus_types_and_make_bus_types_4_digits
Add NVME & VIRT to device types.
2020-03-31 15:20:06 +01:00
PartialVolume
497fcb73b5 Add NVME & VIRT to device types.
Added NVME and VIRT to device type table.

VIRT are virtual devices such as loop devices
created with losetup.

NVME for solid state storage devices.

Due to the longer device names used for NVME, I will
need to do some work on the device name in the selection
window so column alignment is maintained.
2020-03-31 15:14:41 +01:00
PartialVolume
00085b403e Merge pull request #246 from PartialVolume/Add_Green_Red_color_to_SUCCESS_FAILURE_messages
Visually enhance failure messages
2020-03-30 22:19:41 +01:00
PartialVolume
fea6facadc Visually enhance failure messages
When a drive fails display the failure message
with red text on a white background.

This makes it more visually obvious a drive
failure has occurred.
2020-03-30 22:02:54 +01:00
PartialVolume
186bd9e03b Update CHANGELOG.md 2020-03-30 20:42:47 +01:00
PartialVolume
f5db72a983 Merge pull request #244 from PartialVolume/Use_nomenclature_function
Use nwipe's nomenclature function
2020-03-30 16:20:13 +01:00
PartialVolume
030338f1bd Use nwipe's nomenclature function
Benefits include:

1. Standard fixed width output for disk
throughput, combined throughput and disk
capacity. Allows for better column alignment
when wiping multiple drives.

2. Removal of about 40 lines of duplicated code.
2020-03-30 16:01:16 +01:00
PartialVolume
eee523d3d1 Merge pull request #243 from PartialVolume/Make_percentage_fixed_width
Make percentage width fixed.
2020-03-30 14:56:07 +01:00
PartialVolume
c3642e8904 Make percentage width fixed.
For drives that are wiping the percentage
completion is displayed. To retain column
alignment when wiping multiple drives, the
percentage values from 0.01% to 9.99% are
displayed with a leading space, i.e
[ 9.99%, then 10.00% to 99.99% is displayed
as, i.e [10.01%, etc..
2020-03-30 14:49:14 +01:00
PartialVolume
16a3b3c487 Merge pull request #242 from PartialVolume/Combine_writing_syncing_etc_fields_in_GUI
Combine [writing][blanking] fields
2020-03-30 14:26:21 +01:00
PartialVolume
fa9eb6892b Combine [writing][blanking] fields
When wiping a drive a status message is displayed
that show [writing] or [syncing] or [verifying] or
[blanking] etc. Previously there were two bracketed
fields, [syncing] occupied one field and all the others
occupied the other field.

To conserve screen space they all occupy the same
bracketed field.

The bracketed field is also now a fixed length of
9 characters padded with spaces as necessary to maintain
column alignment when wiping multiple drives simultaneously.
2020-03-30 14:22:19 +01:00
PartialVolume
3ed8dfd708 Merge pull request #241 from PartialVolume/Stop_throughput_calculation_once_wipe_has_finished
Fix individual drive throughput running after a wipe has finished
2020-03-30 09:21:31 +01:00
PartialVolume
cbe959455a Fix individual drive throughput running after
a wipe has finished.

This problem was not seen when wiping multiple drives
of the same size as they all ended at the same time.
Also not seen when wiping  a single drive, but if you
wiped multiple drives of different sizes where the
drive wipes ended at different times then you could
see the throughput being calculated as steadily dropping
for a drive that had completed it's wipe.

Also fixed overall throughput. When all wipes had completed
overall throughput showed the throughput of the last drive
that finished. It should show 0 B/s as all wiping had
ceased. In the log table you will see individual drive
throughput and overall throughput which is the sum of
all the drives throughputs.
2020-03-30 09:14:00 +01:00
PartialVolume
8e52c926ab Update README.md, readlink ( coreutils package ) 2020-03-28 22:10:05 +00:00
PartialVolume
22b08d43c8 Update CHANGELOG.md, fix hyperlinks 2020-03-27 21:51:46 +00:00
PartialVolume
98775a4837 Merge pull request #240 from PartialVolume/fix_readlink_missing_message
Fix incorrect readlink error message
2020-03-27 21:43:48 +00:00
PartialVolume
4fe7f4a697 Fix incorrect readlink error message 2020-03-27 21:40:56 +00:00
PartialVolume
ddfa194ed9 Merge pull request #239 from PartialVolume/add_no_usb_option
Add --nousb option.
2020-03-27 21:03:02 +00:00
PartialVolume
b9a9386d2f 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.
2020-03-27 20:57:33 +00:00
PartialVolume
8430befdc3 Update README.md 2020-03-27 00:19:16 +00:00
PartialVolume
dc692735ce Update README.md 2020-03-27 00:16:57 +00:00
PartialVolume
4e4c37dd4a Update CHANGELOG.md 2020-03-26 20:36:18 +00:00
PartialVolume
ac0fe876a1 Merge pull request #237 from PartialVolume/Correct_disk_capacity_nomenclature
Fix incorrect disk capacity nomenclature.
2020-03-26 20:09:51 +00:00
PartialVolume
e46e80277d Fix incorrect disk capacity nomenclature.
I've always wondered, when you first view
all the drives, why drives above 999GB appeared
in their GB nomenclature instead of TB. For
instance a 2TB drive would appear as 2000GB.
Unlike other places in nwipe that does a proper
job of describing capacity just this one location
in the program was wrong.

This information was obtained by a call to a function
in libparted. Maybe when libparted was written there
was no such thing as a TByte drive ?? Who knows, so
anyway it was far easier to use nwipes build in function
called 'determine_C_B_nomenclature()' This provides us
with the correct nomenclature that is a fixed number of
digits (three) and prefixed with spaces so the length
is always the same. In the GUI this gives a nice
list when viewing multiple drives that appears in neat
columns.
2020-03-26 19:41:07 +00:00
PartialVolume
ac9757dfe7 Merge pull request #236 from PartialVolume/Fix_search_for_dmidecode
Fix search method for dmidecode
2020-03-25 23:08:07 +00:00
PartialVolume
7af0dd57c7 Fix search method for dmidecode 2020-03-25 22:58:51 +00:00
PartialVolume
14d5178013 Merge pull request #235 from PartialVolume/smartctl_directory_search-2
Fix the way I look for smartctl & readlink
2020-03-25 22:31:25 +00:00
PartialVolume
2446db741f Fix the way I look for smartctl & readlink 2020-03-25 22:26:43 +00:00
PartialVolume
081051c25f Merge pull request #234 from PartialVolume/smartctl_directory_search-1
fix smartctl directory search
2020-03-25 18:27:22 +00:00
PartialVolume
055b90d4c7 fix smartctl directory search 2020-03-25 18:20:06 +00:00
PartialVolume
9789c4748f Merge pull request #233 from PartialVolume/Check_directories_for_smartmontools_and_readlink
Search extra directories for smartctl & readlink
2020-03-25 17:41:18 +00:00
PartialVolume
a2f70661b8 Search extra directories for smartctl & readlink
This is mainly required for Debian sid if using
su instead of su - to run nwipe.
2020-03-25 17:35:14 +00:00
PartialVolume
bb0019fe40 Merge pull request #232 from PartialVolume/tidy_smartctl_and_readlink_warning_messages
Tidy the smartctl & readlink warning messages
2020-03-25 15:07:41 +00:00
PartialVolume
186ec9172c Tidy the smartctl & readlink warning messages 2020-03-25 15:02:40 +00:00
PartialVolume
415f43c975 Update README.md 2020-03-25 10:11:00 +00:00
PartialVolume
5809d0febd Merge pull request #231 from PartialVolume/Fix_duplicated_serial_no
Fix duplicated serial number
2020-03-24 23:12:29 +00:00
PartialVolume
fdf3140249 Fix duplicated serial number
If any drive doesn't have a serial number it's
serial number field was populated with the previous
drives serial number.

This is fixed by this patch.
2020-03-24 23:07:39 +00:00
PartialVolume
2f7979476b Update README.md readlink smartmontools 2020-03-24 22:41:44 +00:00
PartialVolume
c53a93ec9c Update README.md 2020-03-24 22:39:56 +00:00
PartialVolume
6943e35a33 Merge pull request #230 from PartialVolume/Get_device_bus_type_and_serial_number
Add serial number support for USB devices
2020-03-24 21:07:27 +00:00
PartialVolume
541a002a99 Add serial number support for USB devices
Add serial number support for USB devices for USB
to IDE/SATA adapters. Note this will only work
with USB IDE/SATA adapters that support ATA pass
through. See #149 for further details of
supported devices.

This patch requires readlink and smartmontools (smartctl)
to be installed. If not installed the serial number for
supported USB hardware will be missing.

The device type, i.e USB or ATA is now shown on the selection
and wipe windows.
2020-03-24 21:01:05 +00:00
PartialVolume
c29185999e Update CHANGELOG.md - Fix system info - Debian Sid 2020-03-22 22:53:15 +00:00
PartialVolume
fc406d2346 Merge pull request #229 from PartialVolume/Check_for_dmidecode_in_sbin
Check for dmidecode in /sbin
2020-03-22 22:43:56 +00:00
PartialVolume
0c4493e11c Check for dmidecode in /sbin
In Debian Sid dmidecode is not found as /sbin is not
searched when nwipe only specifies 'dmidecode', so
if it fails then it will next try /sbin/dmidecode
which is where it's normally located if it's installed.

In ubuntu etc, the sudo environment is setup so /sbin
is automatically searched.
2020-03-22 22:34:50 +00:00
PartialVolume
acf296d25d Merge pull request #228 from PartialVolume/Fix_visual_syncing_annoyance
Make the [syncing] a bit easier on the eyes
2020-03-22 16:56:39 +00:00
PartialVolume
2738522bb8 Make the [syncing] a bit easier on the eyes
I don't know if it's just me, but I'm not keen on the
way the status line length changes every few seconds
depending on whether nwipe is syncing or not. So
while still retaining the syncing message I think
it looks better if when not syncing, [syncing] is
replaced with [-------]. This keeps the status line
length pretty much constant and I find it easier on
my eyes.
2020-03-22 16:33:41 +00:00
PartialVolume
34d86e9c19 Merge pull request #227 from PartialVolume/Fix_inaccurate_throughput_calculation
Fix throughput so it shows the average throughput
2020-03-22 10:41:39 +00:00
PartialVolume
8f10179120 Fix throughput so it shows the average throughput
Fix throughput so it shows the average throughput
calculated from the start of the wipe.

Because we currently use cached access to the disks
initially for a few seconds or minute the throughput looks high
as nwipes writes are cached in memory before being written to disc.

When we change to a non cached or nwipe buffered model the
throughput will reflect a throughput that is actual
disc throughput.

Using an averaged throughput means that when the wipe finishes it will show
a higher value than the previous calculation but this new calculation is the
actual averaged speed of the wipe and reflects a value that is closer to what
you would expect a given drive to exhibit.

For instance a 160GB WD1600AAJS using Dod-S, B+VL, using the old
calculation would finish with a throughput of 48MB/s, using the
new calculation it finishes with a throughput of 76MB/s. This was tested
over multiple wipes and multiple rounds and gave consistently similiar
results.

Throughput is not so accurate on small loop drives due to the fact the drive
is so small it fits within CPU memory so when reading back to verify your're
actually reading back from cache not the disk. Another reason I want to move
to non cached I/O and have nwipe manage buffering and size of block writes.
2020-03-22 10:37:03 +00:00
PartialVolume
2b225f5cb9 Merge pull request #225 from PartialVolume/Add_ETA_to_status_when_SIGUSR1_received
Add eta to status when sigusr1 received
2020-03-20 18:57:09 +00:00
PartialVolume
8d31f2cf4a Update CHANGELOG.md 2020-03-20 18:05:51 +00:00
PartialVolume
d59e0323de Add ETA to to status when nwipe is sent a SIGUSR1
If a sudo kill -s USR1 (Nwipe's PID) is issued
on the command line while nwipe is operating in
--nogui mode, ETA is now displayed along with
percentage completion, pass and round information.

Note! Because we rely upon cached I/O at the moment
the calculated ETA early in the wipe is very inaccurate
but becomes more accurate as CPU memory cache is filled.
2020-03-20 17:52:35 +00:00
PartialVolume
7ac7c80731 Update CHANGELOG.md - --nogui drive stats 2020-03-19 22:00:01 +00:00
PartialVolume
a1e6e3bd52 Merge pull request #224 from PartialVolume/fix_summary_duration_during_shutdown_in_middle_of_wipe
Fix incorrect summary duration during shutdown
2020-03-19 21:20:19 +00:00
PartialVolume
62a8e76205 Fix incorrect summary duration during shutdown
If the system is shutdown while nwipe is still
wiping, the duration calculation would be
incorrect. This patch fixes that problem, so for
instance if a UPS signals the system running nwipe to
shutdown, nwipe typically traps that signal and
exits in an orderly manner. The log summary
is generated showing the wipe was aborted and
the wipe duration shows a valid value i.e the
elapsed time since the start of the wipe.
2020-03-19 21:09:02 +00:00
PartialVolume
fbfcbf8d34 Merge pull request #223 from PartialVolume/create_nwipe_log_summary_table
Add a summary table to the log that shows each drives status
2020-03-18 23:57:01 +00:00
PartialVolume
6c99166b75 Add a summary table to the log that shows each drives status
Add a summary table to the log that shows each drives status
i.e. erased or failed, throughput, duration of wipe, model,
serial no etc. In particular it benefits those that wipe many
drives simultaneously in rack servers. At a glance any failed
drives can be seen without having to browse back through the
log. Especially useful in --nogui mode, but also useful in GUI
mode.
2020-03-18 23:42:44 +00:00
PartialVolume
a022fffacb Update README.md 2020-03-14 11:51:11 +00:00
PartialVolume
ec9a322683 Update README.md - changes to automation section 2020-03-14 09:00:29 +00:00
PartialVolume
e6dd32a74b Update README.md 2020-03-14 08:56:01 +00:00
PartialVolume
523351531c Update README.md 2020-03-14 08:54:04 +00:00
PartialVolume
1d83fd6f8f Merge pull request #221 from louib/version_badge
Adding version badge to README.
2020-03-14 07:04:22 +00:00
louib
74243d392d Adding version badge to README. 2020-03-13 21:35:04 -04:00
PartialVolume
06fe803eb1 Merge pull request #220 from PartialVolume/create_spinner
Add a spinner to the GUI for each drive
2020-03-13 23:49:55 +00:00
PartialVolume
298ee05b8c Merge branch 'master' into create_spinner 2020-03-13 23:48:56 +00:00
PartialVolume
4928eb094e Add a spinner to the GUI for each drive
Add a spinner to the GUI for each drive being wiped.
When nwipe is syncing the percentage completion pauses,
having a spinner gives a clear indication that the wipe
is still running. Each devices spinner disappears on completion
of a given devices wipe.
2020-03-13 23:43:32 +00:00
PartialVolume
9caceaa75d Update CHANGELOG.md 2020-03-13 18:06:20 +00:00
PartialVolume
75fce57ab4 Merge pull request #219 from PartialVolume/reduce_unneccesary_lines_in_log_while_retaining_info
Reduce unnecessary lines in log while retaining info
2020-03-13 17:51:32 +00:00
PartialVolume
e955725fc5 Style formatting 2020-03-13 17:48:20 +00:00
PartialVolume
1c1b25e1ae Keep nwipe_log notices succinct
1. Keep nwipe_log notices succinct and below 80 chars in length including
timestamp. This is especially relevant for 80x30 terminal use such
as ALT-F2 etc or Shredos without losing any information.

2. Add [SUCCESS] to blanked & verified messages to make them stand out for quicker checking.
2020-03-13 17:24:08 +00:00
PartialVolume
d4963092dd Update README.md 2020-03-13 08:42:39 +00:00
PartialVolume
1083207d49 Update README.md with automation script
This script will install all the necessary libraries and software to compiling nwipe, download the latest master version of nwipe and run it, all with a single command ./buildnwipe
2020-03-13 01:22:01 +00:00
PartialVolume
458a3d780f Update CHANGELOG.md, adding verbose option to 0.29
Add verbose option -v, --verbose
Only display thread cancellation info messages, excluding error
messages, only when verbose option is selected.

This helps to keep the log a bit cleaner especially when wiping many
drives simultaneously.
2020-03-12 13:03:09 +00:00
PartialVolume
08c9cbe9f1 Merge pull request #217 from PartialVolume/add_verbose_option
Add verbose option
2020-03-12 12:59:13 +00:00
PartialVolume
e9caad3bef Add verbose option
Add verbose option -v, --verbose
Only display thread cancellation info messages, excluding error
messages, only when verbose option is selected.

This helps to keep the log a bit cleaner especially when wiping many
drives simultaneously.
2020-03-12 12:55:10 +00:00
PartialVolume
50e7cfaa7b Merge pull request #216 from PartialVolume/master
Update CHANGELOG.md
2020-03-12 00:45:15 +00:00
PartialVolume
ea39f57afb Update CHANGELOG.md 2020-03-12 00:38:25 +00:00
PartialVolume
880823cc9b Merge pull request #215 from PartialVolume/add_auto_poweroff
Add auto poweroff, fix non working nowait option.
2020-03-12 00:05:20 +00:00
PartialVolume
7d3a3c5f1e format code style 2020-03-12 00:00:06 +00:00
PartialVolume
e33c1bb06d Add --autopoweroff option
Fix non working --nowait option.
Update version info to 0.29-release candidate
2020-03-11 23:44:11 +00:00
PartialVolume
50079a15f9 Merge pull request #211 from PartialVolume/Release_0.28
Release 0.28
2020-03-11 16:48:48 +00:00
PartialVolume
cc82687cf3 Release 0.28 2020-03-11 16:44:13 +00:00
PartialVolume
82a867b569 Merge pull request #210 from martijnvanbrummelen/PartialVolume-fix_individual_throughput
Update CHANGELOG.md
2020-03-11 14:06:21 +00:00
PartialVolume
fee849b35e Update CHANGELOG.md 2020-03-11 14:03:16 +00:00
PartialVolume
09d9fc88fb Merge pull request #209 from PartialVolume/fix_individual_device_throughput
Fix individual device throughput.
2020-03-11 13:58:24 +00:00
PartialVolume
6570197de0 Fix individual device throughput.
On completion of a device wipe, the throughput was continuing
to be calculated for a completed wipe which resulted in the
throughput for that particular device to gradually drop over time
to zero if other drives were still

This has now been corrected. Throughput calculation for a given
device is stopped when the particular device has completed its wipe.
2020-03-11 13:55:44 +00:00
PartialVolume
4eef3e6ab0 Merge pull request #208 from martijnvanbrummelen/PartialVolume-update-CHANGELOG.md
Update CHANGELOG.md
2020-03-11 10:05:27 +00:00
PartialVolume
c4969e36f1 Update CHANGELOG.md
Add hyperlinks to 0.28 changes.
2020-03-11 10:04:01 +00:00
PartialVolume
c75c393e49 Merge pull request #207 from martijnvanbrummelen/PartialVolume-update-CHANGELOG.md
Update CHANGELOG.md
2020-03-10 21:16:33 +00:00
PartialVolume
53e5f4ca3a Update CHANGELOG.md 2020-03-10 21:15:30 +00:00
PartialVolume
72505f00cc Merge pull request #206 from martijnvanbrummelen/PartialVolume-Screen-responsivness-during-wipe
Update CHANGELOG.md
2020-03-10 20:36:22 +00:00
PartialVolume
f4947eb317 Update CHANGELOG.md 2020-03-10 20:34:48 +00:00
PartialVolume
5775498803 Merge pull request #205 from PartialVolume/slow_main_window_refresh_during_wipe_after_terminal_resize
Slow main window refresh during wipe after terminal resize
2020-03-10 20:29:28 +00:00
PartialVolume
85059c73c4 Format code 2020-03-10 20:25:52 +00:00
PartialVolume
cd420a079d Fix 1 second delay on screen update when terminal is resized.
During a wipe there is a approximately 1 second delay between
resizing the window and the screen fully updating. This has been
corrected so screen updates and as a consequence key response is
faster. This makes the GUI interface feel smoother and more responsive.
2020-03-10 20:21:00 +00:00
PartialVolume
e2ec6a560f Merge pull request #204 from PartialVolume/fix_overflow_warning
Fix overflow warning
2020-03-10 15:30:24 +00:00
PartialVolume
87199a1940 Clang formatting. 2020-03-10 15:23:18 +00:00
PartialVolume
88cae05301 Fix overflow warning message.
Use sizeof to determine suitable string size for the dmidecode cmd buffer
2020-03-10 15:18:25 +00:00
Martijn van Brummelen
14d285fb63 Update nwipe.1
Section should be 1 not 4
2020-03-10 10:12:33 +01:00
PartialVolume
69e27abf2b Merge pull request #201 from martijnvanbrummelen/PartialVolume-update-CHANGELOG.md
Update CHANGELOG.md
2020-03-09 14:39:29 +00:00
PartialVolume
32862d6af7 Update CHANGELOG.md 2020-03-09 14:36:18 +00:00
PartialVolume
fb00aa0243 Merge pull request #200 from PartialVolume/fix_flicker
Fix flicker
2020-03-09 14:26:51 +00:00
PartialVolume
e779265b01 Update pre-release title banner -1, update format 2020-03-09 14:20:42 +00:00
PartialVolume
aad29f14c2 This fixes screen flicker seen in the following situations:
These apply in full screen mode ONLY: i.e ALT-F2, Shredos etc.
1. When selecting a drive using up/down arrow keys
2. During a wipe the screen flashes at one second intervals.

These apply in a terminal window such as konsole, tmux etc.
1. When resizing the terminal there was a flicker.

All these problems have been fixed.

Most of the causes of the flicker was an excessive use of wrefresh() which calls
the wnoutrefresh() and doupdate() functions. This can cause flickering when a
number of calls to wrefresh happen at the same time. It is more appropriate to
replace the wrefresh() with wnoutrefresh(), then at an appropriate time call
doupate() just once. The result is that before doupdate() would have been
called multiple times and now it's called once when required.

fixes #115
2020-03-09 14:16:21 +00:00
PartialVolume
fe06f88ae2 Update CHANGELOG.md 2020-03-08 02:25:33 +00:00
PartialVolume
b3adbb3a17 Update CHANGELOG.md 2020-03-08 01:58:26 +00:00
PartialVolume
ce61974eba Merge pull request #199 from PartialVolume/fix_exit_on_terminal_resize_after_wipe_complete
Fix window/panel resizing & display when terminal resized by user
2020-03-08 01:51:07 +00:00
PartialVolume
95ab80cc68 Fix window/panel resizing & display when terminal resized by user
Also fixes an issue where program exits when terminal resized but
only after all the wipes have finished. You can now resize the
terminal, before, during and after the wipes have completed and
the windows are now all correctly updated and sized.

Updated version to 0.28-pre-release

Removed unnecessary zero of gui thread pointer.

Created six new functions in gui.c in order to fix the above problem
and reduce existing duplicated code.
2020-03-08 01:42:47 +00:00
PartialVolume
0077fcbc12 Update CHANGELOG.md 2020-03-07 01:31:18 +00:00
PartialVolume
98f4466d89 Update CHANGELOG.md 2020-03-06 14:41:21 +00:00
PartialVolume
203f6a06f5 Update CHANGELOG.md
Proposed changes in code for release in 0.28 due Summer 2020
2020-03-06 14:14:00 +00:00
PartialVolume
0eeab11af6 Merge pull request #198 from PartialVolume/master
Release 0.27
2020-03-03 20:54:49 +00:00
PartialVolume
97e5591fd5 Release 0.27 2020-03-03 20:38:47 +00:00
PartialVolume
5f1aafed2f Merge pull request #194 from louib/using_git_exit_code
Using git-diff --exit-code for diff details.
2020-02-08 17:22:33 +00:00
louib
6822c463eb Using git-diff --exit-code for diff details. 2020-02-08 12:07:19 -05:00
PartialVolume
6d797b742c Update CHANGELOG.md 2020-01-21 23:29:01 +00:00
PartialVolume
5c60dce0c5 Update CHANGELOG.md 2020-01-21 23:25:33 +00:00
PartialVolume
49b35aef8a Merge pull request #192 from louib/normalize_workflow_names
Normalizing workflow names.
2020-01-13 09:49:05 +00:00
louib
a3a056ce75 Normalizing workflow names. 2020-01-13 01:22:36 -05:00
PartialVolume
ead9a78453 Merge pull request #189 from louib/format_doc
code formatting developer doc.
2020-01-12 21:37:12 +00:00
PartialVolume
bebae43b3b Merge pull request #190 from louib/fix_device_label_printing
Prefixing device fields with `_device`.
2020-01-12 21:36:56 +00:00
louib
49aa14a490 Prefixing device fields with _device.
Also added a `device_label` field to centralize
the creation of the device label. This fixes the
labels for devices without a serial number, and
makes sure we have the same label format everywhere.
2020-01-12 14:24:32 -05:00
louib
3aca56eded code formatting developer doc. 2020-01-12 13:02:36 -05:00
PartialVolume
b26bb839ef Merge pull request #188 from PartialVolume/fix_is5_percentage
Fix percentage calculation for IS5 only
2020-01-12 10:25:32 +00:00
PartialVolume
0a53ec9c42 Fix percentage calculation for IS5 only 2020-01-12 10:20:17 +00:00
PartialVolume
df07393f9d Merge pull request #187 from louib/project_layout
Creating subdirs for third-party modules.
2020-01-11 00:40:17 +00:00
louib
af0fdadc88 Creating subdirs for third-party modules.
Since these modules are considered third-party (at
least for now) and we also don't want to apply
formatting to them.

Also removed the `AUTOMAKE_OPTIONS` from `Makefile.am` since
it would appear the `AM_INIT_AUTOMAKE` is actually defining
the automake options.
2020-01-10 18:08:07 -05:00
PartialVolume
8384142f58 Merge pull request #186 from louib/formatting_pass_9
Formatting gui module.
2020-01-09 23:28:59 +00:00
louib
4071e5f66a Formatting gui module. 2020-01-07 20:05:16 -05:00
PartialVolume
3089a78f72 Merge pull request #185 from louib/formatting_pass_8
Formatting pass 8
2020-01-07 09:25:36 +00:00
louib
6b7186f7ed Formatting logging module. 2020-01-06 20:40:26 -05:00
louib
6ca41a899f Enabling formatting. 2020-01-06 20:25:36 -05:00
PartialVolume
35bcc518b5 Merge pull request #184 from louib/formatting_pass_7
Formatting prng module.
2020-01-06 11:01:07 +00:00
louib
7af9c90e3a Formatting prng module. 2020-01-05 20:45:26 -05:00
PartialVolume
b53a4b58db Merge pull request #183 from louib/formatting_pass_6
Formatting pass module.
2020-01-06 00:53:42 +00:00
louib
851735c1f0 Formatting pass module. 2020-01-05 19:11:24 -05:00
PartialVolume
79dee9cb79 Merge pull request #180 from louib/formatting_pass_5
Formatting device module.
2020-01-05 23:40:51 +00:00
PartialVolume
756db3e0e1 Merge pull request #182 from PartialVolume/fix_zero_fill
Fix zero fill so it works with rounds and is consistent with other methods in terms of pattern creation.
2020-01-05 23:20:33 +00:00
PartialVolume
0037c46860 Check & correct style
clang-format -i -style=file src/method.c
2020-01-05 23:12:41 +00:00
PartialVolume
7d416911d2 Fix zero fill so it works with rounds
Also so that verify and blanking are consistant with other methods.
Fixes percentage calculation for rounds greater than one for the zero fill method.
2020-01-05 23:08:36 +00:00
louib
a5a3f3b9a3 Formatting device module. 2020-01-05 16:29:27 -05:00
PartialVolume
1be4e99a29 Merge pull request #179 from PartialVolume/fix_percentage_calculation_for_rounds_greater_than_one
Fix percentage calculation for rounds greater than one
2020-01-05 21:24:12 +00:00
PartialVolume
d39427ae86 clang-format -i -style=file src/method.c
Check & correct style.
2020-01-05 21:21:05 +00:00
PartialVolume
0b6ce3182d Fix percentage calculation when rounds > 1
Update comment.
2020-01-05 21:10:50 +00:00
PartialVolume
5f01b660bd Merge pull request #177 from louib/formatting_pass_4
Formatting context.h
2020-01-05 19:26:32 +00:00
PartialVolume
10f2678c10 Merge branch 'master' into formatting_pass_4 2020-01-05 19:23:50 +00:00
PartialVolume
3c4a536eeb Merge pull request #171 from louib/formatting_pass_3
formatting method and version module.
2020-01-05 19:17:53 +00:00
louib
bc8cfeb478 formatting method and version module. 2020-01-05 13:10:26 -05:00
PartialVolume
cb4d411b05 Merge pull request #178 from PartialVolume/fix_percentage_for_zero_fill
Fix percentage complete calculation for all methods
2020-01-05 03:33:33 +00:00
PartialVolume
3bcc544610 Fix percentage complete calculation.
Also fixes OPSII method.
Place round_size calculation in the function calculate_round_size()
2020-01-05 03:28:28 +00:00
louib
92c7d99714 Formatting context.h 2020-01-04 12:38:41 -05:00
PartialVolume
c952939dff Merge pull request #175 from PartialVolume/show_percentage_on_completion
Show percentage completed, on completion of wipe.
2019-12-30 18:21:34 +00:00
PartialVolume
e5a0f85d56 Show percentage completed, on completion of wipe.
Rather than delete percentage complete, show it. Because we were hiding
percentage complete we were not aware of inaccuracies in the percentage
calculation that are introduced when you toggle blanking and
verification on various methods.
2019-12-30 18:18:15 +00:00
PartialVolume
f69aff33a4 Merge pull request #169 from louib/formatting_fixes
Small formatting fix.
2019-12-29 21:30:04 +00:00
louib
d19dc05793 Small formatting fix. 2019-12-29 16:19:17 -05:00
PartialVolume
7a87bafc0f Merge pull request #168 from infrastation/master
add HMG IS5 enhanced and make minor fixups
2019-12-29 20:55:57 +00:00
PartialVolume
615c2ee035 Merge branch 'master' into master 2019-12-29 20:47:14 +00:00
PartialVolume
559bc3db56 Merge pull request #167 from louib/formatting_pass_2
Formatting pass 2
2019-12-29 20:17:20 +00:00
Denis Ovsienko
04fe9f217e add an initial implementation of HMG IS5 enhanced
I could not find the original specification of this standard, although
many proprietary implementations exist (or claim to exist). Also there
are many 3rd-party descriptions of the method, which often differ in one
or another detail, but after some reading I could conclude that the most
likely definition should be as follows:

1. Fill the device with zeroes, do not verify.
2. Fill the device with ones, do not verify.
3. Fill the device with a PRNG stream, do verify.

In other words, this is a simplified version of nwipe's "dodshort".
2019-12-28 22:41:32 +00:00
Denis Ovsienko
ead64479f4 remove duplicate "h" from nwipe_options_short[] 2019-12-28 22:09:50 +00:00
Denis Ovsienko
e2c9d030de fixup list formatting for --verify in the man page 2019-12-28 22:09:50 +00:00
Denis Ovsienko
f866d84e3d fixup descriptions of --noblank
Both display_help() and nwipe_options_parse() are consistent about the
--noblank option, in that it exists and has no short form. Make the man
page and nwipe_gui_noblank() indicate that correctly. Mention that "ops2"
never blanks the device regardless of the option.
2019-12-28 22:09:50 +00:00
Denis Ovsienko
97c736e630 fixup a comment in method.c 2019-12-28 22:09:50 +00:00
Denis Ovsienko
c3679f9d3b fixup PRNG names in README.md 2019-12-28 22:09:50 +00:00
louib
e180154320 Update else styling. 2019-12-28 13:21:42 -05:00
louib
ff357298bd Activate CI on pull requests. 2019-12-28 13:18:41 -05:00
louib
cd0d9e028b Activate temp code format checks. 2019-12-28 13:15:02 -05:00
louib
25116c2046 Formatting options module. 2019-12-28 13:11:47 -05:00
PartialVolume
d5fe1c096a Merge pull request #164 from louib/formatting_pass_1
Formatting pass 1
2019-12-28 17:50:15 +00:00
louib
254ef3236e Rename sources variable in makefile. 2019-12-28 12:28:19 -05:00
PartialVolume
719bfa66f6 Merge pull request #166 from louib/update_zero_fill_doc
Updated zero-fill documentation.
2019-12-27 19:57:48 +00:00
louib
a384bd75fd Updated zero-fill documentation. 2019-12-27 13:55:16 -05:00
PartialVolume
ddc4f9eaa2 Merge pull request #165 from louib/rename_quick_erase
Rename Quick Erase for Zero Fill
2019-12-27 18:26:11 +00:00
louib
f212192155 Rename Quick Erase for Zero Fill 2019-12-27 12:21:20 -05:00
louib
494d269936 Formatting nwipe.c and nwipe.h 2019-12-26 14:04:38 -05:00
louib
f1baadb4de Setup code formatting with make. 2019-12-26 14:00:17 -05:00
PartialVolume
8e196eb830 Merge pull request #163 from louib/help_typos
Fixed typos in help message.
2019-12-23 22:56:49 +00:00
louib
d8749ab9da Fixed typos in help message. 2019-12-23 17:35:42 -05:00
PartialVolume
89598f3de9 Merge pull request #159 from PartialVolume/fix_missing_log_messages_when_wipe_selected_then_CNTRL-C_abort
Fix missing log lines
2019-12-15 18:22:14 +00:00
PartialVolume
8bb3f9ff14 Fix missing log lines
Change code so that there is only one place where the log is flushed on
exit from the ncurses gui. Prior to this patch the flush was done twice
which resulted in duplicated lines and missing lines. The
log_current_element variable was being initialised after the first flush.
This caused subsequent writes to nwipe to write log_lines pointers passed
the end of the pointer array causing memory corruption and resulting in the
occassional segfault on attempts to print the log array.
2019-12-15 18:14:27 +00:00
PartialVolume
8d02bfe6f8 Merge pull request #157 from PartialVolume/fix_segfault_and_missing_log_lines
Fix segfault & missing log lines
2019-12-10 23:32:16 +00:00
PartialVolume
a215aa14fa Fix segfault & missing log lines
This patch fixes a segfault that occurs when a logfile is specified.
The segfault occurred on exit of nwipe. It did not affect the wipe
process.

This patch also fixes a related issue, at the end of a wipe some
of the log lines were missing on stdout, this occurred when a log
file was not specified as an option.
2019-12-10 23:29:42 +00:00
PartialVolume
1091a5291f Merge pull request #155 from PartialVolume/fix_implicit_declaration_of_fdatasync
Fixes warning "Implicit declaration of function 'fdatasync' is invalid in C99"
2019-12-08 22:37:53 +00:00
PartialVolume
4666f17930 Fixes Implicit declaration of function 'fdatasync' is invalid in C99 2019-12-08 22:26:09 +00:00
PartialVolume
c7a565dbc8 Merge pull request #153 from martijnvanbrummelen/PartialVolume-patch_add_apt-get_update_to-ci_update-16.04.yml-1
Update ci_update-16.04.yml
2019-12-08 11:57:13 +00:00
PartialVolume
f1f1002207 Update ci_update-16.04.yml
As I did with ci.yml (ubuntu-latest) use apt-get update prior to installing system dependencies else CI will fail with missing dependencies when upstream versions change.
2019-12-08 11:56:11 +00:00
PartialVolume
dd9e97ec52 Merge pull request #152 from PartialVolume/gui_status_function_uses_too_much_CPU
Runtime statistics uses too much CPU
2019-12-08 11:46:39 +00:00
PartialVolume
11a0c2de6b Runtime statistics uses too much CPU
During testing a single drive two cores consistently run at close to 100%,
one core at 100% and the other varying between 80-100%. This shouldn't be
the case. Although there would be two threads running, i.e. the gui status
thread and the disk drives wipe thread I would have expected the amount of
CPU required to calculate the on screen stats to be insignificant as they
are only updated once a second.

To reduce the gui stats thread to near zero% while still maintaining the
stats update at one second I inserted an nanosleep interval of 100ms. This
now means that only the one core now shows at 80-100% while all other cores
are close to zero.
2019-12-08 11:40:14 +00:00
PartialVolume
68c3cfe5ca Delete example_wipe.png
No longer required.
2019-12-05 00:05:50 +00:00
PartialVolume
1717958843 Add animated gif 2019-12-05 00:02:29 +00:00
PartialVolume
01648108a0 Update README.md with animated gif
Example in animated gif format.
2019-12-04 23:59:49 +00:00
PartialVolume
b102bee6fa Update version.c
Make the change in both version strings.
2019-12-04 22:09:12 +00:00
PartialVolume
551836e092 Update version.c with release candidate versioning
To avoid confusion, the master code should have the version number in the title bar. The version number shown in the master should be the version number of the next (unreleased version) followed by the suffix rc1. As an example, the current official released version is 0.26 so in the master title bar the version should be 0.27rc1, i.e. the release candidate for the proposed release 0.27.
2019-12-04 22:07:59 +00:00
PartialVolume
4dc84a727c Update version.c, Simplify the title text 2019-12-04 21:50:48 +00:00
PartialVolume
3c55dda2f4 Update README.md, two methods
run from src folder or installed copy
2019-12-03 23:01:30 +00:00
PartialVolume
52bcea8ee1 Update README.md with info on running 2019-12-03 22:55:50 +00:00
PartialVolume
0e15c16cac Update README.md, multiple disk wipe info 2019-12-03 22:18:10 +00:00
PartialVolume
01bc6b92b7 Less bright border ! 2019-12-03 21:55:22 +00:00
PartialVolume
6858e42fcf Update README.md with usage info.
i.e. command line or GUI.
2019-12-03 21:49:02 +00:00
PartialVolume
70b7497734 Add border to image 2019-12-03 21:41:03 +00:00
PartialVolume
178bc558fa Add an example of nwipe in GUI mode 2019-12-03 21:40:27 +00:00
PartialVolume
c0dc1e9ff7 Add example of how nwipe looks during a wipe 2019-12-03 21:33:42 +00:00
PartialVolume
bc5bfb73a7 Create example_wipe.png 2019-12-03 21:26:47 +00:00
PartialVolume
e37ccd4fdb Update readme.md URLs to Parted Magic and Shredos 2019-12-03 20:50:12 +00:00
PartialVolume
48c01f7cfa Update readme with wipe methods 2019-12-03 20:40:45 +00:00
PartialVolume
5004c15481 Merge pull request #144 from PartialVolume/add_error_checking_code_tidy_up
Add error checking code to pthread_mutex_lock functions
2019-12-01 22:26:07 +00:00
PartialVolume
3110267373 Add error checking code to pthread_mutex_lock functions
Move flush of logs into final cleanup function
Minor alteration to one or two error messages
2019-12-01 22:22:47 +00:00
PartialVolume
82e4d1b2ea Merge pull request #136 from louib/backspace_as_return
Update footers for key commands.
2019-11-30 23:14:55 +00:00
PartialVolume
a16a67d84e Merge pull request #143 from martijnvanbrummelen/PartialVolume-patch-1
Update ci.yml with apt-get update
2019-11-30 19:56:41 +00:00
PartialVolume
881ddcf0cb Update ci.yml 2019-11-30 19:49:40 +00:00
PartialVolume
1360196be2 Merge pull request #142 from martijnvanbrummelen/PartialVolume-patch-2
Update Readme with CI workflow ubuntu.16.04 badge
2019-11-30 17:55:33 +00:00
PartialVolume
91dfc37574 Update Readme with CI workflow ubuntu.16.04 badge 2019-11-30 17:54:49 +00:00
PartialVolume
675dd694a3 Rename ci_ubuntu-16.04 to ci_ubuntu-16.04.yml 2019-11-30 17:50:56 +00:00
PartialVolume
3ab826f11d Merge pull request #141 from martijnvanbrummelen/PartialVolume-patch-1
Create ci_ubuntu-16.04
2019-11-30 17:48:06 +00:00
PartialVolume
2cd8fce66a Create ci_ubuntu-16.04
Add workflow for ubuntu 16.04 test
2019-11-30 17:47:25 +00:00
PartialVolume
649cc09da0 Merge pull request #140 from martijnvanbrummelen/PartialVolume-patch-1
warning: logical 'or' of collectively exhaustive tests is always true
2019-11-30 17:20:25 +00:00
PartialVolume
c064a66115 warning: logical 'or' of collectively exhaustive tests is always true
If using || in the while statement and if 'MAX_DRIVE_PATH_LENGTH' was exceeded the while loop would loop indefinitely.
2019-11-30 17:07:14 +00:00
PartialVolume
000ebe6deb Merge pull request #137 from louib/exit_invalid_option
Exit on invalid long option.
2019-11-24 17:11:13 +00:00
PartialVolume
8a7ca91da6 Update URL with correct workflow name
i.e underscores
2019-11-24 17:00:52 +00:00
PartialVolume
404962e6fc Update README.md
Update URL to badge for new workflow name
2019-11-24 16:57:09 +00:00
PartialVolume
f96f17b0a6 Update ci.yml
Maybe better to use ubuntu-latest so we don't need to update every so often.
2019-11-24 16:51:15 +00:00
louib
d3ddd8d2ac Exit on invalid long option. 2019-11-24 11:14:28 -05:00
louib
974f323857 Update footers for key commands.
Update the footers for the commands available in each
screen. Also added the possibility to cancel from the
rounds screen. It was possible to cancel with backspace
from the other screens (method prng etc) but this was not
displayed in the footers. Added the `Ctrl-C` command
to all the footers since this is a global command.
Added the `Left` command to the rounds screen, since it
was implemented but not documented.
Also made sure the Ctrl-C was placed at the end on every
footer.
2019-11-24 10:52:22 -05:00
PartialVolume
4f6354919b Merge pull request #135 from louib/github-ci
Adding GitHub CI build process.
2019-11-24 08:25:39 +00:00
louib
2a7d07676b Adding CI badge 2019-11-23 21:31:45 -05:00
louib
06aecbb8f8 Adding GitHub CI build process. 2019-11-19 19:00:49 -05:00
PartialVolume
353a577282 Merge pull request #133 from louib/glibc_deprecated_warnings
Suppress warnings from glibc macros.
2019-11-19 12:44:10 +00:00
louib
5bf579d5b2 Suppress warnings from glibc macros. 2019-11-16 18:25:34 -05:00
PartialVolume
607a244bbf Make it clear 0.27 is a pending release 2019-11-14 11:32:56 +00:00
PartialVolume
d770f219b9 Merge pull request #132 from PartialVolume/fix_segfault_on_CNTRL-C_at_end_wipe_take3
Fix segfault on control c at end wipe
2019-11-14 01:27:33 +00:00
PartialVolume
1090ac5d83 Merge branch 'master' into fix_segfault_on_CNTRL-C_at_end_wipe_take3 2019-11-14 01:26:20 +00:00
PartialVolume
4241485e6a Fix segfault on Control-C, after a successful wipe
Symptoms: If you control-C to exit nwipe at the end of a successful
wipe you would get a segmentation fault. If nwipe log data was being
sent to stdout rather than to a log file, then you would not see the
log in the terminal windows after nwipe had exited. This patch fixes
those problems by creating a tri-state wipe flag for each wipe
thread. The main thread after having launched the wipe threads
will wait for ALL wipe flags to report that the wipe routine has
completed and the thread has exited. Only at that time does the
main() routine then proceed with joining the threads and waiting
for the join to confirm the thread has indeed exited. This join
is important as the thread will not actually exit until the OS
has flushed the disk buffers. Currently nwipe does not use O_SYNC
where data is sent straight to disk. Therefore it's important
to wait for data to be flushed before exiting nwipe. Part of this
patch is introducing a "please wait .. disks are being flushed"
prior to exiting nwipe otherwise it might look like nwipe had
hung. A disk flush in terms of how long it takes, can be from
instantly to 30 seconds or more, depending on how much system
memory you have, when the last sync occurred and if you have
changed the sync option from it's default. Something else to
note is that when all wipes have finished nwipe displays "Enter
To Exit" on the status line at the bottom of the screen. I
believe typing 'enter' rather than control-c did not produce a
segmentation fault. Irrespective, both methods of exiting nwipe
have been tested and confirmed to now work correctly. Tested
overnight with two drives using multiple wipe methods,
verification and blanking.
2019-11-14 01:07:08 +00:00
PartialVolume
dd3828008d Add notification of cache flush on CNTRL-C exit 2019-11-14 01:07:08 +00:00
PartialVolume
4f72927146 Merge pull request #130 from louib/verify_option_documentation
Add documentation for verify
2019-11-14 00:03:51 +00:00
louib
a5715eeca4 Add documentation for verify 2019-11-13 18:35:12 -05:00
PartialVolume
214ff8fb7a Merge pull request #128 from Legogizmo/Verify_Method
Added Verify Method
2019-11-13 23:03:51 +00:00
Legogizmo
94a9437166 Fixed the Error count issue 2019-11-13 14:30:20 -06:00
Legogizmo
a216fa2c24 Added Verify Method
and fixed other bugs.
2019-11-13 10:59:44 -06:00
PartialVolume
08d61dc9f1 Merge pull request #124 from PartialVolume/fix_control-C_segfault_after_successful_wipe
Fix segfault on Control-C, after a successful wipe
2019-11-11 12:54:59 +00:00
PartialVolume
f6cf615a12 Fix segfault on Control-C, after a successful wipe
Symptoms: If you control-C to exit nwipe at the end of a successful
wipe you would get a segmentation fault. If nwipe log data was being
sent to stdout rather than to a log file, then you would not see the
log in the terminal windows after nwipe had exited. This patch fixes
those problems by creating a tri-state wipe flag for each wipe
thread. The main thread after having launched the wipe threads
will wait for ALL wipe flags to report that the wipe routine has
completed and the thread has exited. Only at that time does the
main() routine then proceed with joining the threads and waiting
for the join to confirm the thread has indeed exited. This join
is important as the thread will not actually exit until the OS
has flushed the disk buffers. Currently nwipe does not use O_SYNC
where data is sent straight to disk. Therefore it's important
to wait for data to be flushed before exiting nwipe. Part of this
patch is introducing a "please wait .. disks are being flushed"
prior to exiting nwipe otherwise it might look like nwipe had
hung. A disk flush in terms of how long it takes, can be from
instantly to 30 seconds or more, depending on how much system
memory you have, when the last sync occurred and if you have
changed the sync option from it's default. Something else to
note is that when all wipes have finished nwipe displays "Enter
To Exit" on the status line at the bottom of the screen. I
believe typing 'enter' rather than control-c did not produce a
segmentation fault. Irrespective, both methods of exiting nwipe
have been tested and confirmed to now work correctly. Tested
overnight with two drives using multiple wipe methods,
verification and blanking.
2019-11-11 12:34:28 +00:00
PartialVolume
df36255e06 Merge pull request #123 from PartialVolume/add_notification_of_cache_flush
Add notification of cache flush on CNTRL-C exit
2019-11-10 11:55:12 +00:00
PartialVolume
602cdcaa58 Add notification of cache flush on CNTRL-C exit 2019-11-10 11:42:26 +00:00
PartialVolume
95b30f6286 Merge pull request #122 from PartialVolume/update_README.md_with_dmidecode
Add dmidecode as an optional package to README.md
2019-11-09 21:10:14 +00:00
PartialVolume
b4d82ec19b Add dmidecode as an optional package to README.md 2019-11-09 21:06:08 +00:00
PartialVolume
d968225417 Merge pull request #121 from louib/cleanup_top_level_doc
Cleanup top-level documentation
2019-11-09 20:23:28 +00:00
louib
46f8cc352d Cleanup top-level documentation
Moved most of the documentation from `README` to
`README.md`, and added MarkDown formatting when
required. Also move the release notes to a
`CHANGELOG.md`, and made sure the formatting
was consistent.
2019-11-09 10:39:22 -05:00
PartialVolume
42e58bbd22 Merge pull request #120 from louib/clang_format_dont_sort_includes
Do not sort includes on clang-format
2019-11-08 22:35:39 +00:00
louib
10028b6f95 Do not sort includes on clang-format 2019-11-08 17:06:52 -05:00
PartialVolume
7d70fa5dc5 Merge pull request #119 from PartialVolume/fix_header_order
Fix order of include files in options.c
2019-11-08 18:02:03 +00:00
PartialVolume
53b1c6ba62 Fix order of include files in options.c
After running clang on options.c the includes were reordered. This caused the compilation to fail with multiple errors.
2019-11-08 18:00:24 +00:00
PartialVolume
88ce0b7494 Merge pull request #105 from Legogizmo/SyncChanges
Sync changes
2019-11-08 13:21:31 +00:00
PartialVolume
2a056b7bfa Changed sync from 0 (at end) to every 1000000 blks
Instead of defaulting to only calling fdatasync at the end of a wipe, it now defaults to calling fdatasync every 1000000 blocks. This shows a unresponsive drive far quicker and also allows wipe threads to complete and be cancelled within a couple of seconds if a wipe is aborted with control-c.
2019-11-08 13:18:50 +00:00
Legogizmo
f9f0ec605c Merge branch 'master' into SyncChanges 2019-11-07 14:09:07 -06:00
PartialVolume
9331061cbf Merge pull request #112 from louib/clang_format
First clang-format file version.
2019-11-07 19:47:01 +00:00
PartialVolume
2402ca0602 Merge branch 'master' into clang_format 2019-11-07 19:33:32 +00:00
Legogizmo
7db0bd733e Merge branch 'master' into SyncChanges 2019-11-07 11:22:43 -06:00
PartialVolume
128dfb3a4e Merge pull request #116 from PartialVolume/fix_drive_parsing_and_success_status
Fix drive parsing and success status
2019-11-06 20:23:32 +00:00
PartialVolume
5199fb1793 Fix wipe status saying Success when it never even started.
Capitalise success and failure messages in GUI and log to make them stand out
2019-11-06 20:03:39 +00:00
PartialVolume
f6c1cab28a Have nwipe continue with following devices even if one fails 2019-11-06 14:13:33 +00:00
PartialVolume
4b9ae33171 Merge pull request #114 from PartialVolume/limit_help_line_length_to_80_characters
Limit help text line length to 80 characters
2019-11-05 23:32:01 +00:00
PartialVolume
d04ae940b6 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.
2019-11-05 22:56:58 +00:00
PartialVolume
74c05fe290 Merge pull request #113 from PartialVolume/fix_dmidecode_error_reporting
Fix error reporting when accessing dmidecode.
2019-11-04 22:48:02 +00:00
PartialVolume
766d8020c6 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.
2019-11-04 22:39:20 +00:00
louib
76f097c272 First clang-format file version. 2019-11-03 11:38:41 -05:00
PartialVolume
5e2d55ba7f Merge pull request #110 from louib/ac_deprecated_init
Fix AutoConf deprecated warning
2019-11-03 01:10:19 +00:00
louib
7c025040b4 Fix AutoConf deprecated warning
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.
2019-11-02 19:24:25 -04:00
PartialVolume
661785294c Merge pull request #109 from louib/documentation
Fix typos in README and comments.
2019-11-02 22:51:07 +00:00
louib
7b1a5b98a7 Fix typos in README and comments. 2019-11-02 18:33:36 -04:00
Legogizmo
e1475d70ff Update context.h 2019-10-21 11:21:15 -05:00
Legogizmo
a75c29f973 Changed how often fdatasyncs occur.
Changed what the sync option does.
Stopped nwipe from changing the disk blocksize.
Added periodic fdatasyncs within the write loops in pass.c
2019-10-21 11:16:19 -05:00
Martijn van Brummelen
721c8de743 Merge pull request #100 from PartialVolume/add_exclude_drive_to_man_page
Add details of exclude drive option to man page
2019-09-13 09:29:00 +02:00
PartialVolume
4acad452ae Add details of exclude drive option to man page 2019-09-10 22:38:56 +01:00
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
77 changed files with 24097 additions and 4667 deletions

79
.clang-format Normal file
View File

@@ -0,0 +1,79 @@
---
Language: Cpp
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterFunction: true
AfterControlStatement: true
AfterEnum: false
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: true
IndentBraces: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ContinuationIndentWidth: 4
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

2
.codespellrc Normal file
View File

@@ -0,0 +1,2 @@
[codespell]
skip = ./.git

21
.github/workflows/ci_formatting.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: ci_formatting
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: updating available system dependencies
run: sudo apt-get update
- name: installing system dependencies
run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev libconfig-dev libconfig++-dev dmidecode clang-format
- name: creating autoconf files
run: ./autogen.sh
- name: configuring
run: ./configure CFLAGS='-O0 -g -Wall -Wextra'
- name: verifying code style
run: make check-format

21
.github/workflows/ci_ubuntu_latest.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: ci_ubuntu_latest
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: updating available system dependencies
run: sudo apt-get update
- name: installing system dependencies
run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev libconfig-dev libconfig++-dev dmidecode
- name: creating autoconf files
run: ./autogen.sh
- name: configuring
run: ./configure CFLAGS='-O0 -g -Wall -Wextra'
- name: compiling
run: make

22
.gitignore vendored Normal file
View File

@@ -0,0 +1,22 @@
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/**/.dirstamp
*.o
src/Makefile
src/Makefile.in
src/nwipe
stamp-h1

290
CHANGELOG.md Normal file
View File

@@ -0,0 +1,290 @@
RELEASE NOTES
=============
v0.36
-----------------------
- Added the abbreviation MMC for mmcblk devices such as SD and microSD cards and some low budget laptops. #526
- Fixed some serial numbers that were displaying garbage. #527
- Fixed auto power off and nowait when the screen has been blanked by the user. #529
- Fixed nwipe not auto exiting on completion when in non gui mode. #531
- Fixed smart page titles so they have a consistent format with page 1 in the PDF report. #532
- Fixed some of the config help messages that displayed incorrect information. #533
- Inserted a space between temperature and model. #534
- Fixed incorrect footer on return to organisation/customer preview screen. #535
- Made footer completion message more informative. #538
- Fixed hidden sector detection for devices with logical/physical size of 4096/4096. #543 #546
- Fixed some strcpy compiler warnings. #548
v0.35
-----------------------
- Nwipe will now optionally create a multi-page PDF certificate that shows details of a specific discs erasure. The first page forms the certificate of erasure and subsequent pages show the drives smart data. Two related options have been added to nwipe's command line options -P, --PDFreportpath=PATH Path to write PDF reports to. Default is "." If set to "noPDF" no PDF reports are written. From the drive selection screen you can now press 'c' for config. This takes you to the configuration screen where you can select various PDF certificate related options such as enabling PDF, entering customer or company data for entry onto the certificate and enabling a preview of customer/company info prior to the drive selection screen starting.
- Nwipe now supports HPA/DCO detection, aka hidden sector detection. This is where the drive has been configured to report a smaller size to the operating system (O.S.) than it actually is. The HPA/DCO status is reported on the main drive selection screen as [HS? N/A] for drive that does not support HPA/DCO such as NvMe. [HS? YES] for a drive that is reporting a size smaller than it actually is, i.e has hidden sectors and [HS? NO] where the drive is reporting it's actual size correctly to the O.S. And finally [HS? ???] where nwipe cannot determine the HPA/DCO status as the drive is not responding to the ATA commands used to detect HPA/DCO. This might be because the drive does not support HPA/DCO or the interface adapter does not support ATA passthrough as is the case with a lot of the USB adapters on the market, but not all USB adapters. Nwipe does not currently allow removal of the HPA/DCO so you will still need to use hdparm to reset the drive so it reports its correct size before using nwipe to wipe the drive. HPA/DCO reset may be added in the next version. Thanks to @mdcato for the help testing the code and HPA/DCO results as displayed in the report.
- This bug only applies to ones wipe and one or zero's verification. A very rare occurrence of a incorrect percentage on completion. The actual wipe was completed correctly it was just that the percentage calculation was wrong. #459
- Nwipe now supports a configuration file /etc/nwipe/nwipe.conf. Currently it supports settings related to the PDF certificate but more options will be added in the future.
- If you are running nwipe within the KDE konsole terminal and you resize the window by pulling on the corners, occasionally nwipe will exit with the error message: "GUI.c,nwipe_gui_select(), loop runaway, did you close the terminal without exiting nwipe? Initiating shutdown now" The loop runaway detection has been made less sensitive, i.e 32 iterations per second of the GUI update can now be completed before a loop runaway is detected. previously it was 8. In practise when sizing the konsole window, anywhere between 1 and 17 iterations will occur.#467
- Nwipe now provides better temperature support for SAS drives. Thanks to @ggruber for all the code and testing he contributed.
- Disc sizes are now shown differently to provide more information about their size. For instance a 1.2TB drive was shown as 1TB, now it is shown as 1200GB. Thanks to @ggruber for his code contribution.
- Interface/bustype type was reported as UNK fo SAS drives, now reported correctly as SAS. Thanks to @ggruber for his code contribution.
- Interface/bustype type has been enhanced to show SAS-SSD when a SSD drive is present. Thanks to @ggruber for his code contribution.
- Nwipe's temperature retrieval code has been placed in it's own thread. This was done because it was found that any delays in obtaining the temperature resulted in a momentary freeze in the GUI wipe screen updating it's stats. This wasn't noticable if you were erasing a small number of drives but become apparent when wiping ten or twenty drives simultaneously.
v0.34
-----------------------
- Fix a compiler warning -Wformat-zero-length string
v0.33
-----------------------
- Fixes a slight screen corruption on 80 column display. When highlighting the verify ones option the first two digits of DoD 5220.20-M disappear. This patch fixes that issue.@PartialVolume #348
- For some controllers/drivers the readlink method of obtaining the bus type for GUI display does not work. If we haven't already resolved the bus type, we then also check smartctl for the transport protocol for SAS. @PartialVolume #350
- Check smartctl for unresolved bus types SATA @PartialVolume #358
- Changed message from (No ATA pass-thru) to (S/N: unknown) as the reason the serial number is unknown is because there is no ATA pass through for the chipset being used by the USB to SATA adapter, basically we are making the message more meaningful for the end user rather than for the engineer/programmer that may understand the previous terminology used. @PartialVolume @Firminator #356
- Add drive temperature monitoring and display temperature in degrees Celsius in the GUI. Requires the kernel drivetemp module and makes use of the hwmon sub system in the kernel to extract drive temperatures. Nwipe will automatically load the drivetemp module if it's available. @PartialVolume #360 #361 #364
- Remove /dev/ from gui for long device names. This fixes column alignment issues in the gui with nvme drives i.e. nvme0n1 etc. If the drive name including path exceeds 8 characters the /dev/ is removed and prefixed with spaces to a total max length of 8 characters. @PartialVolume #365
- Add -q --quiet option - anonymize serial numbers and SMBIOS-DMI data. This anonymizes serial numbers and related identifiable information for drives and hardware but does not remove model information in both the GUI and the log displayed by stdout at the end of a wipe and also in the log file if enabled in options. This feature is useful for uploading logs when submitting bug reports. @PartialVolume #366 #367 #371 #379 #383
- Fixes a intermittent FAILED message that is displayed in the summary table when the message should have been UABORTED. The incorrect FAILED message only occurred when using control-C to abort a wipe. @PartialVolume #373
- When many verification or pass errors are detected the status line can wrap on a 80 column display. This patch makes the error message more succinct which will free up about 10 characters & prevents the line wrapping. @PartialVolume #374
- Fixes a problem that occurs with a unresponsive drive that causes the ETA to grow to an enormous value. We now do not calculate an individual drives ETA when the throughput of the drive is zero so avoiding the overall ETA being incorrect for drives that are working correctly when multiple drives are being simultaneously wiped. While a individual drives ETA is calculated it is not displayed but only used to determine the overall ETA when all drives have completed. @PartialVolume #375
- Add temperature monitoring and display with NVMe drives. @PartialVolume #377 #380 #381
- When one of the two verify only methods are selected change the drive selected text from WIPE to VRFY to indicate the drive is not being wiped, but is only being verified. @PartialVolume #378
- Fixes a incorrect sector, block and device sizes in 32 bit builds only as displayed in the nwipe log. This problem had no affect on the wipe as the issue was caused by a incorrect format specifier that affected the log text only. @PartialVolume #387 #388
- Fixes a issue where temperatures may not have been available on Debian systems due to the location of modprobe. Particularly relevant to Debian which when logged in as root doesn't put /sbin in the $PATH environment setting. This issue was not necessarily relevant for Linux distros based on Debian, for instance, Ubuntu where nwipe would have found the modprobe command. @PartialVolume #390 #391
- Improve wipe thread cancellation error checking. @PartialVolume #392
- Improve GUI thread messaging if a pthread_join fails. @PartialVolume #393
- Fixed a missing serial number on SAS drive.@PartialVolume #394
- Added ISAAC-64 for 64 bit systems. Thanks @chkboom #398 #401
- Fixes a problem with the Gutmann wipe where the random passes at the beginning and end were being re-arranged when only the inner passes should be rearranged. Thanks @chkboom #399
- Fixes a obscure incorrect summary table status, while the log text correctly reports the failure. If the drive becomes non responsive during the wipe, the MB/s throughput will slowly drop towards 0MB/s and will display a FAILURE -1 error. The logs will correctly display errors and nwipe's return status will be non zero, however the summary table may display erased rather than FAILURE, this is because
the wipe thread exited prematurely without setting the pass error. This fixes the error by checking the context's result status, i.e non zero on failure and if pass equals zero it makes pass equal to one. This is then picked up by the summary table log code which then marks the status
correctly as FAILURE in the summary table. @PartialVolume #400
- Fixes a spurious message on abort before wipe.This patch fixes a minor display issue that occurs when a user aborts a wipe before a wipe has started. It only occurs if the user had selected one or more drives for wipe and then aborted before starting the wipe. The spurious message only occurs in a virtual terminal, i.e. /dev/tty1, /dev/tty2, /dev/console It does not occur in terminal applications such as konsole, xterm, terminator etc. The spurious message that appears in the main window, states that "/dev/sdxyz 100% complete" along with garbage values in the statistics window. The message appears for a fraction of a second before being replaced with the textual log information that correctly states that the user aborted and no wipe was started. Basically the gui status information update function tries to update the data when the wipe hasn't even started. The fix is to only update the statistics information only if a wipe has started by checking the 'global_wipe_status' value which indicates whether any wipe started. '1' indicates that a wipe has started, else '0' if no wipe has started. @PartialVolume #406
- Fixes temperature update in drive selection window. This fixes a problem where the drive temperature is not updated
automatically in only the drive selection window. The temperature is however updated correctly every 60 seconds during a wipe in the wipe status window. This bug would probably never be noticed by most people as usually the drive temperature changes slowly and only rises once a wipe has started. The only time I imagine it would have been noticed would have been if the drive temperature was already high and you were trying to reduce the temperature by cooling before starting a wipe. This has now been corrected so that the temperature in the drive
selection window is updated every 60 seconds. @PartialVolume #407
- Fixes a zombie nwipe process running at 100% CPU on one core but only on a Konsole based terminal. This only occurred when the Konsole terminal is exited while nwipe is sitting at the drive selection screen but nwipe did not exit when the konsole terminal was closed. If nwipe is exited normally on completion of a wipe or aborted by using control C then this problem would not be seen. Also occurs during a wipe if the konsole terminal is closed without exiting nwipe first, again only on Konsole based terminals. @PartialVolume #408 #409
- Fixes a obscure segfault when --logfile option used with a non writable directory. @PartialVolume #410
v0.32
-----------------------
- Add ones (0xFF) wipe to the methods. Renamed Zero Fill to Fill with Zeros and the new ones wipe, is called Fill with Ones.
- Add ones verication to the methods. Renamed Verify Blank to Verify Zeros (0x00) and the new verification is called Verify Ones (0xFF).
- Move method information from below the list of methods to the right of the method list. This allows better use of the screen space by allowing more methods to be added to the list, especially relevant to nwipe running as a standalone application on small distros such as shredos 2020 in frame buffer mode.
- Removed the old DBAN syslinux.cfg configuration hints as not relevant to nwipe. See nwipe --help or man nwipe for command line options.
- Add fdatasync errors to the error summary table.
- During a wipe, you can now toggle between dark screen, blank screen and default blue screen by repeatedly pressing the b key. Dark screen, which is grey text on black background has been introduced to prevent TFT/LCD image persistence on monitors that are sensitive to that issue.
v0.31
-----------------------
- Blanking disabled in GUI for OPS2 (mandatory requirement of standard). [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
- Total bytes written/read for ALL passes or verifications are now logged. [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
- Final blanking being enabled is no longer required for verification passes. GUI Fix. [#326](https://github.com/martijnvanbrummelen/nwipe/pull/326)
- Add a summary table to the log that shows totals for pass & verification errors. [#325](https://github.com/martijnvanbrummelen/nwipe/pull/325)
- Fix the missing 'Verifying' message on final blanking. [#324](https://github.com/martijnvanbrummelen/nwipe/pull/324)
- Fix prng selection always using mersenne irrespective of whatever prng the user selected. [#323](https://github.com/martijnvanbrummelen/nwipe/pull/323)
- Fix a non functional Isaac prng. (May have never worked even in DBAN/dwipe 2.3.0). [#322](https://github.com/martijnvanbrummelen/nwipe/pull/322)
- Log whether the prng produces a stream, if not log failure message. [#321](https://github.com/martijnvanbrummelen/nwipe/pull/321)
- Log the specific prng that is initialised. [#320](https://github.com/martijnvanbrummelen/nwipe/pull/320)
- Log selection details to the log. [#319](https://github.com/martijnvanbrummelen/nwipe/pull/319)
- Improve log messaging. [#317](https://github.com/martijnvanbrummelen/nwipe/pull/317)
- Fix auto shutdown option for some distros. [#315](https://github.com/martijnvanbrummelen/nwipe/pull/315)
- Fix build for musl. [#301](https://github.com/martijnvanbrummelen/nwipe/pull/301)
- Fixes to summary table & fix final status message. [311](https://github.com/martijnvanbrummelen/nwipe/pull/311/commits/12063ad9549860cd625cb91d047bd304217a9ebf)
- Updates to --help options [#309](https://github.com/martijnvanbrummelen/nwipe/pull/309/commits/69c9d7d6c5a091c58b3e747078d0022ccdd95a99)
- Updates to manpage. [#300](https://github.com/martijnvanbrummelen/nwipe/commit/7cc1a68a89236c4b501dde9149be82c208defccd)
v0.30
-----------------------
- Add auto power off option on completion of wipe ( --autopoweroff ) (Thanks PartialVolume)
- Fixed --nowait option that wasn't working. (Thanks PartialVolume)
- Add verbose option. -v, --verbose.
- Add a spinner to the GUI for each drive being wiped. When nwipe is syncing the percentage completion pauses, having a spinner gives a clear indication that the wipe is still running. Each devices spinner disappears on completion of a given devices wipe. (Thanks PartialVolume)
- Make log messages, especially the ones with the tag 'notice' succinct and less than 80 characters including the timestamp. This is of more importance when nwipe is used on a 80x30 terminal (ALT-F2, Shredos etc) but generally makes the logs more readable. While doing this all information was still retained. (Thanks PartialVolume)
- Add a summary table to the log that shows each drives status, i.e. erased or failed, throughput, duration of wipe, model, serial no etc. In particular it benefits those that wipe many drives simultaneously in rack servers. At a glance any failed drives can be seen without having to browse back through the log. (Thanks PartialVolume)
- Add ETA to --nogui wipes status when SIGUSR1 (kill -s USR1 (nwipes PID) is issued on the command line.
- Fixed misleading throughput calculation. Throughput now shows average throughput calculated from start of wipe.
- Fixed system info not being displayed in Debian Sid. [#229](https://github.com/martijnvanbrummelen/nwipe/issues/229) (Thanks PartialVolume)
- 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](https://github.com/martijnvanbrummelen/nwipe/issues/149) for further details (Thanks PartialVolume)
- Fixed disk capacity nomenclature, width and padding on drive selection screen. See [#237](https://github.com/martijnvanbrummelen/nwipe/issues/237) (Thanks PartialVolume)
- Add bus type, ATA or USB, amongst others to drive selection and wipe windows. (Thanks PartialVolume)
- 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.
- Miscellaneous GUI fixes, throughput display format, percentage display format to improve column alignment when wiping multiple discs. (Thanks PartialVolume)
- Improve visibility of failure messages with red text on white background. (Thanks PartialVolume)
- Add NVME and VIRT (loop etc) devices to device type table for display in GUI and logs. NVME devices now show up as NVME devices rather than UNK (Thanks PartialVolume)
- Fixed very obscure segmentation fault going back to at least 0.24 in drive selection window when resizing terminal vertical axis while drive focus symbol '>' is pointing to the last drive of a multi drive selection window. See [#248](https://github.com/martijnvanbrummelen/nwipe/pull/248) for further details (Thanks PartialVolume)
- Warn the user if they are incorrectly typing a lower case s to start a wipe, when they should be typing a capital S [#262](https://github.com/martijnvanbrummelen/nwipe/issues/262) (Thanks PartialVolume)
- Warn the user if they are typing capital S in order to start a wipe but haven't yet selected any drives for wiping [#261](https://github.com/martijnvanbrummelen/nwipe/issues/261) (Thanks PartialVolume)
- Add ctrl A that toggles drive selection, all drives selected for wipe or all drives deselected. [#266](https://github.com/martijnvanbrummelen/nwipe/issues/266)
- Fixed compilation issue with NixOS with broken musl libc error due to missing header [#275](https://github.com/martijnvanbrummelen/nwipe/issues/275)
- Fixed status bar message showing incorrect information [#287](https://github.com/martijnvanbrummelen/nwipe/issues/287)
- Right Justify log labels to maintain column alignment [#280](https://github.com/martijnvanbrummelen/nwipe/issues/280)
- Added nwipe version & OS info to log [#297](https://github.com/martijnvanbrummelen/nwipe/pull/297)
v0.28
-----------------------
- Fixed premature exit when terminal resized on completion of wipes (Thanks PartialVolume)
- Fixed GUI when terminal is resized, currently not handled correctly causing missing or incorrectly sized ncurses windows/panels (Thanks PartialVolume)
- Fixed GUI screen flicker under various situations. [#200](https://github.com/martijnvanbrummelen/nwipe/pull/200) Fixes [#115](https://github.com/martijnvanbrummelen/nwipe/issues/115) (Thanks PartialVolume)
- Fixed responsivness of screen during wipe when resized. Info is updated every 10th/sec. Key presses are more responsive. (Thanks PartialVolume)
- Fixed compiler warning regarding buffer overflow. Fixes [#202](https://github.com/martijnvanbrummelen/nwipe/issues/202) (Thanks PartialVolume)
- Fixed Man page (Thanks martijnvanbrummelen)
- Fixed individual device throughput. On completion of a wipe instead of the throughput calculation stopping for a completed wipe, it would continue to calculate resulting in a particular drives throughtput slowly dropping until eventually it reached zero. The overall throughput was not affected. (Thanks PartialVolume)
v0.27
-----------------------
- Add `verify` method to verify a disk is zero filled [#128](https://github.com/martijnvanbrummelen/nwipe/pull/128) (Thanks Legogizmo)
- Add new HMG IS5 enhanced wipe method [#168](https://github.com/martijnvanbrummelen/nwipe/pull/168) (Thanks infrastation)
- Fixed percentage progress and show on completion of wipe (Thanks PartialVolume)
- Implement clang-format support (Thanks louib)
- Implement more frequent disk sync support (Thanks Legogizmo)
- Format command line help to 80 character line length [#114](https://github.com/martijnvanbrummelen/nwipe/pull/114) (Thanks PartialVolume)
- Fixed nwipe message log and missing messages that was causing segfaults under certain conditions (Thanks PartialVolume)
- Add the Github build CI service and update Readme with build status labels (Thanks louib)
- Miscellaneous smaller fixes
v0.26
-----
- Add exclude drive option (Thanks PartialVolume)
- Log hardware (Thanks PartialVolume)
v0.25
-----
- Correct J=Up K=Down in footer (Thanks PartialVolume)
- Fixed segfault initialize `nwipe_gui_thread` (Thanks PartialVolume)
- Fixed memory leaks (Thanks PartialVolume)
- Check right pointer (Thanks PartialVolume)
- Fixed casting problem (Thanks PartialVolume)
- Fixed serial number
- Fixed 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
-----
- Fixed ETA not updating properly and bad total throughput display. (Thanks Niels Bassler).
v0.20
-----
- Fixed build when panel header is not in `/usr/include` (Thanks Vincent Untz).
v0.19
-----
- Fixed 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).
- Fixed problem with unusable device (Closes debian bug #755473).
v0.16
-----
- Fixed problems building with clang compiler (Thanks Martijn van Brummelen)
v0.15
-----
- Add more detailed information to status page when wiping
- Add ability to send SIGUSR1 to print wiping current status to log
- Fixed problem with status bar disappearing on narrow windows (Github issue #1)
v0.14
-----
- Added explicit check for ncurses (required for Fedora). See bug 3604008.
v0.13
-----
- Added nowait option (patch 3601259 - thanks David Shaw).
- Added nogui option.
- Updated man page and help command for above options and autonuke.
- Added pkg-config check for ncurses (patch 3603140 - thanks Alon Bar-Lev).
v0.12
-----
- Added ability to specify device on command line (patch 3587144).
- Fixed segfault for -p option (patch 3587132).
v0.11
-----
- Fixed bug 3568750. Not closing devices after initial scan.
v0.10
-----
- Fixed bug 3553851. Not exiting on terminal kill. Fixed for all areas of
program including wiping.
v0.09
-----
- Added feature #3545971. Display device name.
- Added feature #3496858. Option to not perform a final blanking pass.
v0.08
-----
- Fixed bug #3501746 whereby "wipe finished" was displayed too early
v0.07
-----
- Added threading synchronisation for logging
- Fixed bug #3486927 (incorrect Sourceforge URL)
v0.06
-----
- Added man page (thanks Michal Ambroz <rebus@seznam.cz>)
- Updated GPL licence and FSF address (thanks Michal Ambroz <rebus@seznam.cz>)
v0.05
-----
- Added sequence number to disk selection
- Added check for ncurses header files in subdir
- Fixed screen corruption bug introduced in 0.04
- Fixed occasional seg fault on start
- Introduced dynamic array allocation for devices, with no hard limit
- Minor updates to configure.ac
v0.04
-----
- Removed references to DBAN in options.c
- Added log file name option (-l|--logfile)
- If no log file specified all messages go to STDOUT
- Incorrect success message after an interruption fixed
- Improved labelling of disks with no partition table
- Added help command
- Added version command
- Added command 'b' to blank screen during wipe
- Compilation needs to include panel library
KNOWN BUG - display sometimes becomes corrupted after starting wipe
v0.03
-----
- Added quit option label (ctrl-c)
- Removed further references to DWIPE
- Added GPL V2 licence file (COPYING)
v0.02
-----
- Fixed segfault that happened during multiple disk wipes

View File

@@ -1,2 +1,9 @@
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src man
# The set of files to be formatted.
FORMATSOURCES = src/*.c src/*.h
format:
clang-format -i -style=file $(FORMATSOURCES)
check-format:
clang-format -i -style=file $(FORMATSOURCES) && git diff --exit-code

131
README
View File

@@ -1,131 +0,0 @@
Installation
============
First bootstrap the source tree:
./init.sh
The install using the standard:
./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/martijnvanbrummelen/nwipe
Martijn van Brummelen
RELEASE NOTES
=============
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
- Add ability to send SIGUSR1 to print wiping current status to log
- Fixed problem with status bar disappearing on narrow windows (Github issue #1)
v0.14
=====
- Added explicit check for ncurses (required for Fedora). See bug 3604008.
v0.13
=====
- Added nowait option (patch 3601259 - thanks David Shaw).
- Added nogui option.
- Updated man page and help command for above options and autonuke.
- Added pkg-config check for ncurses (patch 3603140 - thanks Alon Bar-Lev).
v0.12
=====
- Added ability to specify device on command line (patch 3587144).
- Fixed segfault for -p option (patch 3587132).
v0.11
=====
- Fixed bug 3568750. Not closing devices after initial scan.
v0.10
=====
- Fixed bug 3553851. Not exiting on terminal kill. Fixed for all areas of
program including wiping.
v0.09
=====
- Added feature #3545971. Display device name.
- Added feature #3496858. Option to not perform a final blanking pass.
v0.08
=====
- Fixed bug #3501746 whereby "wipe finished" was displayed too early
v0.07
=====
- Added threading synchronisation for logging
- Fixed bug #3486927 (incorrect Sourceforge URL)
v0.06
=====
- Added man page (thanks Michal Ambroz <rebus@seznam.cz>)
- Updated GPL licence and FSF address (thanks Michal Ambroz <rebus@seznam.cz>)
v0.05
=====
- Added sequence number to disk selection
- Added check for ncurses header files in subdir
- Fixed screen corruption bug introduced in 0.04
- Fixed occasional seg fault on start
- Introduced dynamic array allocation for devices, with no hard limit
- Minor updates to configure.ac
v0.04
=====
- Removed references to DBAN in options.c
- Added log file name option (-l|--logfile)
- If no log file specified all messages go to STDOUT
- Incorrect success message after an interruption fixed
- Improved labelling of disks with no partition table
- Added help command
- Added version command
- Added command 'b' to blank screen during wipe
- Compilation needs to include panel library
KNOWN BUG - display sometimes becomes corrupted after starting wipe
v0.03
=====
- Added quit option label (ctrl-c)
- Removed further references to DWIPE
- Added GPL V2 licence file (COPYING)
v0.02
=====
- Fixed segfault that happened during multiple disk wipes

232
README.md
View File

@@ -1,15 +1,225 @@
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 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.
# nwipe
![GitHub CI badge](https://github.com/martijnvanbrummelen/nwipe/workflows/ci_ubuntu_latest/badge.svg)
[![GitHub release](https://img.shields.io/github/release/martijnvanbrummelen/nwipe)](https://github.com/martijnvanbrummelen/nwipe/releases/)
To use from the git repository, first create all the autoconf files with
./init.sh
nwipe is a fork of the dwipe command originally used by Darik's Boot and Nuke (DBAN). 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.
Then do the standard ./configure --prefix=/usr && make && make install
nwipe is a program that will securely erase the entire contents of disks. It can wipe a single drive or multiple disks simultaneously. It can operate as both a command line tool without a GUI or with a ncurses GUI as shown in the example below:
For release notes please see the [README file](README)
> **Warning**
> For some of nwipes features such as smart data in the PDF certificate, HPA/DCO detection and other uses, nwipe utilises smartmontools and hdparm. Therefore both hdparm & smartmontools are a mandatory requirement if you want all of nwipes features to be fully available. If you do not install smartmontools and hdparm, nwipe will provide a warning in the log that these programs cannot be found but will still run but many important features may not work as they should do.
![Example wipe](/images/example_wipe.gif)
<i>The video above shows six drives being simultaneously erased. It skips to the completion of all six wipes and shows five drives that were successfully erased and one drive that failed due to an I/O error. The drive that failed would then normally be physically destroyed. The five drives that were successfully wiped with zero errors or failures can then be redeployed.</i>
![nwipe_certificate_0 35_5s](https://github.com/martijnvanbrummelen/nwipe/assets/22084881/cf181a9c-af2d-4bca-a6ed-15a4726cb12b)
<i>The snapshot above shows nwipe's three page PDF certificate, drive identifiable information such as serial numbers have been anonymised using the nwipe command line option -q</i>
## Erasure methods
The user can select from a variety of recognised secure erase methods which include:
* Fill With Zeros - Fills the device with zeros (0x00), one round only.
* Fill With Ones - Fills the device with ones (0xFF), one round only.
* RCMP TSSIT OPS-II - Royal Candian Mounted Police Technical Security Standard, OPS-II
* DoD Short - The American Department of Defense 5220.22-M short 3 pass wipe (passes 1, 2 & 7).
* DoD 5220.22M - The American Department of Defense 5220.22-M full 7 pass wipe.
* Gutmann Wipe - Peter Gutmann's method (Secure Deletion of Data from Magnetic and Solid-State Memory).
* PRNG Stream - Fills the device with a stream from the PRNG.
* Verify Zeros - This method only reads the device and checks that it is filled with zeros (0x00).
* Verify Ones - This method only reads the device and checks that it is filled with ones (0xFF).
* HMG IS5 enhanced - Secure Sanitisation of Protectively Marked Information or Sensitive Information
nwipe also includes the following pseudo random number generators:
* Mersenne Twister
* ISAAC
These can be used to overwrite a drive with a stream of randomly generated characters.
nwipe can be found in many [Linux distro repositories](#which-linux-distro-uses-the-latest-nwipe).
nwipe is also included in [ShredOS](https://github.com/PartialVolume/shredos.x86_64) which was developed in particular to showcase nwipe as a fast-to-boot standalone method similar to DBAN. ShredOS always contains the latest nwipe version.
## Compiling & Installing
For a development setup, see the [Hacking section](#hacking) below. For a bootable version of the very latest nwipe master that you can write to an USB flash drive or CD/DVD, see the [Quick and easy bootable version of nwipe master section](#quick--easy-usb-bootable-version-of-nwipe-master-for-x86_64-systems) below.
`nwipe` requires the following libraries to be installed:
* ncurses
* pthreads
* parted
* libconfig
`nwipe` also requires the following program to be installed, it will abort with a warning if not found:
* hdparm (as of current master and v0.35+)
and optionally, but recommended, the following programs:
* dmidecode
* readlink
* smartmontools
### Debian & Ubuntu prerequisites
If you are compiling `nwipe` from source, the following libraries will need to be installed first:
```bash
sudo apt install \
build-essential \
pkg-config \
automake \
libncurses5-dev \
autotools-dev \
libparted-dev \
libconfig-dev \
libconfig++-dev \
dmidecode \
coreutils \
smartmontools \
hdparm
```
### Fedora prerequisites
```bash
sudo bash
dnf update
dnf groupinstall "Development Tools"
dnf groupinstall "C Development Tools and Libraries"
yum install ncurses-devel
yum install parted-devel
yum install libconfig-devel
yum install libconfig++-devel
yum install dmidecode
yum install coreutils
yum install smartmontools
yum install hdparm
```
Note. The following programs are optionally installed although recommended. 1. dmidecode 2. readlink 3. smartmontools.
#### hdparm [REQUIRED]
hdparm provides some of the information regarding disk size in sectors as related to the host protected area (HPA) and device configuration overlay (DCO). We do however have our own function that directly access the DCO to obtain the 'real max sectors' so reliance on hdparm may be removed at a future date.
#### dmidecode [RECOMMENDED]
dmidecode provides SMBIOS/DMI host data to stdout or the log file. If you don't install it you won't see the SMBIOS/DMI host data at the beginning of nwipes log.
#### coreutils (provides readlink) [RECOMMENDED]
readlink determines the bus type, i.e. ATA, USB etc. Without it the --nousb option won't work and bus type information will be missing from nwipes selection and wipe windows. The coreutils package is often automatically installed as default in most if not all distros.
#### smartmontools [REQUIRED]
smartmontools obtains serial number information for supported USB to IDE/SATA adapters. Without it, drives plugged into USB ports will not show serial number information.
If you want a quick and easy way to keep your copy of nwipe running the latest master release of nwipe see the [automating the download and compilation](#automating-the-download-and-compilation-process-for-debian-based-distros) section.
### Compilation
First create all the autoconf files:
```
./autogen.sh
```
Then compile & install using the following standard commands:
```
./configure
make format (only required if submitting pull requests)
make
make install
```
Then run nwipe !
```
cd src
sudo ./nwipe
```
or
```
sudo nwipe
```
### Hacking
If you wish to submit pull requests to this code we would prefer you enable all warnings when compiling.
This can be done using the following compile commands:
```
./configure --prefix=/usr CFLAGS='-O0 -g -Wall -Wextra'
make format (necessary if submitting pull requests)
make
make install
```
The `-O0 -g` flags disable optimisations. This is required if you're debugging with `gdb` in an IDE such as Kdevelop. With these optimisations enabled 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` and `-Wextra` flags enable all compiler warnings. Please submit code with zero warnings.
Also make sure that your changes are consistent with the coding style defined in the `.clang-format` file, using:
```
make format
```
You will need `clang-format` installed to use the `format` command.
Once done with your coding then the released/patch/fixed code can be compiled, with all the normal optimisations, using:
```
./configure --prefix=/usr && make && make install
```
## Automating the download and compilation process for Debian based distros.
Here's a script that will do just that! It will create a directory in your home folder called 'nwipe_master'. It installs all the libraries required to compile the software (build-essential) and all the libraries that nwipe requires (libparted etc). It downloads the latest master copy of nwipe from github. It then compiles the software and then runs the latest nwipe. It doesn't write over the version of nwipe that's installed in the repository (If you had nwipe already installed). To run the latest master version of nwipe manually you would run it like this `sudo ~/nwipe_master/nwipe/src/nwipe`
You can run the script multiple times; the first time it's run it will install all the libraries; subsequent times it will just say the libraries are up to date. As it always downloads a fresh copy of the nwipe master from Github, you can always stay up to date. Just run it to get the latest version of nwipe. It only takes 11 seconds to compile on my i7.
If you already have nwipe installed from the repository, you need to take care which version you are running. If you typed `nwipe` from any directory it will always run the original repository copy of nwipe. To run the latest nwipe you have to explicitly tell it where the new copy is, e.g in the directory `~/nwipe_master/nwipe/src`. That's why you would run it by typing `sudo ~/nwipe_master/nwipe/src/nwipe` alternatively you could cd to the directory and run it like this:
```
cd ~/nwipe_master/nwipe/src
./nwipe
```
Note the ./, that means only look in the current directory for nwipe. if you forgot to type ./ the computer would run the older repository version of nwipe.
Once you have copied the script below into a file called buildnwipe, you need to give the file execute permissions `chmod +x buildnwipe` before you can run it.
```
#!/bin/bash
cd "$HOME"
nwipe_directory="nwipe_master"
mkdir $nwipe_directory
cd $nwipe_directory
sudo apt install build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev libconfig-dev libconfig++-dev dmidecode readlink smartmontools git
rm -rf nwipe
git clone https://github.com/martijnvanbrummelen/nwipe.git
cd "nwipe"
./autogen.sh
./configure
make
cd "src"
sudo ./nwipe
```
## Quick & Easy, USB bootable version of nwipe master for x86_64 systems.
If you want to just try out a bootable version of nwipe you can download [ShredOS](https://github.com/PartialVolume/shredos.x86_64). The ShredOS image is around 60MB and can be written to an USB flash drive in seconds, allowing you to boot straight into the latest version of nwipe. ShredOS is available for x86_64 (64-bit) and i686 (32-bit) CPU architectures and will boot both legacy BIOS and UEFI devices. It comes as .IMG (bootable USB flash drive image) or .ISO (for CD-R/DVD-R). Instructions and download can be found [here](https://github.com/PartialVolume/shredos.x86_64#obtaining-and-writing-shredos-to-a-usb-flash-drive-the-easy-way-).
## Which Linux distro uses the latest nwipe?
See [Repology](https://repology.org/project/nwipe/versions)
And in addition checkout the following distros that all include nwipe:
- [ShredOS](https://github.com/PartialVolume/shredos.x86_64) Always has the latest nwipe release.
- [netboot.xyz](https://github.com/netbootxyz/netboot.xyz) Can network-boot ShredOS.
- [partedmagic](https://partedmagic.com)
- [SystemRescueCD](https://www.system-rescue.org)
- [gparted live](https://sourceforge.net/projects/gparted/files/gparted-live-testing/1.2.0-2/)
- [grml](https://grml.org/)
Know of other distros that include nwipe? Then please let us know or issue a PR on this README.md. Thanks.
## Bugs
Bugs can be reported on GitHub:
https://github.com/martijnvanbrummelen/nwipe
## License
GNU General Public License v2.0

View File

View File

@@ -1,10 +1,11 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.64])
AC_INIT(nwipe, 0.18, git@brumit.nl)
AM_INIT_AUTOMAKE(nwipe, 0.18)
AC_OUTPUT(Makefile src/Makefile man/Makefile)
AC_PREREQ([2.63])
AC_INIT([nwipe],[0.36],[git@brumit.nl])
AM_INIT_AUTOMAKE(foreign subdir-objects)
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
AC_OUTPUT
AC_CONFIG_SRCDIR([src/nwipe.c])
AC_CONFIG_HEADERS([config.h])
@@ -49,13 +50,30 @@ PKG_CHECK_MODULES(
)]
)
PKG_CHECK_MODULES(
[LIBCONFIG],
[libconfig],
[
CFLAGS="${CFLAGS} ${LIBCONFIG_CFLAGS}"
LIBS="${LIBS} ${LIBCONFIG_LIBS}"
],
[AC_CHECK_LIB([libconfig], [main], [
LIBS="-llibconfig $LIBS"
AC_CHECK_HEADERS(libconfig.h,, [
AC_CHECK_HEADERS(libconfig.h, [
AC_DEFINE([LIBCONFIG_IN_SUBDIR], [libconfig/], [Look for libconfig headers in subdir])
], [AC_MSG_ERROR([libconfig headers not found])])
])
], [AC_MSG_ERROR([libconfig 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])
PKG_CHECK_MODULES([PARTED], [libparted], [libconfig])
AC_CHECK_LIB([pthread], [main], ,[AC_MSG_ERROR([pthread development library not found])])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h inttypes.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/ioctl.h unistd.h])
AC_CHECK_HEADERS([libconfig.h fcntl.h inttypes.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/ioctl.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T

BIN
images/example_wipe.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 MiB

View File

@@ -1,4 +1,4 @@
.TH NWIPE "1" "October 2014" "nwipe version 0.17" "User Commands"
.TH NWIPE "20" "February 2024" "nwipe version 0.36" "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
@@ -34,8 +34,26 @@ If no devices have been specified on the command line, starts wiping all
devices immediately. If devices have been specified, starts wiping only
those specified devices immediately.
.TP
\fB\-\-sync\fR
Open devices in sync mode
\fB\-\-autopoweroff\fR
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
Will perform a syn after NUM writes (default: 100000)
.IP
0 \- fdatasync after the disk is completely written
fdatasync errors not detected until completion.
0 is not recommended as disk errors may cause nwipe
to appear to hang
.IP
1 \- fdatasync after every write
Warning: Lower values will reduce wipe speeds.
.IP
1000 \- fdatasync after 1000 writes
.TP
\fB\-\-noblank\fR
Do not perform the final blanking pass after the wipe (default is to blank,
except when the method is RCMP TSSIT OPS\-II).
.TP
\fB\-\-nowait\fR
Do not wait for a key before exiting (default is to wait).
@@ -43,16 +61,29 @@ 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.
SIGUSR1 can be used to retrieve the current wiping statistics.
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Log more messages, useful for debugging.
.TP
\fB\-\-verify\fR=\fITYPE\fR
Whether to perform verification of erasure (default: last)
.IP
off \- Do not verify
.IP
last \- Verify after the last pass
.IP
all \- Verify every pass
.IP
Please mind that HMG IS5 enhanced always verifies the last (PRNG) pass
regardless of this option.
.TP
\fB\-m\fR, \fB\-\-method\fR=\fIMETHOD\fR
The wiping method (default: dodshort).
@@ -67,26 +98,47 @@ ops2 \- RCMP TSSIT OPS\-II
.IP
random / prng / stream \- PRNG Stream
.IP
zero / quick \- Overwrite with zeros
zero / quick \- Overwrite with zeros 0x00
.IP
one \- Overwrite with ones 0xFF
.IP
verify_zero \- Verifies disk is zero filled
.IP
verify_one \- Verifies disk is 0xFF filled
.IP
is5enh \- HMG IS5 enhanced
.TP
\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)
PRNG option (mersenne|twister|isaac|isaac64)
.TP
\fB\-q\fR, \fB\-\-quiet\fR
Anonymize serial numbers, Gui & logs display:
XXXXXXXX = S/N obtained & anonymized.
???????? = S/N not available.
.TP
\fB\-r\fR, \fB\-\-rounds\fR=\fINUM\fR
Number of times to wipe the device using the selected method (default: 1)
.TP
\fB\-e\fR, \fB\-\-exclude\fR=\fIDEVICES\fR
Up to ten comma separated devices to be excluded, examples:
--exclude=/dev/sdc
--exclude=/dev/sdc,/dev/sdd
.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),
.BR dd (1),
.BR dcfldd (1),
.BR dc3dd (1)

View File

@@ -6,6 +6,5 @@ AM_LDFLAGS =
# this lists the binaries to produce, the (non-PHONY, binary) targets in
# 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)
nwipe_SOURCES = context.h logging.h options.h prng.h version.h temperature.h nwipe.c gui.c method.h pass.c device.c gui.h isaac_rand/isaac_standard.h isaac_rand/isaac_rand.h isaac_rand/isaac_rand.c isaac_rand/isaac64.h isaac_rand/isaac64.c mt19937ar-cok/mt19937ar-cok.c nwipe.h mt19937ar-cok/mt19937ar-cok.h pass.h device.h logging.c method.c options.c prng.c version.c temperature.c PDFGen/pdfgen.h PDFGen/pdfgen.c create_pdf.c create_pdf.h embedded_images/shred_db.jpg.c embedded_images/shred_db.jpg.h embedded_images/tick_erased.jpg.c embedded_images/tick_erased.jpg.h embedded_images/redcross.c embedded_images/redcross.h hpa_dco.h hpa_dco.c miscellaneous.h miscellaneous.c embedded_images/nwipe_exclamation.jpg.h embedded_images/nwipe_exclamation.jpg.c conf.h conf.c customers.h customers.c hddtemp_scsi/hddtemp.h hddtemp_scsi/scsi.h hddtemp_scsi/scsicmds.h hddtemp_scsi/get_scsi_temp.c hddtemp_scsi/scsi.c hddtemp_scsi/scsicmds.c
nwipe_LDADD = $(PARTED_LIBS) $(LIBCONFIG)

4057
src/PDFGen/pdfgen.c Normal file

File diff suppressed because it is too large Load Diff

773
src/PDFGen/pdfgen.h Normal file
View File

@@ -0,0 +1,773 @@
/**
* Simple engine for creating PDF files.
* It supports text, shapes, images etc...
* Capable of handling millions of objects without too much performance
* penalty.
* Public domain license - no warrenty implied; use at your own risk.
* @file pdfgen.h
*/
#ifndef PDFGEN_H
#define PDFGEN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
/**
* @defgroup subsystem Simple PDF Generation
* Allows for quick generation of simple PDF documents.
* This is useful for producing easily printed output from C code, where
* advanced formatting is not required
*
* Note: All coordinates/sizes are in points (1/72 of an inch).
* All coordinates are based on 0,0 being the bottom left of the page.
* All colours are specified as a packed 32-bit value - see @ref PDF_RGB.
* Text strings are interpreted as UTF-8 encoded, but only a small subset of
* characters beyond 7-bit ascii are supported (see @ref pdf_add_text for
* details).
*
* @par PDF library example:
* @code
#include "pdfgen.h"
...
struct pdf_info info = {
.creator = "My software",
.producer = "My software",
.title = "My document",
.author = "My name",
.subject = "My subject",
.date = "Today"
};
struct pdf_doc *pdf = pdf_create(PDF_A4_WIDTH, PDF_A4_HEIGHT, &info);
pdf_set_font(pdf, "Times-Roman");
pdf_append_page(pdf);
pdf_add_text(pdf, NULL, "This is text", 12, 50, 20, PDF_BLACK);
pdf_add_line(pdf, NULL, 50, 24, 150, 24);
pdf_save(pdf, "output.pdf");
pdf_destroy(pdf);
* @endcode
*/
struct pdf_doc;
struct pdf_object;
/**
* pdf_info describes the metadata to be inserted into the
* header of the output PDF
*/
struct pdf_info {
char creator[64]; //!< Software used to create the PDF
char producer[64]; //!< Software used to create the PDF
char title[64]; //!< The title of the PDF (typically displayed in the
//!< window bar when viewing)
char author[64]; //!< Who created the PDF
char subject[64]; //!< What is the PDF about
char date[64]; //!< The date the PDF was created
};
/**
* Enum that declares the different image file formats we currently support.
* Each value has a corresponding header struct used within
* the format_specific_img_info union.
*/
enum {
IMAGE_PNG,
IMAGE_JPG,
IMAGE_PPM,
IMAGE_BMP,
IMAGE_UNKNOWN
};
/**
* Since we're casting random areas of memory to these, make sure
* they're packed properly to match the image format requirements
*/
#pragma pack(push, 1)
/**
* Information about color type of PNG format
* As defined by https://www.w3.org/TR/2003/REC-PNG-20031110/#6Colour-values
*/
enum /* png colortype */ {
// Greyscale
PNG_COLOR_GREYSCALE = 0,
// Truecolour
PNG_COLOR_RGB = 2,
// Indexed-colour
PNG_COLOR_INDEXED = 3,
// Greyscale with alpha
PNG_COLOR_GREYSCALE_A = 4,
// Truecolour with alpha
PNG_COLOR_RGBA = 6,
PNG_COLOR_INVALID = 255
};
/**
* png_header describes the header information extracted from .PNG files
*/
struct png_header {
uint32_t width; //!< Width in pixels
uint32_t height; //!< Height in pixels
uint8_t bitDepth; //!< Bit Depth
uint8_t colorType; //!< Color type - see PNG_COLOR_xx
uint8_t deflate; //!< Deflate setting
uint8_t filtering; //!< Filtering
uint8_t interlace; //!< Interlacing
};
/**
* bmp_header describes the header information extracted from .BMP files
*/
struct bmp_header {
uint32_t bfSize; //!< size of BMP in bytes
uint16_t bfReserved1; //!< ignore!
uint16_t bfReserved2; //!< ignore!
uint32_t bfOffBits; //!< Offset to BMP data
uint32_t biSize; //!< Size of this header (40)
int32_t biWidth; //!< Width in pixels
int32_t biHeight; //!< Height in pixels
uint16_t biPlanes; //!< Number of colour planes - must be 1
uint16_t biBitCount; //!< Bits Per Pixel
uint32_t biCompression; //!< Compression Method
};
#pragma pack(pop)
/**
* jpeg_header describes the header information extracted from .JPG files
*/
struct jpeg_header {
int ncolours; //!< Number of colours
};
/**
* PPM color spaces
*/
enum {
PPM_BINARY_COLOR_RGB, //!< binary ppm with RGB colors (magic number P5)
PPM_BINARY_COLOR_GRAY, //!< binary ppm with grayscale colors (magic number
//!< P6)
};
/**
* ppm_header describes the header information extracted from .PPM files
*/
struct ppm_header {
size_t size; //!< Indicate the size of the image data
size_t data_begin_pos; //!< position in the data where the image starts
int color_space; //!< PPM color space
};
/**
* pdf_img_info describes the metadata for an arbitrary image
*/
struct pdf_img_info {
int image_format; //!< Indicates the image format (IMAGE_PNG, ...)
uint32_t width; //!< Width in pixels
uint32_t height; //!< Height in pixels
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Doxygen doesn't like anonymous unions
//!< Image specific details
union {
struct bmp_header bmp; //!< BMP header info
struct jpeg_header jpeg; //!< JPEG header info
struct png_header png; //!< PNG header info
struct ppm_header ppm; //!< PPM header info
};
#endif
};
/**
* pdf_path_operation holds information about a path
* drawing operation.
* See PDF reference for detailed usage.
*/
struct pdf_path_operation {
char op; /*!< Operation command. Possible operators are: m = move to, l =
line to, c = cubic bezier curve with two control points, v =
cubic bezier curve with one control point fixed at first
point, y = cubic bezier curve with one control point fixed
at second point, h = close path */
float x1; /*!< X offset of the first point. Used with: m, l, c, v, y */
float y1; /*!< Y offset of the first point. Used with: m, l, c, v, y */
float x2; /*!< X offset of the second point. Used with: c, v, y */
float y2; /*!< Y offset of the second point. Used with: c, v, y */
float x3; /*!< X offset of the third point. Used with: c */
float y3; /*!< Y offset of the third point. Used with: c */
};
/**
* Convert a value in inches into a number of points.
* @param inch inches value to convert to points
*/
#define PDF_INCH_TO_POINT(inch) ((float)((inch)*72.0f))
/**
* Convert a value in milli-meters into a number of points.
* @param mm millimeter value to convert to points
*/
#define PDF_MM_TO_POINT(mm) ((float)((mm)*72.0f / 25.4f))
/*! Point width of a standard US-Letter page */
#define PDF_LETTER_WIDTH PDF_INCH_TO_POINT(8.5f)
/*! Point height of a standard US-Letter page */
#define PDF_LETTER_HEIGHT PDF_INCH_TO_POINT(11.0f)
/*! Point width of a standard A4 page */
#define PDF_A4_WIDTH PDF_MM_TO_POINT(210.0f)
/*! Point height of a standard A4 page */
#define PDF_A4_HEIGHT PDF_MM_TO_POINT(297.0f)
/*! Point width of a standard A3 page */
#define PDF_A3_WIDTH PDF_MM_TO_POINT(297.0f)
/*! Point height of a standard A3 page */
#define PDF_A3_HEIGHT PDF_MM_TO_POINT(420.0f)
/**
* Convert three 8-bit RGB values into a single packed 32-bit
* colour. These 32-bit colours are used by various functions
* in PDFGen
*/
#define PDF_RGB(r, g, b) \
(uint32_t)((((r)&0xff) << 16) | (((g)&0xff) << 8) | (((b)&0xff)))
/**
* Convert four 8-bit ARGB values into a single packed 32-bit
* colour. These 32-bit colours are used by various functions
* in PDFGen. Alpha values range from 0 (opaque) to 0xff
* (transparent)
*/
#define PDF_ARGB(a, r, g, b) \
(uint32_t)(((uint32_t)((a)&0xff) << 24) | (((r)&0xff) << 16) | \
(((g)&0xff) << 8) | (((b)&0xff)))
/*! Utility macro to provide bright red */
#define PDF_RED PDF_RGB(0xff, 0, 0)
/*! Utility macro to provide bright green */
#define PDF_GREEN PDF_RGB(0, 0xff, 0)
/*! Utility macro to provide bright blue */
#define PDF_BLUE PDF_RGB(0, 0, 0xff)
/*! Utility macro to provide black */
#define PDF_BLACK PDF_RGB(0, 0, 0)
/*! Utility macro to provide white */
#define PDF_WHITE PDF_RGB(0xff, 0xff, 0xff)
/*!
* Utility macro to provide a transparent colour
* This is used in some places for 'fill' colours, where no fill is required
*/
#define PDF_TRANSPARENT (uint32_t)(0xffu << 24)
/**
* Different alignment options for rendering text
*/
enum {
PDF_ALIGN_LEFT, //!< Align text to the left
PDF_ALIGN_RIGHT, //!< Align text to the right
PDF_ALIGN_CENTER, //!< Align text in the center
PDF_ALIGN_JUSTIFY, //!< Align text in the center, with padding to fill the
//!< available space
PDF_ALIGN_JUSTIFY_ALL, //!< Like PDF_ALIGN_JUSTIFY, except even short
//!< lines will be fully justified
PDF_ALIGN_NO_WRITE, //!< Fake alignment for only checking wrap height with
//!< no writes
};
/**
* Create a new PDF object, with the given page
* width/height
* @param width Width of the page
* @param height Height of the page
* @param info Optional information to be put into the PDF header
* @return PDF document object, or NULL on failure
*/
struct pdf_doc *pdf_create(float width, float height,
const struct pdf_info *info);
/**
* Destroy the pdf object, and all of its associated memory
* @param pdf PDF document to clean up
*/
void pdf_destroy(struct pdf_doc *pdf);
/**
* Retrieve the error message if any operation fails
* @param pdf pdf document to retrieve error message from
* @param errval optional pointer to an integer to be set to the error code
* @return NULL if no error message, string description of error otherwise
*/
const char *pdf_get_err(const struct pdf_doc *pdf, int *errval);
/**
* Acknowledge an outstanding pdf error
* @param pdf pdf document to clear the error message from
*/
void pdf_clear_err(struct pdf_doc *pdf);
/**
* Sets the font to use for text objects. Default value is Times-Roman if
* this function is not called.
* Note: The font selection should be done before text is output,
* and will remain until pdf_set_font is called again.
* @param pdf PDF document to update font on
* @param font New font to use. This must be one of the standard PDF fonts:
* Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
* Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
* Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic,
* Symbol or ZapfDingbats
* @return < 0 on failure, 0 on success
*/
int pdf_set_font(struct pdf_doc *pdf, const char *font);
/**
* Calculate the width of a given string in the current font
* @param pdf PDF document
* @param font_name Name of the font to get the width of.
* This must be one of the standard PDF fonts:
* Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
* Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
* Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic,
* Symbol or ZapfDingbats
* @param text Text to determine width of
* @param size Size of the text, in points
* @param text_width area to store calculated width in
* @return < 0 on failure, 0 on success
*/
int pdf_get_font_text_width(struct pdf_doc *pdf, const char *font_name,
const char *text, float size, float *text_width);
/**
* Retrieves a PDF document height
* @param pdf PDF document to get height of
* @return height of PDF document (in points)
*/
float pdf_height(const struct pdf_doc *pdf);
/**
* Retrieves a PDF document width
* @param pdf PDF document to get width of
* @return width of PDF document (in points)
*/
float pdf_width(const struct pdf_doc *pdf);
/**
* Retrieves page height
* @param page Page object to get height of
* @return height of page (in points)
*/
float pdf_page_height(const struct pdf_object *page);
/**
* Retrieves page width
* @param page Page object to get width of
* @return width of page (in points)
*/
float pdf_page_width(const struct pdf_object *page);
/**
* Add a new page to the given pdf
* @param pdf PDF document to append page to
* @return new page object
*/
struct pdf_object *pdf_append_page(struct pdf_doc *pdf);
/**
* Adjust the width/height of a specific page
* @param pdf PDF document that the page belongs to
* @param page object returned from @ref pdf_append_page
* @param width Width of the page in points
* @param height Height of the page in points
* @return < 0 on failure, 0 on success
*/
int pdf_page_set_size(struct pdf_doc *pdf, struct pdf_object *page,
float width, float height);
/**
* Save the given pdf document to the supplied filename.
* @param pdf PDF document to save
* @param filename Name of the file to store the PDF into (NULL for stdout)
* @return < 0 on failure, >= 0 on success
*/
int pdf_save(struct pdf_doc *pdf, const char *filename);
/**
* Save the given pdf document to the given FILE output
* @param pdf PDF document to save
* @param fp FILE pointer to store the data into (must be writable)
* @return < 0 on failure, >= 0 on success
*/
int pdf_save_file(struct pdf_doc *pdf, FILE *fp);
/**
* Add a text string to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param text String to display
* @param size Point size of the font
* @param xoff X location to put it in
* @param yoff Y location to put it in
* @param colour Colour to draw the text
* @return 0 on success, < 0 on failure
*/
int pdf_add_text(struct pdf_doc *pdf, struct pdf_object *page,
const char *text, float size, float xoff, float yoff,
uint32_t colour);
/**
* Add a text string to the document, making it wrap if it is too
* long
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param text String to display
* @param size Point size of the font
* @param xoff X location to put it in
* @param yoff Y location to put it in
* @param colour Colour to draw the text
* @param wrap_width Width at which to wrap the text
* @param align Text alignment (see PDF_ALIGN_xxx)
* @param height Store the final height of the wrapped text here (optional)
* @return < 0 on failure, >= 0 on success
*/
int pdf_add_text_wrap(struct pdf_doc *pdf, struct pdf_object *page,
const char *text, float size, float xoff, float yoff,
uint32_t colour, float wrap_width, int align,
float *height);
/**
* Add a line to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x1 X offset of start of line
* @param y1 Y offset of start of line
* @param x2 X offset of end of line
* @param y2 Y offset of end of line
* @param width Width of the line
* @param colour Colour to draw the line
* @return 0 on success, < 0 on failure
*/
int pdf_add_line(struct pdf_doc *pdf, struct pdf_object *page, float x1,
float y1, float x2, float y2, float width, uint32_t colour);
/**
* Add a cubic bezier curve to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x1 X offset of the initial point of the curve
* @param y1 Y offset of the initial point of the curve
* @param x2 X offset of the final point of the curve
* @param y2 Y offset of the final point of the curve
* @param xq1 X offset of the first control point of the curve
* @param yq1 Y offset of the first control point of the curve
* @param xq2 X offset of the second control of the curve
* @param yq2 Y offset of the second control of the curve
* @param width Width of the curve
* @param colour Colour to draw the curve
* @return 0 on success, < 0 on failure
*/
int pdf_add_cubic_bezier(struct pdf_doc *pdf, struct pdf_object *page,
float x1, float y1, float x2, float y2, float xq1,
float yq1, float xq2, float yq2, float width,
uint32_t colour);
/**
* Add a quadratic bezier curve to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x1 X offset of the initial point of the curve
* @param y1 Y offset of the initial point of the curve
* @param x2 X offset of the final point of the curve
* @param y2 Y offset of the final point of the curve
* @param xq1 X offset of the control point of the curve
* @param yq1 Y offset of the control point of the curve
* @param width Width of the curve
* @param colour Colour to draw the curve
* @return 0 on success, < 0 on failure
*/
int pdf_add_quadratic_bezier(struct pdf_doc *pdf, struct pdf_object *page,
float x1, float y1, float x2, float y2,
float xq1, float yq1, float width,
uint32_t colour);
/**
* Add a custom path to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param operations Array of drawing operations
* @param operation_count The number of operations
* @param stroke_width Width of the stroke
* @param stroke_colour Colour to stroke the curve
* @param fill_colour Colour to fill the path
* @return 0 on success, < 0 on failure
*/
int pdf_add_custom_path(struct pdf_doc *pdf, struct pdf_object *page,
struct pdf_path_operation *operations,
int operation_count, float stroke_width,
uint32_t stroke_colour, uint32_t fill_colour);
/**
* Add an ellipse to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x X offset of the center of the ellipse
* @param y Y offset of the center of the ellipse
* @param xradius Radius of the ellipse in the X axis
* @param yradius Radius of the ellipse in the Y axis
* @param width Width of the ellipse outline stroke
* @param colour Colour to draw the ellipse outline stroke
* @param fill_colour Colour to fill the ellipse
* @return 0 on success, < 0 on failure
*/
int pdf_add_ellipse(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float xradius, float yradius, float width,
uint32_t colour, uint32_t fill_colour);
/**
* Add a circle to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x X offset of the center of the circle
* @param y Y offset of the center of the circle
* @param radius Radius of the circle
* @param width Width of the circle outline stroke
* @param colour Colour to draw the circle outline stroke
* @param fill_colour Colour to fill the circle
* @return 0 on success, < 0 on failure
*/
int pdf_add_circle(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float radius, float width, uint32_t colour,
uint32_t fill_colour);
/**
* Add an outline rectangle to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x X offset to start rectangle at
* @param y Y offset to start rectangle at
* @param width Width of rectangle
* @param height Height of rectangle
* @param border_width Width of rectangle border
* @param colour Colour to draw the rectangle
* @return 0 on success, < 0 on failure
*/
int pdf_add_rectangle(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float width, float height, float border_width,
uint32_t colour);
/**
* Add a filled rectangle to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x X offset to start rectangle at
* @param y Y offset to start rectangle at
* @param width Width of rectangle
* @param height Height of rectangle
* @param border_width Width of rectangle border
* @param colour_fill Colour to fill the rectangle
* @param colour_border Colour to draw the rectangle
* @return 0 on success, < 0 on failure
*/
int pdf_add_filled_rectangle(struct pdf_doc *pdf, struct pdf_object *page,
float x, float y, float width, float height,
float border_width, uint32_t colour_fill,
uint32_t colour_border);
/**
* Add an outline polygon to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x array of X offsets for points comprising the polygon
* @param y array of Y offsets for points comprising the polygon
* @param count Number of points comprising the polygon
* @param border_width Width of polygon border
* @param colour Colour to draw the polygon
* @return 0 on success, < 0 on failure
*/
int pdf_add_polygon(struct pdf_doc *pdf, struct pdf_object *page, float x[],
float y[], int count, float border_width,
uint32_t colour);
/**
* Add a filled polygon to the document
* @param pdf PDF document to add to
* @param page Page to add object to (NULL => most recently added page)
* @param x array of X offsets of points comprising the polygon
* @param y array of Y offsets of points comprising the polygon
* @param count Number of points comprising the polygon
* @param border_width Width of polygon border
* @param colour Colour to draw the polygon
* @return 0 on success, < 0 on failure
*/
int pdf_add_filled_polygon(struct pdf_doc *pdf, struct pdf_object *page,
float x[], float y[], int count,
float border_width, uint32_t colour);
/**
* Add a bookmark to the document
* @param pdf PDF document to add bookmark to
* @param page Page to jump to for bookmark
(or NULL for the most recently added page)
* @param parent ID of a previously created bookmark that is the parent
of this one. -1 if this should be a top-level bookmark.
* @param name String to associate with the bookmark
* @return < 0 on failure, new bookmark id on success
*/
int pdf_add_bookmark(struct pdf_doc *pdf, struct pdf_object *page, int parent,
const char *name);
/**
* Add a link annotation to the document
* @param pdf PDF document to add link to
* @param page Page that holds the clickable rectangle
(or NULL for the most recently added page)
* @param x X coordinate of bottom LHS corner of clickable rectangle
* @param y Y coordinate of bottom LHS corner of clickable rectangle
* @param width width of clickable rectangle
* @param height height of clickable rectangle
* @param target_page Page to jump to for link
* @param target_x X coordinate to position at the left of the view
* @param target_y Y coordinate to position at the top of the view
* @return < 0 on failure, new bookmark id on success
*/
int pdf_add_link(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float width, float height,
struct pdf_object *target_page, float target_x,
float target_y);
/**
* List of different barcode encodings that are supported
*/
enum {
PDF_BARCODE_128A, //!< Produce code-128A style barcodes
PDF_BARCODE_39, //!< Produce code-39 style barcodes
PDF_BARCODE_EAN13, //!< Produce EAN-13 style barcodes
PDF_BARCODE_UPCA, //!< Produce UPC-A style barcodes
PDF_BARCODE_EAN8, //!< Produce EAN-8 style barcodes
PDF_BARCODE_UPCE, //!< Produce UPC-E style barcodes
};
/**
* Add a barcode to the document
* @param pdf PDF document to add barcode to
* @param page Page to add barcode to (NULL => most recently added page)
* @param code Type of barcode to add (PDF_BARCODE_xxx)
* @param x X offset to put barcode at
* @param y Y offset to put barcode at
* @param width Width of barcode
* @param height Height of barcode
* @param string Barcode contents
* @param colour Colour to draw barcode
* @return < 0 on failure, >= 0 on success
*/
int pdf_add_barcode(struct pdf_doc *pdf, struct pdf_object *page, int code,
float x, float y, float width, float height,
const char *string, uint32_t colour);
/**
* Add image data as an image to the document.
* Image data must be one of: JPEG, PNG, PPM, PGM or BMP formats
* Passing 0 for either the display width or height will
* include the image but not render it visible.
* Passing a negative number either the display height or width will
* have the image be resized while keeping the original aspect ratio.
* @param pdf PDF document to add image to
* @param page Page to add image to (NULL => most recently added page)
* @param x X offset to put image at
* @param y Y offset to put image at
* @param display_width Displayed width of image
* @param display_height Displayed height of image
* @param data Image data bytes
* @param len Length of data
* @return < 0 on failure, >= 0 on success
*/
int pdf_add_image_data(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float display_width, float display_height,
const uint8_t *data, size_t len);
/**
* Add a raw 24 bit per pixel RGB buffer as an image to the document
* Passing 0 for either the display width or height will
* include the image but not render it visible.
* Passing a negative number either the display height or width will
* have the image be resized while keeping the original aspect ratio.
* @param pdf PDF document to add image to
* @param page Page to add image to (NULL => most recently added page)
* @param x X offset to put image at
* @param y Y offset to put image at
* @param display_width Displayed width of image
* @param display_height Displayed height of image
* @param data RGB data to add
* @param width width of image in pixels
* @param height height of image in pixels
* @return < 0 on failure, >= 0 on success
*/
int pdf_add_rgb24(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float display_width, float display_height,
const uint8_t *data, uint32_t width, uint32_t height);
/**
* Add a raw 8 bit per pixel grayscale buffer as an image to the document
* @param pdf PDF document to add image to
* @param page Page to add image to (NULL => most recently added page)
* @param x X offset to put image at
* @param y Y offset to put image at
* @param display_width Displayed width of image
* @param display_height Displayed height of image
* @param data grayscale pixel data to add
* @param width width of image in pixels
* @param height height of image in pixels
* @return < 0 on failure, >= 0 on success
*/
int pdf_add_grayscale8(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float display_width, float display_height,
const uint8_t *data, uint32_t width, uint32_t height);
/**
* Add an image file as an image to the document.
* Passing 0 for either the display width or height will
* include the image but not render it visible.
* Passing a negative number either the display height or width will
* have the image be resized while keeping the original aspect ratio.
* Supports image formats: JPEG, PNG, PPM, PGM & BMP
* @param pdf PDF document to add bookmark to
* @param page Page to add image to (NULL => most recently added page)
* @param x X offset to put image at
* @param y Y offset to put image at
* @param display_width Displayed width of image
* @param display_height Displayed height of image
* @param image_filename Filename of image file to display
* @return < 0 on failure, >= 0 on success
*/
int pdf_add_image_file(struct pdf_doc *pdf, struct pdf_object *page, float x,
float y, float display_width, float display_height,
const char *image_filename);
/**
* Parse image data to determine the image type & metadata
* @param info structure to hold the parsed metadata
* @param data image data to parse
* @param length number of bytes in data
* @param err_msg area to put any failure details
* @param err_msg_length maximum number of bytes to store in err_msg
* @return < 0 on failure, >= 0 on success
*/
int pdf_parse_image_header(struct pdf_img_info *info, const uint8_t *data,
size_t length, char *err_msg,
size_t err_msg_length);
#ifdef __cplusplus
}
#endif
#endif // PDFGEN_H

620
src/conf.c Normal file
View File

@@ -0,0 +1,620 @@
/*
* conf.c: functions that handle the nwipe.conf configuration file
* and the creation of the nwipe_customers.csv file. nwipe.conf uses
* libconfig format, while nwipe_customers.csv uses comma separted
* values. CSV is used so that the user can build there own customer
* listing using spreadsheets rather than enter all the customer
* information via the nwipe GUI interface.
*
* Copyright PartialVolume <https://github.com/PartialVolume>.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
*
*/
#include <libconfig.h>
#include <unistd.h>
#include <sys/types.h>
#include "nwipe.h"
#include "context.h"
#include "logging.h"
#include "method.h"
#include "options.h"
#include "conf.h"
config_t nwipe_cfg;
config_setting_t *nwipe_conf_setting, *group_organisation, *root, *group, *previous_group, *setting;
const char* nwipe_conf_str;
char nwipe_config_directory[] = "/etc/nwipe";
char nwipe_config_file[] = "/etc/nwipe/nwipe.conf";
char nwipe_customers_file[] = "/etc/nwipe/nwipe_customers.csv";
char nwipe_customers_file_backup[] = "/etc/nwipe/nwipe_customers.csv.backup";
char nwipe_customers_file_backup_tmp[] = "/etc/nwipe/nwipe_customers.csv.backup.tmp";
/*
* Checks for the existence of nwipe.conf and nwipe_customers.csv
* If either one does not exist, they are created and formatted
* with a basic configuration.
*/
int nwipe_conf_init()
{
FILE* fp_config;
FILE* fp_customers;
config_init( &nwipe_cfg );
char nwipe_customers_initial_content[] =
"\"Customer Name\";\"Contact Name\";\"Customer Address\";\"Contact Phone\"\n"
"\"Not Applicable\";\"Not Applicable\";\"Not Applicable\";\"Not Applicable\"\n";
/* Read /etc/nwipe/nwipe.conf. If there is an error, determine whether
* it's because it doesn't exist. If it doesn't exist create it and
* populate it with a basic structure.
*/
/* Does the /etc/nwipe/nwipe.conf file exist? If not, then create it */
if( access( nwipe_config_file, F_OK ) == 0 )
{
nwipe_log( NWIPE_LOG_INFO, "Nwipes config file %s exists", nwipe_config_file );
/* Read the nwipe.conf configuration file and report any errors */
nwipe_log( NWIPE_LOG_INFO, "Reading nwipe's config file %s", nwipe_config_file );
if( !config_read_file( &nwipe_cfg, nwipe_config_file ) )
{
nwipe_log( NWIPE_LOG_ERROR,
"Syntax error: %s:%d - %s\n",
config_error_file( &nwipe_cfg ),
config_error_line( &nwipe_cfg ),
config_error_text( &nwipe_cfg ) );
}
}
else
{
nwipe_log( NWIPE_LOG_WARNING, "%s does not exist", nwipe_config_file );
/* We assume the /etc/nwipe directory doesn't exist, so try to create it */
mkdir( nwipe_config_directory, 0755 );
/* create the nwipe.conf file */
if( !( fp_config = fopen( nwipe_config_file, "w" ) ) )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to create %s", nwipe_config_file );
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Created %s", nwipe_config_file );
fclose( fp_config );
}
}
root = config_root_setting( &nwipe_cfg );
/**
* If they don't already exist, populate nwipe.conf with groups, settings and values.
* This will also fill in missing group or settings if they have been corrupted or
* accidently deleted by the user. It will also update an existing nwipe.conf
* file as new groups and settings are added to nwipe. If new settings are added
* to nwipes conf file they MUST appear below in this list of groups and settings.
*/
nwipe_conf_populate( "Organisation_Details.Business_Name", "Not Applicable (BN)" );
nwipe_conf_populate( "Organisation_Details.Business_Address", "Not Applicable (BA)" );
nwipe_conf_populate( "Organisation_Details.Contact_Name", "Not Applicable (BCN)" );
nwipe_conf_populate( "Organisation_Details.Contact_Phone", "Not Applicable (BCP)" );
nwipe_conf_populate( "Organisation_Details.Op_Tech_Name", "Not Applicable (OTN)" );
/**
* Add PDF Certificate/Report settings
*/
nwipe_conf_populate( "PDF_Certificate.PDF_Enable", "ENABLED" );
nwipe_conf_populate( "PDF_Certificate.PDF_Preview", "DISABLED" );
/**
* The currently selected customer that will be printed on the report
*/
nwipe_conf_populate( "Selected_Customer.Customer_Name", "Not Applicable (CN)" );
nwipe_conf_populate( "Selected_Customer.Customer_Address", "Not Applicable (CA)" );
nwipe_conf_populate( "Selected_Customer.Contact_Name", "Not Applicable (CCN)" );
nwipe_conf_populate( "Selected_Customer.Contact_Phone", "Not Applicable (CP)" );
/**
* Write out the new configuration.
*/
if( !config_write_file( &nwipe_cfg, nwipe_config_file ) )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to write nwipe config to %s", nwipe_config_file );
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Sucessfully written nwipe config to %s", nwipe_config_file );
}
/* Read the nwipe.conf configuration file and report any errors */
if( !config_read_file( &nwipe_cfg, nwipe_config_file ) )
{
nwipe_log( NWIPE_LOG_ERROR,
"Syntax error: %s:%d - %s\n",
config_error_file( &nwipe_cfg ),
config_error_line( &nwipe_cfg ),
config_error_text( &nwipe_cfg ) );
}
/* -----------------------------------------------------------------------------
* Now check nwipe_customers.csv exists, if not create it with a basic structure
*/
if( access( nwipe_customers_file, F_OK ) == 0 )
{
nwipe_log( NWIPE_LOG_INFO, "Nwipes customer file %s exists", nwipe_customers_file );
}
else
{
nwipe_log( NWIPE_LOG_WARNING, "%s does not exist", nwipe_customers_file );
/* We assume the /etc/nwipe directory doesn't exist, so try to create it */
mkdir( nwipe_config_directory, 0755 );
/* create the nwipe_customers.csv file */
if( !( fp_customers = fopen( nwipe_customers_file, "w" ) ) )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to create %s", nwipe_customers_file );
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Created %s", nwipe_customers_file );
/* Now populate the csv header and first entry, Lines 1 and 2 */
if( fwrite( nwipe_customers_initial_content, sizeof( nwipe_customers_initial_content ), 1, fp_customers )
== 1 )
{
nwipe_log( NWIPE_LOG_INFO, "Populated %s with basic config", nwipe_customers_file );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to write basic config to %s", nwipe_customers_file );
}
fclose( fp_customers );
}
}
return ( 0 );
}
void save_selected_customer( char** customer )
{
/* This function saves the user selected customer
* to nwipe's config file /etc/nwipe/nwipe.conf
* for later use by the PDF creation functions.
*/
int idx;
int field_count;
int field_idx;
char field_1[FIELD_LENGTH];
char field_2[FIELD_LENGTH];
char field_3[FIELD_LENGTH];
char field_4[FIELD_LENGTH];
/* zero the field strings */
for( idx = 0; idx < FIELD_LENGTH; idx++ )
field_1[idx] = 0;
for( idx = 0; idx < FIELD_LENGTH; idx++ )
field_2[idx] = 0;
for( idx = 0; idx < FIELD_LENGTH; idx++ )
field_3[idx] = 0;
for( idx = 0; idx < FIELD_LENGTH; idx++ )
field_4[idx] = 0;
/* Extract the field contents from the csv string
*/
idx = 0;
field_idx = 0;
field_count = 1;
while( *( *customer + idx ) != 0 && field_count < NUMBER_OF_FIELDS + 1 )
{
/* Start of a field? */
if( *( *customer + idx ) == '\"' )
{
idx++;
while( *( *customer + idx ) != '\"' && *( *customer + idx ) != 0 )
{
if( field_count == 1 && field_idx < ( FIELD_LENGTH - 1 ) )
{
field_1[field_idx++] = *( *customer + idx );
}
else
{
if( field_count == 2 && field_idx < ( FIELD_LENGTH - 1 ) )
{
field_2[field_idx++] = *( *customer + idx );
}
else
{
if( field_count == 3 && field_idx < ( FIELD_LENGTH - 1 ) )
{
field_3[field_idx++] = *( *customer + idx );
}
else
{
if( field_count == 4 && field_idx < ( FIELD_LENGTH - 1 ) )
{
field_4[field_idx++] = *( *customer + idx );
}
}
}
}
idx++;
}
if( *( *customer + idx ) == '\"' )
{
/* Makesure the field string is terminated */
switch( field_count )
{
case 1:
field_1[field_idx] = 0;
break;
case 2:
field_2[field_idx] = 0;
break;
case 3:
field_3[field_idx] = 0;
break;
case 4:
field_4[field_idx] = 0;
break;
}
field_count++;
field_idx = 0;
}
}
idx++;
}
/* All 4 fields present? */
if( field_count != NUMBER_OF_FIELDS + 1 )
{
nwipe_log( NWIPE_LOG_ERROR,
"Insuffient fields in customer entry, expected %i, actual(field_count) %i, idx=%i",
NUMBER_OF_FIELDS,
field_count,
idx );
return;
}
/* -------------------------------------------------------------
* Write the fields to nwipe's config file /etc/nwipe/nwipe.conf
*/
if( ( setting = config_lookup( &nwipe_cfg, "Selected_Customer.Customer_Name" ) ) )
{
config_setting_set_string( setting, field_1 );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Can't find \"Selected Customers.Customer_Name\" in %s", nwipe_config_file );
}
if( ( setting = config_lookup( &nwipe_cfg, "Selected_Customer.Customer_Address" ) ) )
{
config_setting_set_string( setting, field_2 );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Can't find \"Selected Customers.Customer_Address\" in %s", nwipe_config_file );
}
if( ( setting = config_lookup( &nwipe_cfg, "Selected_Customer.Contact_Name" ) ) )
{
config_setting_set_string( setting, field_3 );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Can't find \"Selected Customers.Contact_Name\" in %s", nwipe_config_file );
}
if( ( setting = config_lookup( &nwipe_cfg, "Selected_Customer.Contact_Phone" ) ) )
{
config_setting_set_string( setting, field_4 );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Can't find \"Selected Customers.Contact_Phone\" in %s", nwipe_config_file );
}
/* Write out the new configuration. */
if( !config_write_file( &nwipe_cfg, nwipe_config_file ) )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to write user selected customer to %s", nwipe_config_file );
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Populated %s with user selected customer", nwipe_config_file );
}
}
int nwipe_conf_update_setting( char* group_name_setting_name, char* setting_value )
{
/* You would call this function of you wanted to update an existing setting in nwipe.conf, i.e
*
* nwipe_conf_update_setting( "PDF_Certificate.PDF_Enable", "ENABLED" )
*
* It is NOT used for creating a new group or setting name.
*/
/* -------------------------------------------------------------
* Write the field to nwipe's config file /etc/nwipe/nwipe.conf
*/
if( ( setting = config_lookup( &nwipe_cfg, group_name_setting_name ) ) )
{
config_setting_set_string( setting, setting_value );
}
else
{
nwipe_log(
NWIPE_LOG_ERROR, "Can't find group.setting_name %s in %s", group_name_setting_name, nwipe_config_file );
return 1;
}
/* Write the new configuration to nwipe.conf
*/
if( !config_write_file( &nwipe_cfg, nwipe_config_file ) )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to write %s to %s", group_name_setting_name, nwipe_config_file );
return 2;
}
else
{
nwipe_log( NWIPE_LOG_INFO,
"Updated %s with value %s in %s",
group_name_setting_name,
setting_value,
nwipe_config_file );
}
return 0;
} // end nwipe_conf_update_setting()
int nwipe_conf_read_setting( char* group_name_setting_name, const char** setting_value )
{
/* You would call this function if you wanted to read a settings value in nwipe.conf, i.e
*
* const char ** pReturnString;
* nwipe_conf_read_setting( "PDF_Certificate", "PDF_Enable", pReturnString );
*
*/
/* Separate group_name_setting_name i.e "PDF_Certificate.PDF_Enable" string
* into two separate strings by replacing the period with a NULL.
*/
int return_status;
int length = strlen( group_name_setting_name );
char* group_name = malloc( length );
char* setting_name = malloc( length );
int idx = 0;
while( group_name_setting_name[idx] != 0 && group_name_setting_name[idx] != '.' )
{
if( group_name_setting_name[idx] == '.' )
{
break;
}
idx++;
}
memcpy( group_name, group_name_setting_name, idx );
strcpy( setting_name, &group_name_setting_name[idx + 1] );
if( !( setting = config_lookup( &nwipe_cfg, group_name ) ) )
{
nwipe_log( NWIPE_LOG_ERROR, "Can't find group name %s.%s in %s", group_name, setting_name, nwipe_config_file );
return_status = -1;
}
else
{
/* Retrieve data from nwipe.conf */
if( CONFIG_TRUE == config_setting_lookup_string( setting, setting_name, setting_value ) )
{
return_status = 0; /* Success */
}
else
{
nwipe_log(
NWIPE_LOG_ERROR, "Can't find setting_name %s.%s in %s", group_name, setting_name, nwipe_config_file );
return_status = -2;
}
}
free( group_name );
free( setting_name );
return ( return_status );
} // end nwipe_conf_read_setting()
int nwipe_conf_populate( char* path, char* value )
{
/* This function will check that a path containing a group or multiple groups that lead to a setting all exist,
* if they don't exist, the group/s, settings and associated value are created.
*
* The path, a string consisting of one or more groups separted by a period symbol
* '.' with the final element in the path being the setting name. For instance the path might be
* PDF_Certificate.PDF_Enable. Where PDF_Certificate is the group name and PDF_Enable is the setting name.
* If one or other don't exist then they will be created.
*
* An arbitary depth of four groups are allowed for nwipe's configuration file, although we only currently, as of
* October 2023 use a depth of one group. The number of groups can be increased in the future if required by
* changing the definition MAX_GROUP_DEPTH in conf.h
*/
char* path_copy;
char* path_build;
char* group_start[MAX_GROUP_DEPTH + 2]; // A pointer to the start of each group string
char* setting_start;
int idx; // General index
int group_count; // Counts the number of groups in the path
/* Initialise the pointers */
memset( group_start, 0, MAX_GROUP_DEPTH + 2 );
memset( &setting_start, 0, 1 );
/* Allocate enough memory for a copy of the path and initialise to zero */
path_copy = calloc( strlen( path ) + 1, sizeof( char ) );
path_build = calloc( strlen( path ) + 1, sizeof( char ) );
/* Duplicate the path */
strcpy( path_copy, path );
/* Create individual strings by replacing the period '.' with NULL, counting the number of groups. */
idx = 0;
group_count = 0;
/* pointer to first group */
group_start[group_count] = path_copy;
while( *( path_copy + idx ) != 0 )
{
if( group_count > MAX_GROUP_DEPTH )
{
nwipe_log( NWIPE_LOG_ERROR,
"Too many groups in path, specified = %i, allowed = %i ",
group_count,
MAX_GROUP_DEPTH );
return 1;
}
if( *( path_copy + idx ) == '.' )
{
*( path_copy + idx ) = 0;
group_count++;
group_start[group_count] = path_copy + idx + 1;
}
idx++;
}
/* setting_start points to a string that represents the setting to be created */
setting_start = group_start[group_count];
/* Remove the last entry from group_start as that would be the setting and not a group */
group_start[group_count] = 0;
if( group_count == 0 )
{
nwipe_log( NWIPE_LOG_ERROR, "No groups specified in path, i.e. no period . separator found." );
return 2;
}
/**
* Now determine whether the group/s in the path exist, if not create them.
*/
idx = 0;
while( group_start[idx] != 0 )
{
strcat( path_build, group_start[idx] );
if( !( group = config_lookup( &nwipe_cfg, path_build ) ) )
{
if( idx == 0 )
{
group = config_setting_add( root, path_build, CONFIG_TYPE_GROUP );
previous_group = group;
}
else
{
group = config_setting_add( previous_group, group_start[idx], CONFIG_TYPE_GROUP );
previous_group = group;
}
if( group )
{
nwipe_log( NWIPE_LOG_INFO, "Created group [%s] in %s", path_build, nwipe_config_file );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to create group [%s] in %s", path_build, nwipe_config_file );
}
}
else
{
previous_group = group;
}
idx++;
if( group_start[idx] != 0 )
{
strcat( path_build, "." );
}
}
/**
* And finally determine whether the setting already exists, if not create it and assign the value to it
*/
/* Does the full path exist ? i.e AAA.BBB */
if( ( group = config_lookup( &nwipe_cfg, path_build ) ) )
{
/* Does the path and setting exist? AAA.BBB.SETTING_NAME */
if( !( setting = config_lookup( &nwipe_cfg, path ) ) )
{
/* Add the new SETTING_NAME */
if( ( setting = config_setting_add( group, setting_start, CONFIG_TYPE_STRING ) ) )
{
nwipe_log( NWIPE_LOG_INFO, "Created setting name %s in %s", path, nwipe_config_file );
}
else
{
nwipe_log(
NWIPE_LOG_ERROR, "Failed to create setting name %s in %s", setting_start, nwipe_config_file );
}
if( config_setting_set_string( setting, value ) == CONFIG_TRUE )
{
nwipe_log( NWIPE_LOG_INFO, "Set value for %s in %s to %s", path, nwipe_config_file, value );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to set value for %s in %s to %s", path, nwipe_config_file, value );
}
}
else
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "Setting already exists [%s] in %s", path, nwipe_config_file );
}
}
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Couldn't find constructed path [%s] in %s", path_build, nwipe_config_file );
}
free( path_copy );
free( path_build );
return 0;
}
void nwipe_conf_close()
{
config_destroy( &nwipe_cfg );
}

55
src/conf.h Normal file
View File

@@ -0,0 +1,55 @@
#ifndef CONF_H_
#define CONF_H_
/**
* Initialises the libconfig code, called once at the
* start of nwipe, prior to any attempts to access
* nwipe's config file /etc/nwipe/nwipe.conf
* @param none
* @return int
* 0 = success
* -1 = error
*/
int nwipe_conf_init();
/**
* Before exiting nwipe, this function should be called
* to free up libconfig's memory usage
* @param none
* @return void
*/
void nwipe_conf_close();
void save_selected_customer( char** );
/**
* int nwipe_conf_update_setting( char *, char * );
* Use this function to update a setting in nwipe.conf
* @param char * this is the group name and setting name separated by a period '.'
* i.e "PDF_Certificate.PDF_Enable"
* @param char * this is the setting, i.e ENABLED
* @return int 0 = Success
* 1 = Unable to update memory copy
* 2 = Unable to write new configuration to /etc/nwipe/nwipe.conf
*/
int nwipe_conf_update_setting( char*, char* );
/**
* int nwipe_conf_read_setting( char *, char *, const char ** )
* Use this function to read a setting value in nwipe.conf
* @param char * this is the group name
* @param char * this is the setting name
* @param char ** this is a pointer to the setting value
* @return int 0 = Success
* -1 = Unable to find the specified group name
* -2 = Unable to find the specified setting name
*/
int nwipe_conf_read_setting( char*, const char** );
int nwipe_conf_populate( char* path, char* value );
#define FIELD_LENGTH 256
#define NUMBER_OF_FIELDS 4
#define MAX_GROUP_DEPTH 4
#endif /* CONF_H_ */

View File

@@ -2,7 +2,7 @@
* context.h: The internal state representation of nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
* This program is free software; you can redistribute it and/or modify it under
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
@@ -24,121 +24,205 @@
#define CONTEXT_H_
#include "prng.h"
#ifndef __HDDTEMP_H__
#include "hddtemp_scsi/hddtemp.h"
#endif /* __HDDTEMP_H__ */
typedef enum nwipe_device_t_
{
NWIPE_DEVICE_UNKNOWN = 0, /* Unknown device. */
NWIPE_DEVICE_IDE,
NWIPE_DEVICE_SCSI,
NWIPE_DEVICE_COMPAQ, /* Unimplemented. */
NWIPE_DEVICE_USB, /* Unimplemented. */
NWIPE_DEVICE_IEEE1394 /* Unimplemented. */
typedef enum nwipe_device_t_ {
NWIPE_DEVICE_UNKNOWN = 0, // Unknown device.
NWIPE_DEVICE_IDE,
NWIPE_DEVICE_SCSI,
NWIPE_DEVICE_COMPAQ, // Unimplemented.
NWIPE_DEVICE_USB,
NWIPE_DEVICE_IEEE1394, // Unimplemented.
NWIPE_DEVICE_ATA,
NWIPE_DEVICE_NVME,
NWIPE_DEVICE_VIRT,
NWIPE_DEVICE_SAS,
NWIPE_DEVICE_MMC
} nwipe_device_t;
typedef enum nwipe_pass_t_
{
NWIPE_PASS_NONE = 0, /* Not running. */
NWIPE_PASS_WRITE, /* Writing patterns to the device. */
NWIPE_PASS_VERIFY, /* Verifying a pass. */
NWIPE_PASS_FINAL_BLANK, /* Filling the device with zeros. */
NWIPE_PASS_FINAL_OPS2 /* Special case for nwipe_ops2. */
typedef enum nwipe_pass_t_ {
NWIPE_PASS_NONE = 0, // Not running.
NWIPE_PASS_WRITE, // Writing patterns to the device.
NWIPE_PASS_VERIFY, // Verifying a pass.
NWIPE_PASS_FINAL_BLANK, // Filling the device with zeros.
NWIPE_PASS_FINAL_OPS2 // Special case for nwipe_ops2.
} nwipe_pass_t;
typedef enum nwipe_select_t_
{
NWIPE_SELECT_NONE = 0, /* Unused. */
NWIPE_SELECT_TRUE, /* Wipe this device. */
NWIPE_SELECT_TRUE_PARENT, /* A parent of this device has been selected, so the wipe is implied. */
NWIPE_SELECT_FALSE, /* Do not wipe this device. */
NWIPE_SELECT_FALSE_CHILD, /* A child of this device has been selected, so we can't wipe this device. */
NWIPE_SELECT_DISABLED /* Do not wipe this device and do not allow it to be selected. */
typedef enum nwipe_select_t_ {
NWIPE_SELECT_NONE = 0, // Unused.
NWIPE_SELECT_TRUE, // Wipe this device.
NWIPE_SELECT_TRUE_PARENT, // A parent of this device has been selected, so the wipe is implied.
NWIPE_SELECT_FALSE, // Do not wipe this device.
NWIPE_SELECT_FALSE_CHILD, // A child of this device has been selected, so we can't wipe this device.
NWIPE_SELECT_DISABLED // Do not wipe this device and do not allow it to be selected.
} nwipe_select_t;
#define NWIPE_KNOB_SPEEDRING_SIZE 30
#define NWIPE_KNOB_SPEEDRING_GRANULARITY 10
#define NWIPE_KNOB_SPEEDRING_SIZE 30
#define NWIPE_KNOB_SPEEDRING_GRANULARITY 10
typedef struct nwipe_speedring_t_
{
u64 bytes[NWIPE_KNOB_SPEEDRING_SIZE];
u64 bytestotal;
u64 byteslast;
time_t times[NWIPE_KNOB_SPEEDRING_SIZE];
time_t timestotal;
time_t timeslast;
u32 position;
u64 bytes[NWIPE_KNOB_SPEEDRING_SIZE];
u64 bytestotal;
u64 byteslast;
time_t times[NWIPE_KNOB_SPEEDRING_SIZE];
time_t timestotal;
time_t timeslast;
u32 position;
} nwipe_speedring_t;
#define NWIPE_DEVICE_LABEL_LENGTH 200
#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
// 20 chracters for serial number plus null Byte
#define NWIPE_SERIALNUMBER_LENGTH 20
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. */
off64_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) */
/*
* Device fields
*/
int device_block_size; // The soft block size reported by the device, as logical
int device_sector_size; // The logical sector size reported by libparted
int device_phys_sector_size; // The physical sector size reported by libparted
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.
char device_name_without_path[100];
char gui_device_name[100];
unsigned long long device_size; // The device size in bytes.
u64 device_size_in_sectors; // The device size in number of logical sectors, this may be 512 or 4096 sectors
u64 device_size_in_512byte_sectors; // The device size in number of 512byte sectors, irrespective of logical sector
// size reported by libata
unsigned long long bytes_erased; // Irrespective of pass, this how much of the drive has been erased, CANNOT be
// greater than device_size.
char* device_size_text; // The device size in a more (human)readable format.
char device_size_txt[NWIPE_DEVICE_SIZE_TXT_LENGTH]; // The device size in a more (human)readable format.
char* device_model; // The model of the device.
char device_label[NWIPE_DEVICE_LABEL_LENGTH]; // The label (name, model, size and serial) of the device.
struct stat device_stat; // The device file state from fstat().
nwipe_device_t device_type; // Indicates an IDE, SCSI, or Compaq SMART device in enumerated form (int)
char device_type_str[14]; // Indicates an IDE, SCSI, USB etc as per nwipe_device_t but in ascii
int device_is_ssd; // 0 = no SSD, 1 = is a SSD
char device_serial_no[NWIPE_SERIALNUMBER_LENGTH
+ 1]; // Serial number(processed, 20 characters plus null termination) of the 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.
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 requested by the user for 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.
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.
char throughput_txt[13]; // Human readable throughput.
u64 verify_errors; // The number of verification errors across all passes.
int templ_has_hwmon_data; // 0 = no hwmon data available, 1 = hwmon data available
int templ_has_scsitemp_data; // 0 = no scsitemp data available, 1 = scsitemp data available
char temp1_path[MAX_HWMON_PATH_LENGTH]; // path to temperature variables /sys/class/hwmon/hwmonX/ etc.
int temp1_crit; // Critical high drive temperature, 1000000=unitialised, millidegree celsius.
int temp1_highest; // Historical highest temperature reached, 1000000=unitialised, millidegree celsius.
int temp1_input; // drive temperature, -1=unitialised. 1000000=unitialised, millidegree celsius.
int temp1_lcrit; // Critical low drive temperature, 1000000=unitialised, millidegree celsius.
int temp1_lowest; // Historically lowest temperature, 1000000=unitialised, millidegree celsius.
int temp1_max; // Maximum allowed temperature, 1000000=unitialised, millidegree celsius.
int temp1_min; // Minimum allowed temperature, 1000000=unitialised, millidegree celsius.
int temp1_monitored_wipe_max;
int temp1_monitored_wipe_min;
int temp1_monitored_wipe_avg;
int temp1_flash_rate; // number relates to one tenth of a second, so 2 means a flash on and off = 0.4s
int temp1_flash_rate_counter; // used by the gui for timing the flash rate
int temp1_flash_rate_status; // 0=blank 1=visible
time_t temp1_time; // The time when temperature was last checked, seconds since epoch
struct disk* templ_disk; // Pointer to disk structure for hddtemp SCSI routines
int wipe_status; // Wipe finished = 0, wipe in progress = 1, wipe yet to start = -1.
char wipe_status_txt[10]; // ERASED, FAILED, ABORTED, INSANITY
int spinner_idx; // Index into the spinner character array
char spinner_character[1]; // The current spinner character
double duration; // Duration of the wipe in seconds
char duration_str[20]; // The duration string in hh:mm:ss
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[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
u64 HPA_reported_real; // the 'HPA real' value reported hdparm -N, i.e the second value of n/n
int DCO_status; // 0 = No DCO found, 1 = DCO detected, 2 = Unknown, unable to checked
u64 DCO_reported_real_max_sectors; // real max sectors as reported by hdparm --dco-identify
u64 DCO_reported_real_max_size; // real max sectors in bytes
u64 Calculated_real_max_size_in_bytes; // This value is determined from all the possible variations for drives that
// don't support DCO/HPA and those that do. Also drives that can't provide
// HPA/DCO due to the chips they use (USB adapters)
char DCO_reported_real_max_size_text[NWIPE_DEVICE_SIZE_TXT_LENGTH]; // real max size in human readable form i.e 1TB
char Calculated_real_max_size_in_bytes_text[NWIPE_DEVICE_SIZE_TXT_LENGTH]; // calculated real max human readable
u64 HPA_sectors; // The size of the host protected area in sectors
char HPA_size_text[NWIPE_DEVICE_SIZE_TXT_LENGTH]; // Human readable size bytes, KB, MB, GB ..
int HPA_display_toggle_state; // 0 or 1 Used to toggle between "[1TB] [ 33C]" and [HDA STATUS]
time_t HPA_toggle_time; // records a time, then if for instance 3 seconds has elapsed the display changes
int test_use1;
int test_use2;
/*
* 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);
*/
struct hd_driveid identity;
} nwipe_context_t;
/* We use 2 data structs to pass data between threads. */
/* The first contains any required values: */
/* Values cannot form part of the second array below, hence the need for this. */
/*
* We use 2 data structs to pass data between threads.
* The first contains any required values.
* Values cannot form part of the second array below, hence the need for this.
*/
typedef struct
{
int nwipe_enumerated; /* The number of devices available. */
int nwipe_selected; /* The number of devices being wiped. */
time_t maxeta; /* The estimated runtime of the slowest device. */
u64 throughput; /* Total throughput */
u64 errors; /* The combined number of errors of all processes. */
pthread_t *gui_thread; /* The ID of GUI thread. */
int nwipe_enumerated; // The number of devices available.
int nwipe_selected; // The number of devices being wiped.
time_t maxeta; // The estimated runtime of the slowest device.
u64 throughput; // Total throughput.
u64 errors; // The combined number of errors of all processes.
pthread_t* gui_thread; // The ID of GUI thread.
} nwipe_misc_thread_data_t;
/* The second points to the first structure, as well as the structure of all the devices */
typedef struct
/*
* The second points to the first structure, as well as the structure of all the devices
*/
typedef struct
{
nwipe_context_t **c; /* Pointer to the nwipe context structure. */
nwipe_misc_thread_data_t *nwipe_misc_thread_data; /* Pointer to the misc structure above. */
nwipe_context_t** c; // Pointer to the nwipe context structure.
nwipe_misc_thread_data_t* nwipe_misc_thread_data; // Pointer to the misc structure above.
} nwipe_thread_data_ptr_t;
#endif /* CONTEXT_H_ */
/* eof */

997
src/create_pdf.c Normal file
View File

@@ -0,0 +1,997 @@
/*
* create_pdf.c: Routines that create the PDF erasure certificate
*
* Copyright PartialVolume <https://github.com/PartialVolume>.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#include <stdint.h>
#include "stdarg.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "nwipe.h"
#include "context.h"
#include "create_pdf.h"
#include "PDFGen/pdfgen.h"
#include "version.h"
#include "method.h"
#include "embedded_images/shred_db.jpg.h"
#include "embedded_images/tick_erased.jpg.h"
#include "embedded_images/redcross.h"
#include "embedded_images/nwipe_exclamation.jpg.h"
#include "logging.h"
#include "options.h"
#include "prng.h"
#include "hpa_dco.h"
#include "miscellaneous.h"
#include <libconfig.h>
#include "conf.h"
#define text_size_data 10
struct pdf_doc* pdf;
struct pdf_object* page;
char model_header[50] = ""; /* Model text in the header */
char serial_header[30] = ""; /* Serial number text in the header */
char barcode[100] = ""; /* Contents of the barcode, i.e model:serial */
char pdf_footer[MAX_PDF_FOOTER_TEXT_LENGTH];
float height;
float page_width;
int status_icon;
int create_pdf( nwipe_context_t* ptr )
{
extern nwipe_prng_t nwipe_twister;
extern nwipe_prng_t nwipe_isaac;
extern nwipe_prng_t nwipe_isaac64;
/* Used by libconfig functions to retrieve data from nwipe.conf defined in conf.c */
extern config_t nwipe_cfg;
extern char nwipe_config_file[];
// char pdf_footer[MAX_PDF_FOOTER_TEXT_LENGTH];
nwipe_context_t* c;
c = ptr;
// char model_header[50] = ""; /* Model text in the header */
// char serial_header[30] = ""; /* Serial number text in the header */
char device_size[100] = ""; /* Device size in the form xMB (xxxx bytes) */
// char barcode[100] = ""; /* Contents of the barcode, i.e model:serial */
char verify[20] = ""; /* Verify option text */
char blank[10] = ""; /* blanking pass, none, zeros, ones */
char rounds[50] = ""; /* rounds ASCII numeric */
char prng_type[50] = ""; /* type of prng, twister, isaac, isaac64 */
char start_time_text[50] = "";
char end_time_text[50] = "";
char bytes_erased[50] = "";
char HPA_status_text[50] = "";
char HPA_size_text[50] = "";
char errors[50] = "";
char throughput_txt[50] = "";
char bytes_percent_str[7] = "";
// int status_icon;
// float height;
// float page_width;
struct pdf_info info = { .creator = "https://github.com/PartialVolume/shredos.x86_64",
.producer = "https://github.com/martijnvanbrummelen/nwipe",
.title = "PDF Disk Erasure Certificate",
.author = "Nwipe",
.subject = "Disk Erase Certificate",
.date = "Today" };
/* A pointer to the system time struct. */
struct tm* p;
/* variables used by libconfig */
config_setting_t* setting;
const char *business_name, *business_address, *contact_name, *contact_phone, *op_tech_name, *customer_name,
*customer_address, *customer_contact_name, *customer_contact_phone;
/* ------------------ */
/* Initialise Various */
/* Used to display correct icon on page 2 */
status_icon = 0; // zero don't display icon, see header STATUS_ICON_..
// nwipe_log( NWIPE_LOG_NOTICE, "Create the PDF disk erasure certificate" );
// struct pdf_doc* pdf = pdf_create( PDF_A4_WIDTH, PDF_A4_HEIGHT, &info );
pdf = pdf_create( PDF_A4_WIDTH, PDF_A4_HEIGHT, &info );
/* Create footer text string and append the version */
snprintf( pdf_footer, sizeof( pdf_footer ), "Disc Erasure by NWIPE version %s", version_string );
pdf_set_font( pdf, "Helvetica" );
struct pdf_object* page_1 = pdf_append_page( pdf );
/* Obtain page page_width */
page_width = pdf_page_width( page_1 );
/*********************************************************************
* Create header and footer on page 1, with the exception of the green
* tick/red icon which is set from the 'status' section below
*/
pdf_add_text_wrap( pdf, NULL, pdf_footer, 12, 0, 30, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
pdf_add_line( pdf, NULL, 50, 50, 550, 50, 3, PDF_BLACK );
pdf_add_line( pdf, NULL, 50, 650, 550, 650, 3, PDF_BLACK );
pdf_add_image_data( pdf, NULL, 45, 665, 100, 100, bin2c_shred_db_jpg, 27063 );
pdf_set_font( pdf, "Helvetica-Bold" );
snprintf( model_header, sizeof( model_header ), " %s: %s ", "Model", c->device_model );
pdf_add_text_wrap( pdf, NULL, model_header, 14, 0, 755, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
snprintf( serial_header, sizeof( serial_header ), " %s: %s ", "S/N", c->device_serial_no );
pdf_add_text_wrap( pdf, NULL, serial_header, 14, 0, 735, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
pdf_set_font( pdf, "Helvetica" );
pdf_add_text_wrap( pdf, NULL, "Disk Erasure Report", 24, 0, 695, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
snprintf( barcode, sizeof( barcode ), "%s:%s", c->device_model, c->device_serial_no );
pdf_add_text_wrap(
pdf, NULL, "Page 1 - Erasure Status", 14, 0, 670, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
pdf_add_barcode( pdf, NULL, PDF_BARCODE_128A, 100, 790, 400, 25, barcode, PDF_BLACK );
/* ------------------------ */
/* Organisation Information */
pdf_add_line( pdf, NULL, 50, 550, 550, 550, 1, PDF_GRAY );
pdf_add_text( pdf, NULL, "Organisation Performing The Disk Erasure", 12, 50, 630, PDF_BLUE );
pdf_add_text( pdf, NULL, "Business Name:", 12, 60, 610, PDF_GRAY );
pdf_add_text( pdf, NULL, "Business Address:", 12, 60, 590, PDF_GRAY );
pdf_add_text( pdf, NULL, "Contact Name:", 12, 60, 570, PDF_GRAY );
pdf_add_text( pdf, NULL, "Contact Phone:", 12, 300, 570, PDF_GRAY );
/* Obtain organisational details from nwipe.conf - See conf.c */
setting = config_lookup( &nwipe_cfg, "Organisation_Details" );
if( setting != NULL )
{
pdf_set_font( pdf, "Helvetica-Bold" );
if( config_setting_lookup_string( setting, "Business_Name", &business_name ) )
{
pdf_add_text( pdf, NULL, business_name, text_size_data, 153, 610, PDF_BLACK );
}
if( config_setting_lookup_string( setting, "Business_Address", &business_address ) )
{
pdf_add_text( pdf, NULL, business_address, text_size_data, 165, 590, PDF_BLACK );
}
if( config_setting_lookup_string( setting, "Contact_Name", &contact_name ) )
{
pdf_add_text( pdf, NULL, contact_name, text_size_data, 145, 570, PDF_BLACK );
}
if( config_setting_lookup_string( setting, "Contact_Phone", &contact_phone ) )
{
pdf_add_text( pdf, NULL, contact_phone, text_size_data, 390, 570, PDF_BLACK );
}
pdf_set_font( pdf, "Helvetica" );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Cannot locate group [Organisation_Details] in %s", nwipe_config_file );
}
/* -------------------- */
/* Customer Information */
pdf_add_line( pdf, NULL, 50, 450, 550, 450, 1, PDF_GRAY );
pdf_add_text( pdf, NULL, "Customer Details", 12, 50, 530, PDF_BLUE );
pdf_add_text( pdf, NULL, "Name:", 12, 60, 510, PDF_GRAY );
pdf_add_text( pdf, NULL, "Address:", 12, 60, 490, PDF_GRAY );
pdf_add_text( pdf, NULL, "Contact Name:", 12, 60, 470, PDF_GRAY );
pdf_add_text( pdf, NULL, "Contact Phone:", 12, 300, 470, PDF_GRAY );
/* Obtain current customer details from nwipe.conf - See conf.c */
setting = config_lookup( &nwipe_cfg, "Selected_Customer" );
if( setting != NULL )
{
pdf_set_font( pdf, "Helvetica-Bold" );
if( config_setting_lookup_string( setting, "Customer_Name", &customer_name ) )
{
pdf_add_text( pdf, NULL, customer_name, text_size_data, 100, 510, PDF_BLACK );
}
if( config_setting_lookup_string( setting, "Customer_Address", &customer_address ) )
{
pdf_add_text( pdf, NULL, customer_address, text_size_data, 110, 490, PDF_BLACK );
}
if( config_setting_lookup_string( setting, "Contact_Name", &customer_contact_name ) )
{
pdf_add_text( pdf, NULL, customer_contact_name, text_size_data, 145, 470, PDF_BLACK );
}
if( config_setting_lookup_string( setting, "Contact_Phone", &customer_contact_phone ) )
{
pdf_add_text( pdf, NULL, customer_contact_phone, text_size_data, 390, 470, PDF_BLACK );
}
pdf_set_font( pdf, "Helvetica" );
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Cannot locate group [Selected_Customer] in %s", nwipe_config_file );
}
/******************
* Disk Information
*/
pdf_add_line( pdf, NULL, 50, 350, 550, 350, 1, PDF_GRAY );
pdf_add_text( pdf, NULL, "Disk Information", 12, 50, 430, PDF_BLUE );
/************
* Make/model
*/
pdf_add_text( pdf, NULL, "Make/Model:", 12, 60, 410, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, c->device_model, text_size_data, 135, 410, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/************
* Serial no.
*/
pdf_add_text( pdf, NULL, "Serial:", 12, 340, 410, PDF_GRAY );
if( c->device_serial_no[0] == 0 )
{
snprintf( c->device_serial_no, sizeof( c->device_serial_no ), "Unknown" );
}
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, c->device_serial_no, text_size_data, 380, 410, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/******************************
* Bus type, ATA, USB, NVME etc
*/
pdf_add_text( pdf, NULL, "Bus:", 12, 340, 390, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, c->device_type_str, text_size_data, 370, 390, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/*************************
* Capacity (Size) of disk
*/
/* Size (Apparent) */
pdf_add_text( pdf, NULL, "Size(Apparent): ", 12, 60, 390, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
snprintf( device_size, sizeof( device_size ), "%s, %lli bytes", c->device_size_text, c->device_size );
if( ( c->device_size == c->Calculated_real_max_size_in_bytes ) || c->device_type == NWIPE_DEVICE_NVME
|| c->device_type == NWIPE_DEVICE_VIRT || c->HPA_status == HPA_NOT_APPLICABLE || c->HPA_status != HPA_UNKNOWN )
{
pdf_add_text( pdf, NULL, device_size, text_size_data, 145, 390, PDF_DARK_GREEN );
}
else
{
pdf_add_text( pdf, NULL, device_size, text_size_data, 145, 390, PDF_RED );
}
pdf_set_font( pdf, "Helvetica" );
/* Size (Real) */
pdf_add_text( pdf, NULL, "Size(Real):", 12, 60, 370, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
if( c->device_type == NWIPE_DEVICE_NVME || c->device_type == NWIPE_DEVICE_VIRT
|| c->HPA_status == HPA_NOT_APPLICABLE )
{
snprintf( device_size, sizeof( device_size ), "%s, %lli bytes", c->device_size_text, c->device_size );
pdf_add_text( pdf, NULL, device_size, text_size_data, 125, 370, PDF_DARK_GREEN );
}
else
{
/* If the calculared real max size as determined from HPA/DCO and libata data is larger than
* or equal to the apparent device size then display that value in green.
*/
if( c->Calculated_real_max_size_in_bytes >= c->device_size )
{
/* displays the real max size of the disc from the DCO displayed in Green */
snprintf( device_size,
sizeof( device_size ),
"%s, %lli bytes",
c->Calculated_real_max_size_in_bytes_text,
c->Calculated_real_max_size_in_bytes );
pdf_add_text( pdf, NULL, device_size, text_size_data, 125, 370, PDF_DARK_GREEN );
}
else
{
/* If there is no real max size either because the drive or adapter doesn't support it */
if( c->HPA_status == HPA_UNKNOWN )
{
snprintf( device_size, sizeof( device_size ), "Unknown" );
pdf_add_text( pdf, NULL, device_size, text_size_data, 125, 370, PDF_RED );
}
else
{
/* we are already here because c->DCO_reported_real_max_size < 1 so if HPA enabled then use the
* value we determine from whether HPA set, HPA real exist and if not assume libata's value*/
if( c->HPA_status == HPA_ENABLED )
{
snprintf( device_size,
sizeof( device_size ),
"%s, %lli bytes",
c->device_size_text,
c->Calculated_real_max_size_in_bytes );
pdf_add_text( pdf, NULL, device_size, text_size_data, 125, 370, PDF_DARK_GREEN );
}
else
{
/* Sanity check, should never get here! */
snprintf( device_size, sizeof( device_size ), "Sanity: HPA_status = %i", c->HPA_status );
pdf_add_text( pdf, NULL, device_size, text_size_data, 125, 370, PDF_RED );
}
}
}
}
pdf_set_font( pdf, "Helvetica" );
/* --------------- */
/* Erasure Details */
pdf_add_text( pdf, NULL, "Disk Erasure Details", 12, 50, 330, PDF_BLUE );
/* start time */
pdf_add_text( pdf, NULL, "Start time:", 12, 60, 310, PDF_GRAY );
p = localtime( &c->start_time );
snprintf( start_time_text,
sizeof( start_time_text ),
"%i/%02i/%02i %02i:%02i:%02i",
1900 + p->tm_year,
1 + p->tm_mon,
p->tm_mday,
p->tm_hour,
p->tm_min,
p->tm_sec );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, start_time_text, text_size_data, 120, 310, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* end time */
pdf_add_text( pdf, NULL, "End time:", 12, 300, 310, PDF_GRAY );
p = localtime( &c->end_time );
snprintf( end_time_text,
sizeof( end_time_text ),
"%i/%02i/%02i %02i:%02i:%02i",
1900 + p->tm_year,
1 + p->tm_mon,
p->tm_mday,
p->tm_hour,
p->tm_min,
p->tm_sec );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, end_time_text, text_size_data, 360, 310, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* Duration */
pdf_add_text( pdf, NULL, "Duration:", 12, 60, 290, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, c->duration_str, text_size_data, 115, 290, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/*******************
* Status of erasure
*/
pdf_add_text( pdf, NULL, "Status:", 12, 300, 290, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
if( !strcmp( c->wipe_status_txt, "ERASED" )
&& ( c->HPA_status == HPA_DISABLED || c->HPA_status == HPA_NOT_APPLICABLE || c->device_type == NWIPE_DEVICE_NVME
|| c->device_type == NWIPE_DEVICE_VIRT ) )
{
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 365, 290, PDF_DARK_GREEN );
pdf_add_ellipse( pdf, NULL, 390, 295, 45, 10, 2, PDF_DARK_GREEN, PDF_TRANSPARENT );
/* Display the green tick icon in the header */
pdf_add_image_data( pdf, NULL, 450, 665, 100, 100, bin2c_te_jpg, 54896 );
status_icon = STATUS_ICON_GREEN_TICK; // used later on page 2
}
else
{
if( !strcmp( c->wipe_status_txt, "ERASED" )
&& ( c->HPA_status == HPA_ENABLED || c->HPA_status == HPA_UNKNOWN ) )
{
pdf_add_ellipse( pdf, NULL, 390, 295, 45, 10, 2, PDF_RED, PDF_BLACK );
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 365, 290, PDF_YELLOW );
pdf_add_text( pdf, NULL, "See Warning !", 12, 450, 290, PDF_RED );
/* Display the yellow exclamation icon in the header */
pdf_add_image_data( pdf, NULL, 450, 665, 100, 100, bin2c_nwipe_exclamation_jpg, 65791 );
status_icon = STATUS_ICON_YELLOW_EXCLAMATION; // used later on page 2
}
else
{
if( !strcmp( c->wipe_status_txt, "FAILED" ) )
{
// text shifted left slightly in ellipse due to extra character
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 370, 290, PDF_RED );
// Display the red cross in the header
pdf_add_image_data( pdf, NULL, 450, 665, 100, 100, bin2c_redcross_jpg, 60331 );
status_icon = STATUS_ICON_RED_CROSS; // used later on page 2
}
else
{
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 360, 290, PDF_RED );
// Print the red cross
pdf_add_image_data( pdf, NULL, 450, 665, 100, 100, bin2c_redcross_jpg, 60331 );
status_icon = STATUS_ICON_RED_CROSS; // used later on page 2
}
pdf_add_ellipse( pdf, NULL, 390, 295, 45, 10, 2, PDF_RED, PDF_TRANSPARENT );
}
}
pdf_set_font( pdf, "Helvetica" );
/********
* Method
*/
pdf_add_text( pdf, NULL, "Method:", 12, 60, 270, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, nwipe_method_label( nwipe_options.method ), text_size_data, 110, 270, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/***********
* prng type
*/
pdf_add_text( pdf, NULL, "PRNG algorithm:", 12, 300, 270, PDF_GRAY );
if( nwipe_options.method == &nwipe_verify_one || nwipe_options.method == &nwipe_verify_zero
|| nwipe_options.method == &nwipe_zero || nwipe_options.method == &nwipe_one )
{
snprintf( prng_type, sizeof( prng_type ), "Not applicable to method" );
}
else
{
if( nwipe_options.prng == &nwipe_twister )
{
snprintf( prng_type, sizeof( prng_type ), "Twister" );
}
else
{
if( nwipe_options.prng == &nwipe_isaac )
{
snprintf( prng_type, sizeof( prng_type ), "Isaac" );
}
else
{
if( nwipe_options.prng == &nwipe_isaac64 )
{
snprintf( prng_type, sizeof( prng_type ), "Isaac64" );
}
else
{
snprintf( prng_type, sizeof( prng_type ), "Unknown" );
}
}
}
}
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, prng_type, text_size_data, 395, 270, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/******************************************************
* Final blanking pass if selected, none, zeros or ones
*/
if( nwipe_options.noblank )
{
strcpy( blank, "None" );
}
else
{
strcpy( blank, "Zeros" );
}
pdf_add_text( pdf, NULL, "Final Pass(Zeros/Ones/None):", 12, 60, 250, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, blank, text_size_data, 230, 250, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* ***********************************************************************
* Create suitable text based on the numeric value of type of verification
*/
switch( nwipe_options.verify )
{
case NWIPE_VERIFY_NONE:
strcpy( verify, "Verify None" );
break;
case NWIPE_VERIFY_LAST:
strcpy( verify, "Verify Last" );
break;
case NWIPE_VERIFY_ALL:
strcpy( verify, "Verify All" );
break;
}
pdf_add_text( pdf, NULL, "Verify Pass(Last/All/None):", 12, 300, 250, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, verify, text_size_data, 450, 250, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* ************
* bytes erased
*/
pdf_add_text( pdf, NULL, "*Bytes Erased:", 12, 60, 230, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
/* Bytes erased is not applicable when user only requested a verify */
if( nwipe_options.method == &nwipe_verify_one || nwipe_options.method == &nwipe_verify_zero )
{
snprintf( bytes_erased, sizeof( bytes_erased ), "Not applicable to method" );
pdf_add_text( pdf, NULL, bytes_erased, text_size_data, 145, 230, PDF_BLACK );
}
else
{
if( c->device_type == NWIPE_DEVICE_NVME || c->device_type == NWIPE_DEVICE_VIRT
|| c->HPA_status == HPA_NOT_APPLICABLE )
{
convert_double_to_string( bytes_percent_str,
(double) ( (double) c->bytes_erased / (double) c->device_size ) * 100 );
snprintf( bytes_erased, sizeof( bytes_erased ), "%lli, (%s%%)", c->bytes_erased, bytes_percent_str );
if( c->bytes_erased == c->device_size )
{
pdf_add_text( pdf, NULL, bytes_erased, text_size_data, 145, 230, PDF_DARK_GREEN );
}
else
{
pdf_add_text( pdf, NULL, bytes_erased, text_size_data, 145, 230, PDF_RED );
}
}
else
{
convert_double_to_string(
bytes_percent_str,
(double) ( (double) c->bytes_erased / (double) c->Calculated_real_max_size_in_bytes ) * 100 );
snprintf( bytes_erased, sizeof( bytes_erased ), "%lli, (%s%%)", c->bytes_erased, bytes_percent_str );
if( c->bytes_erased == c->Calculated_real_max_size_in_bytes )
{
pdf_add_text( pdf, NULL, bytes_erased, text_size_data, 145, 230, PDF_DARK_GREEN );
}
else
{
pdf_add_text( pdf, NULL, bytes_erased, text_size_data, 145, 230, PDF_RED );
}
}
}
pdf_set_font( pdf, "Helvetica" );
/************************************************
* rounds - How many times the method is repeated
*/
pdf_add_text( pdf, NULL, "Rounds(completed/requested):", 12, 300, 230, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
if( !strcmp( c->wipe_status_txt, "ERASED" ) )
{
snprintf( rounds, sizeof( rounds ), "%i/%i", c->round_working, nwipe_options.rounds );
pdf_add_text( pdf, NULL, rounds, text_size_data, 470, 230, PDF_DARK_GREEN );
}
else
{
snprintf( rounds, sizeof( rounds ), "%i/%i", c->round_working - 1, nwipe_options.rounds );
pdf_add_text( pdf, NULL, rounds, text_size_data, 470, 230, PDF_RED );
}
pdf_set_font( pdf, "Helvetica" );
/*******************
* HPA, DCO - LABELS
*/
pdf_add_text( pdf, NULL, "HPA/DCO:", 12, 60, 210, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_status_text, text_size_data, 155, 210, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
pdf_add_text( pdf, NULL, "HPA/DCO Size:", 12, 300, 210, PDF_GRAY );
/*******************
* Populate HPA size
*/
pdf_set_font( pdf, "Helvetica-Bold" );
if( c->HPA_status == HPA_ENABLED )
{
snprintf( HPA_size_text, sizeof( HPA_size_text ), "%lli sectors", c->HPA_sectors );
pdf_add_text( pdf, NULL, HPA_size_text, text_size_data, 390, 210, PDF_RED );
}
else
{
if( c->HPA_status == HPA_DISABLED )
{
snprintf( HPA_size_text, sizeof( HPA_size_text ), "No hidden sectors" );
pdf_add_text( pdf, NULL, HPA_size_text, text_size_data, 390, 210, PDF_DARK_GREEN );
}
else
{
if( c->HPA_status == HPA_NOT_APPLICABLE )
{
snprintf( HPA_size_text, sizeof( HPA_size_text ), "Not Applicable" );
pdf_add_text( pdf, NULL, HPA_size_text, text_size_data, 390, 210, PDF_DARK_GREEN );
}
else
{
if( c->HPA_status == HPA_UNKNOWN )
{
snprintf( HPA_size_text, sizeof( HPA_size_text ), "Unknown" );
pdf_add_text( pdf, NULL, HPA_size_text, text_size_data, 390, 210, PDF_RED );
}
}
}
}
pdf_set_font( pdf, "Helvetica" );
/*********************
* Populate HPA status (and size if not applicable, NVMe and VIRT)
*/
if( c->device_type == NWIPE_DEVICE_NVME || c->device_type == NWIPE_DEVICE_VIRT
|| c->HPA_status == HPA_NOT_APPLICABLE )
{
snprintf( HPA_status_text, sizeof( HPA_status_text ), "Not applicable" );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_status_text, text_size_data, 130, 210, PDF_DARK_GREEN );
pdf_set_font( pdf, "Helvetica" );
}
else
{
if( c->HPA_status == HPA_ENABLED )
{
snprintf( HPA_status_text, sizeof( HPA_status_text ), "Hidden sectors found!" );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_status_text, text_size_data, 130, 210, PDF_RED );
pdf_set_font( pdf, "Helvetica" );
}
else
{
if( c->HPA_status == HPA_DISABLED )
{
snprintf( HPA_status_text, sizeof( HPA_status_text ), "No hidden sectors" );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_status_text, text_size_data, 130, 210, PDF_DARK_GREEN );
pdf_set_font( pdf, "Helvetica" );
}
else
{
if( c->HPA_status == HPA_UNKNOWN )
{
snprintf( HPA_status_text, sizeof( HPA_status_text ), "Unknown" );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_status_text, text_size_data, 130, 210, PDF_RED );
pdf_set_font( pdf, "Helvetica" );
}
else
{
if( c->HPA_status == HPA_NOT_SUPPORTED_BY_DRIVE )
{
snprintf( HPA_status_text, sizeof( HPA_status_text ), "No hidden sectors **DDNSHDA" );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_status_text, text_size_data, 130, 210, PDF_DARK_GREEN );
pdf_set_font( pdf, "Helvetica" );
}
}
}
}
}
/************
* Throughput
*/
pdf_add_text( pdf, NULL, "Throughput:", 12, 300, 190, PDF_GRAY );
snprintf( throughput_txt, sizeof( throughput_txt ), "%s/sec", c->throughput_txt );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, throughput_txt, text_size_data, 370, 190, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/********
* Errors
*/
pdf_add_text( pdf, NULL, "Errors(pass/sync/verify):", 12, 60, 190, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
snprintf( errors, sizeof( errors ), "%llu/%llu/%llu", c->pass_errors, c->fsyncdata_errors, c->verify_errors );
if( c->pass_errors != 0 || c->fsyncdata_errors != 0 || c->verify_errors != 0 )
{
pdf_add_text( pdf, NULL, errors, text_size_data, 195, 190, PDF_RED );
}
else
{
pdf_add_text( pdf, NULL, errors, text_size_data, 195, 190, PDF_DARK_GREEN );
}
pdf_set_font( pdf, "Helvetica" );
/*************
* Information
*/
pdf_add_text( pdf, NULL, "Information:", 12, 60, 170, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
if( !strcmp( c->wipe_status_txt, "ERASED" ) && c->HPA_status == HPA_ENABLED )
{
pdf_add_ellipse( pdf, NULL, 160, 173, 30, 9, 2, PDF_RED, PDF_BLACK );
pdf_add_text( pdf, NULL, "Warning", text_size_data, 140, 170, PDF_YELLOW );
pdf_add_text( pdf,
NULL,
"Visible sectors erased as requested, however hidden sectors NOT erased",
text_size_data,
200,
170,
PDF_RED );
}
else
{
if( c->HPA_status == HPA_UNKNOWN )
{
pdf_add_ellipse( pdf, NULL, 160, 173, 30, 9, 2, PDF_RED, PDF_BLACK );
pdf_add_text( pdf, NULL, "Warning", text_size_data, 140, 170, PDF_YELLOW );
pdf_add_text( pdf,
NULL,
"HPA/DCO data unavailable, can not determine hidden sector status.",
text_size_data,
200,
170,
PDF_RED );
}
}
/* info descripting what bytes erased actually means */
pdf_add_text( pdf,
NULL,
"* bytes erased: The amount of drive that's been erased at least once",
text_size_data,
60,
137,
PDF_BLACK );
/* meaning of abreviation DDNSHPA */
if( c->HPA_status == HPA_NOT_SUPPORTED_BY_DRIVE )
{
pdf_add_text(
pdf, NULL, "** DDNSHPA = Drive does not support HPA/DCO", text_size_data, 60, 125, PDF_DARK_GREEN );
}
pdf_set_font( pdf, "Helvetica" );
/************************
* Technician/Operator ID
*/
pdf_add_line( pdf, NULL, 50, 120, 550, 120, 1, PDF_GRAY );
pdf_add_text( pdf, NULL, "Technician/Operator ID", 12, 50, 100, PDF_BLUE );
pdf_add_text( pdf, NULL, "Name/ID:", 12, 60, 80, PDF_GRAY );
pdf_add_text( pdf, NULL, "Signature:", 12, 300, 100, PDF_BLUE );
pdf_add_line( pdf, NULL, 360, 65, 550, 66, 1, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
/* Obtain organisational details from nwipe.conf - See conf.c */
setting = config_lookup( &nwipe_cfg, "Organisation_Details" );
if( config_setting_lookup_string( setting, "Op_Tech_Name", &op_tech_name ) )
{
pdf_add_text( pdf, NULL, op_tech_name, text_size_data, 120, 80, PDF_BLACK );
}
pdf_set_font( pdf, "Helvetica" );
/***************************************
* Populate page 2 and 3 with smart data
*/
nwipe_get_smart_data( c );
/*****************************
* Create the reports filename
*
* Sanitize the strings that we are going to use to create the report filename
* by converting any non alphanumeric characters to an underscore or hyphon
*/
replace_non_alphanumeric( end_time_text, '-' );
replace_non_alphanumeric( c->device_model, '_' );
replace_non_alphanumeric( c->device_serial_no, '_' );
snprintf( c->PDF_filename,
sizeof( c->PDF_filename ),
"%s/nwipe_report_%s_Model_%s_Serial_%s.pdf",
nwipe_options.PDFreportpath,
end_time_text,
c->device_model,
c->device_serial_no );
pdf_save( pdf, c->PDF_filename );
pdf_destroy( pdf );
return 0;
}
int nwipe_get_smart_data( nwipe_context_t* c )
{
FILE* fp;
char* pdata;
char page_title[50];
char smartctl_command[] = "smartctl -a %s";
char smartctl_command2[] = "/sbin/smartctl -a %s";
char smartctl_command3[] = "/usr/bin/smartctl -a %s";
char final_cmd_smartctl[sizeof( smartctl_command3 ) + 256];
char result[512];
char smartctl_labels_to_anonymize[][18] = {
"serial number:", "lu wwn device id:", "logical unit id:", "" /* Don't remove this empty string !, important */
};
int idx, idx2, idx3;
int x, y;
int set_return_value;
int page_number;
final_cmd_smartctl[0] = 0;
/* Determine whether we can access smartctl, required if the PATH environment is not setup ! (Debian sid 'su' as
* opposed to 'su -' */
if( system( "which smartctl > /dev/null 2>&1" ) )
{
if( system( "which /sbin/smartctl > /dev/null 2>&1" ) )
{
if( system( "which /usr/bin/smartctl > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install smartmontools !" );
}
else
{
sprintf( final_cmd_smartctl, smartctl_command3, c->device_name );
}
}
else
{
sprintf( final_cmd_smartctl, smartctl_command2, c->device_name );
}
}
else
{
sprintf( final_cmd_smartctl, smartctl_command, c->device_name );
}
if( final_cmd_smartctl[0] != 0 )
{
fp = popen( final_cmd_smartctl, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING, "nwipe_get_smart_data(): Failed to create stream to %s", smartctl_command );
set_return_value = 3;
}
else
{
x = 50; // left side of page
y = 630; // top row of page
page_number = 2;
/* Create Page 2 of the report. This shows the drives smart data
*/
page = pdf_append_page( pdf );
/* Create the header and footer for page 2, the start of the smart data */
snprintf( page_title, sizeof( page_title ), "Page %i - Smart Data", page_number );
create_header_and_footer( c, page_title );
/* Read the output a line at a time - output it. */
while( fgets( result, sizeof( result ) - 1, fp ) != NULL )
{
/* Convert the label, i.e everything before the ':' to lower case, it's required to
* convert to lower case as smartctl seems to use inconsistent case when labeling
* for serial number, i.e mostly it produces labels "Serial Number:" but occasionally
* it produces a label "Serial number:" */
idx = 0;
while( result[idx] != 0 && result[idx] != ':' )
{
/* If upper case alpha character, change to lower case */
if( result[idx] >= 'A' && result[idx] <= 'Z' )
{
result[idx] += 32;
}
idx++;
}
if( nwipe_options.quiet == 1 )
{
for( idx2 = 0; idx2 < 3; idx2++ )
{
if( strstr( result, &smartctl_labels_to_anonymize[idx2][0] ) )
{
if( ( pdata = strstr( result, ":" ) ) )
{
idx3 = 1;
while( pdata[idx3] != 0 )
{
if( pdata[idx3] != ' ' )
{
pdata[idx3] = 'X';
}
idx3++;
}
}
}
}
}
pdf_set_font( pdf, "Courier" );
pdf_add_text( pdf, NULL, result, 8, x, y, PDF_BLACK );
y -= 9;
/* Have we reached the bottom of the page yet */
if( y < 60 )
{
/* Append an extra page */
page = pdf_append_page( pdf );
page_number++;
y = 630;
/* create the header and footer for the next page */
snprintf( page_title, sizeof( page_title ), "Page %i - Smart Data", page_number );
create_header_and_footer( c, page_title );
}
}
set_return_value = 0;
}
}
else
{
set_return_value = 1;
}
return set_return_value;
}
void create_header_and_footer( nwipe_context_t* c, char* page_title )
{
/**************************************************************************
* Create header and footer on most recently added page, with the exception
* of the green tick/red icon which is set from the 'status' section below.
*/
pdf_add_text_wrap( pdf, NULL, pdf_footer, 12, 0, 30, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
pdf_add_line( pdf, NULL, 50, 50, 550, 50, 3, PDF_BLACK );
pdf_add_line( pdf, NULL, 50, 650, 550, 650, 3, PDF_BLACK );
pdf_add_image_data( pdf, NULL, 45, 665, 100, 100, bin2c_shred_db_jpg, 27063 );
pdf_set_font( pdf, "Helvetica-Bold" );
snprintf( model_header, sizeof( model_header ), " %s: %s ", "Model", c->device_model );
pdf_add_text_wrap( pdf, NULL, model_header, 14, 0, 755, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
snprintf( serial_header, sizeof( serial_header ), " %s: %s ", "S/N", c->device_serial_no );
pdf_add_text_wrap( pdf, NULL, serial_header, 14, 0, 735, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
pdf_set_font( pdf, "Helvetica" );
pdf_add_text_wrap( pdf, NULL, "Disk Erasure Report", 24, 0, 695, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
snprintf( barcode, sizeof( barcode ), "%s:%s", c->device_model, c->device_serial_no );
pdf_add_text_wrap( pdf, NULL, page_title, 14, 0, 670, PDF_BLACK, page_width, PDF_ALIGN_CENTER, &height );
pdf_add_barcode( pdf, NULL, PDF_BARCODE_128A, 100, 790, 400, 25, barcode, PDF_BLACK );
/**********************************************************
* Display the appropriate status icon, top right on page on
* most recently added page.
*/
switch( status_icon )
{
case STATUS_ICON_GREEN_TICK:
/* Display the green tick icon in the header */
pdf_add_image_data( pdf, NULL, 450, 665, 100, 100, bin2c_te_jpg, 54896 );
break;
case STATUS_ICON_YELLOW_EXCLAMATION:
/* Display the yellow exclamation icon in the header */
pdf_add_image_data( pdf, NULL, 450, 665, 100, 100, bin2c_nwipe_exclamation_jpg, 65791 );
break;
case STATUS_ICON_RED_CROSS:
// Display the red cross in the header
pdf_add_image_data( pdf, NULL, 450, 665, 100, 100, bin2c_redcross_jpg, 60331 );
break;
default:
break;
}
}

52
src/create_pdf.h Normal file
View File

@@ -0,0 +1,52 @@
/*.
* create_pdf.h: The header file for the pdf creation routines
*
* Copyright https://github.com/PartialVolume/shredos.x86_64
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef CREATE_PDF_H_
#define CREATE_PDF_H_
#define MAX_PDF_FOOTER_TEXT_LENGTH 100
#define STATUS_ICON_GREEN_TICK 1
#define STATUS_ICON_YELLOW_EXCLAMATION 2
#define STATUS_ICON_RED_CROSS 3
/* Additional colors that supplement the standard colors in pdfgen.h
*/
/*! Utility macro to provide gray */
#define PDF_DARK_GREEN PDF_RGB( 0, 0x64, 0 )
/*! Utility macro to provide gray */
#define PDF_GRAY PDF_RGB( 0x5A, 0x5A, 0x5A )
/*! Utility macro to provide gray */
#define PDF_YELLOW PDF_RGB( 0xFF, 0xFF, 0x5A )
/**
* Create the disk erase report in PDF format
* @param pointer to a drive context
* @return returns 0 on success < 1 on error
*/
int create_pdf( nwipe_context_t* ptr );
int nwipe_get_smart_data( nwipe_context_t* );
void create_header_and_footer( nwipe_context_t*, char* );
#endif /* CREATE_PDF_H_ */

713
src/customers.c Normal file
View File

@@ -0,0 +1,713 @@
/*
* ****************************************************************************
* customers.c: Functions related to customer processing for the PDF erasure *
* certificate. *
* ****************************************************************************
*
* Copyright PartialVolume <https://github.com/PartialVolume>.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <stdio.h>
#include "nwipe.h"
#include "context.h"
#include "gui.h"
#include "logging.h"
#include "conf.h"
#include "customers.h"
#include <sys/stat.h>
void customer_processes( int mode )
{
/* This function reads the customers.csv file, counts the number of lines,
* converts line feeds to NULL and constructs a array of pointers that point
* to the variable length strings.
*
* Depending on the value of mode the pointer array is passed to either
* the select_customers() or delete_customer() functions.
*/
int idx;
int idx2;
FILE* fptr;
struct stat st;
intmax_t size = 0;
int lines;
int list_idx;
int current_list_size;
size_t result_size;
extern char nwipe_customers_file[];
/* Determine size of customers.csv file */
stat( nwipe_customers_file, &st );
size = st.st_size;
current_list_size = 0;
nwipe_customers_buffer_t raw_buffer = (nwipe_customers_buffer_t) calloc( 1, size + 1 );
/* Allocate storage for the contents of customers.csv */
nwipe_customers_buffer_t buffer = (nwipe_customers_buffer_t) calloc( 1, size + 1 );
/* Allocate storage for the processed version of customers.csv,
* i.e we convert the csv format to strings without the quotes
* and semi colon delimiters
*/
nwipe_customers_pointers_t list = (nwipe_customers_pointers_t) calloc( 1, sizeof( char* ) );
current_list_size += sizeof( char* );
/* Open customers.csv */
if( ( fptr = fopen( nwipe_customers_file, "rb" ) ) == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Unable to open %s", nwipe_customers_file );
free( buffer );
free( *list );
return;
}
/* Read the customers.csv file and populate the list array with the data */
result_size = fread( raw_buffer, size, 1, fptr );
fclose( fptr );
/* Validate csv contents. With the exception of line feeds,
* remove non printable characters and move to a secondary buffer.
*/
idx = 0;
idx2 = 0;
while( idx < size )
{
if( ( raw_buffer[idx] > 0x1F && raw_buffer[idx] < 0x7F ) || raw_buffer[idx] == 0x0A )
{
/* copy printable characters and line feeds */
buffer[idx2++] = raw_buffer[idx];
}
idx++;
}
/* Construct a array of pointers that point to each line of the csv file
*/
idx = 0;
lines = 0;
list_idx = 0;
while( idx < size )
{
if( buffer[idx] == 0x0A )
{
buffer[idx] = 0;
/* increment the line counter, but don't count
* the first line as that is the csv header line.
*/
if( idx != 0 )
{
lines++;
/* Change the line feed to a NULL, string terminator */
buffer[idx] = 0;
/* Save the pointer to the first data line of the csv. */
list[list_idx++] = &buffer[idx + 1];
current_list_size += sizeof( char* );
/* Expand allocated memory by the size of one pointer */
if( ( list = realloc( list, current_list_size ) ) == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Unable to realloc customer list array, out of memory?" );
break;
}
current_list_size += sizeof( char* );
}
}
else
{
/* Replace colons with commas */
if( buffer[idx] == ';' )
{
buffer[idx] = ',';
}
}
idx++;
}
/* Sync lines variable to actual number of lines */
if( lines > 0 )
lines--;
if( idx == size )
{
/* makesure the very last entry is NULL terminated */
buffer[idx] = 0;
}
/* Select the requested mode, customer or delete customer.
*/
switch( mode )
{
case SELECT_CUSTOMER:
select_customers( lines, list );
break;
case DELETE_CUSTOMER:
delete_customer( lines, list );
break;
}
free( raw_buffer );
free( buffer );
}
void select_customers( int count, char** customer_list_array )
{
int selected_entry = 0;
char window_title[] = " Select Customer For PDF Report ";
/* Display the customer selection window */
nwipe_gui_list( count, window_title, customer_list_array, &selected_entry );
/* Save the selected customer details to nwipe's config file /etc/nwipe/nwipe.conf
* If selected entry equals 0, then the customer did not select an entry so skip save.
*/
if( selected_entry != 0 )
{
save_selected_customer( &customer_list_array[selected_entry - 1] );
}
}
void delete_customer( int count, char** customer_list_array )
{
char window_title[] = " Delete Customer ";
int selected_entry = 0;
nwipe_gui_list( count, window_title, customer_list_array, &selected_entry );
if( selected_entry != 0 )
{
delete_customer_csv_entry( &selected_entry );
}
}
void write_customer_csv_entry( char* customer_name,
char* customer_address,
char* customer_contact_name,
char* customer_contact_phone )
{
/**
* Write the attached strings in csv format to the first
* line after the header (line 2 of file)
*/
FILE* fptr = 0;
FILE* fptr2 = 0;
size_t result_size;
/* General index variables */
int idx1, idx2, idx3;
/* Length of the new customer line */
int csv_line_length;
/* Size of the new buffer that holds old contents plus new entry */
int new_customers_buffer_size;
struct stat st;
extern char nwipe_customers_file[];
extern char nwipe_customers_file_backup[];
extern char nwipe_customers_file_backup_tmp[];
intmax_t existing_file_size = 0;
/* pointer to the new customer entry in csv format. */
char* csv_buffer = 0;
/* pointer to the buffer containing the existing customer file */
char* customers_buffer = 0;
/* pointer to the buffer containing the existing customer file plus the new entry */
char* new_customers_buffer = 0;
size_t new_customers_buffer_length;
/* Determine length of all four strings and malloc sufficient storage + 12 = 8 quotes + three colons + null */
csv_line_length = strlen( customer_name ) + strlen( customer_address ) + strlen( customer_contact_name )
+ strlen( customer_contact_phone ) + 12;
if( !( csv_buffer = calloc( 1, csv_line_length == 0 ) ) )
{
nwipe_log( NWIPE_LOG_ERROR, "func:nwipe_gui_add_customer:csv_buffer, calloc returned NULL " );
}
else
{
/* Determine current size of the csv file containing the customers */
stat( nwipe_customers_file, &st );
existing_file_size = st.st_size;
/* calloc sufficient storage to hold the existing customers file */
if( !( customers_buffer = calloc( 1, existing_file_size + 1 ) ) )
{
nwipe_log( NWIPE_LOG_ERROR, "func:nwipe_gui_add_customer:customers_buffer, calloc returned NULL " );
}
else
{
/* create a third buffer which is the combined size of the previous two, i.e existing file size, plus the
* new customer entry + 1 (NULL) */
new_customers_buffer_size = existing_file_size + csv_line_length + 1;
if( !( new_customers_buffer = calloc( 1, new_customers_buffer_size ) ) )
{
nwipe_log( NWIPE_LOG_ERROR, "func:nwipe_gui_add_customer:customers_buffer, calloc returned NULL " );
}
else
{
/* Read the whole of customers.csv file into customers_buffer */
if( ( fptr = fopen( nwipe_customers_file, "rb" ) ) == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Unable to open %s", nwipe_customers_file );
}
else
{
/* Read the customers.csv file and populate the list array with the data */
if( ( result_size = fread( customers_buffer, existing_file_size, 1, fptr ) ) != 1 )
{
nwipe_log(
NWIPE_LOG_ERROR,
"func:nwipe_gui_add_customer:Error reading customers file, # bytes read not as expected "
"%i bytes",
result_size );
}
else
{
/* --------------------------------------------------------------------
* Read the first line which is the csv header from the existing customer
* buffer & write to the new buffer.
*/
idx1 = 0; // Index for the current csv buffer
idx2 = 0; // Index for the new csv buffer
idx3 = 0; // Index for new customer fields
while( idx1 < existing_file_size && idx2 < new_customers_buffer_size )
{
if( customers_buffer[idx1] != LINEFEED )
{
new_customers_buffer[idx2++] = customers_buffer[idx1++];
}
else
{
new_customers_buffer[idx2++] = LINEFEED;
break;
}
}
/* --------------------------------------------------------------------------
* Copy the new customer name entry so it is immediately after the csv header
*/
/* Start with first entries opening quote */
new_customers_buffer[idx2++] = '"';
/* Copy the customer_name string */
while( idx3 < FIELD_LENGTH && idx2 < new_customers_buffer_size && customer_name[idx3] != 0 )
{
new_customers_buffer[idx2++] = customer_name[idx3++];
}
/* Close customer name field with a quote */
new_customers_buffer[idx2++] = '"';
/* Insert field delimiters, we use a semi-colon, not a comma ';' */
new_customers_buffer[idx2++] = ';';
/* -----------------------------------------------------------------------------
* Copy the new customer address entry so it is immediately after the csv header
*/
idx3 = 0;
/* Start with first entries opening quote */
new_customers_buffer[idx2++] = '\"';
/* Copy the customer_name string */
while( idx3 < FIELD_LENGTH && idx2 < new_customers_buffer_size && customer_address[idx3] != 0 )
{
new_customers_buffer[idx2++] = customer_address[idx3++];
}
/* Close customer name field with a quote */
new_customers_buffer[idx2++] = '\"';
/* Insert field delimiters, we use a semi-colon, not a comma ';' */
new_customers_buffer[idx2++] = ';';
/* -----------------------------------------------------------------------------
* Copy the new customer contact name entry so it is immediately after the csv header
*/
idx3 = 0;
/* Start with first entries opening quote */
new_customers_buffer[idx2++] = '\"';
/* Copy the customer_name string */
while( idx3 < FIELD_LENGTH && idx2 < new_customers_buffer_size
&& customer_contact_name[idx3] != 0 )
{
new_customers_buffer[idx2++] = customer_contact_name[idx3++];
}
/* Close customer name field with a quote */
new_customers_buffer[idx2++] = '\"';
/* Insert field delimiters, we use a semi-colon, not a comma ';' */
new_customers_buffer[idx2++] = ';';
/* -----------------------------------------------------------------------------
* Copy the new customer contact phone entry so it is immediately after the csv header
*/
idx3 = 0;
/* Start with first entries opening quote */
new_customers_buffer[idx2++] = '\"';
/* Copy the customer_name string */
while( idx3 < FIELD_LENGTH && idx2 < new_customers_buffer_size
&& customer_contact_phone[idx3] != 0 )
{
new_customers_buffer[idx2++] = customer_contact_phone[idx3++];
}
/* Close customer name field with a quote */
new_customers_buffer[idx2++] = '\"';
/* Insert a line feed to finish the new entry */
new_customers_buffer[idx2++] = LINEFEED;
/* skip any LINEFEEDS in the existing customer entry as we just inserted one */
while( customers_buffer[idx1] != 0 && customers_buffer[idx1] == LINEFEED )
{
idx1++;
}
/* -------------------------------------------------------------------------------
* Now copy the existing customer entries, if any, immediately after the new entry
*/
while( idx1 < existing_file_size && idx2 < new_customers_buffer_size )
{
/* Removes any nulls when copying and pasting, which would break this process? */
if( customers_buffer[idx1] == 0 )
{
while( idx1 < existing_file_size && customers_buffer[idx1] == 0 )
{
idx1++;
}
}
new_customers_buffer[idx2++] = customers_buffer[idx1++];
}
/* Rename the customers.csv file to customers.csv.backup */
if( rename( nwipe_customers_file, nwipe_customers_file_backup_tmp ) != 0 )
{
nwipe_log( NWIPE_LOG_ERROR,
"Unable to rename %s to %s",
nwipe_customers_file,
nwipe_customers_file_backup_tmp );
}
else
{
/* Create/open the customers.csv file */
if( ( fptr2 = fopen( nwipe_customers_file, "wb" ) ) == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Unable to open %s", nwipe_customers_file );
}
else
{
/* write the new customers.csv file */
new_customers_buffer_length = strlen( new_customers_buffer );
if( ( result_size = fwrite(
new_customers_buffer, sizeof( char ), new_customers_buffer_length, fptr2 ) )
!= new_customers_buffer_length )
{
nwipe_log(
NWIPE_LOG_ERROR,
"func:write_customer_csv_entry:fwrite: Error result_size = %i not as expected",
result_size );
}
else
{
/* Remove the customer.csv.backup file if it exists */
if( remove( nwipe_customers_file_backup ) != 0 )
{
nwipe_log(
NWIPE_LOG_ERROR, "Unable to remove %s", nwipe_customers_file_backup_tmp );
}
else
{
/* Rename the customers.csv.backup.tmp file to customers.csv.backup */
if( rename( nwipe_customers_file_backup_tmp, nwipe_customers_file_backup )
!= 0 )
{
nwipe_log( NWIPE_LOG_ERROR,
"Unable to rename %s to %s",
nwipe_customers_file,
nwipe_customers_file_backup_tmp );
}
nwipe_log( NWIPE_LOG_INFO,
"Succesfully write new customer entry to %s",
nwipe_customers_file );
}
}
fclose( fptr2 );
}
}
fclose( fptr );
}
}
free( new_customers_buffer );
}
free( customers_buffer );
}
free( csv_buffer );
}
}
void delete_customer_csv_entry( int* selected_entry )
{
/**
* Deletes a line from the csv file. The line to be deleted is determined
* by the value of selected_entry
*/
FILE* fptr = 0;
FILE* fptr2 = 0;
size_t result_size;
struct stat st;
extern char nwipe_customers_file[];
extern char nwipe_customers_file_backup[];
extern char nwipe_customers_file_backup_tmp[];
intmax_t existing_file_size = 0;
int linecount;
/* General index variables */
int idx1, idx2, idx3;
/* pointer to the buffer containing the existing customer file */
char* customers_buffer = 0;
/* pointer to the buffer containing the existing customer minus the deleted entry */
char* new_customers_buffer = 0;
int status_flag = 0;
size_t new_customers_buffer_length;
/* Determine current size of the csv file containing the customers */
stat( nwipe_customers_file, &st );
existing_file_size = st.st_size;
/* calloc sufficient storage to hold the existing customers file */
if( !( customers_buffer = calloc( 1, existing_file_size + 1 ) ) )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:nwipe_gui_delete_customer_csv_entry:customers_buffer, calloc returned NULL " );
}
else
{
/* create a second buffer which is identical in size to the first, it will store the customer
* csv file minus the one selected entry
*/
if( !( new_customers_buffer = calloc( 1, existing_file_size + 1 ) ) )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:nwipe_gui_delete_customer_csv_entry:customers_buffer, calloc returned NULL " );
}
else
{
/* Read the whole of customers.csv file into customers_buffer */
if( ( fptr = fopen( nwipe_customers_file, "rb" ) ) == NULL )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:nwipe_gui_delete_customer_csv_entry:Unable to open %s",
nwipe_customers_file );
}
else
{
/* Read the customers.csv file and populate the list array with the data */
if( ( result_size = fread( customers_buffer, existing_file_size, 1, fptr ) ) != 1 )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:nwipe_gui_delete_customer_csv_entry:Error reading customers file, # elements read "
"not as expected "
"%i elements",
result_size );
}
else
{
/* --------------------------------------------------------------------
* Read the first line which is the csv header from the existing customer
* buffer & write to the new buffer.
*/
idx1 = 0; // Index for the current csv buffer
idx2 = 0; // Index for the new csv buffer
linecount = 1; // count the lines in the csv file starting at line 1
while( idx1 < existing_file_size && idx2 < existing_file_size )
{
if( customers_buffer[idx1] != LINEFEED )
{
new_customers_buffer[idx2++] = customers_buffer[idx1++];
}
else
{
new_customers_buffer[idx2++] = customers_buffer[idx1++];
break;
}
}
/* -------------------------------------------------------------------------------
* Now copy the existing customer entries, counting the lines as we go and when we
* get to the the line selected for deletion we skip over it and then carry on
* copying.
*/
while( idx1 < existing_file_size && idx2 < existing_file_size )
{
/* Don't copy nulls */
if( customers_buffer[idx1] == 0 )
{
idx1++;
continue;
}
/* Is this the line to delete? */
if( linecount == *selected_entry )
{
/* skip all the characters in this line */
while( idx1 < existing_file_size && customers_buffer[idx1] != LINEFEED )
{
idx1++;
}
/* skip the trailing linefeed if it exists, may not exist if last line */
if( customers_buffer[idx1] == LINEFEED )
{
idx1++;
}
linecount++;
nwipe_log( NWIPE_LOG_INFO, "Deleted customer entry from cache" );
status_flag = 1;
}
else
{
/* Is the character a LINEFEED? */
if( customers_buffer[idx1] == LINEFEED )
{
linecount++;
}
/* Copy a character */
new_customers_buffer[idx2++] = customers_buffer[idx1++];
}
}
/* Rename the customers.csv file to customers.csv.backup */
if( rename( nwipe_customers_file, nwipe_customers_file_backup_tmp ) != 0 )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:delete_customer_csv_entry:Unable to rename %s to %s",
nwipe_customers_file,
nwipe_customers_file_backup_tmp );
}
else
{
/* Create/open the customers.csv file */
if( ( fptr2 = fopen( nwipe_customers_file, "wb" ) ) == NULL )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:delete_customer_csv_entry:Unable to open %s",
nwipe_customers_file );
}
else
{
/* write the new customers.csv file */
new_customers_buffer_length = strlen( new_customers_buffer );
if( ( result_size = fwrite(
new_customers_buffer, sizeof( char ), new_customers_buffer_length, fptr2 ) )
!= new_customers_buffer_length )
{
nwipe_log(
NWIPE_LOG_ERROR,
"func:delete_customer_csv_entry:fwrite: Error result_size = %i not as expected",
result_size );
}
else
{
/* Remove the customer.csv.backup file if it exists */
if( remove( nwipe_customers_file_backup ) != 0 )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:delete_customer_csv_entry:Unable to remove %s",
nwipe_customers_file_backup_tmp );
}
else
{
/* Rename the customers.csv.backup.tmp file to customers.csv.backup */
if( rename( nwipe_customers_file_backup_tmp, nwipe_customers_file_backup ) != 0 )
{
nwipe_log( NWIPE_LOG_ERROR,
"func:delete_customer_csv_entry:Unable to rename %s to %s",
nwipe_customers_file,
nwipe_customers_file_backup_tmp );
}
if( status_flag == 1 )
{
nwipe_log(
NWIPE_LOG_INFO, "Deleted customer entry in %s", nwipe_customers_file );
}
else
{
nwipe_log( NWIPE_LOG_INFO,
"Failed to delete customer entry in %s",
nwipe_customers_file );
}
}
}
fclose( fptr2 );
}
}
}
fclose( fptr );
}
free( new_customers_buffer );
}
free( customers_buffer );
}
}

42
src/customers.h Normal file
View File

@@ -0,0 +1,42 @@
/*
* ****************************************************************************
* customers.h: Functions related to customer processing for the PDF erasure *
* certificate. *
* ****************************************************************************
*
* Copyright PartialVolume <https://github.com/PartialVolume>.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef CUSTOMERS_H_INCLUDED
#define CUSTOMERS_H_INCLUDED
void customer_processes( int );
void select_customers( int, char** );
void delete_customer();
void add_customer();
void write_customer_csv_entry( char*, char*, char*, char* );
void delete_customer_csv_entry( int* );
typedef char* nwipe_customers_buffer_t;
typedef char** nwipe_customers_pointers_t;
#define SELECT_CUSTOMER 1
#define DELETE_CUSTOMER 2
#define LINEFEED 0x0A
#endif // CUSTOMERS_H_INCLUDED

View File

@@ -2,9 +2,9 @@
* device.c: Device routines for nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
@@ -16,120 +16,902 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
/* Why is this needed? Segfaults without it */
#include <netinet/in.h>
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#include <stdio.h>
#include <stdint.h>
#include <ctype.h>
#include "nwipe.h"
#include "context.h"
#include "device.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 "hpa_dco.h"
#include "miscellaneous.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 );
extern int terminate_signal;
int nwipe_device_scan( nwipe_context_t*** c )
{
/**
* Scans the 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
* @returns The number of strings in the device_names array.
*
*/
/**
* 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_context_t
* @returns The number of strings in the device_names array.
*
*/
PedDevice* dev = NULL;
ped_device_probe_all();
int dcount = 0;
PedDevice* dev = NULL;
ped_device_probe_all();
while ((dev = ped_device_get_next (dev)))
int dcount = 0;
while( ( dev = ped_device_get_next( dev ) ) )
{
/* to have some progress indication. can help if there are many/slow disks */
fprintf( stderr, "." );
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 )
{
if (check_device(c, dev, dcount))
dcount++;
}
break;
}
}
/* Return the number of devices that were found. */
return dcount;
/* Return the number of devices that were found. */
return dcount;
} /* nwipe_device_scan */
int nwipe_device_get( nwipe_context_t*** c, char **devnamelist, int ndevnames )
int nwipe_device_get( nwipe_context_t*** c, char** devnamelist, int ndevnames )
{
/**
* Gets information about devices
*
* @parameter device_names A reference to a null array pointer.
* @parameter devnamelist An array of string pointers to the device names
* @parameter ndevnames Number of elements in devnamelist
* @modifies device_names Populates device_names with an array of nwipe_contect_t
* @returns The number of strings in the device_names array.
*
*/
PedDevice* dev = NULL;
PedDevice* dev = NULL;
int i;
int dcount = 0;
int i;
int dcount = 0;
for(i = 0; i < ndevnames; i++) {
for( i = 0; i < ndevnames; i++ )
{
/* to have some progress indication. can help if there are many/slow disks */
fprintf( stderr, "." );
dev = ped_device_get(devnamelist[i]);
if (!dev)
break;
dev = ped_device_get( devnamelist[i] );
if( !dev )
{
nwipe_log( NWIPE_LOG_WARNING, "Device %s not found", devnamelist[i] );
continue;
}
if (check_device(c, dev, dcount))
dcount++;
}
if( check_device( c, dev, dcount ) )
dcount++;
/* Return the number of devices that were found. */
return 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. */
return dcount;
} /* nwipe_device_get */
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;
/* Populate this struct, then assign it to overall array of structs. */
nwipe_context_t* next_device;
int fd;
int idx;
int r;
char tmp_serial[NWIPE_SERIALNUMBER_LENGTH + 1];
nwipe_device_t bus;
int is_ssd;
int check_HPA; // a flag that indicates whether we check for a HPA on this device
/* Try opening the device to see if it's valid. Close on completion. */
if (!ped_device_open(dev))
return 0;
ped_device_close(dev);
/* New device, reallocate memory for additional struct pointer */
*c = realloc (*c, (dcount+1) * sizeof(nwipe_context_t *));
next_device = malloc (sizeof(nwipe_context_t));
bus = 0;
/* Check the allocation. */
if( ! next_device )
/* Check whether this drive is on the excluded drive list ? */
idx = 0;
while( idx < MAX_NUMBER_EXCLUDED_DRIVES )
{
if( !strcmp( dev->path, nwipe_options.exclude[idx++] ) )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to create the array of enumeration contexts." );
return 0;
nwipe_log( NWIPE_LOG_NOTICE, "Device %s excluded as per command line option -e", dev->path );
return 0;
}
}
/* Zero the allocation. */
memset( next_device , 0, sizeof( nwipe_context_t ) );
/* 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 */
/* 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);
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, &is_ssd, tmp_serial );
(*c)[dcount] = next_device;
return 1;
/* See nwipe_get_device_bus_type_and_serialno() function for meaning of these codes */
if( r == 0 || ( r >= 3 && r <= 6 ) )
{
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 ) )
{
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* ) );
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;
}
/* Zero the allocation. */
memset( next_device, 0, sizeof( nwipe_context_t ) );
/* Get device information */
next_device->device_model = dev->model;
remove_ATA_prefix( next_device->device_model );
/* Some USB adapters have drive model endian swapped, pattern match and fix */
fix_endian_model_names( next_device->device_model );
/* full device name, i.e. /dev/sda */
next_device->device_name = dev->path;
/* remove /dev/ from device, right justify and prefix name so string length is eight characters */
nwipe_strip_path( next_device->device_name_without_path, next_device->device_name );
/* To maintain column alignment in the gui we have to remove /dev/ from device names that
* exceed eight characters including the /dev/ path.
*/
if( strlen( next_device->device_name ) > MAX_LENGTH_OF_DEVICE_STRING )
{
strcpy( next_device->gui_device_name, next_device->device_name_without_path );
}
else
{
strcpy( next_device->gui_device_name, next_device->device_name );
}
next_device->device_size = dev->length * dev->sector_size;
next_device->device_sector_size = dev->sector_size; // logical sector size
next_device->device_block_size = dev->sector_size; // set as logical but could be a multiple of logical sector size
next_device->device_phys_sector_size = dev->phys_sector_size; // physical sector size
next_device->device_size_in_sectors = next_device->device_size / next_device->device_sector_size;
next_device->device_size_in_512byte_sectors = next_device->device_size / 512;
Determine_C_B_nomenclature( next_device->device_size, next_device->device_size_txt, NWIPE_DEVICE_SIZE_TXT_LENGTH );
next_device->device_size_text = next_device->device_size_txt;
next_device->result = -2;
/* Attempt to get serial number of device.
*/
next_device->device_serial_no[0] = 0; /* initialise the serial number */
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 );
for( idx = 0; idx < NWIPE_SERIALNUMBER_LENGTH; 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[idx] = 0;
// Remove leading/trailing whitespace from serial number and left justify.
trim( (char*) next_device->device_serial_no );
/* if we couldn't obtain serial number by using the above method .. try this */
r = nwipe_get_device_bus_type_and_serialno(
next_device->device_name, &next_device->device_type, &next_device->device_is_ssd, tmp_serial );
/* If serial number & bus retrieved (0) OR unsupported USB bus identified (5) */
if( r == 0 || r == 5 )
{
/* If the serial number hasn't already been populated */
if( next_device->device_serial_no[0] == 0 )
{
strncpy( next_device->device_serial_no, tmp_serial, NWIPE_SERIALNUMBER_LENGTH );
}
}
/* Does the user want to anonymize serial numbers ? */
if( nwipe_options.quiet )
{
if( next_device->device_serial_no[0] == 0 )
{
strncpy( next_device->device_serial_no, "????????????????????", NWIPE_SERIALNUMBER_LENGTH + 1 );
}
else
{
strncpy( next_device->device_serial_no, "XXXXXXXXXXXXXXXXXXXX", NWIPE_SERIALNUMBER_LENGTH + 1 );
}
}
/* strncpy would have copied the null terminator BUT just to be sure, just in case somebody changes the length
* of those strings we should explicitly terminate the string */
next_device->device_serial_no[NWIPE_SERIALNUMBER_LENGTH] = 0;
/* Initialise the variables that toggle the [size][temp c] with [HPA status]
* Not currently used, but may be used in the future or for other purposes
*/
next_device->HPA_toggle_time = time( NULL );
next_device->HPA_display_toggle_state = 0;
/* Initialise the HPA variables for this device
*/
next_device->HPA_reported_set = 0;
next_device->HPA_reported_real = 0;
next_device->DCO_reported_real_max_sectors = 0;
next_device->HPA_status = HPA_NOT_APPLICABLE;
/* All device strings should be 4 characters, prefix with space if under 4 characters
* We also set a switch for certain devices to check for the host protected area (HPA)
*/
check_HPA = 0;
// WARNING TEMP LINE WARNING
// next_device->device_type = NWIPE_DEVICE_ATA;
switch( next_device->device_type )
{
case NWIPE_DEVICE_UNKNOWN:
strcpy( next_device->device_type_str, " UNK" );
check_HPA = 1;
break;
case NWIPE_DEVICE_IDE:
strcpy( next_device->device_type_str, " IDE" );
check_HPA = 1;
break;
case NWIPE_DEVICE_SCSI:
strcpy( next_device->device_type_str, " SCSI" );
check_HPA = 1;
break;
case NWIPE_DEVICE_COMPAQ:
strcpy( next_device->device_type_str, " CPQ" );
break;
case NWIPE_DEVICE_USB:
strcpy( next_device->device_type_str, " USB" );
check_HPA = 1;
break;
case NWIPE_DEVICE_IEEE1394:
strcpy( next_device->device_type_str, "1394" );
break;
case NWIPE_DEVICE_ATA:
strcpy( next_device->device_type_str, " ATA" );
check_HPA = 1;
break;
case NWIPE_DEVICE_NVME:
strcpy( next_device->device_type_str, "NVME" );
break;
case NWIPE_DEVICE_VIRT:
strcpy( next_device->device_type_str, "VIRT" );
break;
case NWIPE_DEVICE_SAS:
strcpy( next_device->device_type_str, " SAS" );
check_HPA = 1;
break;
case NWIPE_DEVICE_MMC:
strcpy( next_device->device_type_str, " MMC" );
break;
}
if( next_device->device_is_ssd )
{
strcpy( next_device->device_type_str + 4, "-SSD" );
}
else
{
strcpy( next_device->device_type_str + 4, " " );
}
if( strlen( (const char*) next_device->device_serial_no ) )
{
snprintf( next_device->device_label,
NWIPE_DEVICE_LABEL_LENGTH,
"%s %s [%s] %s/%s",
next_device->device_name,
next_device->device_type_str,
next_device->device_size_text,
next_device->device_model,
next_device->device_serial_no );
}
else
{
snprintf( next_device->device_label,
NWIPE_DEVICE_LABEL_LENGTH,
"%s %s [%s] %s",
next_device->device_name,
next_device->device_type_str,
next_device->device_size_text,
next_device->device_model );
}
nwipe_log( NWIPE_LOG_NOTICE,
"Found %s, %s, %s, %s, S/N=%s",
next_device->device_name,
next_device->device_type_str,
next_device->device_model,
next_device->device_size_text,
next_device->device_serial_no );
nwipe_log( NWIPE_LOG_INFO,
"%s, sector(logical)/block(physical) sizes %i/%i",
next_device->device_name,
dev->sector_size,
dev->phys_sector_size );
/******************************
* Check for hidden sector_size
*/
if( check_HPA == 1 )
{
hpa_dco_status( next_device );
}
/* print an empty line to separate the drives in the log */
nwipe_log( NWIPE_LOG_INFO, " " );
( *c )[dcount] = next_device;
return 1;
}
/* eof */
/* Remove leading/trailing 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;
}
int nwipe_get_device_bus_type_and_serialno( char* device, nwipe_device_t* bus, int* is_ssd, char* serialnumber )
{
/* The caller provides a string that contains the device, i.e. /dev/sdc, also a pointer
* to an integer (bus type), another pointer to an integer (is_ssd), and finally a 21 byte
* character string which this function populates with the serial number (20 characters + null terminator).
*
* The function populates the bus integer and serial number strings for the given device.
* Results for bus would typically be ATA or USB see nwipe_device_t in context.h
*
* Return Values:
* 0 = Success
* 1 = popen failed to create stream for readlink
* 2 = readlink exit code not 0, see nwipe logs
* 3 = popen failed to create stream for smartctl
* 4 = smartctl command not found, install smartmontools
* 5 = smartctl detected unsupported USB to IDE/SATA adapter
* 6 = All other errors !
*
*/
FILE* fp;
int r; // A result buffer.
int idx_src;
int idx_dest;
int device_len;
int set_return_value;
int exit_status;
int idx;
int idx2;
char readlink_command[] = "readlink /sys/block/%s";
char readlink_command2[] = "/usr/bin/readlink /sys/block/%s";
char readlink_command3[] = "/sbin/readlink /sys/block/%s";
char smartctl_command[] = "smartctl -i %s";
char smartctl_command2[] = "/sbin/smartctl -i %s";
char smartctl_command3[] = "/usr/bin/smartctl -i %s";
char device_shortform[50];
char result[512];
char final_cmd_readlink[sizeof( readlink_command ) + sizeof( device_shortform )];
char final_cmd_smartctl[sizeof( smartctl_command ) + 256];
char* pResult;
char smartctl_labels_to_anonymize[][18] = {
"serial number:", "lu wwn device id:", "logical unit id:", "" /* Don't remove this empty string !, important */
};
/* Initialise return value */
set_return_value = 0;
*bus = 0;
/* Scan device name and if device is for instance /dev/sdx then convert to sdx
* If already sdx then just copy. */
idx_dest = 0;
device_shortform[idx_dest] = 0;
device_len = strlen( device );
idx_src = device_len;
while( idx_src >= 0 )
{
if( device[idx_src] == '/' || idx_src == 0 )
{
idx_src++;
/* Now scan forwards copying the short form device i.e sdc */
while( idx_src < device_len )
{
device_shortform[idx_dest++] = device[idx_src++];
}
break;
}
else
{
idx_src--;
}
}
device_shortform[idx_dest] = 0;
final_cmd_readlink[0] = 0;
/* Determine whether we can access readlink, required if the PATH environment is not setup ! (Debian sid 'su' as
* opposed to 'su -' */
if( system( "which readlink > /dev/null 2>&1" ) )
{
if( system( "which /sbin/readlink > /dev/null 2>&1" ) )
{
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 immediately if --nousb specified. Readlink is a requirement for this option. */
if( nwipe_options.nousb )
{
return set_return_value;
}
}
else
{
sprintf( final_cmd_readlink, readlink_command3, device_shortform );
}
}
else
{
sprintf( final_cmd_readlink, readlink_command2, device_shortform );
}
}
else
{
sprintf( final_cmd_readlink, readlink_command, device_shortform );
}
if( final_cmd_readlink[0] != 0 )
{
fp = popen( final_cmd_readlink, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno: Failed to create stream to %s",
readlink_command );
set_return_value = 1;
}
if( fp != NULL )
{
/* Read the output a line at a time - output it. */
if( fgets( result, sizeof( result ) - 1, fp ) != NULL )
{
if( nwipe_options.verbose )
{
strip_CR_LF( result );
nwipe_log( NWIPE_LOG_DEBUG, "Readlink: %s", result );
}
/* Scan the readlink results for bus types, i.e. USB or ATA
* Example: readlink
* /sys/block/sdd../devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/host6/target6:0:0/6:0:0:0/block/sdd
*/
if( strstr( result, "/usb" ) != 0 )
{
*bus = NWIPE_DEVICE_USB;
}
else
{
if( strstr( result, "/ata" ) != 0 )
{
*bus = NWIPE_DEVICE_ATA;
}
else
{
if( strstr( result, "/nvme/" ) != 0 )
{
*bus = NWIPE_DEVICE_NVME;
}
else
{
if( strstr( result, "/virtual/" ) != 0 )
{
*bus = NWIPE_DEVICE_VIRT;
}
else
{
if( strstr( result, "/mmcblk" ) != 0 )
{
*bus = NWIPE_DEVICE_MMC;
}
}
}
}
}
}
/* close */
r = pclose( fp );
if( r > 0 )
{
exit_status = WEXITSTATUS( r );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno(): readlink failed, \"%s\" exit status = %u",
final_cmd_readlink,
exit_status );
}
if( exit_status == 127 )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install Readlink recommended !" );
set_return_value = 2;
if( nwipe_options.nousb )
{
return set_return_value;
}
}
}
}
}
/*
* Retrieve smartmontools drive information if USB bridge supports it, so we can retrieve the serial number of the
* drive that's on the other side of the USB bridge.. */
final_cmd_smartctl[0] = 0;
/* Determine whether we can access smartctl, required if the PATH environment is not setup ! (Debian sid 'su' as
* opposed to 'su -' */
if( system( "which smartctl > /dev/null 2>&1" ) )
{
if( system( "which /sbin/smartctl > /dev/null 2>&1" ) )
{
if( system( "which /usr/bin/smartctl > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install smartmontools !" );
}
else
{
sprintf( final_cmd_smartctl, smartctl_command3, device );
}
}
else
{
sprintf( final_cmd_smartctl, smartctl_command2, device );
}
}
else
{
sprintf( final_cmd_smartctl, smartctl_command, device );
}
if( final_cmd_smartctl[0] != 0 )
{
fp = popen( final_cmd_smartctl, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno(): Failed to create stream to %s",
smartctl_command );
set_return_value = 3;
}
else
{
/* Read the output a line at a time - output it. */
while( fgets( result, sizeof( result ) - 1, fp ) != NULL )
{
/* Convert the label, i.e everything before the ':' to lower case, it's required to
* convert to lower case as smartctl seems to use inconsistent case when labeling
* for serial number, i.e mostly it produces labels "Serial Number:" but occasionally
* it produces a label "Serial number:" */
idx = 0;
while( result[idx] != 0 && result[idx] != ':' )
{
/* If upper case alpha character, change to lower case */
if( result[idx] >= 'A' && result[idx] <= 'Z' )
{
result[idx] = tolower( result[idx] );
}
idx++;
}
if( nwipe_options.verbose && result[0] != 0x0A )
{
strip_CR_LF( result );
/* Remove serial number if -q option specified */
if( nwipe_options.quiet )
{
/* initialise index into string array */
idx2 = 0;
while( smartctl_labels_to_anonymize[idx2][0] != 0 )
{
if( ( pResult = strstr( result, &smartctl_labels_to_anonymize[idx2][0] ) ) != 0 )
{
/* set index to character after end of label string */
idx = strlen( &smartctl_labels_to_anonymize[idx2][0] );
/* Ignore spaces, overwrite other characters */
while( *( pResult + idx ) != 0x0A && *( pResult + idx ) != 0x0D
&& *( pResult + idx ) != 0 && idx <= sizeof( result ) - 1 )
{
if( *( pResult + idx ) == ' ' )
{
idx++;
continue;
}
else
{
/* ignore if the serial number has been written over with '?' */
if( *( pResult + idx ) != '?' )
{
*( pResult + idx ) = 'X';
}
idx++;
}
}
}
idx2++;
}
}
nwipe_log( NWIPE_LOG_INFO, "smartctl: %s", result );
}
if( strstr( result, "serial number:" ) != 0 )
{
/* strip any leading or trailing spaces and left justify, +15 is the length of "Serial Number:" */
trim( &result[15] );
strncpy( serialnumber, &result[15], NWIPE_SERIALNUMBER_LENGTH );
serialnumber[NWIPE_SERIALNUMBER_LENGTH] = 0;
}
if( *bus == 0 )
{
if( strstr( result, "transport protocol:" ) != 0 )
{
/* strip any leading or trailing spaces and left justify, +4 is the length of "bus type:" */
trim( &result[19] );
for( idx = 19; result[idx]; idx++ )
{
result[idx] = tolower( result[idx] );
}
if( strncmp( &result[19], "sas", 3 ) == 0 )
{
*bus = NWIPE_DEVICE_SAS;
}
}
if( strstr( result, "sata version is:" ) != 0 )
{
/* strip any leading or trailing spaces and left justify, +4 is the length of "bus type:" */
trim( &result[16] );
for( idx = 16; result[idx]; idx++ )
{
result[idx] = tolower( result[idx] );
}
if( strncmp( &result[16], "sata", 4 ) == 0 )
{
*bus = NWIPE_DEVICE_ATA;
}
}
}
if( strstr( result, "rotation rate:" ) != 0 )
{
/* strip any leading or trailing spaces and left justify, +15 is the length of "Rotation Rate:" */
trim( &result[15] );
for( idx = 15; result[idx]; idx++ )
{
result[idx] = tolower( result[idx] );
}
if( strncmp( &result[15], "solid state device", 19 ) == 0 )
{
*is_ssd = 1;
}
}
}
/* close */
r = pclose( fp );
if( r > 0 )
{
exit_status = WEXITSTATUS( r );
if( nwipe_options.verbose && exit_status != 1 )
{
nwipe_log( NWIPE_LOG_WARNING,
"nwipe_get_device_bus_type_and_serialno(): smartctl failed, \"%s\" exit status = %u",
final_cmd_smartctl,
exit_status );
}
set_return_value = 6;
if( exit_status == 127 )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Install Smartctl recommended !" );
set_return_value = 4;
}
if( exit_status == 1 )
{
nwipe_log( NWIPE_LOG_WARNING, "Smartctl is unable to provide smart data for %s", device );
if( *bus == NWIPE_DEVICE_USB || *bus == NWIPE_DEVICE_MMC )
{
strcpy( serialnumber, "(S/N: unknown)" );
set_return_value = 5;
}
}
}
}
}
return set_return_value;
}
void remove_ATA_prefix( char* str )
{
/* Remove "ATA" prefix if present in the model no. string, left justifing string */
int idx_pre = 4;
int idx_post = 0;
if( !strncmp( str, "ATA ", 4 ) )
{
while( str[idx_pre] != 0 )
{
str[idx_post++] = str[idx_pre++];
}
str[idx_post] = 0;
}
}

View File

@@ -2,7 +2,7 @@
* device.h: Device routines for nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
* This program is free software; you can redistribute it and/or modify it under
@@ -16,18 +16,34 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef DEVICE_H_
#define DEVICE_H_
void nwipe_device_identify( nwipe_context_t* c ); /* Get hardware information about the device. */
int nwipe_device_scan( nwipe_context_t*** c ); /* Find devices that we can wipe. */
int nwipe_device_get( nwipe_context_t*** c, char **devnamelist, int ndevnames ); /* Get info about devices to wipe */
#define MAX_LENGTH_OF_DEVICE_STRING 8
void nwipe_device_identify( nwipe_context_t* c ); // Get hardware information about the device.
int nwipe_device_scan( nwipe_context_t*** c ); // Find devices that we can wipe.
/**
* Gets information about devices
*
* @parameter device_names A reference to a null array pointer.
* @parameter devnamelist An array of string pointers to the device names
* @parameter ndevnames Number of elements in devnamelist
* @modifies device_names Populates device_names with an array of nwipe_contect_t
* @returns The number of strings in the device_names array.
*
*/
int nwipe_device_get( nwipe_context_t*** c, char** devnamelist, int ndevnames ); // Get info about devices to wipe.
int nwipe_get_device_bus_type_and_serialno( char*, nwipe_device_t*, int*, char* );
void strip_CR_LF( char* );
void determine_disk_capacity_nomenclature( u64, char* );
void remove_ATA_prefix( char* );
char* trim( char* );
#endif /* DEVICE_H_ */
/* eof */

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
/* Autogenerated by hxtools bin2c */
#ifndef NWIPE_EXCLAMATION_JPG_H
#define NWIPE_EXCLAMATION_JPG_H 1
#ifdef __cplusplus
extern "C" {
#endif
extern const unsigned char bin2c_nwipe_exclamation_jpg[63304];
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* NWIPE_EXCLAMATION_JPG_H */

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
/* Autogenerated by hxtools bin2c */
#ifndef REDCROSS_H
#define REDCROSS_H 1
#ifdef __cplusplus
extern "C" {
#endif
extern const unsigned char bin2c_redcross_jpg[60331];
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* REDCROSS_H */

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
/* Autogenerated by hxtools bin2c */
#ifndef SHRED_DB_JPG_H
#define SHRED_DB_JPG_H 1
#ifdef __cplusplus
extern "C" {
#endif
extern const unsigned char bin2c_shred_db_jpg[27063];
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SHRED_DB_JPG_H */

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
/* Autogenerated by hxtools bin2c */
#ifndef TICK_ERASED_JPG_H
#define TICK_ERASED_JPG_H 1
#ifdef __cplusplus
extern "C" {
#endif
extern const unsigned char bin2c_te_jpg[54896];
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* TICK_ERASED_JPG_H */

Binary file not shown.

8786
src/gui.c

File diff suppressed because it is too large Load Diff

133
src/gui.h
View File

@@ -2,7 +2,7 @@
* gui.h: An ncurses GUI for nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
* This program is free software; you can redistribute it and/or modify it under
@@ -16,29 +16,130 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef GUI_H_
#define GUI_H_
void nwipe_gui_free( void ); /* Stop the GUI. */
void nwipe_gui_init( void ); /* Start the GUI. */
void nwipe_gui_select( int count, nwipe_context_t** c ); /* Select devices to wipe. */
void *nwipe_gui_status( void *ptr ); /* Update operation progress. */
void nwipe_gui_method( void ); /* Change the method option. */
void nwipe_gui_options( void ); /* Update the options window. */
void nwipe_gui_prng( void ); /* Change the prng option. */
void nwipe_gui_rounds( void ); /* Change the rounds option. */
void nwipe_gui_verify( void ); /* Change the verify option. */
void nwipe_gui_noblank( void ); /* Change the noblank option. */
void nwipe_gui_free( void ); // Stop the GUI.
void nwipe_gui_init( void ); // Start the GUI.
void nwipe_gui_create_main_window( void ); // Create the main window
void nwipe_gui_create_header_window( void ); // Create the header window
void nwipe_gui_create_footer_window( const char* ); // Create the footer window and write text
void nwipe_gui_create_options_window( void ); // Create the options window
void nwipe_gui_create_stats_window( void ); // Create the stats window
void nwipe_gui_create_all_windows_on_terminal_resize(
int force_creation,
const char* footer_text ); // If terminal is resized recreate all windows
int compute_stats(void *ptr);
/**
* The primary user interface. Allows the user to
* change options and specify the devices to be wiped.
*
* @parameter count The number of contexts in the array.
* @parameter c An array of device contexts.
*
* @modifies c[].select Sets the select flag according to user input.
* @modifies options Sets program options according to to user input.
*
*/
void nwipe_gui_select( int count, nwipe_context_t** c ); // Select devices to wipe.
void* nwipe_gui_status( void* ptr ); // Update operation progress.
void nwipe_gui_method( void ); // Change the method option.
void nwipe_gui_options( void ); // Update the options window.
void nwipe_gui_prng( void ); // Change the prng option.
void nwipe_gui_rounds( void ); // Change the rounds option.
void nwipe_gui_verify( void ); // Change the verify option.
void nwipe_gui_noblank( void ); // Change the noblank option.
void nwipe_gui_config( void ); // Change the nwipe settings
void nwipe_gui_edit_organisation( void ); // Edit organisation performing the erasure
void nwipe_gui_organisation_business_name( const char* ); // Edit business name performing erase
void nwipe_gui_organisation_business_address( const char* ); // Edit business address performing erase
void nwipe_gui_organisation_contact_name( const char* ); // Edit business contact name
void nwipe_gui_organisation_contact_phone( const char* ); // Edit business contact phone
void nwipe_gui_organisation_op_tech_name( const char* ); // Edit the name of the operator/technician
void nwipe_gui_list( int, char* window_title, char**, int* );
void nwipe_gui_add_customer( void ); // Add new customer
void nwipe_gui_add_customer_name( char* ); // Add new customer name
void nwipe_gui_add_customer_address( char* ); // Add new customer address
void nwipe_gui_add_customer_contact_name( char* ); // Add new customer contact name
void nwipe_gui_add_customer_contact_phone( char* ); // Add new customer contact phone
int nwipe_gui_yes_no_footer( void ); // Change footer to yes no
/** nwipe_gui_preview_org_customer( int )
* Display a editable preview of organisation, customer and date/time
*
* @param int mode 0 = use prior to drive selection
* 1 = use in config menus
* The different modes simply change the text in the footer menu and in the case
* of mode 0 enable the A key which means accept & display drive selection.
*/
void nwipe_gui_preview_org_customer( int ); // Preview window for wipe organisation and customer
void nwipe_gui_set_system_year( void ); // Set the systems current year
void nwipe_gui_set_system_month( void ); // Set the systems month
void nwipe_gui_set_system_day( void ); // Set the system day of the month
void nwipe_gui_set_system_hour( void ); // Set the system hour
void nwipe_gui_set_system_minute( void ); // Set the system minute
/**
* Truncate a string based on start position and terminal width
*
* @parameter wcols Width of window, obtained from getmaxyx(..)
* @parameter start_column Start column where the string starts
* @parameter input_string The string to be truncated if necessary
* @parameter ouput_string The possibly truncated string
* @parameter ouput_string_length Max length of output string
* @Return returns a pointer to the output string
*/
char* str_truncate( int, int, const char*, char*, int ); // Truncate string based on start column and terminal width
/**
* Set system date and time
*
* @parameter void
* @Return void
*/
void nwipe_gui_set_date_time( void );
int spinner( nwipe_context_t** ptr, int ); // Return the next spinner character
void temp1_flash( nwipe_context_t* ); // toggles term1_flash_status, which flashes the temperature
/**
* If the current drive temperature is available, print it to the GUI.
* This function determines if the drive temperature limits are specified &
* if so, whether the temperature should be printed as white text on blue if the
* drive is operating within it's temperature specification or red text on
* blue if the drive has exceeded the critical high temperature or black on
* blue if the drive has dropped below the drives minimum temperature specification.
* @param pointer to the drive context
*/
void wprintw_temperature( nwipe_context_t* );
int compute_stats( void* ptr );
void nwipe_update_speedring( nwipe_speedring_t* speedring, u64 speedring_done, time_t speedring_now );
#define NOMENCLATURE_RESULT_STR_SIZE 8
/* Note Do not change unless you understand how this value affects keyboard response and screen refresh when
* the drive selection screen is displayed. (prior to wipe starting). */
#define GETCH_BLOCK_MS 250 /* millisecond block time for getch() */
/* Note The value of 1 (100ms) is the ideal speed for screen refresh during a wipe, a value of 2 is noticeably slower,
* don't change unless you understand how this value affects keyboard responsiveness and speed of screen stats/spinner
* updating */
#define GETCH_GUI_STATS_UPDATE_MS 1 /* 1 * 100 = 1/10/sec = millisecond block time for gui stats screen updates */
#define FIELD_LENGTH 256
#define MAX_TITLE_LENGTH 76
#define YES 1
#define NO 0
#define SHOWING_PRIOR_TO_DRIVE_SELECTION 0
#define SHOWING_IN_CONFIG_MENUS 1
#endif /* GUI_H_ */
/* eof */

View File

@@ -0,0 +1,159 @@
/*
* get_scsi_temp.c: functions that populate the drive temperature variables
* in SCSI/SAS drives context structure.
* Routines from hddtemp are used here.
*
* Author: Gerold Gruber <Gerold.Gruber@edv2g.de>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//#define _LARGEFILE64_SOURCE
//#define _FILE_OFFSET_BITS 64
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <dirent.h>
#include <assert.h>
#include "nwipe.h"
#include "context.h"
#include "method.h"
#include "device.h"
#include "prng.h"
#include "options.h"
#include "device.h"
#include "logging.h"
#include "temperature.h"
#include "miscellaneous.h"
#include "hddtemp.h"
#include "scsi.h"
int scsi_get_temperature( struct disk * );
int nwipe_init_scsi_temperature( nwipe_context_t* c )
{
/* dsk anlegen, malloc */
struct disk *dsk = (struct disk *) malloc(sizeof(struct disk));
/* Check the allocation. */
if( !dsk )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to get memory for disk struct for %s",
c->device_name );
exit( 1 ) ;
}
assert(dsk);
memset(dsk, 0, sizeof(*dsk));
/* save the dsk pointer for later use */
c->templ_disk = dsk;
/* initialize */
dsk->drive = c->device_name;
dsk->type = BUS_SCSI; /* we know this as we are only called in this case */
errno = 0;
dsk->errormsg[0] = '\0';
if( (dsk->fd = open(dsk->drive, O_RDONLY | O_NONBLOCK)) < 0) {
snprintf(dsk->errormsg, MAX_ERRORMSG_SIZE, "open: %s\n", strerror(errno));
dsk->type = ERROR;
return 1;
}
// sg_logs -t <device>
if( scsi_get_temperature( dsk ) == GETTEMP_SUCCESS )
{
c->temp1_input = dsk->value;
c->temp1_crit = dsk->refvalue;
c->temp1_lcrit = -40; /* just to give it a value with some kind of sense */
c->temp1_highest = dsk->value;
c->temp1_lowest = dsk->value;
c->temp1_max = dsk->refvalue - 5; /* seems to be kind of useful */
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Can not read SCSI temperature for %s, %s",
dsk->drive, dsk->errormsg );
close( dsk->fd );
free( dsk );
c->templ_disk = NULL;
return 1;
}
return 0;
}
int nwipe_get_scsi_temperature( nwipe_context_t* c )
{
struct disk *dsk;
dsk = c->templ_disk;
if( c->templ_disk != NULL && c->templ_disk->fd != -1 )
{
if( scsi_get_temperature( dsk ) == GETTEMP_SUCCESS )
{
c->temp1_input = dsk->value;
/* not at all of interest */
if( c->temp1_input > c->temp1_highest )
{
c->temp1_highest = c->temp1_input;
}
if( c->temp1_input < c->temp1_lowest )
{
c->temp1_lowest = c->temp1_input;
}
/* end not at all of interest ;-) */
}
else
{
nwipe_log( NWIPE_LOG_ERROR, "Could not read SCSI temperature for %s, %s",
dsk->drive, dsk->errormsg );
return 2;
}
}
else
{
nwipe_log( NWIPE_LOG_INFO, "no SCSI temperature reading for %s", dsk->drive );
return 1;
}
return 0;
}
void nwipe_shut_scsi_temperature( nwipe_context_t* c )
{
if( c->templ_disk->fd != -1 )
{
close( c->templ_disk->fd );
}
if( c->templ_disk != NULL )
{
free( c->templ_disk );
}
return;
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2002 Emmanuel VARAGNAT <hddtemp@guzu.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __HDDTEMP_H__
#define __HDDTEMP_H__
#include <time.h>
// #include "db.h"
//#ifdef ARCH_I386
//typedef unsigned short u16;
//#endif
#include <linux/types.h>
typedef __u16 u16;
#define MAX_ERRORMSG_SIZE 128
#define DEFAULT_ATTRIBUTE_ID 194
#define F_to_C(val) (int)(((double)(val)-32.0)/1.8)
#define C_to_F(val) (int)(((double)(val)*(double)1.8) + (double)32.0)
enum e_bustype { ERROR = 0, BUS_UNKNOWN, BUS_SATA, BUS_ATA, BUS_SCSI, BUS_TYPE_MAX };
#define GETTEMP_SUCCESS 0
#define GETTEMP_ERROR 1
#define GETTEMP_NOT_APPLICABLE 2
#define GETTEMP_UNKNOWN 3
#define GETTEMP_GUESS 4
#define GETTEMP_KNOWN 5
#define GETTEMP_NOSENSOR 6
#define GETTEMP_DRIVE_SLEEP 7
enum e_powermode {
PWM_UNKNOWN,
PWM_ACTIVE,
PWM_SLEEPING,
PWM_STANDBY
};
struct disk {
struct disk * next;
int fd;
const char * drive;
const char * model;
enum e_bustype type;
int value; /* the drive's temperature */
int refvalue; /* aka trip temperature */
struct harddrive_entry * db_entry;
char errormsg[MAX_ERRORMSG_SIZE];
// enum e_gettemp ret;
int ret;
time_t last_time;
};
struct bustype {
char *name;
int (*probe)(int);
const char *(*model)(int);
enum e_gettemp (*get_temperature)(struct disk *);
};
extern struct bustype * bus[BUS_TYPE_MAX];
extern char errormsg[MAX_ERRORMSG_SIZE];
extern int tcp_daemon, debug, quiet, wakeup, af_hint;
extern char separator;
extern long portnum, syslog_interval;
extern char * listen_addr;
int value_to_unit(struct disk *dsk);
char get_unit(struct disk *dsk);
#endif

125
src/hddtemp_scsi/scsi.c Normal file
View File

@@ -0,0 +1,125 @@
/*
* Copyright (C) 2002 Emmanuel VARAGNAT <hddtemp@guzu.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Adapted from a patch sended by : Frederic LOCHON <lochon@roulaise.net>
*/
/*
* Adapted for use with nwipe by : Gerold Gruber <Gerold.Gruber@edv2g.de>
*/
// Include file generated by ./configure
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Gettext includes
#if ENABLE_NLS
#include <libintl.h>
#define _(String) gettext (String)
#else
#define _(String) (String)
#endif
// Standard includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <scsi/scsi.h>
// Application specific includes
#include "scsicmds.h"
#include "hddtemp.h"
int scsi_get_temperature(struct disk *dsk) {
int i;
int tempPage = 0;
unsigned char buffer[1024];
/*
on triche un peu
we cheat a little and do not really read form drivedb as SCSI disks are not included there
original code omitted as there is no need for it in the context of nwipe
*/
/*
Enable SMART
*/
if (scsi_smartDEXCPTdisable(dsk->fd) != 0) {
snprintf(dsk->errormsg, MAX_ERRORMSG_SIZE, "%s", strerror(errno));
close(dsk->fd);
dsk->fd = -1;
return GETTEMP_ERROR;
}
/*
Temp. capable
*/
if (scsi_logsense(dsk->fd , SUPPORT_LOG_PAGES, buffer, sizeof(buffer)) != 0) {
snprintf(dsk->errormsg, MAX_ERRORMSG_SIZE, _("log sense failed : %s"), strerror(errno));
close(dsk->fd);
dsk->fd = -1;
return GETTEMP_ERROR;
}
for ( i = 4; i < buffer[3] + LOGPAGEHDRSIZE ; i++) {
if (buffer[i] == TEMPERATURE_PAGE) {
tempPage = 1;
break;
}
}
if(tempPage) {
/*
get temperature (from scsiGetTemp (scsicmd.c))
*/
if (scsi_logsense(dsk->fd , TEMPERATURE_PAGE, buffer, sizeof(buffer)) != 0) {
snprintf(dsk->errormsg, MAX_ERRORMSG_SIZE, _("log sense failed : %s"), strerror(errno));
close(dsk->fd);
dsk->fd = -1;
return GETTEMP_ERROR;
}
if( (int)buffer[7] == 2 ) /* PARAMETER LENGTH */
{
dsk->value = buffer[9];
}
else
{
snprintf(dsk->errormsg, MAX_ERRORMSG_SIZE, _("parameter length unexpected: %d"), (int)buffer[7] );
return GETTEMP_UNKNOWN;
}
dsk->refvalue = buffer[15];
if( (int)buffer[13] == 2 ) /* PARAMETER LENGTH */
{
dsk->refvalue = buffer[15];
}
else
{
snprintf(dsk->errormsg, MAX_ERRORMSG_SIZE, _("parameter ref length unexpected: %d"), (int)buffer[13] );
return GETTEMP_UNKNOWN;
}
return GETTEMP_SUCCESS;
} else {
return GETTEMP_NOSENSOR;
}
}

24
src/hddtemp_scsi/scsi.h Normal file
View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2002 Emmanuel VARAGNAT <hddtemp@guzu.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SCSIC_H_
#define SCSIC_H_
extern struct bustype scsi_bus;
#endif

221
src/hddtemp_scsi/scsicmds.c Normal file
View File

@@ -0,0 +1,221 @@
/*
* Copyright (C) 2002 Emmanuel VARAGNAT <hddtemp@guzu.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Include file generated by ./configure
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// Gettext includes
#if ENABLE_NLS
#include <libintl.h>
#define _(String) gettext (String)
#else
#define _(String) (String)
#endif
// Standard includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <scsi/scsi.h>
#include <scsi/sg.h>
#include <scsi/scsi_ioctl.h>
// Application specific includes
#include "scsicmds.h"
static void scsi_fixstring(unsigned char *s, int bytecount)
{
unsigned char *p;
unsigned char *end;
p = s;
end = s + bytecount;
/* strip leading blanks */
while (s != end && *s == ' ')
++s;
/* compress internal blanks and strip trailing blanks */
while (s != end && *s) {
if (*s++ != ' ' || (s != end && *s && *s != ' '))
*p++ = *(s-1);
}
/* wipe out trailing garbage */
while (p != end)
*p++ = '\0';
}
int scsi_SG_IO(int device, unsigned char *cdb, int cdb_len, unsigned char *buffer, int buffer_len, unsigned char *sense, unsigned char sense_len, int dxfer_direction) {
struct sg_io_hdr io_hdr;
memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
io_hdr.interface_id = 'S';
io_hdr.cmdp = cdb;
io_hdr.cmd_len = cdb_len;
io_hdr.dxfer_len = buffer_len;
io_hdr.dxferp = buffer;
io_hdr.mx_sb_len = sense_len;
io_hdr.sbp = sense;
io_hdr.dxfer_direction = dxfer_direction;
io_hdr.timeout = 3000; /* 3 seconds should be ample */
return ioctl(device, SG_IO, &io_hdr);
}
int scsi_SEND_COMMAND(int device, unsigned char *cdb, int cdb_len, unsigned char *buffer, int buffer_len, int dxfer_direction)
{
unsigned char buf[2048];
unsigned int inbufsize, outbufsize, ret;
switch(dxfer_direction) {
case SG_DXFER_FROM_DEV:
inbufsize = 0;
outbufsize = buffer_len;
break;
case SG_DXFER_TO_DEV:
inbufsize = buffer_len;
outbufsize = 0;
break;
default:
inbufsize = 0;
outbufsize = 0;
break;
}
memcpy(buf, &inbufsize , sizeof(inbufsize));
memcpy(buf + sizeof(inbufsize), &outbufsize , sizeof(outbufsize));
memcpy(buf + sizeof(inbufsize) + sizeof(outbufsize), cdb, cdb_len);
memcpy(buf + sizeof(inbufsize) + sizeof(outbufsize) + cdb_len, buffer, buffer_len);
ret = ioctl(device, SCSI_IOCTL_SEND_COMMAND, buf);
memcpy(buffer, buf + sizeof(inbufsize) + sizeof(outbufsize), buffer_len);
return ret;
}
int scsi_command(int device, unsigned char *cdb, int cdb_len, unsigned char *buffer, int buffer_len, int dxfer_direction)
{
static int SG_IO_supported = -1;
int ret;
if (SG_IO_supported == 1)
return scsi_SG_IO(device, cdb, cdb_len, buffer, buffer_len, NULL, 0, dxfer_direction);
else if (SG_IO_supported == 0)
return scsi_SEND_COMMAND(device, cdb, cdb_len, buffer, buffer_len, dxfer_direction);
else {
ret = scsi_SG_IO(device, cdb, cdb_len, buffer, buffer_len, NULL, 0, dxfer_direction);
if (ret == 0) {
SG_IO_supported = 1;
return ret;
} else {
SG_IO_supported = 0;
return scsi_SEND_COMMAND(device, cdb, cdb_len, buffer, buffer_len, dxfer_direction);
}
}
}
int scsi_inquiry(int device, unsigned char *buffer)
{
unsigned char cdb[6];
memset(cdb, 0, sizeof(cdb));
cdb[0] = INQUIRY;
cdb[4] = 36; /* should be 36 for unsafe devices (like USB mass storage stuff)
* otherwise they can lock up! SPC sections 7.4 and 8.6 */
if (scsi_command(device, cdb, sizeof(cdb), buffer, cdb[4], SG_DXFER_FROM_DEV) != 0)
return 1;
else {
scsi_fixstring(buffer + 8, 24);
return 0;
}
}
int scsi_modesense(int device, unsigned char pagenum, unsigned char *buffer, int buffer_len) {
unsigned char cdb[6];
int ret;
memset(cdb, 0, sizeof(cdb));
cdb[0] = MODE_SENSE;
cdb[2] = pagenum;
cdb[4] = 0xff;
ret = scsi_command(device, cdb, sizeof(cdb), buffer, buffer_len, SG_DXFER_FROM_DEV);
if (ret == 0) {
if ((buffer[3] + 5) > buffer[0]) /* response length too short */
return -1;
}
return ret;
}
int scsi_modeselect(int device, char *buffer) {
unsigned char cdb[6];
memset(cdb, 0, sizeof(cdb));
cdb[0] = MODE_SELECT;
cdb[1] = 0x11;
cdb[4] = buffer[0] + 1;
memset(buffer, 0, 12);
buffer[3] = 0x08;
buffer[10] = 0x02;
buffer[12] &= 0x3f;
return scsi_command(device, cdb, sizeof(cdb), buffer, cdb[4], SG_DXFER_TO_DEV);
}
int scsi_logsense(int device, int pagenum, unsigned char *buffer, int buffer_len) {
unsigned char cdb[10];
memset(cdb, 0, sizeof(cdb));
cdb[0] = LOG_SENSE;
cdb[2] = 0x40 | pagenum;
cdb[7] = 0x04;
return scsi_command(device, cdb, sizeof(cdb), buffer, buffer_len, SG_DXFER_FROM_DEV);
}
int scsi_smartsupport(int device) {
unsigned char buf[255];
if (scsi_modesense (device, EXCEPTIONS_CONTROL_PAGE, buf, sizeof(buf)) != 0)
return 0;
else
return (buf[14] & 0x08) == 0;
}
int scsi_smartDEXCPTdisable(int device) {
unsigned char buf[255];
if (scsi_modesense (device, EXCEPTIONS_CONTROL_PAGE, buf, sizeof(buf)) != 0)
return 1;
if (buf[14] & 0x08) {
buf[14] &= 0xf7;
buf[15] = 0x04;
return scsi_modeselect (device, buf);
}
else
return 0;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2002 Emmanuel VARAGNAT <hddtemp@guzu.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SCSICMDS_H_
#define SCSICMDS_H_
#define SUPPORT_LOG_PAGES 0x00
#define TEMPERATURE_PAGE 0x0d
#define EXCEPTIONS_CONTROL_PAGE 0x1c
#define LOGPAGEHDRSIZE 4
int scsi_SG_IO(int device, unsigned char *cdb, int cdb_len, unsigned char *buffer, int buffer_len, unsigned char *sense, unsigned char sense_len, int dxfer_direction);
int scsi_inquiry(int device, unsigned char *buffer);
int scsi_modesense(int device, unsigned char pagenum, unsigned char *buffer, int buffer_len);
int scsi_modeselect(int device, char *buffer);
int scsi_logsense(int device, int pagenum, unsigned char *buffer, int buffer_len);
int scsi_smartsupport(int device);
int scsi_smartDEXCPTdisable(int device);
#endif

858
src/hpa_dco.c Normal file
View File

@@ -0,0 +1,858 @@
/*
* hpa_dco.c: functions that handle the host protected area (HPA) and
* device configuration overlay (DCO)
*
* Copyright PartialVolume <https://github.com/PartialVolume>.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <scsi/sg.h>
#include <scsi/scsi_ioctl.h>
#include "nwipe.h"
#include "context.h"
#include "version.h"
#include "method.h"
#include "logging.h"
#include "options.h"
#include "hpa_dco.h"
#include "miscellaneous.h"
/* This function makes use of both the hdparm program to determine HPA/DCO status and we also access
* the device configuration overlay identify data structure via the sg driver with ioctl calls.
* I would prefer to write these functions without any reliance on hdparm however for the time being
* we will utilize both methods. However, I don't like doing it like this as a change in formatted
* output of hdparm could potentially break HPA/DCO detection requiring a fix. Time permitting I may
* come back to this and fully implement it without any reliance on hdparm.
*/
int hpa_dco_status( nwipe_context_t* ptr )
{
nwipe_context_t* c;
c = ptr;
int r; // A result buffer.
int set_return_value;
int exit_status;
int hpa_line_found;
int dco_line_found;
FILE* fp;
char path_hdparm_cmd1_get_hpa[] = "hdparm --verbose -N";
char path_hdparm_cmd2_get_hpa[] = "/sbin/hdparm --verbose -N";
char path_hdparm_cmd3_get_hpa[] = "/usr/bin/hdparm --verbose -N";
char path_hdparm_cmd4_get_dco[] = "hdparm --verbose --dco-identify";
char path_hdparm_cmd5_get_dco[] = "/sbin/hdparm --verbose --dco-identify";
char path_hdparm_cmd6_get_dco[] = "/usr/bin/hdparm --verbose --dco-identify";
char pipe_std_err[] = "2>&1";
char result[512];
u64 nwipe_dco_real_max_sectors;
char* p;
/* Use the longest of the 'path_hdparm_cmd.....' strings above to
*determine size in the strings below
*/
char hdparm_cmd_get_hpa[sizeof( path_hdparm_cmd3_get_hpa ) + sizeof( c->device_name ) + sizeof( pipe_std_err )];
char hdparm_cmd_get_dco[sizeof( path_hdparm_cmd6_get_dco ) + sizeof( c->device_name ) + sizeof( pipe_std_err )];
/* Initialise return value */
set_return_value = 0;
/* Construct the command including path to the binary if required, I do it like this to cope
* with distros that don't setup their paths in a standard way or maybe don't even define a
* path. By doing this we avoid the 'No such file or directory' message you would otherwise
* get on some distros. -> debian SID
*/
if( system( "which hdparm > /dev/null 2>&1" ) )
{
if( system( "which /sbin/hdparm > /dev/null 2>&1" ) )
{
if( system( "which /usr/bin/hdparm > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_WARNING, "hdparm command not found." );
nwipe_log( NWIPE_LOG_WARNING,
"Required by nwipe for HPA/DCO detection & correction and ATA secure erase." );
nwipe_log( NWIPE_LOG_WARNING, "** Please install hdparm **\n" );
cleanup();
exit( 1 );
}
else
{
snprintf( hdparm_cmd_get_hpa,
sizeof( hdparm_cmd_get_hpa ),
"%s %s %s\n",
path_hdparm_cmd3_get_hpa,
c->device_name,
pipe_std_err );
snprintf( hdparm_cmd_get_dco,
sizeof( hdparm_cmd_get_dco ),
"%s %s %s\n",
path_hdparm_cmd6_get_dco,
c->device_name,
pipe_std_err );
}
}
else
{
snprintf( hdparm_cmd_get_hpa,
sizeof( hdparm_cmd_get_hpa ),
"%s %s %s\n",
path_hdparm_cmd2_get_hpa,
c->device_name,
pipe_std_err );
snprintf( hdparm_cmd_get_dco,
sizeof( hdparm_cmd_get_dco ),
"%s %s %s\n",
path_hdparm_cmd5_get_dco,
c->device_name,
pipe_std_err );
}
}
else
{
snprintf( hdparm_cmd_get_hpa,
sizeof( hdparm_cmd_get_hpa ),
"%s %s %s\n",
path_hdparm_cmd1_get_hpa,
c->device_name,
pipe_std_err );
snprintf( hdparm_cmd_get_dco,
sizeof( hdparm_cmd_get_dco ),
"%s %s %s\n",
path_hdparm_cmd4_get_dco,
c->device_name,
pipe_std_err );
}
/* Initialise the results buffer, so we don't some how inadvertently process a past result */
memset( result, 0, sizeof( result ) );
if( hdparm_cmd_get_hpa[0] != 0 )
{
fp = popen( hdparm_cmd_get_hpa, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING, "hpa_dco_status: Failed to create stream to %s", hdparm_cmd_get_hpa );
set_return_value = 1;
}
if( fp != NULL )
{
hpa_line_found = 0; //* init */
/* Read the output a line at a time - output it. */
while( fgets( result, sizeof( result ) - 1, fp ) != NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "%s \n%s", hdparm_cmd_get_hpa, result );
}
/* Change the output of hdparm to lower case and search using lower case strings, to try
* to avoid minor changes in case in hdparm's output from breaking HPA/DCO detection
*/
strlower( result ); // convert the result to lower case
/* Scan the hdparm results for HPA is disabled
*/
if( strstr( result, "sg_io: bad/missing sense data" ) != 0 )
{
c->HPA_status = HPA_UNKNOWN;
nwipe_log( NWIPE_LOG_ERROR, "SG_IO bad/missing sense data %s", hdparm_cmd_get_hpa );
break;
}
else
{
if( strstr( result, "hpa is disabled" ) != 0 )
{
c->HPA_status = HPA_DISABLED;
nwipe_log( NWIPE_LOG_DEBUG,
"hdparm says the host protected area is disabled on %s but this information may or "
"may not be correct, as occurs when you get a SG_IO error and 0/1 sectors and it "
"says HPA is enabled. Further checks are conducted below..",
c->device_name );
hpa_line_found = 1;
break;
}
else
{
if( strstr( result, "hpa is enabled" ) != 0 )
{
c->HPA_status = HPA_ENABLED;
nwipe_log( NWIPE_LOG_DEBUG,
"hdparm says the host protected area is enabled on %s but this information may "
"or may not be correct, as occurs when you get a SG_IO error and 0/1 sectors "
"and it says HPA is enabled. Further checks are conducted below..",
c->device_name );
hpa_line_found = 1;
break;
}
else
{
if( strstr( result, "accessible max address disabled" ) != 0 )
{
c->HPA_status = HPA_DISABLED;
nwipe_log( NWIPE_LOG_DEBUG,
"hdparm says the accessible max address disabled on %s"
"this means that there are no hidden sectors, "
"",
c->device_name );
hpa_line_found = 1;
break;
}
else
{
if( strstr( result, "accessible max address enabled" ) != 0 )
{
c->HPA_status = HPA_ENABLED;
nwipe_log( NWIPE_LOG_DEBUG,
"hdparm says the accessible max address enabled on %s"
"this means that there are hidden sectors",
c->device_name );
hpa_line_found = 1;
break;
}
else
{
if( strstr( result, "invalid" ) != 0 )
{
nwipe_log(
NWIPE_LOG_WARNING,
"hdparm reports invalid output, sector information may be invalid, buggy "
"drive firmware on %s?",
c->device_name );
// We'll assume the HPA values are in the string as we may be able to extract
// something meaningful
hpa_line_found = 1;
break;
}
}
}
}
}
}
}
/* if the HPA line was found then process the line,
* extracting the 'hpa set' and 'hpa real' values.
*/
if( hpa_line_found == 1 )
{
/* Extract the 'HPA set' value, the first value in the line and convert
* to binary and save in context */
nwipe_log( NWIPE_LOG_INFO, "HPA: %s on %s", result, c->device_name );
c->HPA_reported_set = str_ascii_number_to_ll( result );
/* Check whether the number was too large or no number found & log */
if( c->HPA_reported_set == -1 )
{
nwipe_log( NWIPE_LOG_INFO, "HPA_set_value: HPA set value too large on %s", c->device_name );
c->HPA_reported_set = 0;
}
else
{
if( c->HPA_reported_set == -2 )
{
nwipe_log( NWIPE_LOG_INFO, "HPA_set_value: No HPA set value found %s", c->device_name );
c->HPA_reported_set = 0;
}
}
/* Extract the 'HPA real' value, the second value in the line and convert
* to binary and save in context, this is a little more difficult as sometimes
* a odd value is returned so instead of nnnnn/nnnnn you get nnnnnn/1(nnnnnn).
* So first we scan for a open bracket '(' then if there is no '(' we then start the
* search immediately after the '/'.
*/
if( ( p = strstr( result, "(" ) ) )
{
c->HPA_reported_real = str_ascii_number_to_ll( p + 1 );
}
else
{
if( ( p = strstr( result, "/" ) ) )
{
c->HPA_reported_real = str_ascii_number_to_ll( p + 1 );
}
}
/* Check whether the number was too large or no number found & log */
if( c->HPA_reported_real == -1 )
{
nwipe_log( NWIPE_LOG_INFO, "HPA_set_value: HPA real value too large on %s", c->device_name );
c->HPA_reported_real = 0;
}
else
{
if( c->HPA_reported_real == -2 )
{
nwipe_log( NWIPE_LOG_INFO, "HPA_set_value: No HPA real value found %s", c->device_name );
c->HPA_reported_real = 0;
}
}
nwipe_log( NWIPE_LOG_INFO,
"HPA values %lli / %lli on %s",
c->HPA_reported_set,
c->HPA_reported_real,
c->device_name );
}
else
{
c->HPA_status = HPA_UNKNOWN;
nwipe_log( NWIPE_LOG_WARNING,
"[UNKNOWN] We can't find the HPA line, has hdparm ouput unknown/changed? %s",
c->device_name );
}
/* close */
r = pclose( fp );
if( r > 0 )
{
exit_status = WEXITSTATUS( r );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_WARNING,
"hpa_dco_status(): hdparm failed, \"%s\" exit status = %u",
hdparm_cmd_get_hpa,
exit_status );
}
if( exit_status == 127 )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Installing hdparm is mandatory !" );
set_return_value = 2;
if( nwipe_options.nousb )
{
return set_return_value;
}
}
}
}
}
/* Initialise the results buffer again, so we don't
* some how inadvertently process a past result */
memset( result, 0, sizeof( result ) );
/* -----------------------------------------------
* Run the dco identify command and determine the
* real max sectors, store it in the drive context
* for comparison against the hpa reported drive
* size values.
*/
dco_line_found = 0;
if( hdparm_cmd_get_dco[0] != 0 )
{
fp = popen( hdparm_cmd_get_dco, "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_WARNING, "hpa_dco_status: Failed to create stream to %s", hdparm_cmd_get_dco );
set_return_value = 1;
}
if( fp != NULL )
{
/* Read the output a line at a time - output it. */
while( fgets( result, sizeof( result ) - 1, fp ) != NULL )
{
/* Change the output of hdparm to lower case and search using lower case strings, to try
* to avoid minor changes in case in hdparm's output from breaking HPA/DCO detection */
strlower( result );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "%s \n%s", hdparm_cmd_get_dco, result );
}
if( strstr( result, "real max sectors" ) != 0 )
{
/* extract the real max sectors, convert to binary and store in drive context */
dco_line_found = 1;
break;
}
}
/* DCO line found, now process it */
if( dco_line_found == 1 )
{
c->DCO_reported_real_max_sectors = str_ascii_number_to_ll( result );
nwipe_log( NWIPE_LOG_INFO,
"hdparm:DCO Real max sectors reported as %lli on %s",
c->DCO_reported_real_max_sectors,
c->device_name );
/* Validate the real max sectors to detect extreme or impossible
* values, so the size must be greater than zero but less than
* 200TB (429496729600 sectors). As its 2023 and the largest drive
* available is 20TB I wonder if somebody in the future will be looking
* at this and thinking, yep we need to increase that value... and I'm
* wondering what year that will be. This validation is necessary all
* because of a bug in hdparm v9.60 (and maybe other versions) which
* produced wildly inaccurate values, often negative.
*/
if( c->DCO_reported_real_max_sectors > 0 && c->DCO_reported_real_max_sectors < 429496729600 )
{
nwipe_log( NWIPE_LOG_INFO,
"NWipe: DCO Real max sectors reported as %lli on %s",
c->DCO_reported_real_max_sectors,
c->device_name );
}
else
{
/* Call nwipe's own low level function to retrieve the drive configuration
* overlay and retrieve the real max sectors. We may remove reliance on hdparm
* if nwipes own low level drive access code works well.
*/
c->DCO_reported_real_max_sectors = nwipe_read_dco_real_max_sectors( c->device_name );
/* Check our real max sectors function is returning sensible data too */
if( c->DCO_reported_real_max_sectors > 0 && c->DCO_reported_real_max_sectors < 429496729600 )
{
nwipe_log( NWIPE_LOG_INFO,
"NWipe: DCO Real max sectors reported as %lli on %s",
c->DCO_reported_real_max_sectors,
c->device_name );
}
else
{
c->DCO_reported_real_max_sectors = 0;
nwipe_log( NWIPE_LOG_INFO, "DCO Real max sectors not found" );
}
}
}
else
{
c->DCO_reported_real_max_sectors = 0;
nwipe_log( NWIPE_LOG_INFO, "DCO Real max sectors not found" );
}
nwipe_log(
NWIPE_LOG_INFO,
"libata: apparent max sectors reported as %lli with sector size as %i/%i (logical/physical) on %s",
c->device_size_in_sectors,
c->device_sector_size, // logical
c->device_phys_sector_size, // physical
c->device_name );
/* close */
r = pclose( fp );
if( r > 0 )
{
exit_status = WEXITSTATUS( r );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_WARNING,
"hpa_dco_status(): hdparm failed, \"%s\" exit status = %u",
hdparm_cmd_get_dco,
exit_status );
}
if( exit_status == 127 )
{
nwipe_log( NWIPE_LOG_WARNING, "Command not found. Installing hdparm is mandatory !" );
set_return_value = 2;
if( nwipe_options.nousb )
{
return set_return_value;
}
}
}
}
}
/* Compare the results of hdparm -N (HPA set / HPA real)
* and hdparm --dco-identidy (real max sectors). All three
* values may be different or perhaps 'HPA set' and 'HPA real' are
* different and 'HPA real' matches 'real max sectors'.
*
* A perfect HPA disabled result would be where all three
* values are the same. It can then be considered that the
* HPA is disabled.
*
* If 'HPA set' and 'HPA real' are different then it
* can be considered that HPA is enabled, assuming 'HPA set'
* and 'HPA real' are not 0/1 which occurs when a SG_IO error
* occurs. That also is checked for as it often indicates a
* poor USB device that does not have ATA pass through support.
*
* However we also need to consider that more recent drives
* no longer support HPA/DCO such as the Seagate ST10000NM0016,
* ST4000NM0033 and ST1000DM003. If you try to issue those drives
* with the ATA command code 0xB1 (device configuration overlay)
* you will get a generic illegal request in the returned sense data.
*
* One other thing to note, we use HPA enabled/disabled to mean
* hidden area detected or not detected, this could be caused by
* either the dco-setmax being issued or Np, either way an area
* of the disc can be hidden. From the user interface we just call
* it a HPA/DCO hidden area detected (or not) which is more
* meaningful than just saying HDA enabled or disabled and a user
* not familiar with the term HPA or DCO not understanding why a
* HDA being detected could be significant.
*/
/* Determine, based on the values of 'HPA set', 'HPA real and
* 'real max sectors' whether we set the HPA flag as HPA_DISABLED,
* HPA_ENABLED, HPA_UNKNOWN or HPA_NOT_APPLICABLE. The HPA flag
* will be displayed in the GUI and on the certificate and is
* used to determine whether to reset the HPA.
*
*/
/* WARNING temp assignments WARNING
* s=28,r=28,rm=0
*
*/
#if 0
c->HPA_reported_set = 10;
c->HPA_reported_real = 28;
c->DCO_reported_real_max_sectors = 0;
c->HPA_reported_set = 28;
c->HPA_reported_real = 28;
c->DCO_reported_real_max_sectors = 0;
c->HPA_reported_set = 1000;
c->HPA_reported_real = 2048;
c->DCO_reported_real_max_sectors = 2048;
#endif
/* If any of the HPA or DCO values are larger than the apparent size then HPA is enabled. */
if( /*c->HPA_reported_set > c->device_size_in_sectors || */ c->HPA_reported_real > c->device_size_in_512byte_sectors
|| c->DCO_reported_real_max_sectors > c->device_size_in_512byte_sectors )
{
c->HPA_status = HPA_ENABLED;
nwipe_log( NWIPE_LOG_WARNING, " *********************************" );
nwipe_log( NWIPE_LOG_WARNING, " *** HIDDEN SECTORS DETECTED ! *** on %s", c->device_name );
nwipe_log( NWIPE_LOG_WARNING, " *********************************" );
}
else
{
/* This occurs when a SG_IO error occurs with USB devices that don't support ATA pass
* through */
if( c->HPA_reported_set == 0 && c->HPA_reported_real == 0 && c->DCO_reported_real_max_sectors <= 1 )
{
c->HPA_status = HPA_UNKNOWN;
if( c->device_bus == NWIPE_DEVICE_USB )
{
nwipe_log( NWIPE_LOG_WARNING,
"HIDDEN SECTORS INDETERMINATE! on %s, Some USB adapters & memory sticks don't support "
"ATA pass through",
c->device_name );
}
}
else
{
c->HPA_status = HPA_DISABLED;
nwipe_log( NWIPE_LOG_INFO, "No hidden sectors on %s", c->device_name );
}
}
c->DCO_reported_real_max_size = c->DCO_reported_real_max_sectors * c->device_sector_size;
nwipe_dco_real_max_sectors = nwipe_read_dco_real_max_sectors( c->device_name );
/* Analyse all the variations to produce the final real max bytes which takes into
* account drives that don't support DCO or HPA. This result is used in the PDF
* creation functions.
*/
if( c->device_type == NWIPE_DEVICE_NVME || c->device_type == NWIPE_DEVICE_VIRT
|| c->HPA_status == HPA_NOT_APPLICABLE )
{
c->Calculated_real_max_size_in_bytes = c->device_size;
}
else
{
/* If the DCO is reporting a real max sectors > the apparent size
* as reported by libata then that is what we will use as the real disc size
*/
if( c->DCO_reported_real_max_size > c->device_size_in_512byte_sectors )
{
c->Calculated_real_max_size_in_bytes = c->DCO_reported_real_max_sectors * c->device_sector_size;
}
else
{
/* If HPA is enabled and DCO real max sectors did not exist, then we have to assume - c->HPA_reported_real
* is the value we need, however if that is zero, then c->HPA_reported_set and if that is zero then
* c->device_size as reported by libata
*/
if( c->HPA_reported_real > c->device_size_in_512byte_sectors )
{
c->Calculated_real_max_size_in_bytes = c->HPA_reported_real * c->device_sector_size;
}
else
{
if( c->HPA_reported_set > c->device_size_in_512byte_sectors )
{
c->Calculated_real_max_size_in_bytes = c->HPA_reported_set * c->device_sector_size;
}
else
{
c->Calculated_real_max_size_in_bytes = c->device_size;
}
}
}
}
/* -------------------------------------------------------------------
* create two variables for later use by the PDF creation function
* based on real max sectors and calculated real max size in bytes.
*
* DCO_reported_real_max_size = real max sectors * sector size = bytes
* DCO_reported_real_max_size_text = human readable string, i.e 1TB etc.
*/
Determine_C_B_nomenclature(
c->DCO_reported_real_max_size, c->DCO_reported_real_max_size_text, NWIPE_DEVICE_SIZE_TXT_LENGTH );
Determine_C_B_nomenclature(
c->Calculated_real_max_size_in_bytes, c->Calculated_real_max_size_in_bytes_text, NWIPE_DEVICE_SIZE_TXT_LENGTH );
/* ----------------------------------------------------------------------------------
* Determine the size of the HPA if it's enabled and store the results in the context
*/
if( c->HPA_status == HPA_ENABLED )
{
if( c->Calculated_real_max_size_in_bytes != c->device_size )
{
c->HPA_sectors =
( (u64) ( c->Calculated_real_max_size_in_bytes - c->device_size ) / c->device_sector_size );
}
else
{
c->HPA_sectors = 0;
}
/* Convert the size to a human readable format and save in context */
Determine_C_B_nomenclature( c->HPA_sectors, c->HPA_size_text, NWIPE_DEVICE_SIZE_TXT_LENGTH );
}
else
{
/* HPA not enabled so initialise these values */
c->HPA_sectors = 0;
c->HPA_size_text[0] = 0;
}
nwipe_log( NWIPE_LOG_DEBUG,
"c->Calculated_real_max_size_in_bytes=%lli, c->device_size=%lli, c->device_sector_size=%lli, "
"c->DCO_reported_real_max_size=%lli, c->DCO_reported_real_max_sectors=%lli, c->HPA_sectors=%lli, "
"c->HPA_reported_set=%lli, c->HPA_reported_real=%lli, c->device_type=%i, "
"libata:c->device_size_in_sectors=%lli ",
"libata:c->device_size_in_512byte_sectors=%lli ",
c->Calculated_real_max_size_in_bytes,
c->device_size,
c->device_sector_size,
c->DCO_reported_real_max_size,
c->DCO_reported_real_max_sectors,
c->HPA_sectors,
c->HPA_reported_set,
c->HPA_reported_real,
c->device_type,
c->device_size_in_sectors,
c->device_size_in_512byte_sectors );
return set_return_value;
}
u64 nwipe_read_dco_real_max_sectors( char* device )
{
/* This function sends a device configuration overlay identify command 0xB1 (dco-identify)
* to the drive and extracts the real max sectors. The value is incremented by 1 and
* then returned. We rely upon this function to determine real max sectors as there
* is a bug in hdparm 9.60, including possibly earlier or later versions but which is
* fixed in 9.65, that returns a incorrect (negative) value
* for some drives that are possibly over a certain size.
*/
/* TODO Add checks in case of failure, especially with recent drives that may not
* support drive configuration overlay commands.
*/
#define LBA_SIZE 512
#define CMD_LEN 16
#define BLOCK_MAX 65535
#define LBA_MAX ( 1 << 30 )
#define SENSE_BUFFER_SIZE 32
u64 nwipe_real_max_sectors;
/* This command issues command 0xb1 (dco-identify) 15th byte */
unsigned char cmd_blk[CMD_LEN] = { 0x85, 0x08, 0x0e, 0x00, 0xc2, 0, 0x01, 0, 0, 0, 0, 0, 0, 0x40, 0xb1, 0 };
sg_io_hdr_t io_hdr;
unsigned char buffer[LBA_SIZE]; // Received data block
unsigned char sense_buffer[SENSE_BUFFER_SIZE]; // Sense data
/* three characters represent one byte of sense data, i.e
* two characters and a space "01 AE 67"
*/
char sense_buffer_hex[( SENSE_BUFFER_SIZE * 3 ) + 1];
int i, i2; // index
int fd; // file descripter
if( ( fd = open( device, O_RDWR ) ) < 0 )
{
/* Unable to open device */
return -1;
}
/******************************************
* Initialise the sg header for reading the
* device configuration overlay identify data
*/
memset( &io_hdr, 0, sizeof( sg_io_hdr_t ) );
io_hdr.interface_id = 'S';
io_hdr.cmd_len = sizeof( cmd_blk );
io_hdr.mx_sb_len = sizeof( sense_buffer );
io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
io_hdr.dxfer_len = LBA_SIZE;
io_hdr.dxferp = buffer;
io_hdr.cmdp = cmd_blk;
io_hdr.sbp = sense_buffer;
io_hdr.timeout = 20000;
if( ioctl( fd, SG_IO, &io_hdr ) < 0 )
{
nwipe_log( NWIPE_LOG_ERROR, "IOCTL command failed retrieving DCO" );
i2 = 0;
for( i = 0, i2 = 0; i < SENSE_BUFFER_SIZE; i++, i2 += 3 )
{
/* IOCTL returned an error */
snprintf( &sense_buffer_hex[i2], sizeof( sense_buffer_hex ), "%02x ", sense_buffer[i] );
}
sense_buffer_hex[i2] = 0; // terminate string
nwipe_log( NWIPE_LOG_DEBUG, "Sense buffer from failed DCO identify cmd:%s", sense_buffer_hex );
return -2;
}
/* Close the device */
close( fd );
/***************************************************************
* Extract the real max sectors from the returned 512 byte block.
* Assuming the first word/byte is 0. We extract the bytes & switch
* the endian. Words 3-6(bytes 6-13) contain the max sector address
*/
nwipe_real_max_sectors = (u64) ( (u64) buffer[13] << 56 ) | ( (u64) buffer[12] << 48 ) | ( (u64) buffer[11] << 40 )
| ( (u64) buffer[10] << 32 ) | ( (u64) buffer[9] << 24 ) | ( (u64) buffer[8] << 16 ) | ( (u64) buffer[7] << 8 )
| buffer[6];
/* Don't really understand this but hdparm adds 1 to
* the real max sectors too, counting zero as sector?
* but only increment if it's already greater than zero
*/
if( nwipe_real_max_sectors > 0 )
{
nwipe_real_max_sectors++;
}
nwipe_log(
NWIPE_LOG_INFO, "func:nwipe_read_dco_real_max_sectors(), DCO real max sectors = %lli", nwipe_real_max_sectors );
return nwipe_real_max_sectors;
}
int ascii2binary_array( char* input, unsigned char* output_bin, int bin_size )
{
/* Converts ascii sense data output by hdparm to binary.
* Scans a character string that contains hexadecimal ascii data, ignores spaces
* and extracts and converts the hexadecimal ascii data to binary and places in a array.
* Typically for dco_identify sense data the bin size will be 512 bytes but for error
* sense data this would be 32 bytes.
*/
int idx_in; // Index into ascii input string
int idx_out; // Index into the binary output array
int byte_count; // Counts which 4 bit value we are working on
char upper4bits;
char lower4bits;
byte_count = 0;
idx_in = 0;
idx_out = 0;
while( input[idx_in] != 0 )
{
if( input[idx_in] >= '0' && input[idx_in] <= '9' )
{
if( byte_count == 0 )
{
upper4bits = input[idx_in] - 0x30;
byte_count++;
}
else
{
lower4bits = input[idx_in] - 0x30;
output_bin[idx_out++] = ( upper4bits << 4 ) | ( lower4bits );
byte_count = 0;
if( idx_out >= bin_size )
{
return 0; // output array full.
}
}
}
else
{
if( input[idx_in] >= 'a' && input[idx_in] <= 'f' )
{
if( byte_count == 0 )
{
upper4bits = input[idx_in] - 0x57;
byte_count++;
}
else
{
lower4bits = input[idx_in] - 0x57;
output_bin[idx_out++] = ( upper4bits << 4 ) | ( lower4bits );
byte_count = 0;
if( idx_out >= bin_size )
{
return 0; // output array full.
}
}
}
}
idx_in++; // next byte in the input string
}
return 0;
}

43
src/hpa_dco.h Normal file
View File

@@ -0,0 +1,43 @@
/*.
* hpa_dco.h: The header file for the host protected area (HPA) and
* disk configuration overlay routines
*
* Copyright https://github.com/PartialVolume/shredos.x86_64
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef HPA_DCO_H_
#define HPA_DCO_H_
#define HPA_DISABLED 0
#define HPA_ENABLED 1
#define HPA_UNKNOWN 2
#define HPA_NOT_APPLICABLE 3
#define HPA_NOT_SUPPORTED_BY_DRIVE 4
int hpa_dco_status( nwipe_context_t* );
u64 nwipe_read_dco_real_max_sectors( char* );
typedef struct nwipe_sense_dco_identify_t_t_
{
/* This struct contains some of the decoded fields from the sense data after a
* ATA 0xB1 device configuration overlay command has been issued. We mainly
* use it to decode the real max sectors
*/
u64 dco_real_max_sectors;
} nwipe_sense_dco_identify_t_t_;
#endif /* HPA_DCO_H_ */

119
src/isaac_rand/isaac64.c Normal file
View File

@@ -0,0 +1,119 @@
/*
------------------------------------------------------------------------------
isaac64.c: My random number generator for 64-bit machines.
By Bob Jenkins, 1996. Public Domain.
------------------------------------------------------------------------------
*/
#ifndef STANDARD
#include "isaac_standard.h"
#endif
#ifndef ISAAC64
#include "isaac64.h"
#endif
#define ind(mm,x) (*(ub8 *)((ub1 *)(mm) + ((x) & ((RANDSIZ-1)<<3))))
#define rngstep(mix,a,b,mm,m,m2,r,x) \
{ \
x = *m; \
a = (mix) + *(m2++); \
*(m++) = y = ind(mm,x) + a + b; \
*(r++) = b = ind(mm,y>>RANDSIZL) + x; \
}
void isaac64(rand64ctx *ctx)
{
register ub8 a,b,x,y,*m,*mm,*m2,*r,*mend;
mm=ctx->mm; r=ctx->randrsl;
a = ctx->aa; b = ctx->bb + (++ctx->cc);
for (m = mm, mend = m2 = m+(RANDSIZ/2); m<mend; )
{
rngstep(~(a^(a<<21)), a, b, mm, m, m2, r, x);
rngstep( a^(a>>5) , a, b, mm, m, m2, r, x);
rngstep( a^(a<<12) , a, b, mm, m, m2, r, x);
rngstep( a^(a>>33) , a, b, mm, m, m2, r, x);
}
for (m2 = mm; m2<mend; )
{
rngstep(~(a^(a<<21)), a, b, mm, m, m2, r, x);
rngstep( a^(a>>5) , a, b, mm, m, m2, r, x);
rngstep( a^(a<<12) , a, b, mm, m, m2, r, x);
rngstep( a^(a>>33) , a, b, mm, m, m2, r, x);
}
ctx->bb = b; ctx->aa = a;
}
#define mix(a,b,c,d,e,f,g,h) \
{ \
a-=e; f^=h>>9; h+=a; \
b-=f; g^=a<<9; a+=b; \
c-=g; h^=b>>23; b+=c; \
d-=h; a^=c<<15; c+=d; \
e-=a; b^=d>>14; d+=e; \
f-=b; c^=e<<20; e+=f; \
g-=c; d^=f>>17; f+=g; \
h-=d; e^=g<<14; g+=h; \
}
void rand64init(rand64ctx *ctx, word flag)
{
word i;
ub8 a,b,c,d,e,f,g,h;
ub8 *mm, *randrsl;
ctx->aa = ctx->bb = ctx->cc = (ub8)0;
mm=ctx->mm;
randrsl=ctx->randrsl;
a=b=c=d=e=f=g=h=0x9e3779b97f4a7c13LL; /* the golden ratio */
for (i=0; i<4; ++i) /* scramble it */
{
mix(a,b,c,d,e,f,g,h);
}
for (i=0; i<RANDSIZ; i+=8) /* fill in mm[] with messy stuff */
{
if (flag) /* use all the information in the seed */
{
a+=randrsl[i ]; b+=randrsl[i+1]; c+=randrsl[i+2]; d+=randrsl[i+3];
e+=randrsl[i+4]; f+=randrsl[i+5]; g+=randrsl[i+6]; h+=randrsl[i+7];
}
mix(a,b,c,d,e,f,g,h);
mm[i ]=a; mm[i+1]=b; mm[i+2]=c; mm[i+3]=d;
mm[i+4]=e; mm[i+5]=f; mm[i+6]=g; mm[i+7]=h;
}
if (flag)
{ /* do a second pass to make all of the seed affect all of mm */
for (i=0; i<RANDSIZ; i+=8)
{
a+=mm[i ]; b+=mm[i+1]; c+=mm[i+2]; d+=mm[i+3];
e+=mm[i+4]; f+=mm[i+5]; g+=mm[i+6]; h+=mm[i+7];
mix(a,b,c,d,e,f,g,h);
mm[i ]=a; mm[i+1]=b; mm[i+2]=c; mm[i+3]=d;
mm[i+4]=e; mm[i+5]=f; mm[i+6]=g; mm[i+7]=h;
}
}
isaac64(ctx); /* fill in the first set of results */
ctx->randcnt=RANDSIZ; /* prepare to use the first set of results */
}
#ifdef NEVER
int main()
{
ub8 i,j;
rand64ctx ctx;
ctx.aa=ctx.bb=ctx.cc=(ub8)0;
for (i=0; i<RANDSIZ; ++i) ctx.mm[i]=(ub8)0;
rand64init(&ctx, TRUE);
for (i=0; i<2; ++i)
{
isaac64(&ctx);
for (j=0; j<RANDSIZ; ++j)
{
printf("%.8lx%.8lx",(ub4)(ctx.randrsl[j]>>32),(ub4)ctx.randrsl[j]);
if ((j&3)==3) printf("\n");
}
}
}
#endif

41
src/isaac_rand/isaac64.h Normal file
View File

@@ -0,0 +1,41 @@
/*
------------------------------------------------------------------------------
isaac64.h: definitions for a random number generator
Bob Jenkins, 1996, Public Domain
------------------------------------------------------------------------------
*/
#ifndef ISAAC64
#define ISAAC64
#include "isaac_standard.h"
struct rand64ctx
{
ub8 randrsl[RANDSIZ], randcnt;
ub8 mm[RANDSIZ];
ub8 aa, bb, cc;
};
typedef struct rand64ctx rand64ctx;
/*
------------------------------------------------------------------------------
If (flag==TRUE), then use the contents of randrsl[0..255] as the seed.
------------------------------------------------------------------------------
*/
void rand64init(rand64ctx *r, word flag);
void isaac64(rand64ctx *ctx);
/*
------------------------------------------------------------------------------
Call rand64() to retrieve a single 64-bit random value
------------------------------------------------------------------------------
*/
#define isaac64_rand() \
(!(r)->randcnt-- ? \
(isaac64(r), (r)->randcnt=RANDSIZ-1, (r)->randrsl[(r)->>randcnt]) : \
(r)->randrsl[(r)->randcnt])
#endif /* ISAAC64 */

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

@@ -10,14 +10,10 @@ MODIFIED:
010626: note this is public domain
------------------------------------------------------------------------------
*/
#ifndef STANDARD
#include "isaac_standard.h"
#endif
#ifndef RAND
#define RAND
#define RANDSIZL (8) /* I recommend 8 for crypto, 4 for simulations */
#define RANDSIZ (1<<RANDSIZL)
#include "isaac_standard.h"
/* context of random number generator */
struct randctx

View File

@@ -54,4 +54,7 @@ typedef int word; /* fastest type available */
#define FALSE 0
#define SUCCESS 0 /* 1 on VAX */
#define RANDSIZL (8) /* I recommend 8 for crypto, 4 for simulations */
#define RANDSIZ (1<<RANDSIZL)
#endif /* STANDARD */

File diff suppressed because it is too large Load Diff

View File

@@ -14,34 +14,52 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef LOGGING_H_
#define LOGGING_H_
typedef enum nwipe_log_t_
{
NWIPE_LOG_NONE = 0,
NWIPE_LOG_DEBUG, /* TODO: Very verbose logging. */
NWIPE_LOG_INFO, /* TODO: Verbose logging. */
NWIPE_LOG_NOTICE, /* Most logging happens at this level. */
NWIPE_LOG_WARNING, /* Things that the user should know about. */
NWIPE_LOG_ERROR, /* Non-fatal errors that result in failure. */
NWIPE_LOG_FATAL, /* Errors that cause the program to exit. */
NWIPE_LOG_SANITY /* Programming errors. */
/* Maximum size of a log message */
#define MAX_LOG_LINE_CHARS 1024
#define MAX_SIZE_OS_STRING 1024 /* Maximum size of acceptable OS string */
#define OS_info_Line_offset 31 /* OS_info line offset in log */
#define OS_info_Line_Length 48 /* OS_info line length */
typedef enum nwipe_log_t_ {
NWIPE_LOG_NONE = 0,
NWIPE_LOG_DEBUG, // Output only when --verbose option used on cmd line.
NWIPE_LOG_INFO, // General Info not specifically relevant to the wipe.
NWIPE_LOG_NOTICE, // Most logging happens at this level related to wiping.
NWIPE_LOG_WARNING, // Things that the user should know about.
NWIPE_LOG_ERROR, // Non-fatal errors that result in failure.
NWIPE_LOG_FATAL, // Errors that cause the program to exit.
NWIPE_LOG_SANITY, // Programming errors.
NWIPE_LOG_NOTIMESTAMP // logs the message without the timestamp
} nwipe_log_t;
/**
* Writes a string to the log. nwipe_log timestamps the string
* @param level the tag to display:
* NWIPE_LOG_NONE Don't display a tag
* NWIPE_LOG_DEBUG, Very verbose logging.
* NWIPE_LOG_INFO, Verbose logging.
* NWIPE_LOG_NOTICE, Most logging happens at this level.
* NWIPE_LOG_WARNING, Things that the user should know about.
* NWIPE_LOG_ERROR, Non-fatal errors that result in failure.
* NWIPE_LOG_FATAL, Errors that cause the program to exit.
* NWIPE_LOG_SANITY, Programming errors.
* NWIPE_LOG_NOTIMESTAMP logs the message without the timestamp
* @param format the string to be logged
*/
void nwipe_log( nwipe_log_t level, const char* format, ... );
void nwipe_perror( int nwipe_errno, const char* f, const char* s );
/* Global array to hold log values to print when logging to STDOUT */
//extern char **log_lines;
//extern int log_current_element;
//extern int log_elements_allocated;
void nwipe_perror( int nwipe_errno, const char* f, const char* s );
void nwipe_log_OSinfo();
int nwipe_log_sysinfo();
void nwipe_log_summary( nwipe_context_t**, int ); // This produces the wipe status table on exit
#endif /* LOGGING_H_ */
/* eof */

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
* methods.c: Method implementations for nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
* This program is free software; you can redistribute it and/or modify it under
@@ -16,43 +16,45 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef METHOD_H_
#define METHOD_H_
/* The argument list for nwipe methods. */
#define NWIPE_METHOD_SIGNATURE nwipe_context_t* c
typedef enum nwipe_verify_t_
{
NWIPE_VERIFY_NONE = 0, /* Do not read anything back from the device. */
NWIPE_VERIFY_LAST, /* Check the last pass. */
NWIPE_VERIFY_ALL, /* Check all passes. */
typedef enum nwipe_verify_t_ {
NWIPE_VERIFY_NONE = 0, // Do not read anything back from the device.
NWIPE_VERIFY_LAST, // Check the last pass.
NWIPE_VERIFY_ALL, // Check all passes.
} nwipe_verify_t;
/* The typedef of the function that will do the wipe. */
typedef int(*nwipe_method_t)( void *ptr );
typedef int ( *nwipe_method_t )( void* ptr );
typedef struct /* nwipe_pattern_t */
typedef struct
{
int length; /* Length of the pattern in bytes, -1 means random. */
char* s; /* The actual bytes of the pattern. */
int length; // Length of the pattern in bytes, -1 means random.
char* s; // The actual bytes of the pattern.
} nwipe_pattern_t;
const char* nwipe_method_label( void* method );
int nwipe_runmethod( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* patterns );
void *nwipe_dod522022m( void *ptr );
void *nwipe_dodshort( void *ptr );
void *nwipe_gutmann( void *ptr );
void *nwipe_ops2( void *ptr );
void *nwipe_random( void *ptr );
void *nwipe_zero( void *ptr );
void* nwipe_dod522022m( void* ptr );
void* nwipe_dodshort( void* ptr );
void* nwipe_gutmann( void* ptr );
void* nwipe_ops2( void* ptr );
void* nwipe_is5enh( void* ptr );
void* nwipe_random( void* ptr );
void* nwipe_zero( void* ptr );
void* nwipe_one( void* ptr );
void* nwipe_verify_zero( void* ptr );
void* nwipe_verify_one( void* ptr );
void calculate_round_size( nwipe_context_t* );
#endif /* METHOD_H_ */
/* eof */

666
src/miscellaneous.c Normal file
View File

@@ -0,0 +1,666 @@
/*
* miscellaneous.c: functions that may be generally used throughout nwipes code,
* mainly string processing functions but also time related functions.
*
* Copyright PartialVolume <https://github.com/PartialVolume>.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif
#include <stdio.h>
#include "nwipe.h"
#include "context.h"
#include "logging.h"
#include "miscellaneous.h"
/* Convert string to upper case
*/
void strupper( char* str )
{
int idx;
idx = 0;
while( str[idx] != 0 )
{
/* If upper case alpha character, change to lower case */
if( str[idx] >= 'A' && str[idx] <= 'Z' )
{
str[idx] -= 32;
}
idx++;
}
}
/* Convert string to lower case
*/
void strlower( char* str )
{
int idx;
idx = 0;
while( str[idx] != 0 )
{
/* If upper case alpha character, change to lower case */
if( str[idx] >= 'A' && str[idx] <= 'Z' )
{
str[idx] += 32;
}
idx++;
}
}
void strip_CR_LF( char* str )
{
/* In the specified string, replace any CR or LF with a space */
int idx = 0;
int len = strlen( str );
while( idx < len )
{
if( str[idx] == 0x0A || str[idx] == 0x0D )
{
str[idx] = ' ';
}
idx++;
}
}
/* Search a string for a positive number, convert the first
* number found to binary and return the binary number.
* returns the number or -1 if number too large or -2 if
* no number found.
*/
u64 str_ascii_number_to_ll( char* str )
{
int idx;
int idx2;
char number_copy[20];
idx = 0; // index into the main string we are searching
idx2 = 0; // index used for backup copy of ascii number
while( str[idx] != 0 )
{
/* Find the start of the number */
if( str[idx] >= '0' && str[idx] <= '9' )
{
while( str[idx] != 0 )
{
/* Find the end of the number */
if( str[idx] >= '0' && str[idx] <= '9' )
{
if( idx2 < sizeof( number_copy ) - 1 )
{
number_copy[idx2++] = str[idx++];
}
else
{
/* Number is too large ! */
return -1;
}
}
else
{
/* end found */
number_copy[idx2] = 0; // terminate our copy
/* convert ascii number to longlong */
return atoll( number_copy );
}
}
}
else
{
idx++;
}
}
return -2; /* no number found */
}
void Determine_C_B_nomenclature( u64 qty, char* result, int result_array_size )
{
/* C_B ? Determine Capacity or Bandwidth nomenclature
*
* A pointer to a result character string with a minimum of 13 characters in length
* should be provided.
*
* Outputs a string of the form xxxTB, xxxGB, xxxMB, xxxKB B depending on the value of 'qty'
*/
/* Initialise the output array */
int idx = 0;
while( idx < result_array_size )
{
result[idx++] = 0;
}
/* Determine the size of throughput so that the correct nomenclature can be used */
if( qty >= INT64_C( 10000000000000 ) )
{
snprintf( result, result_array_size, "%4llu TB", qty / INT64_C( 1000000000000 ) );
}
else if( qty >= INT64_C( 10000000000 ) )
{
snprintf( result, result_array_size, "%4llu GB", qty / INT64_C( 1000000000 ) );
}
else if( qty >= INT64_C( 10000000 ) )
{
snprintf( result, result_array_size, "%4llu MB", qty / INT64_C( 1000000 ) );
}
else if( qty >= INT64_C( 10000 ) )
{
snprintf( result, result_array_size, "%4llu KB", qty / INT64_C( 1000 ) );
}
else
{
snprintf( result, result_array_size, "%4llu B", qty / INT64_C( 1 ) );
}
}
void convert_seconds_to_hours_minutes_seconds( u64 total_seconds, int* hours, int* minutes, int* seconds )
{
/* Convert binary seconds into binary hours, minutes and seconds */
if( total_seconds % 60 )
{
*minutes = total_seconds / 60;
*seconds = total_seconds - ( *minutes * 60 );
}
else
{
*minutes = total_seconds / 60;
*seconds = 0;
}
if( *minutes > 59 )
{
*hours = *minutes / 60;
if( *minutes % 60 )
{
*minutes = *minutes - ( *hours * 60 );
}
else
{
*minutes = 0;
}
}
}
int nwipe_strip_path( char* output, char* input )
{
/* Take the input string, say "/dev/sda" and remove the "/dev/", prefix the result
* with 'length' spaces. So if length=8 and input=/dev/sda, output will
* be " sda", a string 8 characters long right justified with spaces.
*/
int idx_dest;
int idx_src;
idx_dest = 8;
// idx_dest = length;
output[idx_dest--] = 0;
idx_src = strlen( input );
idx_src--;
while( idx_dest >= 0 )
{
/* if the device name contains a / start prefixing spaces */
if( input[idx_src] == '/' )
{
output[idx_dest--] = ' ';
continue;
}
if( idx_src >= 0 )
{
output[idx_dest--] = input[idx_src--];
}
}
return 0;
}
void replace_non_alphanumeric( char* str, char replacement_char )
{
int i = 0;
while( str[i] != 0 )
{
if( str[i] < '0' || ( str[i] > '9' && str[i] < 'A' ) || ( str[i] > 'Z' && str[i] < 'a' ) || str[i] > 'z' )
{
str[i] = replacement_char;
}
i++;
}
}
void convert_double_to_string( char* output_str, double value )
{
int idx = 0;
int idx2;
int idx3 = 0;
char percstr[512] = "";
snprintf( percstr, sizeof( percstr ), "%5.32lf", value );
while( percstr[idx] != 0 )
{
if( percstr[idx] == '.' )
{
for( idx2 = 0; idx2 < 3; idx2++ )
{
output_str[idx3++] = percstr[idx++];
}
break;
}
output_str[idx3++] = percstr[idx++];
}
output_str[idx3] = 0;
}
int read_system_datetime( char* year, char* month, char* day, char* hours, char* minutes, char* seconds )
{
/* Reads system date & time and populates the caller provided strings.
* Each string is null terminated by this function. The calling program
* must provide the minimum string sizes as shown below.
*
* year 5 bytes (4 numeric digits plus NULL terminator)
* month 3 bytes (2 numeric digits plus NULL terminator)
* day 3 bytes (2 numeric digits plus NULL terminator)
* hours 3 bytes (2 numeric digits plus NULL terminator)
* minutes 3 bytes (2 numeric digits plus NULL terminator)
* seconds 3 bytes (2 numeric digits plus NULL terminator)
*
* return value:
* 0 = success
* -1 = Failure, see nwipe log for detail.
*/
FILE* fp;
int r; // A result buffer.
int idx; // general index
int status = 0;
/**
* Obtain the year
*/
fp = popen( "date +%Y", "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to obtain system year using commmand = date +%Y" );
}
else
{
/* Read the first line and validate it. Should be 4 numeric digits */
if( fgets( year, FOUR_DIGITS + 1, fp ) != NULL )
{
idx = 0;
while( idx < 4 )
{
if( year[idx] >= '0' && year[idx] <= '9' )
{
idx++;
}
else
{
/* if we haven't reached the correct number of digits due to invalid data, log error */
year[++idx] = 0; /* terminate the string, prior to using in nwipe_log */
nwipe_log( NWIPE_LOG_ERROR,
"Obtained system year using command = date +%Y, but result appears invalid = %s",
year );
status = -1;
break;
}
}
year[idx] = 0; /* terminate the string */
}
r = pclose( fp );
}
/**
* Obtain the month
*/
fp = popen( "date +%m", "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to obtain system month using the command = date +%m" );
}
else
{
/* Read the first line and validate it. Should be 2 numeric digits */
if( fgets( month, TWO_DIGITS + 1, fp ) != NULL )
{
idx = 0;
while( idx < 2 )
{
if( month[idx] >= '0' && month[idx] <= '9' )
{
idx++;
}
else
{
/* if we haven't reached the correct number of digits due to invalid data, log error */
month[++idx] = 0; /* terminate the string, prior to using in nwipe_log */
nwipe_log( NWIPE_LOG_ERROR,
"Obtained system month using command = date +%m, but result appears invalid = %s",
month );
status = -1;
break;
}
}
month[idx] = 0; /* terminate the string */
}
r = pclose( fp );
}
/**
* Obtain the day
*/
fp = popen( "date +\%d", "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to obtain system day using the command = date +\%d" );
}
else
{
/* Read the first line and validate it. Should be 2 numeric digits */
if( fgets( day, TWO_DIGITS + 1, fp ) != NULL )
{
idx = 0;
while( idx < 2 )
{
if( day[idx] >= '0' && day[idx] <= '9' )
{
idx++;
}
else
{
/* if we haven't reached the correct number of digits due to invalid data, log error */
day[++idx] = 0; /* terminate the string, prior to using in nwipe_log */
nwipe_log( NWIPE_LOG_ERROR,
"Obtained system day using command = date +\%d, but result appears invalid = %s",
day );
status = -1;
break;
}
}
day[idx] = 0; /* terminate the string */
}
r = pclose( fp );
}
/**
* Obtain the hours
*/
fp = popen( "date +%H", "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to obtain system hour using the command = date +%H" );
}
else
{
/* Read the first line and validate it. Should be 2 numeric digits */
if( fgets( hours, TWO_DIGITS + 1, fp ) != NULL )
{
// nwipe_log( NWIPE_LOG_INFO, "Seconds = %s, Year = %s", seconds, year);
idx = 0;
while( idx < 2 )
{
if( hours[idx] >= '0' && hours[idx] <= '9' )
{
idx++;
}
else
{
/* if we haven't reached the correct number of digits due to invalid data, log error */
hours[++idx] = 0; /* terminate the string, prior to using in nwipe_log */
nwipe_log( NWIPE_LOG_ERROR,
"Obtained system hours using command = date +%H, but result appears invalid = %s",
hours );
status = -1;
break;
}
}
hours[idx] = 0; /* terminate the string */
}
r = pclose( fp );
}
/**
* Obtain the minutes
*/
fp = popen( "date +%M", "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to obtain system minutes using the command = date +%M" );
}
else
{
/* Read the first line and validate it. Should be 2 numeric digits */
if( fgets( minutes, TWO_DIGITS + 1, fp ) != NULL )
{
// nwipe_log( NWIPE_LOG_INFO, "Seconds = %s, Year = %s", seconds, year);
idx = 0;
while( idx < 2 )
{
if( minutes[idx] >= '0' && minutes[idx] <= '9' )
{
idx++;
}
else
{
/* if we haven't reached the correct number of digits due to invalid data, log the error */
minutes[++idx] = 0; /* terminate the string, prior to using in nwipe_log */
nwipe_log( NWIPE_LOG_ERROR,
"Obtained system minutes using command = date +%H, but result appears invalid = %s",
minutes );
status = -1;
break;
}
}
minutes[idx] = 0; /* terminate the string */
}
r = pclose( fp );
}
/**
* Obtain the seconds
*/
fp = popen( "date +%S", "r" );
if( fp == NULL )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to obtain system seconds using the command = date +%S" );
}
else
{
/* Read the first line and validate it. Should be 2 numeric digits */
if( fgets( seconds, TWO_DIGITS + 1, fp ) != NULL )
{
// nwipe_log( NWIPE_LOG_INFO, "Seconds = %s, Year = %s", seconds, year);
idx = 0;
while( idx < 2 )
{
if( seconds[idx] >= '0' && seconds[idx] <= '9' )
{
idx++;
}
else
{
/* if we haven't reached the correct number of digits due to invalid data, log error */
seconds[++idx] = 0; /* terminate the string, prior to using in nwipe_log */
nwipe_log( NWIPE_LOG_ERROR,
"Obtained system seconds using command = date +%S, but result appears invalid = %s",
seconds );
status = -1;
break;
}
}
seconds[idx] = 0; /* terminate the string */
}
r = pclose( fp );
}
return status;
}
int write_system_datetime( char* year, char* month, char* day, char* hours, char* minutes, char* seconds )
{
/* Writes the system date & time using data from the caller provided strings.
* The calling program must provide the minimum string sizes as shown below
* populated with current date and time data.
*
* year 5 bytes (4 numeric digits plus NULL terminator)
* month 3 bytes (2 numeric digits plus NULL terminator)
* day 3 bytes (2 numeric digits plus NULL terminator)
* hours 3 bytes (2 numeric digits plus NULL terminator)
* minutes 3 bytes (2 numeric digits plus NULL terminator)
* seconds 3 bytes (2 numeric digits plus NULL terminator)
*
* return value:
* 0 = success
* -1 = Failure, see nwipe log for detail.
*/
FILE* fp;
int r; // A result buffer.
int idx; // general index
int strIdx; // Index into each string
int bufferIdx; // Index into the buffer
char buffer[5];
/**
* Basic validation that confirms the input strings are numeric and of the correct length, we do this
* by first constructing three arrays. The first are the names of the variables in order
* year, month, day, hours, minutes and seconds. The second array contains the address of
* each of those strings. The third array are the lengths.
* This allows us to create a single loop to validate all fields.
*/
char* names[] = { "year", "month", "day", "hours", "minutes", "seconds" };
char* pdata[] = { year, month, day, hours, minutes, seconds };
int lengths[] = { 4, 2, 2, 2, 2, 2 };
char cmd_format[] = "date %s%s%s%s%s.%s >/dev/null 2>&1";
char cmd[256];
for( idx = 0; idx < 6; idx++ )
{
strIdx = 0; // initialise string index
/* check each characters is numeric */
while( strIdx < lengths[idx] )
{
if( pdata[idx][strIdx] >= '0' && pdata[idx][strIdx] <= '9' )
{
strIdx++;
}
else
{
/* if we haven't reached the correct number of digits due to invalid data, log error,
* but first we read the valid data acquired so far into a buffer, this is done to avoid
* writing to the user provided string because if they did not size the string correctly
* writing a zero at the end could cause a segfault.
*/
for( bufferIdx = 0; bufferIdx < strIdx + 1; bufferIdx++ )
{
buffer[bufferIdx] = pdata[idx][bufferIdx];
}
buffer[bufferIdx] = 0; /* terminate the string, prior to using in nwipe_log */
/* A typical error will look like ..
* "User provided year data that appear invalid = 202£" */
nwipe_log( NWIPE_LOG_ERROR, "User provided %s data that appears invalid = %s", names[idx], buffer );
return -1;
}
}
}
/**
* Now using the validated strings construct the date command that we will use to write the system date/time
*/
sprintf( cmd, cmd_format, month, day, hours, minutes, year, seconds );
/**
* Run the date command to write the new date/time
*/
fp = popen( cmd, "w" );
r = pclose( fp );
if( fp == NULL || r != 0 )
{
nwipe_log( NWIPE_LOG_ERROR, "Failed to write system date/time using command = %s", cmd );
}
else
{
nwipe_log( NWIPE_LOG_INFO, "Date/time succesfully writen to system using command = %s", cmd );
}
return 0;
}
void fix_endian_model_names( char* model )
{
/* Some IDE USB adapters get the endian wrong, we can't determine the endian from the drive
* as the drive standard doesn't provide that information, so we have to resort to matching
* the model name against known strings with the endian incorrect, then reverse the endian.
*/
int idx = 0;
int idx2 = 0;
unsigned int length = 0;
char* tmp_string;
length = strlen( model );
tmp_string = calloc( length, 1 );
/* "ASSMNU G" = "SAMSUNG ", tested against model Samsung HM160HC so that
* "ASSMNU G MH61H0 C" becomes "SAMSUNG HM160HC ")
*/
if( !( strncmp( model, "ASSMNU G", 8 ) ) )
{
while( model[idx] != 0 )
{
tmp_string[idx2 + 1] = model[idx];
if( model[idx + 1] != 0 )
{
tmp_string[idx2] = model[idx + 1];
}
else
{
break;
}
if( tmp_string[idx2 + 1] == ' ' && model[idx + 2] == ' ' )
{
idx++;
}
idx += 2;
idx2 += 2;
}
tmp_string[idx2 + 1] = 0;
strcpy( model, tmp_string );
}
}

132
src/miscellaneous.h Normal file
View File

@@ -0,0 +1,132 @@
/*
* miscellaneous.h: header file for miscellaneous.c ..
*
* functions that may be generally used throughout nwipes code,
* mainly string processing related functions.
*
* Copyright PartialVolume <https://github.com/PartialVolume>.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef MISCELLANEOUS_H_
#define MISCELLANEOUS_H_
#define FOUR_DIGITS 4
#define TWO_DIGITS 2
/**
* Convert the string from lower to upper case
* @param pointer to a null terminated string
* @return void
*/
void strupper( char* );
/**
* Convert the string from upper to lower case
* @param pointer to a null terminated string
* @return void
*/
void strlower( char* str );
/**
* Search a string for a positive number, convert the first
* number found to binary and return the binary number.
* returns the number or -1 if number too large or -2 if
* no number found.
*
* @param pointer to a null terminated string
* @return longlong returns:
* the number
* -1 = number too large
* -2 = no number found.
*/
u64 str_ascii_number_to_ll( char* );
void Determine_C_B_nomenclature( u64, char*, int );
void convert_seconds_to_hours_minutes_seconds( u64, int*, int*, int* );
int nwipe_strip_path( char*, char* );
/**
* Scan a string and replace any characters that are not alpha-numeric with
* the character_char.
* Example:
* char str[] = 18:21:56;
* calling the function replace_non_alphanumeric( &str, '_' )
* would result in str changing from 18:21:56 to 18_21_56
* @param char* pointer to the string to be processed
* @param char the character used to replace non alpha-numeric characters
* @return void
*/
void replace_non_alphanumeric( char*, char );
/**
* I found this function necessary when converting a double of say
* 99.999999999999999999 to text using printf. I only wanted 99.99
* printed but if you specified a precision of %.2f in printf i.e 2 digits
* after the decimal point you get 100.00 and not 99.99 If you increase
* the precision to %.10f then you get 99.9999999999 but I only want
* two significant digits displayed.i.e 99.99% not 100%
* So this function converts to double retaining sufficient precision
* so that a 30TB disc with one hidden sector will display as 99.99% erased
* As an example if the double value to be converted is 99.999999999999999987
* this function will always output 99.99 unlike printf which outputs 100.00
* @param char* pointer to the string we write our percentage to. Needs to be
* a minimum of 7 bytes, i.e 100.00 plus null terminator.
* @param double the floating point value to be converted to a string.
* @return void
*/
void convert_double_to_string( char*, double );
/**
* Reads system date & time and populates the caller provided strings.
* Each string is null terminated by this function. The calling
* program must provide the minimum string sizes as shown below.
*
* @param char* year 5 bytes (4 numeric digits plus NULL terminator)
* @param char* month 3 bytes (2 numeric digits plus NULL terminator)
* @param char* day 3 bytes (2 numeric digits plus NULL terminator)
* @param char* hours 3 bytes (2 numeric digits plus NULL terminator)
* @param char* minutes 3 bytes (2 numeric digits plus NULL terminator)
* @param char* seconds 3 bytes (2 numeric digits plus NULL terminator)
* @return 0 = success, -1 = failure. See nwipe log for detail.
*/
int read_system_datetime( char*, char*, char*, char*, char*, char* );
/**
* Writes system date & time from the caller provided strings.
* The calling program must provide the minimum populated string sizes
* as shown below.
*
* @param char* year 5 bytes (4 numeric digits plus NULL terminator)
* @param char* month 3 bytes (2 numeric digits plus NULL terminator)
* @param char* day 3 bytes (2 numeric digits plus NULL terminator)
* @param char* hours 3 bytes (2 numeric digits plus NULL terminator)
* @param char* minutes 3 bytes (2 numeric digits plus NULL terminator)
* @param char* seconds 3 bytes (2 numeric digits plus NULL terminator)
* @return 0 = success, -1 = failure. See nwipe log for detail.
*/
int write_system_datetime( char*, char*, char*, char*, char*, char* );
/**
* Fixes drive model names that have the incorrect endian. This happens
* with some IDE USB adapters.
*
* @param char* pointer to the drive model names
* @return void
*/
void fix_endian_model_names( char* model );
#endif /* HPA_DCO_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/*
/*.
* nwipe.h: The header file of the nwipe program.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
* This program is free software; you can redistribute it and/or modify it under
@@ -16,13 +16,18 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef NWIPE_H_
#define NWIPE_H_
/* Function prototypes */
int cleanup();
void check_for_autopoweroff( void );
void* signal_hand( void* );
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
@@ -31,11 +36,6 @@
#define _FILE_OFFSET_BITS 64
#endif
/* workaround for Fedora */
#ifndef off64_t
# define off64_t off_t
#endif
/* Busybox headers. */
#ifdef BB_VER
#include "busybox.h"
@@ -59,27 +59,33 @@
#include <time.h>
#include <unistd.h>
#include "config.h"
/* workaround for Fedora */
#ifndef off64_t
#ifndef off_t
#define off64_t int64_t
#else
#define off64_t off_t
#endif
#endif
/*#include "config.h"*/
/* System errors. */
extern int errno;
/* Global array to hold log values to print when logging to STDOUT */
extern char **log_lines;
extern int log_current_element;
extern int log_elements_allocated;
extern pthread_mutex_t mutex1;
/* 0=wipe not yet started, 1=wipe has been started by the user */
extern int global_wipe_status;
/* Ncurses headers. */
#ifdef NCURSES_IN_SUBDIR
#include <ncurses/ncurses.h>
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#include <ncurses.h>
#endif
#ifdef PANEL_IN_SUBDIR
#include <ncurses/panel.h>
#include <ncurses/panel.h>
#else
#include <panel.h>
#include <panel.h>
#endif
/* Kernel device headers. */
@@ -87,24 +93,22 @@ extern pthread_mutex_t mutex1;
/* These types are usually defined in <asm/types.h> for __KERNEL__ code. */
typedef unsigned long long u64;
typedef unsigned long u32;
typedef unsigned short u16;
typedef unsigned char u8;
typedef unsigned long u32;
typedef unsigned short u16;
typedef unsigned char u8;
/* This is required for ioctl BLKGETSIZE64, but it conflicts with <wait.h>. */
/* #include <linux/fs.h> */
/* Define ioctls that cannot be included. */
#define BLKSSZGET _IO(0x12,104)
#define BLKBSZGET _IOR(0x12,112,size_t)
#define BLKBSZSET _IOW(0x12,113,size_t)
#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64))
#define BLKSSZGET _IO( 0x12, 104 )
#define BLKBSZGET _IOR( 0x12, 112, size_t )
#define BLKBSZSET _IOW( 0x12, 113, size_t )
#define BLKGETSIZE64 _IOR( 0x12, 114, sizeof( u64 ) )
#define THREAD_CANCELLATION_TIMEOUT 10
/* This is required for ioctl FDFLUSH. */
#include <linux/fd.h>
void *signal_hand(void *);
#endif /* NWIPE_H_ */
/* eof */

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
* options.h: Command line processing routines for nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
* This program is free software; you can redistribute it and/or modify it under
@@ -16,26 +16,29 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef OPTIONS_H_
#define OPTIONS_H_
/* Program knobs. */
#define NWIPE_KNOB_ENTROPY "/dev/urandom"
#define NWIPE_KNOB_IDENTITY_SIZE 512
#define NWIPE_KNOB_LABEL_SIZE 128
#define NWIPE_KNOB_LOADAVG "/proc/loadavg"
#define NWIPE_KNOB_LOG_BUFFERSIZE 1024 /* Maximum length of a log event. */
#define NWIPE_KNOB_PARTITIONS "/proc/partitions"
#define NWIPE_KNOB_PARTITIONS_PREFIX "/dev/"
#define NWIPE_KNOB_PRNG_STATE_LENGTH 512 /* 128 words */
#define NWIPE_KNOB_SCSI "/proc/scsi/scsi"
#define NWIPE_KNOB_SLEEP 1
#define NWIPE_KNOB_STAT "/proc/stat"
#define NWIPE_KNOB_ENTROPY "/dev/urandom"
#define NWIPE_KNOB_IDENTITY_SIZE 512
#define NWIPE_KNOB_LABEL_SIZE 128
#define NWIPE_KNOB_LOADAVG "/proc/loadavg"
#define NWIPE_KNOB_LOG_BUFFERSIZE 1024 // Maximum length of a log event.
#define NWIPE_KNOB_PARTITIONS "/proc/partitions"
#define NWIPE_KNOB_PARTITIONS_PREFIX "/dev/"
#define NWIPE_KNOB_PRNG_STATE_LENGTH 512 // 128 words
#define NWIPE_KNOB_SCSI "/proc/scsi/scsi"
#define NWIPE_KNOB_SLEEP 1
#define NWIPE_KNOB_STAT "/proc/stat"
#define MAX_NUMBER_EXCLUDED_DRIVES 32
#define MAX_DRIVE_PATH_LENGTH 200 // e.g. /dev/sda is only 8 characters long, so 200 should be plenty.
#define DEFAULT_SYNC_RATE 100000
#define PATHNAME_MAX 2048
/* Function prototypes for loading options from the environment and command line. */
int nwipe_options_parse( int argc, char** argv );
@@ -44,25 +47,30 @@ void nwipe_options_log( void );
/* Function to display help text */
void display_help();
typedef struct /* nwipe_options_t */
typedef struct
{
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 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 */
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. */
nwipe_verify_t verify; /* A flag to indicate whether writes should be verified. */
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.
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[PATHNAME_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
int rounds; // The number of times that the wipe method should be called.
int sync; // A flag to indicate whether and how often writes should be sync'd.
int verbose; // Make log more verbose
int PDF_enable; // 0=PDF creation disabled, 1=PDF creation enabled
int PDF_preview_details; // 0=Disable preview Org/Cust/date/time before drive selection, 1=Enable Preview
nwipe_verify_t verify; // A flag to indicate whether writes should be verified.
} nwipe_options_t;
extern nwipe_options_t nwipe_options;
#endif /* OPTIONS_H_ */
/* eof */

1266
src/pass.c

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
* pass.h: Routines that read and write patterns to block devices.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>
*
* This program is free software; you can redistribute it and/or modify it under
@@ -16,20 +16,18 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef PASS_H_
#define PASS_H_
int nwipe_random_pass ( nwipe_context_t* c );
int nwipe_random_pass( nwipe_context_t* c );
int nwipe_random_verify( nwipe_context_t* c );
int nwipe_static_pass ( nwipe_context_t* c, nwipe_pattern_t* pattern );
int nwipe_static_pass( nwipe_context_t* c, nwipe_pattern_t* pattern );
int nwipe_static_verify( nwipe_context_t* c, nwipe_pattern_t* pattern );
void test_functionn( int count, nwipe_context_t** c );
#endif /* PASS_H_ */
/* eof */

View File

@@ -2,154 +2,251 @@
* prng.c: Pseudo Random Number Generator abstractions for nwipe.
*
* Copyright Darik Horn <dajhorn-dban@vanadac.com>.
*
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "nwipe.h"
#include "prng.h"
#include "context.h"
#include "logging.h"
#include "mt19937ar-cok.h"
#include "isaac_rand.h"
#include "mt19937ar-cok/mt19937ar-cok.h"
#include "isaac_rand/isaac_rand.h"
#include "isaac_rand/isaac64.h"
nwipe_prng_t nwipe_twister = { "Mersenne Twister (mt19937ar-cok)", nwipe_twister_init, nwipe_twister_read };
nwipe_prng_t nwipe_twister =
nwipe_prng_t nwipe_isaac = { "ISAAC (rand.c 20010626)", nwipe_isaac_init, nwipe_isaac_read };
nwipe_prng_t nwipe_isaac64 = { "ISAAC-64 (isaac64.c)", nwipe_isaac64_init, nwipe_isaac64_read };
/* Print given number of bytes from unsigned integer number to a byte stream buffer starting with low-endian. */
static inline void u32_to_buffer( u8* restrict buffer, u32 val, const int len )
{
"Mersenne Twister (mt19937ar-cok)",
nwipe_twister_init,
nwipe_twister_read
};
nwipe_prng_t nwipe_isaac =
for( int i = 0; i < len; ++i )
{
buffer[i] = (u8) ( val & 0xFFUL );
val >>= 8;
}
}
static inline void u64_to_buffer( u8* restrict buffer, u64 val, const int len )
{
"ISAAC (rand.c 20010626)",
nwipe_isaac_init,
nwipe_isaac_read
};
/* 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)
for( int i = 0; i < len; ++i )
{
buffer[i] = (u8) ( val & 0xFFULL );
val >>= 8;
}
}
static inline u32 isaac_nextval( randctx* restrict ctx )
{
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;
if( ctx->randcnt == 0 )
{
isaac( ctx );
ctx->randcnt = RANDSIZ;
}
ctx->randcnt--;
return ctx->randrsl[ctx->randcnt];
}
static inline u64 isaac64_nextval( rand64ctx* restrict ctx )
{
if( ctx->randcnt == 0 )
{
isaac64( ctx );
ctx->randcnt = RANDSIZ;
}
ctx->randcnt--;
return ctx->randrsl[ctx->randcnt];
}
int nwipe_twister_init( NWIPE_PRNG_INIT_SIGNATURE )
{
if( *state == NULL )
{
/* This is the first time that we have been called. */
*state = malloc( sizeof( twister_state_t ) );
}
twister_init( (twister_state_t*)*state, (u32*)( seed->s ), seed->length / sizeof( u32 ) );
return 0;
nwipe_log( NWIPE_LOG_NOTICE, "Initialising Mersenne Twister prng" );
if( *state == NULL )
{
/* This is the first time that we have been called. */
*state = malloc( sizeof( twister_state_t ) );
}
twister_init( (twister_state_t*) *state, (u32*) ( seed->s ), seed->length / sizeof( u32 ) );
return 0;
}
int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE )
{
u32 i=0;
u32 ii;
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
u8* restrict bufpos = buffer;
size_t words = count / SIZE_OF_TWISTER; // the values of twister_genrand_int32 is strictly 4 bytes
/* Twister returns 4-bytes per call, so progress by 4 bytes. */
for( ii = 0; ii < words; ++ii )
{
nwipe_u32tobuffer((u8*)(buffer+i), twister_genrand_int32( (twister_state_t*)*state ), SIZE_OF_TWISTER) ;
i = i + SIZE_OF_TWISTER;
}
for( size_t ii = 0; ii < words; ++ii )
{
u32_to_buffer( bufpos, twister_genrand_int32( (twister_state_t*) *state ), SIZE_OF_TWISTER );
bufpos += SIZE_OF_TWISTER;
}
/* If there is some remainder copy only relevant number of bytes to not
* overflow the buffer. */
if ( remain > 0 )
{
nwipe_u32tobuffer((u8*)(buffer+i), twister_genrand_int32( (twister_state_t*)*state ), remain) ;
}
return 0;
const size_t remain = count % SIZE_OF_TWISTER; // SIZE_OF_TWISTER is strictly 4 bytes
if( remain > 0 )
{
u32_to_buffer( bufpos, twister_genrand_int32( (twister_state_t*) *state ), remain );
}
return 0;
}
int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE )
{
int count;
randctx* isaac_state = *state;
int count;
randctx* isaac_state = *state;
if( *state == NULL )
{
/* This is the first time that we have been called. */
*state = malloc( sizeof( randctx ) );
isaac_state = *state;
nwipe_log( NWIPE_LOG_NOTICE, "Initialising Isaac prng" );
/* Check the memory allocation. */
if( isaac_state == 0 )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate memory for the isaac state." );
return -1;
}
}
if( *state == NULL )
{
/* This is the first time that we have been called. */
*state = malloc( sizeof( randctx ) );
isaac_state = *state;
/* Check the memory allocation. */
if( isaac_state == 0 )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate memory for the isaac state." );
return -1;
}
}
/* Take the minimum of the isaac seed size and available entropy. */
if( sizeof( isaac_state->randrsl ) < seed->length )
{
count = sizeof( isaac_state->randrsl );
}
else
{
memset( isaac_state->randrsl, 0, sizeof( isaac_state->randrsl ) );
count = seed->length;
}
/* Take the minimum of the isaac seed size and available entropy. */
if( sizeof( isaac_state->randrsl ) < seed->length )
{
count = sizeof( isaac_state->randrsl );
}
else
{
memset( isaac_state->randrsl, 0, sizeof( isaac_state->randrsl ) );
count = seed->length;
}
if( count == 0 )
{
/* Start ISACC without a seed. */
randinit( isaac_state, 0 );
}
else
{
/* Seed the ISAAC state with entropy. */
memcpy( isaac_state->randrsl, seed->s, count );
if( count == 0 )
{
/* Start ISACC without a seed. */
randinit( isaac_state, 0 );
}
else
{
/* Seed the ISAAC state with entropy. */
memcpy( isaac_state->randrsl, seed->s, count );
/* The second parameter indicates that randrsl is non-empty. */
randinit( isaac_state, 1 );
}
/* The second parameter indicates that randrsl is non-empty. */
randinit( isaac_state, 1 );
}
return 0;
return 0;
}
int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE )
{
return 0;
randctx* isaac_state = *state;
u8* restrict bufpos = buffer;
size_t words = count / SIZE_OF_ISAAC; // the values of isaac is strictly 4 bytes
/* Isaac returns 4-bytes per call, so progress by 4 bytes. */
for( size_t ii = 0; ii < words; ++ii )
{
/* get the next 32bit random number */
u32_to_buffer( bufpos, isaac_nextval( isaac_state ), SIZE_OF_ISAAC );
bufpos += SIZE_OF_ISAAC;
}
/* If there is some remainder copy only relevant number of bytes to not overflow the buffer. */
const size_t remain = count % SIZE_OF_ISAAC; // SIZE_OF_ISAAC is strictly 4 bytes
if( remain > 0 )
{
u32_to_buffer( bufpos, isaac_nextval( isaac_state ), remain );
}
return 0;
}
/* eof */
int nwipe_isaac64_init( NWIPE_PRNG_INIT_SIGNATURE )
{
int count;
rand64ctx* isaac_state = *state;
nwipe_log( NWIPE_LOG_NOTICE, "Initialising ISAAC-64 prng" );
if( *state == NULL )
{
/* This is the first time that we have been called. */
*state = malloc( sizeof( rand64ctx ) );
isaac_state = *state;
/* Check the memory allocation. */
if( isaac_state == 0 )
{
nwipe_perror( errno, __FUNCTION__, "malloc" );
nwipe_log( NWIPE_LOG_FATAL, "Unable to allocate memory for the isaac state." );
return -1;
}
}
/* Take the minimum of the isaac seed size and available entropy. */
if( sizeof( isaac_state->randrsl ) < seed->length )
{
count = sizeof( isaac_state->randrsl );
}
else
{
memset( isaac_state->randrsl, 0, sizeof( isaac_state->randrsl ) );
count = seed->length;
}
if( count == 0 )
{
/* Start ISACC without a seed. */
rand64init( isaac_state, 0 );
}
else
{
/* Seed the ISAAC state with entropy. */
memcpy( isaac_state->randrsl, seed->s, count );
/* The second parameter indicates that randrsl is non-empty. */
rand64init( isaac_state, 1 );
}
return 0;
}
int nwipe_isaac64_read( NWIPE_PRNG_READ_SIGNATURE )
{
rand64ctx* isaac_state = *state;
u8* restrict bufpos = buffer;
size_t words = count / SIZE_OF_ISAAC64; // the values of ISAAC-64 is strictly 8 bytes
for( size_t ii = 0; ii < words; ++ii )
{
u64_to_buffer( bufpos, isaac64_nextval( isaac_state ), SIZE_OF_ISAAC64 );
bufpos += SIZE_OF_ISAAC64;
}
/* If there is some remainder copy only relevant number of bytes to not overflow the buffer. */
const size_t remain = count % SIZE_OF_ISAAC64; // SIZE_OF_ISAAC64 is strictly 8 bytes
if( remain > 0 )
{
u64_to_buffer( bufpos, isaac64_nextval( isaac_state ), remain );
}
return 0;
}

View File

@@ -14,33 +14,35 @@
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef PRNG_H_
#define PRNG_H_
#include <sys/types.h>
/* A chunk of random data. */
typedef struct /* nwipe_entropy_t */
typedef struct
{
size_t length; /* Length of the entropy string in bytes. */
u8* s; /* The actual bytes of the entropy string. */
size_t length; // Length of the entropy string in bytes.
u8* s; // The actual bytes of the entropy string.
} nwipe_entropy_t;
#define NWIPE_PRNG_INIT_SIGNATURE void** state, nwipe_entropy_t* seed
#define NWIPE_PRNG_READ_SIGNATURE void** state, void* buffer, size_t count
#define NWIPE_PRNG_INIT_SIGNATURE void **state, nwipe_entropy_t *seed
#define NWIPE_PRNG_READ_SIGNATURE void **state, void *buffer, size_t count
/* Function pointers for PRNG actions. */
typedef int(*nwipe_prng_init_t)( NWIPE_PRNG_INIT_SIGNATURE );
typedef int(*nwipe_prng_read_t)( NWIPE_PRNG_READ_SIGNATURE );
typedef int ( *nwipe_prng_init_t )( NWIPE_PRNG_INIT_SIGNATURE );
typedef int ( *nwipe_prng_read_t )( NWIPE_PRNG_READ_SIGNATURE );
/* The generic PRNG definition. */
typedef struct /* nwipe_prng_t */
typedef struct
{
const char* label; /* The name of the pseudo random number generator. */
nwipe_prng_init_t init; /* Inialize the prng state with the seed. */
nwipe_prng_read_t read; /* Read data from the prng. */
const char* label; // The name of the pseudo random number generator.
nwipe_prng_init_t init; // Inialize the prng state with the seed.
nwipe_prng_read_t read; // Read data from the prng.
} nwipe_prng_t;
/* Mersenne Twister prototypes. */
@@ -50,11 +52,14 @@ int nwipe_twister_read( NWIPE_PRNG_READ_SIGNATURE );
/* ISAAC prototypes. */
int nwipe_isaac_init( NWIPE_PRNG_INIT_SIGNATURE );
int nwipe_isaac_read( NWIPE_PRNG_READ_SIGNATURE );
int nwipe_isaac64_init( NWIPE_PRNG_INIT_SIGNATURE );
int nwipe_isaac64_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
/* Size of the isaac/isaac64 is not derived from the architecture, but it is strictly 4 or 8 bytes */
#define SIZE_OF_ISAAC 4
#define SIZE_OF_ISAAC64 8
#endif /* PRNG_H_ */
/* eof */

BIN
src/redcross.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
src/te.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

495
src/temperature.c Normal file
View File

@@ -0,0 +1,495 @@
/*
* temperature.c: functions that populate the drive temperature variables
* in each drives context structure.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//#define _LARGEFILE64_SOURCE
//#define _FILE_OFFSET_BITS 64
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <dirent.h>
#include <sys/time.h>
#include "nwipe.h"
#include "context.h"
#include "method.h"
#include "device.h"
#include "prng.h"
#include "options.h"
#include "device.h"
#include "logging.h"
#include "temperature.h"
#include "miscellaneous.h"
extern int terminate_signal;
int nwipe_init_temperature( nwipe_context_t* c )
{
/* See header definition for description of function
*/
DIR* dir;
DIR* dir2;
const char dirpath[] = "/sys/class/hwmon";
char dirpath_tmp[256];
char dirpath_tmp2[256];
char dirpath_hwmonX[256];
char device[256];
char device_context_name[256];
// const char dirpath[] = "/home/nick/mouse/hwmon1";
struct dirent* dp;
struct dirent* dp2;
/* Why Initialise with 1000000 (defined as NO_TEMPERATURE_DATA)?
* Because the GUI needs to know whether data has been obtained
* so it can display appropriate information when a
* device is unable to provide temperature data */
c->templ_has_hwmon_data = 0;
c->temp1_crit = NO_TEMPERATURE_DATA;
c->temp1_highest = NO_TEMPERATURE_DATA;
c->temp1_input = NO_TEMPERATURE_DATA;
c->temp1_lcrit = NO_TEMPERATURE_DATA;
c->temp1_lowest = NO_TEMPERATURE_DATA;
c->temp1_max = NO_TEMPERATURE_DATA;
c->temp1_min = NO_TEMPERATURE_DATA;
c->temp1_monitored_wipe_max = NO_TEMPERATURE_DATA;
c->temp1_monitored_wipe_min = NO_TEMPERATURE_DATA;
c->temp1_monitored_wipe_avg = NO_TEMPERATURE_DATA;
c->temp1_flash_rate = 0;
c->temp1_flash_rate_counter = 0;
c->temp1_path[0] = 0;
c->temp1_time = 0;
/* Each hwmonX directory is processed in turn and once a hwmonX directory has been
* found that is a block device and the block device name matches the drive
* name in the current context then the path to ../hwmonX is constructed and written
* to the drive context structure '* c'. This path is used in the nwipe_update_temperature
* function to retrieve temperature data and store it in the device context
*/
if( ( dir = opendir( dirpath ) ) != NULL )
{
/* Process each hwmonX sub directory in turn */
while( ( dp = readdir( dir ) ) != NULL )
{
/* Does the directory start with 'hwmon' */
if( strstr( dp->d_name, "hwmon" ) != NULL )
{
if( nwipe_options.verbose )
{
/* print a empty line to separate the different hwmon sensors */
nwipe_log( NWIPE_LOG_DEBUG, "hwmon:" );
}
strcpy( dirpath_tmp, dirpath );
strcat( dirpath_tmp, "/" );
strcat( dirpath_tmp, dp->d_name );
strcpy( dirpath_hwmonX, dirpath_tmp );
strcat( dirpath_tmp, "/device/block" );
/* Depending on the class of block device, the device name may
* appear in different sub-directories. So we try to open each
* directory that are known to contain block devices. These are
* /sys/class/hwmon/hwmonX/device/block
* /sys/class/hwmon/hwmonX/device/nvme/nvme0
* /sys/class/hwmon/hwmonX/device/
*/
if( ( dir2 = opendir( dirpath_tmp ) ) == NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: %s doesn't exist, trying next path", dirpath_tmp );
}
strcpy( dirpath_tmp2, dirpath_hwmonX );
strcat( dirpath_tmp2, "/device/nvme/nvme0" );
strcpy( dirpath_tmp, dirpath_tmp2 );
if( ( dir2 = opendir( dirpath_tmp ) ) == NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: %s doesn't exist, trying next path", dirpath_tmp );
}
strcpy( dirpath_tmp2, dirpath_hwmonX );
strcat( dirpath_tmp2, "/device" );
strcpy( dirpath_tmp, dirpath_tmp2 );
if( ( dir2 = opendir( dirpath_tmp ) ) == NULL )
{
if( nwipe_options.verbose )
{
nwipe_log(
NWIPE_LOG_DEBUG, "hwmon: %s doesn't exist, no more paths to try", dirpath_tmp );
}
continue;
}
}
}
if( dir2 != NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: Found %s", dirpath_tmp );
}
/* Read the device name */
while( ( dp2 = readdir( dir2 ) ) != NULL )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: dirpath_tmp=%s/%s", dirpath_tmp, &dp2->d_name[0] );
}
/* Skip the '.' and '..' directories */
if( dp2->d_name[0] == '.' )
{
continue;
}
strcpy( device, dp2->d_name );
/* Create a copy of the device name from the context but strip the path from it, right justify
* device name, prefix with spaces so length is 8. */
nwipe_strip_path( device_context_name, c->device_name );
/* Remove leading/training whitespace from a string and left justify result */
trim( device_context_name );
/* Does the hwmon device match the device for this drive context */
if( strcmp( device, device_context_name ) != 0 )
{
/* No, so try next hwmon device */
continue;
}
else
{
/* Match ! This hwmon device matches this context, so write the hwmonX path to the context
*/
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: %s has temperature monitoring", device, dirpath_tmp );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_DEBUG, "hwmon: %s found in %s", device, dirpath_tmp );
}
/* Copy the hwmon path to the drive context structure */
strcpy( c->temp1_path, dirpath_hwmonX );
c->templ_has_hwmon_data = 1;
}
}
closedir( dir2 );
}
}
}
closedir( dir );
}
/* if no hwmon data available try scsi access (SAS Disks are known to be not working in hwmon */
if( c->templ_has_hwmon_data == 0 && ( c->device_type == NWIPE_DEVICE_SAS || c->device_type == NWIPE_DEVICE_SCSI ) )
{
nwipe_log( NWIPE_LOG_NOTICE, "no hwmon data for %s, try to get SCSI data", c->device_name );
if( nwipe_init_scsi_temperature( c ) == 0 )
{
c->templ_has_scsitemp_data = 1;
nwipe_log( NWIPE_LOG_INFO, "got SCSI temperature data for %s", c->device_name );
}
else
{
c->templ_has_scsitemp_data = 0;
nwipe_log( NWIPE_LOG_INFO, "got no SCSI temperature data for %s", c->device_name );
}
}
return 0;
}
float timedifference_msec( struct timeval tv_start, struct timeval tv_end )
{
/* helper function for time measurement in msec */
return ( tv_end.tv_sec - tv_start.tv_sec ) * 1000.0f + ( tv_end.tv_usec - tv_start.tv_usec ) / 1000.0f;
}
void* nwipe_update_temperature_thread( void* ptr )
{
int i;
/* Set up the structs we will use for the data required. */
nwipe_thread_data_ptr_t* nwipe_thread_data_ptr;
nwipe_context_t** c;
nwipe_misc_thread_data_t* nwipe_misc_thread_data;
/* Retrieve from the pointer passed to the function. */
nwipe_thread_data_ptr = (nwipe_thread_data_ptr_t*) ptr;
c = nwipe_thread_data_ptr->c;
nwipe_misc_thread_data = nwipe_thread_data_ptr->nwipe_misc_thread_data;
/* mark start second of update */
time_t nwipe_timemark = time( NULL );
/* update immediately on entry to thread */
for( i = 0; i < nwipe_misc_thread_data->nwipe_enumerated; i++ )
{
nwipe_update_temperature( c[i] );
if( terminate_signal == 1 )
{
break;
}
}
while( terminate_signal != 1 )
{
/* Update all drive/s but never repeat checking the
* set of drive/s faster than once every 2 seconds */
if( time( NULL ) > ( nwipe_timemark + 1 ) )
{
nwipe_timemark = time( NULL );
for( i = 0; i < nwipe_misc_thread_data->nwipe_enumerated; i++ )
{
nwipe_update_temperature( c[i] );
}
}
else
{
sleep( 1 );
}
}
return NULL;
}
void nwipe_update_temperature( nwipe_context_t* c )
{
/* Warning !! This function should only be called by nwipe_update_temperature_thread()
* Due to delays of upto 2 seconds with some drives, especially SAS in obtaining
* temperatures while wiping, the delays being worse the more drives you are wiping. Updating
* temperatures are performed within it's own thread so it doesn't cause momentary freezes
* in the GUI interface.
*
* For the given drive context obtain the path to it's hwmon temperature settings
* and read then write the temperature values back to the context. A numeric ascii to integer conversion is
* performed. The temperaures should be updated no more frequently than every 60 seconds
*/
char temperature_label[NUMBER_OF_FILES][20] = {
"temp1_crit", "temp1_highest", "temp1_input", "temp1_lcrit", "temp1_lowest", "temp1_max", "temp1_min" };
int* temperature_pcontext[NUMBER_OF_FILES] = {
&( c->temp1_crit ),
&( c->temp1_highest ),
&( c->temp1_input ),
&( c->temp1_lcrit ),
&( c->temp1_lowest ),
&( c->temp1_max ),
&( c->temp1_min ) };
char path[256];
char temperature[256];
FILE* fptr;
int idx;
int result;
struct timeval tv_start;
struct timeval tv_end;
float delta_t;
/* avoid being called more often than 1x per 60 seconds */
time_t nwipe_time_now = time( NULL );
if( nwipe_time_now - c->temp1_time < 60 )
{
return;
}
/* measure time it takes to get the temperatures */
gettimeofday( &tv_start, 0 );
/* try to get temperatures from hwmon, standard */
if( c->templ_has_hwmon_data == 1 )
{
for( idx = 0; idx < NUMBER_OF_FILES; idx++ )
{
/* Construct the full path including filename */
strcpy( path, c->temp1_path );
strcat( path, "/" );
strcat( path, &( temperature_label[idx][0] ) );
/* Open the file */
if( ( fptr = fopen( path, "r" ) ) != NULL )
{
/* Acquire data until we reach a newline */
result = fscanf( fptr, "%[^\n]", temperature );
/* Convert numeric ascii to binary integer */
*( temperature_pcontext[idx] ) = atoi( temperature );
/* Divide by 1000 to get degrees celsius */
*( temperature_pcontext[idx] ) = *( temperature_pcontext[idx] ) / 1000;
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: %s %dC", path, *( temperature_pcontext[idx] ) );
}
fclose( fptr );
}
else
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_NOTICE, "hwmon: Unable to open %s", path );
}
}
}
}
else
{
/* alternative method to get temperature from SCSI/SAS disks */
if( c->device_type == NWIPE_DEVICE_SAS || c->device_type == NWIPE_DEVICE_SCSI )
{
if( c->templ_has_scsitemp_data == 1 )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_NOTICE, "hddtemp: %s temp1_crit %dC", c->device_name, c->temp1_crit );
nwipe_log( NWIPE_LOG_NOTICE, "hddtemp: %s temp1_highest %dC", c->device_name, c->temp1_highest );
nwipe_log( NWIPE_LOG_NOTICE, "hddtemp: %s temp1_input %dC", c->device_name, c->temp1_input );
nwipe_log( NWIPE_LOG_NOTICE, "hddtemp: %s temp1_lcrit %dC", c->device_name, c->temp1_lcrit );
nwipe_log( NWIPE_LOG_NOTICE, "hddtemp: %s temp1_lowest %dC", c->device_name, c->temp1_lowest );
nwipe_log( NWIPE_LOG_NOTICE, "hddtemp: %s temp1_max %dC", c->device_name, c->temp1_max );
nwipe_log( NWIPE_LOG_NOTICE, "hddtemp: %s temp1_min %dC", c->device_name, c->temp1_min );
}
if( nwipe_get_scsi_temperature( c ) != 0 )
{
nwipe_log( NWIPE_LOG_ERROR, "get_scsi_temperature error" );
}
}
}
}
/* Update the time stamp that records when we checked the temperature,
* this is used by the GUI to check temperatures periodically, typically
* every 60 seconds */
c->temp1_time = time( NULL );
gettimeofday( &tv_end, 0 );
delta_t = timedifference_msec( tv_start, tv_end );
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_NOTICE, "get temperature for %s took %f ms", c->device_name, delta_t );
}
return;
}
void nwipe_log_drives_temperature_limits( nwipe_context_t* c )
{
/* See header for description of function
*/
char temperature_limits_txt[500];
int idx = 0;
/*
* Initialise the character string, as we are building it a few
* characters at a time and it's important there it is populated
* with all zeros as we are using strlen() as we build the line up.
*/
memset( &temperature_limits_txt, 0, sizeof( temperature_limits_txt ) );
if( c->temp1_crit != NO_TEMPERATURE_DATA )
{
snprintf( temperature_limits_txt,
sizeof( temperature_limits_txt ),
"Temperature limits for %s, critical=%ic, ",
c->device_name,
c->temp1_crit );
}
else
{
snprintf( temperature_limits_txt,
sizeof( temperature_limits_txt ),
"Temperature limits for %s, critical=N/A, ",
c->device_name );
}
idx = strlen( temperature_limits_txt );
if( c->temp1_max != NO_TEMPERATURE_DATA )
{
snprintf( &temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "max=%ic, ", c->temp1_max );
}
else
{
snprintf( &temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "max=N/A, " );
}
idx = strlen( temperature_limits_txt );
if( c->temp1_highest != NO_TEMPERATURE_DATA )
{
snprintf( &temperature_limits_txt[idx],
( sizeof( temperature_limits_txt ) - idx ),
"highest=%ic, ",
c->temp1_highest );
}
else
{
snprintf( &temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "highest=N/A, " );
}
idx = strlen( temperature_limits_txt );
if( c->temp1_lowest != NO_TEMPERATURE_DATA )
{
snprintf(
&temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "lowest=%ic, ", c->temp1_lowest );
}
else
{
snprintf( &temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "lowest=N/A, " );
}
idx = strlen( temperature_limits_txt );
if( c->temp1_min != NO_TEMPERATURE_DATA )
{
snprintf( &temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "min=%ic, ", c->temp1_min );
}
else
{
snprintf( &temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "min=N/A, " );
}
idx = strlen( temperature_limits_txt );
if( c->temp1_lcrit != NO_TEMPERATURE_DATA )
{
snprintf( &temperature_limits_txt[idx],
( sizeof( temperature_limits_txt ) - idx ),
"low critical=%ic.",
c->temp1_lcrit );
}
else
{
snprintf( &temperature_limits_txt[idx], ( sizeof( temperature_limits_txt ) - idx ), "low critical=N/A. " );
}
nwipe_log( NWIPE_LOG_INFO, "%s", temperature_limits_txt );
return;
}

61
src/temperature.h Normal file
View File

@@ -0,0 +1,61 @@
/*
* temperature.h: The header file for disk drive temperature sensing
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef TEMPERATURE_H_
#define TEMPERATURE_H_
#include <sys/types.h>
#include "context.h"
/**
* This function is called after each nwipe_context_t has been created.
* It initialises the temperature variables in each context and then
* constructs a path that is placed in the context that points to the
* appropriate /sys/class/hwmon/hwmonX directory that corresponds with
* the particular drive represented in the context structure.
* @param pointer to a drive context
* @return returns 0 on success < 1 on error
*/
int nwipe_init_temperature( nwipe_context_t* );
void nwipe_update_temperature( nwipe_context_t* );
/**
* Workaround for obtaining temperatures from SCSI/SAS drives
* @param pointer to a drive context
* @return returns 0 on success < 1 on error
*/
int nwipe_init_scsi_temperature( nwipe_context_t* );
int nwipe_get_scsi_temperature( nwipe_context_t* );
void nwipe_shut_scsi_temperature( nwipe_context_t* );
void* nwipe_update_temperature_thread( void* ptr );
/**
* This function is normally called only once. It's called after both the
* nwipe_init_temperature() function and nwipe_update_temperature()
* functions have been called. It logs the drives critical, highest, lowest
* and lowest critical temperatures. Not all drives report four temperatures.
* @param pointer to a drive context
*/
void nwipe_log_drives_temperature_limits( nwipe_context_t* );
#define NUMBER_OF_FILES 7
#define NO_TEMPERATURE_DATA 1000000
#endif /* TEMPERATURE_H_ */

View File

@@ -1,16 +1,17 @@
/**
* version_string and program_name are used by siege
* and configure; author_name and email_address are
* used by configure to dynamically assign those values
* and configure; author_name and email_address are
* used by configure to dynamically assign those values
* to documentation files.
*/
const char *version_string = "0.20";
const char *program_name = "nwipe";
const char *author_name = "Martijn van Brummelen";
const char *email_address = "git@brumit.nl";
const char *years = "2016";
const char *copyright = "Copyright Darik Horn <dajhorn-dban@vanadac.com>\n\
const char* version_string = "0.36";
const char* program_name = "nwipe";
const char* author_name = "Martijn van Brummelen";
const char* email_address = "git@brumit.nl";
const char* years = "2024";
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.36";

View File

@@ -1,10 +1,11 @@
#ifndef __VERSION_H
#define __VERSION_H
extern char *version_string;
extern char *program_name;
extern char *author_name;
extern char *email_address;
extern char *copyright;
extern char* version_string;
extern char* program_name;
extern char* author_name;
extern char* email_address;
extern char* copyright;
extern char* banner;
#endif/*__VERSION_H*/
#endif /*__VERSION_H*/