Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Omaha sha1 hash if available and Verify checksum after download, with retry #47

Merged
merged 4 commits into from
Jan 5, 2024

Conversation

pothos
Copy link
Member

@pothos pothos commented Jan 3, 2024

  • Check Omaha sha1 hash if available
    Old Nebraska servers were missing the newly introduced sha256 attribute and might only serve paylads with the regular sha1 attribute set. The generic payload is also just using the regular sha1 attribute because at that time a different extension was used which holds the sha256 checksum for the generic payload.
    Support the regular Omaha sha1 hash for use with old Nebraska servers. This makes it also easy to test with the generic payload.

  • Verify checksum after download, with retry

    The self.verify_checksum(...) call's return value wasn't checked in the
    package download call. Even if we do it there we should rather move it
    into the retry loop and make it explicit whether we expect certain
    checksums or not.
    Check the checksum after the download, and also retry when it
    mismatches.

How to use

Fixes #31

I think this is the last piece to start using it in Flatcar.

Testing done

RUST_LOG=debug target/release/download_sysext -p ~/kinvolk/scripts/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-au-key/files/official-v2.pub.pem -m oem-azure.gz -o /var/tmp/outdir/ -u https://update.release.flatcar-linux.net/amd64-usr/3815.0.0/oem-azure.gz -v
RUST_LOG=debug target/release/download_sysext -p ~/kinvolk/scripts/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-au-key/files/official-v2.pub.pem -m oem-azure.gz -o /var/tmp/outdir/ -i /var/tmp/beta-response -v
RUST_LOG=debug target/release/download_sysext -p ~/kinvolk/scripts/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-au-key/files/official-v2.pub.pem -m flatcar_production_update.gz -o /var/tmp/outdir/ -i /var/tmp/beta-response -v

@pothos pothos requested a review from dongsupark January 3, 2024 14:42
@pothos pothos changed the title Check Omaha sha1 hash if available Check Omaha sha1 hash if available and Verify checksum after download, with retry Jan 3, 2024
@pothos pothos force-pushed the kai/sha1 branch 2 times, most recently from ff6ad75 to 3fc1a8d Compare January 3, 2024 14:56
Copy link
Member

@dongsupark dongsupark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general.

src/download.rs Outdated Show resolved Hide resolved
omaha/src/hash_types.rs Outdated Show resolved Hide resolved
Old Nebraska servers were missing the newly introduced sha256 attribute
and might only serve paylads with the regular sha1 attribute set. The
generic payload is also just using the regular sha1 attribute because
at that time a different extension was used which holds the sha256
checksum for the generic payload.
Support the regular Omaha sha1 hash for use with old Nebraska servers.
This makes it also easy to test with the generic payload.
The self.verify_checksum(...) call's return value wasn't checked in the
package download call. Even if we do it there we should rather move it
into the retry loop and make it explicit whether we expect certain
checksums or not.
Check the checksum after the download, and also retry when it
mismatches.
@pothos
Copy link
Member Author

pothos commented Jan 5, 2024

I've fixed all warnings and added running clippy in the CI, otherwise it's too easy to forget.

@pothos pothos merged commit efc5581 into trunk Jan 5, 2024
1 check passed
@pothos pothos deleted the kai/sha1 branch January 5, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

wire up omaha::Hash<T> with DynDigest
2 participants