Skip to content

Commit a59e55d

Browse files
Extend 'file exists' check to require non-zero size
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
1 parent a5b538a commit a59e55d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/scripts/util.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ allfiles_exist() {
156156
debug "Ignoring ${type} path starting with 'data:' in '${1}'"
157157
elif [[ "${path}" == engine:* ]]; then
158158
debug "Ignoring ${type} path starting with 'engine:' in '${1}'"
159-
elif [ ! -f "${path}" ]; then
160-
warning "Could not find ${type} file '${path}' in '${1}'"
159+
elif [ ! -s "${path}" ]; then
160+
warning "Could not find non-zero size ${type} file '${path}' in '${1}'"
161161
all_exist=1
162162
fi
163163
done
@@ -298,7 +298,7 @@ auto_enable_configs() {
298298
fi
299299
else
300300
if [ "${conf_file##*.}" = "conf" ]; then
301-
error "Important file(s) for '${conf_file}' are missing, disabling..."
301+
error "Important file(s) for '${conf_file}' are missing or empty, disabling..."
302302
mv "${conf_file}" "${conf_file}.nokey"
303303
fi
304304
fi

0 commit comments

Comments
 (0)