Skip to content

Commit

Permalink
Extend 'file exists' check to require non-zero size
Browse files Browse the repository at this point in the history
Somehow it is possible to get into a state where the privkey.pem file
has a zero size when using LOCAL_CA. How this is achieved is not
confirmed, but I suspect that if openssl is interrupted during
its process it just truncates the file.

With a simple change from -f to -s we now also require that all of
the important files has a size greater than 0. The caveat with this
is that a file containing a single newline character will be accepted,
but let's start here and see if we need even more advanced checks.

Resolves #185
  • Loading branch information
JonasAlfredsson committed May 5, 2023
1 parent a5b538a commit a59e55d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ allfiles_exist() {
debug "Ignoring ${type} path starting with 'data:' in '${1}'"
elif [[ "${path}" == engine:* ]]; then
debug "Ignoring ${type} path starting with 'engine:' in '${1}'"
elif [ ! -f "${path}" ]; then
warning "Could not find ${type} file '${path}' in '${1}'"
elif [ ! -s "${path}" ]; then
warning "Could not find non-zero size ${type} file '${path}' in '${1}'"
all_exist=1
fi
done
Expand Down Expand Up @@ -298,7 +298,7 @@ auto_enable_configs() {
fi
else
if [ "${conf_file##*.}" = "conf" ]; then
error "Important file(s) for '${conf_file}' are missing, disabling..."
error "Important file(s) for '${conf_file}' are missing or empty, disabling..."
mv "${conf_file}" "${conf_file}.nokey"
fi
fi
Expand Down

0 comments on commit a59e55d

Please sign in to comment.