mirror of
https://github.com/martijnvanbrummelen/nwipe.git
synced 2026-02-22 06:52:12 +00:00
Compare commits
446 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab6c4c0014 | ||
|
|
22f596c228 | ||
|
|
be0de995f8 | ||
|
|
24a3eb5734 | ||
|
|
5f14819e65 | ||
|
|
e06db0702b | ||
|
|
1e02b754ff | ||
|
|
4a1690be59 | ||
|
|
b826ce9fc5 | ||
|
|
9ebed56d43 | ||
|
|
c03ec324ba | ||
|
|
fb27ab8d55 | ||
|
|
c7d486f776 | ||
|
|
69b125ba4d | ||
|
|
3e15e6ef3c | ||
|
|
2e7de74202 | ||
|
|
21b5190fc4 | ||
|
|
d61b9005c3 | ||
|
|
13ecd9d268 | ||
|
|
e24d7992ef | ||
|
|
948813a692 | ||
|
|
4abff9e287 | ||
|
|
2102301382 | ||
|
|
9b2f71d4e7 | ||
|
|
c54a1296aa | ||
|
|
e543f54029 | ||
|
|
d4261b8e37 | ||
|
|
a7982c8579 | ||
|
|
9f6e2de116 | ||
|
|
337223a126 | ||
|
|
496e51d84e | ||
|
|
ca6b829687 | ||
|
|
2f1e87f09b | ||
|
|
eb1297913a | ||
|
|
7c10bc85a3 | ||
|
|
d830db3c1c | ||
|
|
4075b4b50e | ||
|
|
69d6d9708c | ||
|
|
cbe1d83801 | ||
|
|
0df4678fbc | ||
|
|
18e542bad7 | ||
|
|
24d294cf6f | ||
|
|
08c2b54a3f | ||
|
|
8d8e2e3191 | ||
|
|
86f01f0b36 | ||
|
|
0e92a9ddee | ||
|
|
33690b9e37 | ||
|
|
b29ca4c29e | ||
|
|
cf3c6f148b | ||
|
|
65d6ab45b6 | ||
|
|
d76868617a | ||
|
|
bd59f5ac98 | ||
|
|
af30da3cc2 | ||
|
|
4cc8a34bbc | ||
|
|
b3def7c336 | ||
|
|
dc012e46b2 | ||
|
|
88e2adf6a2 | ||
|
|
ddb0ca8c35 | ||
|
|
b185818732 | ||
|
|
1335455d7e | ||
|
|
cf75391b93 | ||
|
|
082a4e53d6 | ||
|
|
a4d5164602 | ||
|
|
7d93a44f18 | ||
|
|
52df4390f7 | ||
|
|
92a6a76c51 | ||
|
|
68ef665b2d | ||
|
|
fcd35ea910 | ||
|
|
5aded13bf7 | ||
|
|
5cd00da2a6 | ||
|
|
3ee514c395 | ||
|
|
fe93c77e22 | ||
|
|
d3ac79bb0e | ||
|
|
2322c690a4 | ||
|
|
243d8a5e81 | ||
|
|
4596c5f06d | ||
|
|
e91721d06b | ||
|
|
2a6d6e10df | ||
|
|
73b6b2ef6d | ||
|
|
0488138c43 | ||
|
|
57eeab2292 | ||
|
|
c3756e0f53 | ||
|
|
d140feb94b | ||
|
|
62beaca8ac | ||
|
|
497fcb73b5 | ||
|
|
00085b403e | ||
|
|
fea6facadc | ||
|
|
186bd9e03b | ||
|
|
f5db72a983 | ||
|
|
030338f1bd | ||
|
|
eee523d3d1 | ||
|
|
c3642e8904 | ||
|
|
16a3b3c487 | ||
|
|
fa9eb6892b | ||
|
|
3ed8dfd708 | ||
|
|
cbe959455a | ||
|
|
8e52c926ab | ||
|
|
22b08d43c8 | ||
|
|
98775a4837 | ||
|
|
4fe7f4a697 | ||
|
|
ddfa194ed9 | ||
|
|
b9a9386d2f | ||
|
|
8430befdc3 | ||
|
|
dc692735ce | ||
|
|
4e4c37dd4a | ||
|
|
ac0fe876a1 | ||
|
|
e46e80277d | ||
|
|
ac9757dfe7 | ||
|
|
7af0dd57c7 | ||
|
|
14d5178013 | ||
|
|
2446db741f | ||
|
|
081051c25f | ||
|
|
055b90d4c7 | ||
|
|
9789c4748f | ||
|
|
a2f70661b8 | ||
|
|
bb0019fe40 | ||
|
|
186ec9172c | ||
|
|
415f43c975 | ||
|
|
5809d0febd | ||
|
|
fdf3140249 | ||
|
|
2f7979476b | ||
|
|
c53a93ec9c | ||
|
|
6943e35a33 | ||
|
|
541a002a99 | ||
|
|
c29185999e | ||
|
|
fc406d2346 | ||
|
|
0c4493e11c | ||
|
|
acf296d25d | ||
|
|
2738522bb8 | ||
|
|
34d86e9c19 | ||
|
|
8f10179120 | ||
|
|
2b225f5cb9 | ||
|
|
8d31f2cf4a | ||
|
|
d59e0323de | ||
|
|
7ac7c80731 | ||
|
|
a1e6e3bd52 | ||
|
|
62a8e76205 | ||
|
|
fbfcbf8d34 | ||
|
|
6c99166b75 | ||
|
|
a022fffacb | ||
|
|
ec9a322683 | ||
|
|
e6dd32a74b | ||
|
|
523351531c | ||
|
|
1d83fd6f8f | ||
|
|
74243d392d | ||
|
|
06fe803eb1 | ||
|
|
298ee05b8c | ||
|
|
4928eb094e | ||
|
|
9caceaa75d | ||
|
|
75fce57ab4 | ||
|
|
e955725fc5 | ||
|
|
1c1b25e1ae | ||
|
|
d4963092dd | ||
|
|
1083207d49 | ||
|
|
458a3d780f | ||
|
|
08c9cbe9f1 | ||
|
|
e9caad3bef | ||
|
|
50e7cfaa7b | ||
|
|
ea39f57afb | ||
|
|
880823cc9b | ||
|
|
7d3a3c5f1e | ||
|
|
e33c1bb06d | ||
|
|
50079a15f9 | ||
|
|
cc82687cf3 | ||
|
|
82a867b569 | ||
|
|
fee849b35e | ||
|
|
09d9fc88fb | ||
|
|
6570197de0 | ||
|
|
4eef3e6ab0 | ||
|
|
c4969e36f1 | ||
|
|
c75c393e49 | ||
|
|
53e5f4ca3a | ||
|
|
72505f00cc | ||
|
|
f4947eb317 | ||
|
|
5775498803 | ||
|
|
85059c73c4 | ||
|
|
cd420a079d | ||
|
|
e2ec6a560f | ||
|
|
87199a1940 | ||
|
|
88cae05301 | ||
|
|
14d285fb63 | ||
|
|
69e27abf2b | ||
|
|
32862d6af7 | ||
|
|
fb00aa0243 | ||
|
|
e779265b01 | ||
|
|
aad29f14c2 | ||
|
|
fe06f88ae2 | ||
|
|
b3adbb3a17 | ||
|
|
ce61974eba | ||
|
|
95ab80cc68 | ||
|
|
0077fcbc12 | ||
|
|
98f4466d89 | ||
|
|
203f6a06f5 | ||
|
|
0eeab11af6 | ||
|
|
97e5591fd5 | ||
|
|
5f1aafed2f | ||
|
|
6822c463eb | ||
|
|
6d797b742c | ||
|
|
5c60dce0c5 | ||
|
|
49b35aef8a | ||
|
|
a3a056ce75 | ||
|
|
ead9a78453 | ||
|
|
bebae43b3b | ||
|
|
49aa14a490 | ||
|
|
3aca56eded | ||
|
|
b26bb839ef | ||
|
|
0a53ec9c42 | ||
|
|
df07393f9d | ||
|
|
af0fdadc88 | ||
|
|
8384142f58 | ||
|
|
4071e5f66a | ||
|
|
3089a78f72 | ||
|
|
6b7186f7ed | ||
|
|
6ca41a899f | ||
|
|
35bcc518b5 | ||
|
|
7af9c90e3a | ||
|
|
b53a4b58db | ||
|
|
851735c1f0 | ||
|
|
79dee9cb79 | ||
|
|
756db3e0e1 | ||
|
|
0037c46860 | ||
|
|
7d416911d2 | ||
|
|
a5a3f3b9a3 | ||
|
|
1be4e99a29 | ||
|
|
d39427ae86 | ||
|
|
0b6ce3182d | ||
|
|
5f01b660bd | ||
|
|
10f2678c10 | ||
|
|
3c4a536eeb | ||
|
|
bc8cfeb478 | ||
|
|
cb4d411b05 | ||
|
|
3bcc544610 | ||
|
|
92c7d99714 | ||
|
|
c952939dff | ||
|
|
e5a0f85d56 | ||
|
|
f69aff33a4 | ||
|
|
d19dc05793 | ||
|
|
7a87bafc0f | ||
|
|
615c2ee035 | ||
|
|
559bc3db56 | ||
|
|
04fe9f217e | ||
|
|
ead64479f4 | ||
|
|
e2c9d030de | ||
|
|
f866d84e3d | ||
|
|
97c736e630 | ||
|
|
c3679f9d3b | ||
|
|
e180154320 | ||
|
|
ff357298bd | ||
|
|
cd0d9e028b | ||
|
|
25116c2046 | ||
|
|
d5fe1c096a | ||
|
|
254ef3236e | ||
|
|
719bfa66f6 | ||
|
|
a384bd75fd | ||
|
|
ddc4f9eaa2 | ||
|
|
f212192155 | ||
|
|
494d269936 | ||
|
|
f1baadb4de | ||
|
|
8e196eb830 | ||
|
|
d8749ab9da | ||
|
|
89598f3de9 | ||
|
|
8bb3f9ff14 | ||
|
|
8d02bfe6f8 | ||
|
|
a215aa14fa | ||
|
|
1091a5291f | ||
|
|
4666f17930 | ||
|
|
c7a565dbc8 | ||
|
|
f1f1002207 | ||
|
|
dd9e97ec52 | ||
|
|
11a0c2de6b | ||
|
|
68c3cfe5ca | ||
|
|
1717958843 | ||
|
|
01648108a0 | ||
|
|
b102bee6fa | ||
|
|
551836e092 | ||
|
|
4dc84a727c | ||
|
|
3c55dda2f4 | ||
|
|
52bcea8ee1 | ||
|
|
0e15c16cac | ||
|
|
01bc6b92b7 | ||
|
|
6858e42fcf | ||
|
|
70b7497734 | ||
|
|
178bc558fa | ||
|
|
c0dc1e9ff7 | ||
|
|
bc5bfb73a7 | ||
|
|
e37ccd4fdb | ||
|
|
48c01f7cfa | ||
|
|
5004c15481 | ||
|
|
3110267373 | ||
|
|
82e4d1b2ea | ||
|
|
a16a67d84e | ||
|
|
881ddcf0cb | ||
|
|
1360196be2 | ||
|
|
91dfc37574 | ||
|
|
675dd694a3 | ||
|
|
3ab826f11d | ||
|
|
2cd8fce66a | ||
|
|
649cc09da0 | ||
|
|
c064a66115 | ||
|
|
000ebe6deb | ||
|
|
8a7ca91da6 | ||
|
|
404962e6fc | ||
|
|
f96f17b0a6 | ||
|
|
d3ddd8d2ac | ||
|
|
974f323857 | ||
|
|
4f6354919b | ||
|
|
2a7d07676b | ||
|
|
06aecbb8f8 | ||
|
|
353a577282 | ||
|
|
5bf579d5b2 | ||
|
|
607a244bbf | ||
|
|
d770f219b9 | ||
|
|
1090ac5d83 | ||
|
|
4241485e6a | ||
|
|
dd3828008d | ||
|
|
4f72927146 | ||
|
|
a5715eeca4 | ||
|
|
214ff8fb7a | ||
|
|
94a9437166 | ||
|
|
a216fa2c24 | ||
|
|
08d61dc9f1 | ||
|
|
f6cf615a12 | ||
|
|
df36255e06 | ||
|
|
602cdcaa58 | ||
|
|
95b30f6286 | ||
|
|
b4d82ec19b | ||
|
|
d968225417 | ||
|
|
46f8cc352d | ||
|
|
42e58bbd22 | ||
|
|
10028b6f95 | ||
|
|
7d70fa5dc5 | ||
|
|
53b1c6ba62 | ||
|
|
88ce0b7494 | ||
|
|
2a056b7bfa | ||
|
|
f9f0ec605c | ||
|
|
9331061cbf | ||
|
|
2402ca0602 | ||
|
|
7db0bd733e | ||
|
|
128dfb3a4e | ||
|
|
5199fb1793 | ||
|
|
f6c1cab28a | ||
|
|
4b9ae33171 | ||
|
|
d04ae940b6 | ||
|
|
74c05fe290 | ||
|
|
766d8020c6 | ||
|
|
76f097c272 | ||
|
|
5e2d55ba7f | ||
|
|
7c025040b4 | ||
|
|
661785294c | ||
|
|
7b1a5b98a7 | ||
|
|
e1475d70ff | ||
|
|
a75c29f973 | ||
|
|
721c8de743 | ||
|
|
4acad452ae | ||
|
|
37dfb1a2b6 | ||
|
|
55783c0b8d | ||
|
|
52d0508b23 | ||
|
|
d2a66e0047 | ||
|
|
11ed6b1472 | ||
|
|
0fec3a1213 | ||
|
|
b341d1dab0 | ||
|
|
c92a87860d | ||
|
|
545491940e | ||
|
|
cd16c2e86b | ||
|
|
00469644d8 | ||
|
|
ac680b4225 | ||
|
|
c58ab04ff6 | ||
|
|
bb91f093a3 | ||
|
|
025a02e87c | ||
|
|
68cad1b640 | ||
|
|
54f643559f | ||
|
|
cd3716f260 | ||
|
|
43172a9741 | ||
|
|
10221fb2a9 | ||
|
|
9b821292ea | ||
|
|
6b350a2348 | ||
|
|
6ec7826692 | ||
|
|
00e9350dd6 | ||
|
|
c46e0c8ba4 | ||
|
|
af1b470456 | ||
|
|
ae51d548d4 | ||
|
|
5f712f3b0c | ||
|
|
99778f187d | ||
|
|
528bb9fd6a | ||
|
|
08215f3fb2 | ||
|
|
f20e7c6b74 | ||
|
|
27bb409efa | ||
|
|
cfd75a918c | ||
|
|
f56977930a | ||
|
|
fa0d72cbaf | ||
|
|
42a114abc0 | ||
|
|
58d4733273 | ||
|
|
fe4fdaee93 | ||
|
|
157797c1ca | ||
|
|
396896e16c | ||
|
|
5cb6003fc0 | ||
|
|
b2bee8ac83 | ||
|
|
4606834286 | ||
|
|
ed5ca0fce7 | ||
|
|
9c69bc0e1a | ||
|
|
a049c871b6 | ||
|
|
f960da3f4a | ||
|
|
81850bde42 | ||
|
|
e92ac3a870 | ||
|
|
0ecc90786d | ||
|
|
5912d0f57a | ||
|
|
e16da663a1 | ||
|
|
a9ed8a091a | ||
|
|
dd74c429b0 | ||
|
|
baab603809 | ||
|
|
0fa21d4c04 | ||
|
|
3bc0235d38 | ||
|
|
533fa56de8 | ||
|
|
011901b28e | ||
|
|
b47fe001b3 | ||
|
|
3638eae8d4 | ||
|
|
b0bc174d32 | ||
|
|
8f5c05506f | ||
|
|
23c69f34c1 | ||
|
|
0b1cb83013 | ||
|
|
17f23ba03b | ||
|
|
22665fa781 | ||
|
|
95dc8abcf3 | ||
|
|
fd55f48267 | ||
|
|
d9ba357722 | ||
|
|
8a85d7e96f | ||
|
|
cac9b17f9b | ||
|
|
37109daae7 | ||
|
|
052852d475 | ||
|
|
4b20e7ca76 | ||
|
|
c8a5a16108 | ||
|
|
4e64cab3c3 | ||
|
|
5f65683f63 | ||
|
|
7b170bb444 | ||
|
|
464bf788c5 | ||
|
|
16e78b8523 | ||
|
|
f71b23afc4 | ||
|
|
e7d9ff73fe | ||
|
|
1fce0eb936 | ||
|
|
72c5cd8a0f | ||
|
|
0f06e91ce5 | ||
|
|
0f26c8ea68 | ||
|
|
9c63eef565 | ||
|
|
db9e7ef1aa | ||
|
|
7039f381af | ||
|
|
b808b8402c |
80
.clang-format
Normal file
80
.clang-format
Normal file
@@ -0,0 +1,80 @@
|
||||
---
|
||||
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
|
||||
...
|
||||
|
||||
21
.github/workflows/ci_formatting.yml
vendored
Normal file
21
.github/workflows/ci_formatting.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: ci_formatting
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- 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 dmidecode clang-format-7
|
||||
- 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_16.04.yml
vendored
Normal file
21
.github/workflows/ci_ubuntu_16.04.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: ci_ubuntu_16.04
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-16.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- 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 dmidecode
|
||||
- name: creating autoconf files
|
||||
run: ./autogen.sh
|
||||
- name: configuring
|
||||
run: ./configure CFLAGS='-O0 -g -Wall -Wextra'
|
||||
- name: compiling
|
||||
run: make
|
||||
21
.github/workflows/ci_ubuntu_latest.yml
vendored
Normal file
21
.github/workflows/ci_ubuntu_latest.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: ci_ubuntu_latest
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- 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 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
22
.gitignore
vendored
Normal 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
|
||||
198
CHANGELOG.md
Normal file
198
CHANGELOG.md
Normal file
@@ -0,0 +1,198 @@
|
||||
RELEASE NOTES
|
||||
=============
|
||||
|
||||
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
|
||||
@@ -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
131
README
@@ -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
|
||||
201
README.md
201
README.md
@@ -1,15 +1,194 @@
|
||||
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
|
||||

|
||||

|
||||
[](https://github.com/martijnvanbrummelen/nwipe/releases/)
|
||||
|
||||
To use from the git repository, first create all the autoconf files with
|
||||
./init.sh
|
||||
nwipe is a program that will securely erase the entire contents of disks. It can operate as both a command line
|
||||
tool without a GUI or with a ncurses GUI as shown in the example below. It can wipe a single drive or multiple
|
||||
disks simultaneously. Nwipe can be found in many Linux distro repositories and the latest version of nwipe is available as a Bootable USB flash image from [here](https://github.com/PartialVolume/shredos.2020.02/blob/master/README.md#obtaining-and-writing-shredos-to-a-usb-flash-drive-the-easy-way-). This can be written to a USB flash drive in seconds, allowing you to boot straight into nwipe.
|
||||
|
||||
Then do the standard ./configure --prefix=/usr && make && make install
|
||||
The user can select from a variety of recognised secure erase methods which include:
|
||||
|
||||
For release notes please see the [README file](README)
|
||||
* Zero Fill - Fills the device with zeros, 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 only - This method only reads the device and checks that it is all zero.
|
||||
* HMG IS5 enhanced - Secure Sanitisation of Protectively Marked Information or Sensitive Information
|
||||
|
||||
It also includes the following pseudo random number generators:
|
||||
* Mersenne Twister
|
||||
* ISAAC
|
||||
|
||||
It is a fork of the dwipe command used by
|
||||
Darik's Boot and Nuke (dban). nwipe is included with [partedmagic](https://partedmagic.com), [SystemRescueCD](http://www.system-rescue-cd) and
|
||||
[ShredOS](https://github.com/nadenislamarre/shredos)/[ShredOS 2020](https://github.com/PartialVolume/shredos.2020.02) if you want a quick and easy, bootable CD or USB version. If you want a bootable version of the very latest nwipe master that you can write to a USB stick, see [quick and easy bootable version of nwipe master](https://github.com/martijnvanbrummelen/nwipe#quick--easy-usb-bootable-version-of-nwipe-master-for-x86_64-systems)
|
||||
|
||||
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.
|
||||
|
||||
The example below shows six drives being simultaneously erased. The video skips to the completion of all six wipes and shows five drives that were successfully erased and one drive that failed due to a 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.
|
||||
|
||||

|
||||
|
||||
## Compiling & Installing
|
||||
|
||||
`nwipe` requires the following libraries to be installed:
|
||||
|
||||
* ncurses
|
||||
* pthreads
|
||||
* parted
|
||||
|
||||
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 \
|
||||
dmidecode \
|
||||
coreutils \
|
||||
smartmontools
|
||||
```
|
||||
|
||||
### 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 dmidecode
|
||||
yum install coreutils
|
||||
yum install smartmontools
|
||||
```
|
||||
Note. The following programs are optionally installed although recommended. 1. dmidecode 2. readlink 3. smartmontools.
|
||||
|
||||
#### dmidecode
|
||||
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)
|
||||
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
|
||||
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 this section [automating the download and compilation](https://github.com/martijnvanbrummelen/nwipe#automating-the-download-and-compilation-process-for-debian-based-distros)
|
||||
|
||||
### Compilation
|
||||
|
||||
For a development setup, see [the hacking section below](#Hacking).
|
||||
|
||||
First create all the autoconf files:
|
||||
```
|
||||
./autogen.sh
|
||||
```
|
||||
|
||||
Then compile & install using the following standard commands:
|
||||
```
|
||||
./configure
|
||||
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
|
||||
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 the libraries are upto 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 takes all of 11 seconds 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. [Download script](
|
||||
https://drive.google.com/file/d/1-kKgvCvKYYuSH_UUBKrLwsI0Xf7fckGg/view?usp=sharing)
|
||||
```
|
||||
#!/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 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 the ShredOS image that's using the latest version of nwipe master and burn it to a USB stick. Instructions and download can be found [here](https://github.com/PartialVolume/shredos.2020.02/blob/master/README.md#obtaining-and-writing-shredos-to-a-usb-flash-drive-the-easy-way-)
|
||||
|
||||
## Bugs
|
||||
|
||||
Bugs can be reported on GitHub:
|
||||
https://github.com/martijnvanbrummelen/nwipe
|
||||
|
||||
## License
|
||||
|
||||
GNU General Public License v2.0
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# 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_INIT([nwipe], [0.30], [git@brumit.nl])
|
||||
AM_INIT_AUTOMAKE(foreign subdir-objects)
|
||||
AC_OUTPUT(Makefile src/Makefile man/Makefile)
|
||||
AC_CONFIG_SRCDIR([src/nwipe.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
BIN
images/example_wipe.gif
Normal file
BIN
images/example_wipe.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 MiB |
41
man/nwipe.1
41
man/nwipe.1
@@ -1,4 +1,4 @@
|
||||
.TH NWIPE "1" "October 2014" "nwipe version 0.17" "User Commands"
|
||||
.TH NWIPE "1" "December 2020" "nwipe version 0.30" "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,25 +34,46 @@ 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\-\-autopoweroff\fR
|
||||
Power off system on completion of wipe delayed for for one minute. During
|
||||
this one minute delay you can abort the shutdown by typing sudo shutdown -c
|
||||
.TP
|
||||
\fB\-\-sync\fR
|
||||
Open devices in sync mode
|
||||
.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).
|
||||
.TP
|
||||
\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).
|
||||
@@ -68,6 +89,10 @@ ops2 \- RCMP TSSIT OPS\-II
|
||||
random / prng / stream \- PRNG Stream
|
||||
.IP
|
||||
zero / quick \- Overwrite with zeros
|
||||
.IP
|
||||
verify \- Verifies disk is zero filled
|
||||
.IP
|
||||
is5enh \- HMG IS5 enhanced
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-logfile\fR=\fIFILE\fR
|
||||
Filename to log to. Default is STDOUT
|
||||
@@ -77,12 +102,16 @@ PRNG option (mersenne|twister|isaac)
|
||||
.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),
|
||||
|
||||
@@ -6,6 +6,6 @@ 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_SOURCES = context.h isaac_rand/isaac_rand.c logging.h options.h prng.h nwipe.c gui.c isaac_rand/isaac_rand.h method.h pass.c device.c gui.h isaac_rand/isaac_standard.h 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 version.h
|
||||
nwipe_CFLAGS = $(PARTED_CFLAGS)
|
||||
nwipe_LDADD = $(PARTED_LIBS)
|
||||
|
||||
211
src/context.h
211
src/context.h
@@ -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.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -25,120 +25,141 @@
|
||||
|
||||
#include "prng.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_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 7
|
||||
|
||||
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.
|
||||
int device_sector_size; // The hard sector size reported by 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.
|
||||
long long device_size; // The device size in bytes.
|
||||
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
|
||||
char device_serial_no[21]; // 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 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.
|
||||
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.
|
||||
int wipe_status; // Wipe finished = 0, wipe in progress = 1, wipe yet to start = -1.
|
||||
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
|
||||
time_t start_time; // Start time of wipe
|
||||
time_t end_time; // End time of wipe
|
||||
/*
|
||||
* 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 */
|
||||
|
||||
721
src/device.c
721
src/device.c
@@ -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,689 @@
|
||||
*
|
||||
* 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 "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 <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_contect_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 ) ) )
|
||||
{
|
||||
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.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
|
||||
int i;
|
||||
int dcount = 0;
|
||||
PedDevice* dev = NULL;
|
||||
|
||||
for(i = 0; i < ndevnames; i++) {
|
||||
int i;
|
||||
int dcount = 0;
|
||||
|
||||
dev = ped_device_get(devnamelist[i]);
|
||||
if (!dev)
|
||||
break;
|
||||
for( i = 0; i < ndevnames; i++ )
|
||||
{
|
||||
|
||||
if (check_device(c, dev, dcount))
|
||||
dcount++;
|
||||
}
|
||||
dev = ped_device_get( devnamelist[i] );
|
||||
if( !dev )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_WARNING, "Device %s not found", devnamelist[i] );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Return the number of devices that were found. */
|
||||
return dcount;
|
||||
if( check_device( c, dev, dcount ) )
|
||||
dcount++;
|
||||
|
||||
/* Don't bother scanning drives if the terminate signal is active ! as in the case of
|
||||
* the readlink program missing which is required if the --nousb option has been specified */
|
||||
if( terminate_signal == 1 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the number of devices that were found. */
|
||||
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[21];
|
||||
nwipe_device_t bus;
|
||||
|
||||
/* 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 < 10 )
|
||||
{
|
||||
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, 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 );
|
||||
next_device->device_name = dev->path;
|
||||
next_device->device_size = dev->length * dev->sector_size;
|
||||
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. */
|
||||
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 < 20; idx++ )
|
||||
{
|
||||
next_device->device_serial_no[idx] = next_device->identity.serial_no[idx];
|
||||
}
|
||||
|
||||
// Terminate the string.
|
||||
next_device->device_serial_no[20] = 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, 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 )
|
||||
{
|
||||
strcpy( next_device->device_serial_no, tmp_serial );
|
||||
}
|
||||
}
|
||||
|
||||
/* All device strings should be 4 characters, prefix with space if under 4 characters */
|
||||
switch( next_device->device_type )
|
||||
{
|
||||
case NWIPE_DEVICE_UNKNOWN:
|
||||
strcpy( next_device->device_type_str, " UNK" );
|
||||
break;
|
||||
|
||||
case NWIPE_DEVICE_IDE:
|
||||
strcpy( next_device->device_type_str, " IDE" );
|
||||
break;
|
||||
|
||||
case NWIPE_DEVICE_SCSI:
|
||||
strcpy( next_device->device_type_str, " SCSI" );
|
||||
break;
|
||||
|
||||
case NWIPE_DEVICE_COMPAQ:
|
||||
strcpy( next_device->device_type_str, " CPQ" );
|
||||
break;
|
||||
|
||||
case NWIPE_DEVICE_USB:
|
||||
strcpy( next_device->device_type_str, " USB" );
|
||||
break;
|
||||
|
||||
case NWIPE_DEVICE_IEEE1394:
|
||||
strcpy( next_device->device_type_str, "1394" );
|
||||
break;
|
||||
|
||||
case NWIPE_DEVICE_ATA:
|
||||
strcpy( next_device->device_type_str, " ATA" );
|
||||
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;
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
( *c )[dcount] = next_device;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* eof */
|
||||
/* Remove leading/training 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, char* serialnumber )
|
||||
{
|
||||
/* The caller provides a string that contains the device, i.e. /dev/sdc, also a pointer
|
||||
* to a integer (bus type) and thirdly 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 un supported 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;
|
||||
|
||||
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];
|
||||
|
||||
/* 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 immediatley if --nousb specified. Readlink is a requirment 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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 )
|
||||
{
|
||||
if( nwipe_options.verbose && result[0] != 0x0A )
|
||||
{
|
||||
strip_CR_LF( result );
|
||||
nwipe_log( NWIPE_LOG_DEBUG, "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], 20 );
|
||||
}
|
||||
}
|
||||
|
||||
/* 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, "%s USB bridge, no passthru support", device );
|
||||
|
||||
if( *bus == NWIPE_DEVICE_USB )
|
||||
{
|
||||
strcpy( serialnumber, "(no ATA pass thru)" );
|
||||
set_return_value = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return set_return_value;
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
17
src/device.h
17
src/device.h
@@ -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,19 @@
|
||||
*
|
||||
* 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 */
|
||||
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.
|
||||
int nwipe_get_device_bus_type_and_serialno( char*, nwipe_device_t*, char* );
|
||||
void strip_CR_LF( char* );
|
||||
void determine_disk_capacity_nomenclature( u64, char* );
|
||||
void remove_ATA_prefix( char* );
|
||||
|
||||
#endif /* DEVICE_H_ */
|
||||
|
||||
/* eof */
|
||||
|
||||
38
src/gui.h
38
src/gui.h
@@ -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,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 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(
|
||||
const char* footer_text ); // If terminal is resized recreate all windows
|
||||
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.
|
||||
int spinner( nwipe_context_t** ptr, int ); // Return the next spinner character
|
||||
|
||||
int compute_stats(void *ptr);
|
||||
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
|
||||
|
||||
#endif /* GUI_H_ */
|
||||
|
||||
/* eof */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
974
src/logging.c
974
src/logging.c
File diff suppressed because it is too large
Load Diff
@@ -14,34 +14,38 @@
|
||||
*
|
||||
* 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 512
|
||||
|
||||
#define MAX_SIZE_OS_STRING 512 /* 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, // 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.
|
||||
NWIPE_LOG_NOTIMESTAMP // logs the message without the timestamp
|
||||
} nwipe_log_t;
|
||||
|
||||
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_log_OSinfo();
|
||||
int nwipe_log_sysinfo();
|
||||
void nwipe_log_summary( nwipe_context_t**, int ); // This produces the wipe status table on exit
|
||||
void Determine_C_B_nomenclature( u64, char*, int );
|
||||
void convert_seconds_to_hours_minutes_seconds( u64, int*, int*, int* );
|
||||
|
||||
#endif /* LOGGING_H_ */
|
||||
|
||||
/* eof */
|
||||
|
||||
1666
src/method.c
1666
src/method.c
File diff suppressed because it is too large
Load Diff
40
src/method.h
40
src/method.h
@@ -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,43 @@
|
||||
*
|
||||
* 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_verify( void* ptr );
|
||||
|
||||
void calculate_round_size( nwipe_context_t* );
|
||||
|
||||
#endif /* METHOD_H_ */
|
||||
|
||||
/* eof */
|
||||
|
||||
1211
src/nwipe.c
1211
src/nwipe.c
File diff suppressed because it is too large
Load Diff
54
src/nwipe.h
54
src/nwipe.h
@@ -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
|
||||
@@ -33,7 +38,11 @@
|
||||
|
||||
/* workaround for Fedora */
|
||||
#ifndef off64_t
|
||||
# define off64_t off_t
|
||||
#ifndef off_t
|
||||
#define off64_t int64_t
|
||||
#else
|
||||
#define off64_t off_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Busybox headers. */
|
||||
@@ -59,27 +68,28 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
/*#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;
|
||||
/* char **log_lines;
|
||||
int log_current_element = 0;
|
||||
int log_elements_allocated = 0;
|
||||
int log_elements_displayed = 0;
|
||||
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; */
|
||||
|
||||
/* 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 +97,20 @@ 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 ) )
|
||||
|
||||
/* This is required for ioctl FDFLUSH. */
|
||||
#include <linux/fd.h>
|
||||
|
||||
void *signal_hand(void *);
|
||||
|
||||
#endif /* NWIPE_H_ */
|
||||
|
||||
/* eof */
|
||||
|
||||
845
src/options.c
845
src/options.c
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* options.c: Command line processing routines for nwipe.
|
||||
* options.c: 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
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, version 2.
|
||||
@@ -16,11 +16,10 @@
|
||||
*
|
||||
* 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 "context.h"
|
||||
#include "method.h"
|
||||
@@ -34,386 +33,502 @@ nwipe_options_t nwipe_options;
|
||||
|
||||
int nwipe_options_parse( int argc, char** argv )
|
||||
{
|
||||
extern char* optarg; /* The working getopt option argument. */
|
||||
extern int optind; /* The working getopt index into argv. */
|
||||
extern int optopt; /* The last unhandled getopt option. */
|
||||
extern int opterr; /* The last getopt error number. */
|
||||
extern char* optarg; // The working getopt option argument.
|
||||
extern int optind; // The working getopt index into argv.
|
||||
extern int optopt; // The last unhandled getopt option.
|
||||
extern int opterr; // The last getopt error number.
|
||||
|
||||
extern nwipe_prng_t nwipe_twister;
|
||||
extern nwipe_prng_t nwipe_isaac;
|
||||
extern nwipe_prng_t nwipe_twister;
|
||||
extern nwipe_prng_t nwipe_isaac;
|
||||
|
||||
/* The maximum banner size, including the null. */
|
||||
const int nwipe_banner_size = 81;
|
||||
/* The getopt() result holder. */
|
||||
int nwipe_opt;
|
||||
|
||||
/* The getopt() result holder. */
|
||||
int nwipe_opt;
|
||||
/* Excluded drive indexes */
|
||||
int idx_drive_chr;
|
||||
int idx_optarg;
|
||||
int idx_drive;
|
||||
|
||||
/* Array index variable. */
|
||||
int i;
|
||||
/* Array index variable. */
|
||||
int i;
|
||||
|
||||
/* The list of acceptable short options. */
|
||||
char nwipe_options_short [] = "Vhl:hm:p:r:";
|
||||
|
||||
/* The list of acceptable long options. */
|
||||
static struct option nwipe_options_long [] =
|
||||
{
|
||||
/* Set when the user wants to wipe without a confirmation prompt. */
|
||||
{ "autonuke", no_argument, 0, 0 },
|
||||
|
||||
/* A GNU standard option. Corresponds to the 'h' short option. */
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
|
||||
/* The wipe method. Corresponds to the 'm' short option. */
|
||||
{ "method", required_argument, 0, 'm' },
|
||||
|
||||
/* Log file. Corresponds to the 'l' short option. */
|
||||
{ "logfile", required_argument, 0, 'l' },
|
||||
|
||||
/* The Pseudo Random Number Generator. */
|
||||
{ "prng", required_argument, 0, 'p' },
|
||||
|
||||
/* The number of times to run the method. */
|
||||
{ "rounds", required_argument, 0, 'r' },
|
||||
|
||||
/* Whether to blank the disk after wiping. */
|
||||
{ "noblank", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{ "nowait", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to allow signals to interrupt a wipe. */
|
||||
{ "nosignals", no_argument, 0, 0 },
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{ "nogui", no_argument, 0, 0 },
|
||||
|
||||
/* A flag to indicate whether the devices whould be opened in sync mode. */
|
||||
{ "sync", no_argument, 0, 0 },
|
||||
|
||||
/* Verify that wipe patterns are being written to the device. */
|
||||
{ "verify", required_argument, 0, 0 },
|
||||
|
||||
/* Display program version. */
|
||||
{ "version", no_argument, 0, 'V' },
|
||||
|
||||
/* Requisite padding for getopt(). */
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/* Note that COLS isn't available until ncurses is initialized. */
|
||||
nwipe_options.banner = malloc( nwipe_banner_size );
|
||||
|
||||
/* Set the default product banner. */
|
||||
/* TODO: Add version constant. */
|
||||
strncpy ( nwipe_options.banner, program_name, nwipe_banner_size);
|
||||
strncat ( nwipe_options.banner, " ", nwipe_banner_size - strlen (nwipe_options.banner) - 1);
|
||||
strncat ( nwipe_options.banner, version_string, nwipe_banner_size - strlen (nwipe_options.banner) - 1);
|
||||
strncat ( nwipe_options.banner, " (based on DBAN's dwipe - Darik's Wipe)", nwipe_banner_size - strlen (nwipe_options.banner) - 1);
|
||||
|
||||
/* Set default options. */
|
||||
nwipe_options.autonuke = 0;
|
||||
nwipe_options.method = &nwipe_dodshort;
|
||||
nwipe_options.prng = &nwipe_twister;
|
||||
nwipe_options.rounds = 1;
|
||||
nwipe_options.noblank = 0;
|
||||
nwipe_options.nowait = 0;
|
||||
nwipe_options.nosignals= 0;
|
||||
nwipe_options.nogui = 0;
|
||||
nwipe_options.sync = 0;
|
||||
nwipe_options.verify = NWIPE_VERIFY_LAST;
|
||||
memset( nwipe_options.logfile, '\0', sizeof(nwipe_options.logfile) );
|
||||
|
||||
|
||||
/* Parse command line options. */
|
||||
while( 1 )
|
||||
{
|
||||
/* Get the next command line option with (3)getopt. */
|
||||
nwipe_opt = getopt_long( argc, argv, nwipe_options_short, nwipe_options_long, &i );
|
||||
|
||||
/* Break when we have processed all of the given options. */
|
||||
if( nwipe_opt < 0 ) { break; }
|
||||
|
||||
switch( nwipe_opt )
|
||||
{
|
||||
case 0: /* Long options without short counterparts. */
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "autonuke" ) == 0 )
|
||||
{
|
||||
nwipe_options.autonuke = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "noblank" ) == 0 )
|
||||
{
|
||||
nwipe_options.noblank = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nowait" ) == 0 )
|
||||
{
|
||||
nwipe_options.nowait = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nosignals" ) == 0 )
|
||||
{
|
||||
nwipe_options.nosignals = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nogui" ) == 0 )
|
||||
{
|
||||
nwipe_options.nogui = 1;
|
||||
nwipe_options.nowait = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "sync" ) == 0 )
|
||||
{
|
||||
nwipe_options.sync = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "verify" ) == 0 )
|
||||
{
|
||||
|
||||
if( strcmp( optarg, "0" ) == 0 || strcmp( optarg, "off" ) == 0 )
|
||||
{
|
||||
nwipe_options.verify = NWIPE_VERIFY_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "1" ) == 0 || strcmp( optarg, "last" ) == 0 )
|
||||
{
|
||||
nwipe_options.verify = NWIPE_VERIFY_LAST;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "2" ) == 0 || strcmp( optarg, "all" ) == 0 )
|
||||
{
|
||||
nwipe_options.verify = NWIPE_VERIFY_ALL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Else we do not know this verification level. */
|
||||
fprintf( stderr, "Error: Unknown verification level '%s'.\n", optarg );
|
||||
exit( EINVAL );
|
||||
|
||||
}
|
||||
|
||||
|
||||
case 'm': /* Method option. */
|
||||
|
||||
if( strcmp( optarg, "dod522022m" ) == 0 || strcmp( optarg, "dod" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_dod522022m;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "dodshort" ) == 0 || strcmp( optarg, "dod3pass" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_dodshort;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "gutmann" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_gutmann;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "ops2" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_ops2;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "random" ) == 0
|
||||
|| strcmp( optarg, "prng" ) == 0
|
||||
|| strcmp( optarg, "stream" ) == 0
|
||||
)
|
||||
{
|
||||
nwipe_options.method= &nwipe_random;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "zero" ) == 0 || strcmp( optarg, "quick" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_zero;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Else we do not know this wipe method. */
|
||||
fprintf( stderr, "Error: Unknown wipe method '%s'.\n", optarg );
|
||||
exit( EINVAL );
|
||||
|
||||
|
||||
case 'l': /* Log file option. */
|
||||
|
||||
nwipe_options.logfile[strlen(optarg)] = '\0';
|
||||
strncpy(nwipe_options.logfile, optarg, sizeof(nwipe_options.logfile));
|
||||
break;
|
||||
|
||||
case 'h': /* Display help. */
|
||||
|
||||
display_help();
|
||||
break;
|
||||
|
||||
case 'p': /* PRNG option. */
|
||||
|
||||
if( strcmp( optarg, "mersenne" ) == 0
|
||||
|| strcmp( optarg, "twister" ) == 0
|
||||
)
|
||||
{
|
||||
nwipe_options.prng = &nwipe_twister;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "isaac" ) == 0 )
|
||||
{
|
||||
nwipe_options.prng = &nwipe_isaac;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Else we do not know this PRNG. */
|
||||
fprintf( stderr, "Error: Unknown prng '%s'.\n", optarg );
|
||||
exit( EINVAL );
|
||||
|
||||
|
||||
case 'r': /* Rounds option. */
|
||||
|
||||
if( sscanf( optarg, " %i", &nwipe_options.rounds ) != 1 \
|
||||
|| nwipe_options.rounds < 1
|
||||
)
|
||||
{
|
||||
fprintf( stderr, "Error: The rounds argument must be a postive integer.\n" );
|
||||
exit( EINVAL );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'V': /* Rounds option. */
|
||||
|
||||
printf ( "%s version %s\n", program_name, version_string );
|
||||
exit( EXIT_SUCCESS );
|
||||
|
||||
default:
|
||||
|
||||
/* Bogus command line argument. */
|
||||
display_help();
|
||||
exit( EINVAL );
|
||||
|
||||
} /* method */
|
||||
|
||||
} /* command line options */
|
||||
|
||||
/* Return the number of options that were processed. */
|
||||
return optind;
|
||||
|
||||
} /* nwipe_options_parse */
|
||||
/* The list of acceptable short options. */
|
||||
char nwipe_options_short[] = "Vvhl:m:p:r:e:";
|
||||
|
||||
/* The list of acceptable long options. */
|
||||
static struct option nwipe_options_long[] = {
|
||||
/* Set when the user wants to wipe without a confirmation prompt. */
|
||||
{"autonuke", no_argument, 0, 0},
|
||||
|
||||
/* Set when the user wants to have the system powerdown on completion of wipe. */
|
||||
{"autopoweroff", no_argument, 0, 0},
|
||||
|
||||
/* A GNU standard option. Corresponds to the 'h' short option. */
|
||||
{"help", no_argument, 0, 'h'},
|
||||
|
||||
/* The wipe method. Corresponds to the 'm' short option. */
|
||||
{"method", required_argument, 0, 'm'},
|
||||
|
||||
/* Log file. Corresponds to the 'l' short option. */
|
||||
{"logfile", required_argument, 0, 'l'},
|
||||
|
||||
/* Exclude devices, comma separated list */
|
||||
{"exclude", required_argument, 0, 'e'},
|
||||
|
||||
/* The Pseudo Random Number Generator. */
|
||||
{"prng", required_argument, 0, 'p'},
|
||||
|
||||
/* The number of times to run the method. */
|
||||
{"rounds", required_argument, 0, 'r'},
|
||||
|
||||
/* Whether to blank the disk after wiping. */
|
||||
{"noblank", no_argument, 0, 0},
|
||||
|
||||
/* Whether to ignore all USB devices. */
|
||||
{"nousb", no_argument, 0, 0},
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{"nowait", no_argument, 0, 0},
|
||||
|
||||
/* Whether to allow signals to interrupt a wipe. */
|
||||
{"nosignals", no_argument, 0, 0},
|
||||
|
||||
/* Whether to exit after wiping or wait for a keypress. */
|
||||
{"nogui", no_argument, 0, 0},
|
||||
|
||||
/* A flag to indicate whether the devices whould be opened in sync mode. */
|
||||
{"sync", required_argument, 0, 0},
|
||||
|
||||
/* Verify that wipe patterns are being written to the device. */
|
||||
{"verify", required_argument, 0, 0},
|
||||
|
||||
/* Display program version. */
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
|
||||
/* Display program version. */
|
||||
{"version", no_argument, 0, 'V'},
|
||||
|
||||
/* Requisite padding for getopt(). */
|
||||
{0, 0, 0, 0}};
|
||||
|
||||
/* Set default options. */
|
||||
nwipe_options.autonuke = 0;
|
||||
nwipe_options.autopoweroff = 0;
|
||||
nwipe_options.method = &nwipe_dodshort;
|
||||
nwipe_options.prng = &nwipe_twister;
|
||||
nwipe_options.rounds = 1;
|
||||
nwipe_options.noblank = 0;
|
||||
nwipe_options.nousb = 0;
|
||||
nwipe_options.nowait = 0;
|
||||
nwipe_options.nosignals = 0;
|
||||
nwipe_options.nogui = 0;
|
||||
nwipe_options.sync = DEFAULT_SYNC_RATE;
|
||||
nwipe_options.verbose = 0;
|
||||
nwipe_options.verify = NWIPE_VERIFY_LAST;
|
||||
memset( nwipe_options.logfile, '\0', sizeof( nwipe_options.logfile ) );
|
||||
|
||||
/* Initialise each of the strings in the excluded drives array */
|
||||
for( i = 0; i < MAX_NUMBER_EXCLUDED_DRIVES; i++ )
|
||||
{
|
||||
nwipe_options.exclude[i][0] = 0;
|
||||
}
|
||||
|
||||
/* Parse command line options. */
|
||||
while( 1 )
|
||||
{
|
||||
/* Get the next command line option with (3)getopt. */
|
||||
nwipe_opt = getopt_long( argc, argv, nwipe_options_short, nwipe_options_long, &i );
|
||||
|
||||
/* Break when we have processed all of the given options. */
|
||||
if( nwipe_opt < 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
switch( nwipe_opt )
|
||||
{
|
||||
case 0: /* Long options without short counterparts. */
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "autonuke" ) == 0 )
|
||||
{
|
||||
nwipe_options.autonuke = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "autopoweroff" ) == 0 )
|
||||
{
|
||||
nwipe_options.autopoweroff = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "noblank" ) == 0 )
|
||||
{
|
||||
nwipe_options.noblank = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nousb" ) == 0 )
|
||||
{
|
||||
nwipe_options.nousb = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nowait" ) == 0 )
|
||||
{
|
||||
nwipe_options.nowait = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nosignals" ) == 0 )
|
||||
{
|
||||
nwipe_options.nosignals = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "nogui" ) == 0 )
|
||||
{
|
||||
nwipe_options.nogui = 1;
|
||||
nwipe_options.nowait = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "verbose" ) == 0 )
|
||||
{
|
||||
nwipe_options.verbose = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "sync" ) == 0 )
|
||||
{
|
||||
if( sscanf( optarg, " %i", &nwipe_options.sync ) != 1 || nwipe_options.sync < 0 )
|
||||
{
|
||||
fprintf( stderr, "Error: The sync argument must be a positive integer or zero.\n" );
|
||||
exit( EINVAL );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( nwipe_options_long[i].name, "verify" ) == 0 )
|
||||
{
|
||||
|
||||
if( strcmp( optarg, "0" ) == 0 || strcmp( optarg, "off" ) == 0 )
|
||||
{
|
||||
nwipe_options.verify = NWIPE_VERIFY_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "1" ) == 0 || strcmp( optarg, "last" ) == 0 )
|
||||
{
|
||||
nwipe_options.verify = NWIPE_VERIFY_LAST;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "2" ) == 0 || strcmp( optarg, "all" ) == 0 )
|
||||
{
|
||||
nwipe_options.verify = NWIPE_VERIFY_ALL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Else we do not know this verification level. */
|
||||
fprintf( stderr, "Error: Unknown verification level '%s'.\n", optarg );
|
||||
exit( EINVAL );
|
||||
}
|
||||
|
||||
/* getopt_long should raise on invalid option, so we should never get here. */
|
||||
exit( EINVAL );
|
||||
|
||||
case 'm': /* Method option. */
|
||||
|
||||
if( strcmp( optarg, "dod522022m" ) == 0 || strcmp( optarg, "dod" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_dod522022m;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "dodshort" ) == 0 || strcmp( optarg, "dod3pass" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_dodshort;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "gutmann" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_gutmann;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "ops2" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_ops2;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "random" ) == 0 || strcmp( optarg, "prng" ) == 0
|
||||
|| strcmp( optarg, "stream" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_random;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "zero" ) == 0 || strcmp( optarg, "quick" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_zero;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "verify" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_verify;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "is5enh" ) == 0 )
|
||||
{
|
||||
nwipe_options.method = &nwipe_is5enh;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Else we do not know this wipe method. */
|
||||
fprintf( stderr, "Error: Unknown wipe method '%s'.\n", optarg );
|
||||
exit( EINVAL );
|
||||
|
||||
case 'l': /* Log file option. */
|
||||
|
||||
nwipe_options.logfile[strlen( optarg )] = '\0';
|
||||
strncpy( nwipe_options.logfile, optarg, sizeof( nwipe_options.logfile ) );
|
||||
break;
|
||||
|
||||
case 'e': /* exclude drives option */
|
||||
|
||||
idx_drive_chr = 0;
|
||||
idx_optarg = 0;
|
||||
idx_drive = 0;
|
||||
|
||||
/* Create an array of excluded drives from the comma separated string */
|
||||
while( optarg[idx_optarg] != 0 && idx_drive < MAX_NUMBER_EXCLUDED_DRIVES )
|
||||
{
|
||||
/* drop the leading '=' character if used */
|
||||
if( optarg[idx_optarg] == '=' && idx_optarg == 0 )
|
||||
{
|
||||
idx_optarg++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( optarg[idx_optarg] == ',' )
|
||||
{
|
||||
/* terminate string and move onto next drive */
|
||||
nwipe_options.exclude[idx_drive++][idx_drive_chr] = 0;
|
||||
idx_drive_chr = 0;
|
||||
idx_optarg++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( idx_drive_chr < MAX_DRIVE_PATH_LENGTH )
|
||||
{
|
||||
nwipe_options.exclude[idx_drive][idx_drive_chr++] = optarg[idx_optarg++];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This section deals with file names that exceed MAX_DRIVE_PATH_LENGTH */
|
||||
nwipe_options.exclude[idx_drive][idx_drive_chr] = 0;
|
||||
while( optarg[idx_optarg] != 0 && optarg[idx_optarg] != ',' )
|
||||
{
|
||||
idx_optarg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h': /* Display help. */
|
||||
|
||||
display_help();
|
||||
break;
|
||||
|
||||
case 'p': /* PRNG option. */
|
||||
|
||||
if( strcmp( optarg, "mersenne" ) == 0 || strcmp( optarg, "twister" ) == 0 )
|
||||
{
|
||||
nwipe_options.prng = &nwipe_twister;
|
||||
break;
|
||||
}
|
||||
|
||||
if( strcmp( optarg, "isaac" ) == 0 )
|
||||
{
|
||||
nwipe_options.prng = &nwipe_isaac;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Else we do not know this PRNG. */
|
||||
fprintf( stderr, "Error: Unknown prng '%s'.\n", optarg );
|
||||
exit( EINVAL );
|
||||
|
||||
case 'r': /* Rounds option. */
|
||||
|
||||
if( sscanf( optarg, " %i", &nwipe_options.rounds ) != 1 || nwipe_options.rounds < 1 )
|
||||
{
|
||||
fprintf( stderr, "Error: The rounds argument must be a positive integer.\n" );
|
||||
exit( EINVAL );
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'v': /* verbose */
|
||||
|
||||
nwipe_options.verbose = 1;
|
||||
break;
|
||||
|
||||
case 'V': /* Version option. */
|
||||
|
||||
printf( "%s version %s\n", program_name, version_string );
|
||||
exit( EXIT_SUCCESS );
|
||||
|
||||
default:
|
||||
|
||||
/* Bogus command line argument. */
|
||||
display_help();
|
||||
exit( EINVAL );
|
||||
|
||||
} /* method */
|
||||
|
||||
} /* command line options */
|
||||
|
||||
/* Return the number of options that were processed. */
|
||||
return optind;
|
||||
}
|
||||
|
||||
void nwipe_options_log( void )
|
||||
{
|
||||
/**
|
||||
* Prints a manifest of options to the log.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Prints a manifest of options to the log.
|
||||
*/
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Program options are set as follows..." );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, "Program options are set as follows..." );
|
||||
|
||||
if( nwipe_options.autonuke )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " autonuke = %i (on)", nwipe_options.autonuke );
|
||||
}
|
||||
if( nwipe_options.autonuke )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " autonuke = %i (on)", nwipe_options.autonuke );
|
||||
}
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " autonuke = %i (off)", nwipe_options.autonuke );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " autonuke = %i (off)", nwipe_options.autonuke );
|
||||
}
|
||||
if( nwipe_options.autopoweroff )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " autopoweroff = %i (on)", nwipe_options.autopoweroff );
|
||||
}
|
||||
else
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " autopoweroff = %i (off)", nwipe_options.autopoweroff );
|
||||
}
|
||||
|
||||
if( nwipe_options.noblank )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not perform a final blank pass" );
|
||||
}
|
||||
if( nwipe_options.noblank )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not perform a final blank pass" );
|
||||
}
|
||||
|
||||
if( nwipe_options.nowait )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not wait for a key before exiting" );
|
||||
}
|
||||
if( nwipe_options.nowait )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not wait for a key before exiting" );
|
||||
}
|
||||
|
||||
if( nwipe_options.nosignals )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not allow signals to interrupt a wipe" );
|
||||
}
|
||||
if( nwipe_options.nosignals )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not allow signals to interrupt a wipe" );
|
||||
}
|
||||
|
||||
if( nwipe_options.nogui )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not show GUI interface" );
|
||||
}
|
||||
if( nwipe_options.nogui )
|
||||
{
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " do not show GUI interface" );
|
||||
}
|
||||
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", nwipe_options.banner );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " method = %s", nwipe_method_label( nwipe_options.method ) );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " rounds = %i", nwipe_options.rounds );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " sync = %i", nwipe_options.sync );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " banner = %s", banner );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " method = %s", nwipe_method_label( nwipe_options.method ) );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " rounds = %i", nwipe_options.rounds );
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " sync = %i", nwipe_options.sync );
|
||||
|
||||
switch( nwipe_options.verify )
|
||||
{
|
||||
case NWIPE_VERIFY_NONE:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i (off)", nwipe_options.verify );
|
||||
break;
|
||||
switch( nwipe_options.verify )
|
||||
{
|
||||
case NWIPE_VERIFY_NONE:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i (off)", nwipe_options.verify );
|
||||
break;
|
||||
|
||||
case NWIPE_VERIFY_LAST:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i (last pass)", nwipe_options.verify );
|
||||
break;
|
||||
case NWIPE_VERIFY_LAST:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i (last pass)", nwipe_options.verify );
|
||||
break;
|
||||
|
||||
case NWIPE_VERIFY_ALL:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i (all passes)", nwipe_options.verify );
|
||||
break;
|
||||
case NWIPE_VERIFY_ALL:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i (all passes)", nwipe_options.verify );
|
||||
break;
|
||||
|
||||
default:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i", nwipe_options.verify );
|
||||
break;
|
||||
}
|
||||
|
||||
} /* nwipe_options_log */
|
||||
|
||||
/**
|
||||
* display_help
|
||||
* displays the help section to STDOUT and exits
|
||||
*/
|
||||
void
|
||||
display_help()
|
||||
{
|
||||
printf("Usage: %s [options] [device1] [device2] ...\n", program_name);
|
||||
printf("Options:\n" );
|
||||
puts(" -V, --version Prints the version number");
|
||||
puts(" -h, --help Prints this help");
|
||||
puts(" --autonuke If no devices have been specified on the command line, starts wiping all");
|
||||
puts(" devices immediately. If devices have been specified, starts wiping only");
|
||||
puts(" those specified devices immediately.");
|
||||
puts(" --sync Open devices in sync mode");
|
||||
puts(" --verify=TYPE Whether to perform verification of erasure (default: last)");
|
||||
puts(" off - Do not verify");
|
||||
puts(" last - Verify after the last pass");
|
||||
puts(" all - Verify every pass");
|
||||
puts(" -m, --method=METHOD The wiping method (default: dodshort). See man page for more details.");
|
||||
puts(" dod522022m / dod - 7 pass DOD 5220.22-M method");
|
||||
puts(" dodshort / dod3pass - 3 pass DOD method");
|
||||
puts(" gutmann - Peter Gutmann's Algorithm");
|
||||
puts(" ops2 - RCMP TSSIT OPS-II");
|
||||
puts(" random / prng / stream - PRNG Stream");
|
||||
puts(" zero / quick - Overwrite with zeros");
|
||||
puts(" -l, --logfile=FILE Filename to log to. Default is STDOUT");
|
||||
puts(" -p, --prng=METHOD PRNG option (mersenne|twister|isaac)" );
|
||||
puts(" -r, --rounds=NUM Number of times to wipe the device using the selected method (default: 1)" );
|
||||
puts(" --noblank Do not blank disk after wipe (default is to complete a final blank pass)" );
|
||||
puts(" --nowait Do not wait for a key before exiting (default is to wait)" );
|
||||
puts(" --nosignals Do not allow signals to interrupt a wipe (default is to allow)" );
|
||||
puts(" --nogui Do not show the GUI interface. Automatically invokes the nowait option" );
|
||||
puts(" Must be used with --autonuke option. Send SIGUSR1 to log current stats");
|
||||
puts("");
|
||||
exit( EXIT_SUCCESS );
|
||||
default:
|
||||
nwipe_log( NWIPE_LOG_NOTICE, " verify = %i", nwipe_options.verify );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* eof */
|
||||
void display_help()
|
||||
{
|
||||
/**
|
||||
* displays the help section to STDOUT and exits.
|
||||
*/
|
||||
|
||||
printf( "Usage: %s [options] [device1] [device2] ...\n", program_name );
|
||||
printf( "Options:\n" );
|
||||
/* Limit line length to a maximum of 80 characters so it looks good in 80x25 terminals i.e shredos */
|
||||
/* ___12345678901234567890123456789012345678901234567890123456789012345678901234567890< Do not exceed */
|
||||
puts( " -V, --version Prints the version number\n" );
|
||||
puts( " -v, --verbose Prints more messages to the log\n" );
|
||||
puts( " -h, --help Prints this help\n" );
|
||||
puts( " --autonuke If no devices have been specified on the command line," );
|
||||
puts( " starts wiping all devices immediately. If devices have" );
|
||||
puts( " been specified, starts wiping only those specified" );
|
||||
puts( " devices immediately.\n" );
|
||||
puts( " --autopoweroff Power off system on completion of wipe delayed for" );
|
||||
puts( " for one minute. During this one minute delay you can" );
|
||||
puts( " abort the shutdown by typing sudo shutdown -c\n" );
|
||||
printf( " --sync=NUM Will perform a sync after NUM writes (default: %d)\n", DEFAULT_SYNC_RATE );
|
||||
puts( " 0 - fdatasync after the disk is completely written" );
|
||||
puts( " fdatasync errors not detected until completion." );
|
||||
puts( " 0 is not recommended as disk errors may cause nwipe" );
|
||||
puts( " to appear to hang" );
|
||||
puts( " 1 - fdatasync after every write" );
|
||||
puts( " Warning: Lower values will reduce wipe speeds." );
|
||||
puts( " 1000000 - fdatasync after 1000000 writes etc.)\n" );
|
||||
puts( " --verify=TYPE Whether to perform verification of erasure" );
|
||||
puts( " (default: last)" );
|
||||
puts( " off - Do not verify" );
|
||||
puts( " last - Verify after the last pass" );
|
||||
puts( " all - Verify every pass\n" );
|
||||
puts( " -m, --method=METHOD The wiping method. See man page for more details." );
|
||||
puts( " (default: dodshort)" );
|
||||
puts( " dod522022m / dod - 7 pass DOD 5220.22-M method" );
|
||||
puts( " dodshort / dod3pass - 3 pass DOD method" );
|
||||
puts( " gutmann - Peter Gutmann's Algorithm" );
|
||||
puts( " ops2 - RCMP TSSIT OPS-II" );
|
||||
puts( " random / prng / stream - PRNG Stream" );
|
||||
puts( " zero / quick - Overwrite with zeros" );
|
||||
puts( " verify - Verifies disk is zero filled\n" );
|
||||
puts( " -l, --logfile=FILE Filename to log to. Default is STDOUT\n" );
|
||||
puts( " -p, --prng=METHOD PRNG option (mersenne|twister|isaac)\n" );
|
||||
puts( " -r, --rounds=NUM Number of times to wipe the device using the selected" );
|
||||
puts( " method (default: 1)\n" );
|
||||
puts( " --noblank Do not blank disk after wipe" );
|
||||
puts( " (default is to complete a final blank pass)\n" );
|
||||
puts( " --nowait Do not wait for a key before exiting" );
|
||||
puts( " (default is to wait)\n" );
|
||||
puts( " --nosignals Do not allow signals to interrupt a wipe" );
|
||||
puts( " (default is to allow)\n" );
|
||||
puts( " --nogui Do not show the GUI interface. Automatically invokes" );
|
||||
puts( " the nowait option. Must be used with the --autonuke" );
|
||||
puts( " option. Send SIGUSR1 to log current stats\n" );
|
||||
puts( " --nousb Do show or wipe any USB devices whether in GUI" );
|
||||
puts( " mode, --nogui or --autonuke modes.\n" );
|
||||
puts( " -e, --exclude=DEVICES Up to ten comma separated devices to be excluded" );
|
||||
puts( " --exclude=/dev/sdc" );
|
||||
puts( " --exclude=/dev/sdc,/dev/sdd" );
|
||||
puts( " --exclude=/dev/sdc,/dev/sdd,/dev/mapper/cryptswap1\n" );
|
||||
puts( "" );
|
||||
exit( EXIT_SUCCESS );
|
||||
}
|
||||
|
||||
@@ -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,28 @@
|
||||
*
|
||||
* 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 10
|
||||
#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
|
||||
|
||||
/* Function prototypes for loading options from the environment and command line. */
|
||||
int nwipe_options_parse( int argc, char** argv );
|
||||
@@ -44,25 +46,26 @@ 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 exclude[MAX_NUMBER_EXCLUDED_DRIVES][MAX_DRIVE_PATH_LENGTH]; // Drives excluded from the search.
|
||||
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 and how often writes should be sync'd.
|
||||
int verbose; // Make log more verbose
|
||||
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 */
|
||||
|
||||
1191
src/pass.c
1191
src/pass.c
File diff suppressed because it is too large
Load Diff
10
src/pass.h
10
src/pass.h
@@ -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 */
|
||||
|
||||
200
src/prng.c
200
src/prng.c
@@ -2,7 +2,7 @@
|
||||
* 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.
|
||||
@@ -14,142 +14,140 @@
|
||||
*
|
||||
* 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"
|
||||
|
||||
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};
|
||||
|
||||
int nwipe_u32tobuffer( u8* buffer, u32 rand, int len )
|
||||
{
|
||||
"Mersenne Twister (mt19937ar-cok)",
|
||||
nwipe_twister_init,
|
||||
nwipe_twister_read
|
||||
};
|
||||
/*
|
||||
* Print given number of bytes from unsigned integer number to a byte stream buffer starting with low-endian.
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
||||
nwipe_prng_t nwipe_isaac =
|
||||
{
|
||||
"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)
|
||||
{
|
||||
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;
|
||||
for( i = 0; i < len; i++ )
|
||||
{
|
||||
c = rand & 0xFFUL;
|
||||
rand = rand >> 8;
|
||||
buffer[i] = c;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
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
|
||||
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
|
||||
|
||||
/* 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) ;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
if( remain > 0 )
|
||||
{
|
||||
nwipe_u32tobuffer( (u8*) ( buffer + i ), 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
/* 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;
|
||||
}
|
||||
/* The purpose of this function is unclear, as it does not do anything except immediately return !
|
||||
* Because the variables in the macro NWIPE_PRNG_READ_SIGNATURE were then unused this throws
|
||||
* up a handful of compiler warnings, related to variables being unused. To stop the compiler warnings
|
||||
* I've simply put in a (void) var so that compiler sees the variable are supposed to be unused.
|
||||
*
|
||||
* As this code works, I thought it best not to remove this function, just in case it serves
|
||||
* some purpose or is there for future use.
|
||||
*/
|
||||
|
||||
/* eof */
|
||||
(void) state;
|
||||
(void) buffer;
|
||||
(void) count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
27
src/prng.h
27
src/prng.h
@@ -14,7 +14,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.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -22,25 +22,25 @@
|
||||
#define PRNG_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. */
|
||||
@@ -54,7 +54,4 @@ int nwipe_isaac_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
|
||||
|
||||
|
||||
#endif /* PRNG_H_ */
|
||||
|
||||
/* eof */
|
||||
|
||||
@@ -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.30";
|
||||
const char* program_name = "nwipe";
|
||||
const char* author_name = "Martijn van Brummelen";
|
||||
const char* email_address = "git@brumit.nl";
|
||||
const char* years = "2020";
|
||||
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.30";
|
||||
|
||||
@@ -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*/
|
||||
|
||||
Reference in New Issue
Block a user