From d14bb1a6875239bbc2a0a95f501f687be0fac428 Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 10 Nov 2020 16:10:54 +0100 Subject: [PATCH] Remove unstable feature and fix docker build Signed-off-by: trivernis --- alpine.dockerfile | 3 ++- scratch.dockerfile | 5 +++-- src/utils/keys.rs | 9 +++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/alpine.dockerfile b/alpine.dockerfile index 8d35524..68ac16e 100644 --- a/alpine.dockerfile +++ b/alpine.dockerfile @@ -1,4 +1,5 @@ -FROM rust AS builder +FROM alpine AS builder +RUN apk add --no-cache build-base cargo WORKDIR /usr/src RUN USER=root cargo new snekcloud-server WORKDIR /usr/src/snekcloud-server diff --git a/scratch.dockerfile b/scratch.dockerfile index b35006b..f1f0caf 100644 --- a/scratch.dockerfile +++ b/scratch.dockerfile @@ -1,4 +1,5 @@ -FROM rust AS builder +FROM alpine AS builder +RUN apk add --no-cache build-base cargo WORKDIR /usr/src RUN USER=root cargo new snekcloud-server WORKDIR /usr/src/snekcloud-server @@ -14,4 +15,4 @@ FROM scratch COPY --from=builder /usr/src/snekcloud-server/target/release/snekcloud-server . COPY --from=builder /usr/src/snekcloud-server/target/release/config / COPY --from=builder /usr/src/snekcloud-server/target/release/private_key / -ENTRYPOINT ["./snekcloud-server"] \ No newline at end of file +ENTRYPOINT ["/snekcloud-server"] \ No newline at end of file diff --git a/src/utils/keys.rs b/src/utils/keys.rs index fe6ca45..57f3666 100644 --- a/src/utils/keys.rs +++ b/src/utils/keys.rs @@ -62,12 +62,9 @@ pub fn extract_public_key(content: &str) -> SnekcloudResult { /// Extracts a base64 encoded key between the prefix and suffix fn extract_key(content: &str, prefix: &str, suffix: &str) -> SnekcloudResult<[u8; 32]> { - let mut content = content - .strip_prefix(prefix) - .ok_or(SnekcloudError::InvalidKey)?; - content = content - .strip_suffix(suffix) - .ok_or(SnekcloudError::InvalidKey)?; + if !content.starts_with(prefix) || !content.ends_with(suffix) {} + let mut content = content.trim_start_matches(prefix); + content = content.trim_end_matches(suffix); let key = base64::decode(content)?; if key.len() != 32 {