utils: use common code for apply_rules and apply_cipso

Code for `apply_rules()` has been rewritten to use `opendir()` and `readdir()`, but `apply_cipso()` remained implemented with nftw(). This patch implements both applying functions with `opendir()` and `readdir()` using a common internal function `apply_dir()`.
The resulting code is 45 lines shorter and keeps directory traversal logic in single place.