bahamas10/bash-vsv

race condition when checking if a service is disabled

bahamas10 opened this issue · 0 comments

if [[ -e $svc/down ]]; then
    verbose "service disabled: $(< $svc/down)"
...

This looks innocent enough, but it really isn't. The first line checks for file existence (using stat(2)), followed up by the second line which reads the file (without any error checking!). This is a a classic stat before open race, and can be eliminated with cat and proper error checking.