bkctld-check-incs: Protect jail_config_epoch

Test if `incs_policy_file` exists before using it. Fixes #43.
This commit is contained in:
Brice Waegeneire 2021-02-08 11:12:57 +01:00 committed by Jérémy Lecour
parent a41eb2a218
commit c27cb81b57
2 changed files with 4 additions and 3 deletions

View File

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
* tests: clean jail configuration after each test
* bkctld-check-incs: Protect `jail_config_epoch`
### Security

View File

@ -20,10 +20,10 @@ for jail_name in $("${LIBDIR}/bkctld-list"); do
# Today in ISO format
today_iso=$(date +"%Y-%m-%d")
# get jail last configuration date
jail_config_epoch=$(date --date "$(stat -c %y ${incs_policy_file})" +"%s")
if [ -n "${incs_policy_file}" ]; then
# get jail last configuration date
jail_config_epoch=$(date --date "$(stat -c %y ${incs_policy_file})" +"%s")
# loop for each line in jail configuration
for line in $(cat ${incs_policy_file}); do
# inc date in ISO format