-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #252 Fixes #370 Fixes #371 When failing to add bundle with a file with the wrong hash remove the file and fall back to the verify_fix_path. Improve warnings so they don't look like errors until they are actually errors. Add tests so we don't regress in this regard. Signed-off-by: Matthew Johnson <[email protected]>
- Loading branch information
1 parent
88eea5f
commit 7483535
Showing
28 changed files
with
197 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Installing bundle(s) files... | ||
Warning: hash check failed for /testfile | ||
will attempt to download fullfile for /testfile | ||
Path /testfile is missing on the file system ... fixing | ||
Bundle(s) installation done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test file |
9 changes: 9 additions & 0 deletions
9
test/functional/bundleadd/bad-hash-state/target-dir/usr/lib/os-release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
NAME="Clear Linux Software for Intel Architecture" | ||
VERSION=1 | ||
ID=clear-linux-os | ||
VERSION_ID=10 | ||
PRETTY_NAME="Clear Linux Software for Intel Architecture" | ||
ANSI_COLOR="1;35" | ||
HOME_URL="https://clearlinux.org" | ||
SUPPORT_URL="https://clearlinux.org" | ||
BUG_REPORT_URL="https://bugs.clearlinux.org/jira" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "../../swupdlib" | ||
|
||
f_hash="ffbe308091534f3b47b876b241166c4c6d0665204977274093f74851380d49b5" | ||
|
||
setup() { | ||
# set up state directory with bad hash file and pack hint | ||
clean_test_dir | ||
sudo mkdir -p $DIR/state/staged | ||
sudo rm -f "$DIR/state/staged/$f_hash" | ||
sudo sh -c "echo \"test file MODIFIED\" > $DIR/state/staged/$f_hash" | ||
sudo touch $DIR/state/pack-test-bundle-from-0-to-10.tar | ||
chown_root -R $DIR/state | ||
sudo chmod -R 0700 $DIR/state | ||
|
||
# set up web dir | ||
create_manifest_tar 10 MoM | ||
sign_manifest_mom 10 | ||
create_manifest_tar 10 os-core | ||
create_manifest_tar 10 test-bundle | ||
create_fullfile_tar 10 $f_hash | ||
tar -C $DIR/web-dir/10 -cf $DIR/web-dir/10/pack-test-bundle-from-0.tar staged/$f_hash | ||
|
||
# clean up test dir | ||
sudo rm -f "$DIR/target-dir/testfile" | ||
} | ||
|
||
teardown() { | ||
clean_tars 10 | ||
} | ||
|
||
@test "bundle-add add bundle with bad hash in state dir" { | ||
# sanity check, the test is invalid if this exists now | ||
[ ! -f "$DIR/target-dir/testfile" ] | ||
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle" | ||
|
||
check_lines "$output" | ||
[ "$status" -eq 0 ] | ||
# the corrected file should exist on the filesystem now | ||
[ -f "$DIR/target-dir/testfile" ] | ||
} | ||
|
||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80 |
9 changes: 9 additions & 0 deletions
9
test/functional/bundleadd/bad-hash-state/web-dir/10/Manifest.MoM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MANIFEST 3 | ||
version: 10 | ||
previous: 0 | ||
filecount: 1 | ||
timestamp: 1451940175 | ||
contentsize: 13805671819 | ||
|
||
M... 0f026bc0017b676ad1eed7db682408007171cc1c148c39c069f91d740be784d7 10 os-core | ||
M... f88a494e5c91a07758ef75910ba6cadb166082e3f0ed68a656eefec06c9503eb 10 test-bundle |
14 changes: 14 additions & 0 deletions
14
test/functional/bundleadd/bad-hash-state/web-dir/10/Manifest.os-core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
MANIFEST 3 | ||
version: 10 | ||
previous: 0 | ||
filecount: 7 | ||
timestamp: 1451936779 | ||
contentsize: 17929151 | ||
|
||
D... cde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr | ||
D... dde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/lib | ||
D... ede33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/lib/kernel | ||
D... cde13514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share | ||
D... cde23514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear | ||
D... cde43514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear/bundles | ||
F... b85f1dc2c2317a20f47a36d3257313b131124ffa6d4f19bb060d43014fd386b0 10 /usr/share/clear/bundles/os-core |
8 changes: 8 additions & 0 deletions
8
test/functional/bundleadd/bad-hash-state/web-dir/10/Manifest.test-bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MANIFEST 3 | ||
version: 10 | ||
previous: 0 | ||
filecount: 1 | ||
timestamp: 1451936779 | ||
contentsize: 17929151 | ||
|
||
F... ffbe308091534f3b47b876b241166c4c6d0665204977274093f74851380d49b5 10 /testfile |
1 change: 1 addition & 0 deletions
1
...h-state/web-dir/10/files/ffbe308091534f3b47b876b241166c4c6d0665204977274093f74851380d49b5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test file |
1 change: 1 addition & 0 deletions
1
...-state/web-dir/10/staged/ffbe308091534f3b47b876b241166c4c6d0665204977274093f74851380d49b5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test file |
1 change: 1 addition & 0 deletions
1
test/functional/bundleadd/bad-hash-state/web-dir/version/formatstaging/latest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Extracting test-bundle pack for version 10 | ||
Installing bundle(s) files... | ||
Warning: hash check failed for /testfile | ||
will attempt to download fullfile for /testfile | ||
Path /testfile is missing on the file system ... fixing | ||
REGEXP:File content hash mismatch for .* |
9 changes: 9 additions & 0 deletions
9
test/functional/bundleadd/bad-hash/target-dir/usr/lib/os-release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
NAME="Clear Linux Software for Intel Architecture" | ||
VERSION=1 | ||
ID=clear-linux-os | ||
VERSION_ID=10 | ||
PRETTY_NAME="Clear Linux Software for Intel Architecture" | ||
ANSI_COLOR="1;35" | ||
HOME_URL="https://clearlinux.org" | ||
SUPPORT_URL="https://clearlinux.org" | ||
BUG_REPORT_URL="https://bugs.clearlinux.org/jira" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "../../swupdlib" | ||
|
||
# expected hash listed in manifest, but not acutal hash of file | ||
# also file name in staged directory | ||
f_hash="e6d85023c5e619eb43d5cfbfdbdec784afef5a82ffa54e8c93bda3e0883360a3" | ||
|
||
setup() { | ||
clean_test_dir | ||
create_manifest_tar 10 MoM | ||
sign_manifest_mom 10 | ||
create_manifest_tar 10 os-core | ||
create_manifest_tar 10 test-bundle | ||
create_fullfile_tar 10 $f_hash | ||
chown_root "$DIR/web-dir/10/staged/$f_hash" | ||
tar -C "$DIR/web-dir/10" -cf "$DIR/web-dir/10/pack-test-bundle-from-0.tar" staged/$f_hash | ||
} | ||
|
||
teardown() { | ||
clean_tars 10 | ||
revert_chown_root "$DIR/web-dir/10/staged/$f_hash" | ||
} | ||
|
||
@test "bundle-add add bundle containing file with different hash from what is listed in manifest" { | ||
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle" | ||
|
||
# downloaded fullfile had a bad hash - immediately fatal with a 1 return code | ||
[ "$status" -eq 1 ] | ||
check_lines "$output" | ||
# the bad hash file should not exist on the system | ||
[ ! -f "$DIR/target-dir/testfile" ] | ||
} | ||
|
||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MANIFEST 3 | ||
version: 10 | ||
previous: 0 | ||
filecount: 1 | ||
timestamp: 1451940175 | ||
contentsize: 13805671819 | ||
|
||
M... 0f026bc0017b676ad1eed7db682408007171cc1c148c39c069f91d740be784d7 10 os-core | ||
M... bacb42d324b642f45ae4323c462e29acb4344987f430b9b55f70e96443f967c9 10 test-bundle |
14 changes: 14 additions & 0 deletions
14
test/functional/bundleadd/bad-hash/web-dir/10/Manifest.os-core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
MANIFEST 3 | ||
version: 10 | ||
previous: 0 | ||
filecount: 7 | ||
timestamp: 1451936779 | ||
contentsize: 17929151 | ||
|
||
D... cde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr | ||
D... dde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/lib | ||
D... ede33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/lib/kernel | ||
D... cde13514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share | ||
D... cde23514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear | ||
D... cde43514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear/bundles | ||
F... b85f1dc2c2317a20f47a36d3257313b131124ffa6d4f19bb060d43014fd386b0 10 /usr/share/clear/bundles/os-core |
8 changes: 8 additions & 0 deletions
8
test/functional/bundleadd/bad-hash/web-dir/10/Manifest.test-bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MANIFEST 3 | ||
version: 10 | ||
previous: 0 | ||
filecount: 1 | ||
timestamp: 1451936779 | ||
contentsize: 17929151 | ||
|
||
F... e6d85023c5e619eb43d5cfbfdbdec784afef5a82ffa54e8c93bda3e0883360a3 10 /testfile |
1 change: 1 addition & 0 deletions
1
...ad-hash/web-dir/10/files/e6d85023c5e619eb43d5cfbfdbdec784afef5a82ffa54e8c93bda3e0883360a3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test file MODIFIED1 |
1 change: 1 addition & 0 deletions
1
...d-hash/web-dir/10/staged/e6d85023c5e619eb43d5cfbfdbdec784afef5a82ffa54e8c93bda3e0883360a3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test file MODIFIED1 |
1 change: 1 addition & 0 deletions
1
test/functional/bundleadd/bad-hash/web-dir/version/formatstaging/latest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Extracting test-bundle pack for version 10 | ||
Installing bundle(s) files... | ||
REGEXP:Update target directory does not exist: .*/usr/bin. Trying to fix it | ||
Path /usr/bin is missing on the file system | ||
Path /usr/bin is missing on the file system ... fixing | ||
Bundle(s) installation done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters