|
@@ -214,6 +214,32 @@ write_state_file() {
|
|
|
done > $filename
|
|
|
}
|
|
|
|
|
|
+check_state_dir() {
|
|
|
+ local PERM
|
|
|
+ local OWNER
|
|
|
+
|
|
|
+ if [ -z "${SQM_STATE_DIR}" ]; then
|
|
|
+ sqm_error '$SQM_STATE_DIR is unset - check your config!'
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+ [ -d "${SQM_STATE_DIR}" ] || ( umask 077; mkdir -p "$SQM_STATE_DIR" ) || exit 1
|
|
|
+
|
|
|
+ if [ ! -w "${SQM_STATE_DIR}" ] || [ ! -x "${SQM_STATE_DIR}" ]; then
|
|
|
+ sqm_error "Cannot write to state dir '$SQM_STATE_DIR'"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+ PERM="0$(stat -L -c '%a' "${SQM_STATE_DIR}")"
|
|
|
+ if [ "$((PERM & 0002))" -ne 0 ]; then
|
|
|
+ sqm_error "State dir '$SQM_STATE_DIR' is world writable; this is unsafe, please fix"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+ OWNER="$(stat -L -c '%u' "${SQM_STATE_DIR}")"
|
|
|
+ if [ "$OWNER" -ne "$(id -u)" ]; then
|
|
|
+ sqm_error "State dir '$SQM_STATE_DIR' is owned by a different user; this is unsafe, please fix"
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
# find the ifb device associated with a specific interface, return nothing of no
|
|
|
# ifb is associated with IF
|