diff --git a/Cargo.toml b/Cargo.toml index 2470460..ef1a2fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "binhost" -version = "0.3.3" +version = "0.3.4" edition = "2021" license = "MIT" repository = "https://github.com/ivabus/binhost" diff --git a/runner/Cargo.toml b/runner/Cargo.toml index df6a9cd..cba54a5 100644 --- a/runner/Cargo.toml +++ b/runner/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runner" -version = "0.1.0" +version = "0.3.4" edition = "2021" [dependencies] @@ -12,7 +12,7 @@ numtoa = "0.2.4" [profile.release] strip = true opt-level = "s" -lto = true +lto = "fat" panic = "abort" codegen-units = 1 diff --git a/runner/src/main.rs b/runner/src/main.rs index ac39701..bd447f0 100644 --- a/runner/src/main.rs +++ b/runner/src/main.rs @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// "Runner" is written in no_std Rust for the smaller executable size: ~49KiB (Darwin arm64) vs ~300KiB +// "Runner" is written in no_std Rust for the smaller executable size: ~49KiB (Darwin arm64) #![no_main] #![no_std] @@ -19,7 +19,6 @@ pub unsafe extern "C" fn main(_argc: i32, _argv: *const *const c_char) -> i32 { printf("Starting runner\n\0".as_bytes().as_ptr() as *const c_char); let mut buff_public_key = [0_u8; PUBKEY_LEN]; - let a = 0; read( open("public_key\0".as_bytes().as_ptr() as *const c_char, O_RDONLY), buff_public_key.as_mut_ptr() as *mut c_void, diff --git a/src/main.rs b/src/main.rs index d8542dc..e950ea6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -221,6 +221,7 @@ async fn rocket() -> _ { } let _ = &*BINS.read().await; + let _ = &*MANIFEST; let figment = Figment::from(rocket::Config::default()) .merge(("ident", "Binhost")) diff --git a/web.sh b/web.sh index 9301321..3e36e3b 100755 --- a/web.sh +++ b/web.sh @@ -23,19 +23,30 @@ requireCommands uname cut dd chmod rm realpath expr # Finding alternative, but supported sha256sums SHA256SUM="" +SHASUMFLAGS="" +PLATFORM="$(uname)" +ARCH="$(uname -m)" if command -v sha256sum > /dev/null 2>&1; then SHA256SUM="sha256sum" + SHASUMFLAGS="-c hashes --ignore-missing" else + if command -v sha256 > /dev/null 2>&1; then + SHA256SUM="sha256" + SHASUMFLAGS="-C hashes runner-$PLATFORM-$ARCH" + fi if command -v shasum > /dev/null 2>&1; then SHASUMVER=$(shasum -v | cut -c 1) if [ "$SHASUMVER" -ge 6 ]; then SHA256SUM="shasum -a 256" + SHASUMFLAGS="-c hashes --ignore-missing" fi - else - fail "Could not find suitable sha256sum executable" fi fi +if [ SHA256SUM = "" ]; then + fail "Could not find suitable sha256sum executable" +fi + if [ "$(realpath "$SHA256SUM" 2> /dev/null)" = "/bin/busybox" ]; then fail "Busybox sha256sum detected, will not work. Refusing to continue" fi @@ -47,8 +58,6 @@ DOWNLOAD_COMMAND="curl" OUTPUT_ARG="-o" DIR="/tmp/binhost-$NAME-$(date +%s)" FILE="$DIR/$NAME" -PLATFORM="$(uname)" -ARCH="$(uname -m)" if ! command -v curl > /dev/null 2>&1; then if ! command -v wget > /dev/null 2>&1; then @@ -75,7 +84,7 @@ cd "$DIR" print ":: Downloading manifest" $DOWNLOAD_COMMAND $EXTERNAL_ADDRESS/runner/manifest $OUTPUT_ARG manifest -MANIFEST_HASHSUM=$($SHA256SUM manifest) +MANIFEST_HASHSUM=$(cat manifest | $SHA256SUM) if [ -n "$KEY" ]; then if [ ! "$KEY" = "$(echo "$MANIFEST_HASHSUM" | cut -c 1-${#KEY})" ]; then @@ -95,7 +104,7 @@ print ":: Downloading runner" $DOWNLOAD_COMMAND "$EXTERNAL_ADDRESS/runner/runner-$PLATFORM-$ARCH" $OUTPUT_ARG "runner-$PLATFORM-$ARCH" -if ! $SHA256SUM -c hashes --ignore-missing >&2 ; then +if ! $SHA256SUM $SHASUMFLAGS >&2 ; then fail "Incorrect hashsum of runner" fi