| 196 | } |
| 197 | |
| 198 | bool FirewallController::loadTableDef(const std::string &tableDef) |
| 199 | { |
| 200 | // Use a dedicated file so a targeted load never clobbers the main pf.conf. `pfctl -T load` only |
| 201 | // updates table contents; it does not touch rules or the state table. |
| 202 | if (!IO::writeFile(WS_POSIX_CONFIG_DIR "/pf_partial.conf", tableDef + "\n", 0600)) { |
| 203 | spdlog::error("loadTableDef: could not write pf_partial.conf: {}", IO::strerror(errno)); |
| 204 | return false; |
| 205 | } |
| 206 | if (Utils::executeCommand("/sbin/pfctl", {"-T", "load", "-f", WS_POSIX_CONFIG_DIR "/pf_partial.conf"}) != 0) { |
| 207 | spdlog::error("loadTableDef: pfctl failed to load table"); |
| 208 | return false; |
| 209 | } |
| 210 | return true; |
| 211 | } |
| 212 | |
| 213 | bool FirewallController::loadAnchor(const std::string &anchorName, const std::vector<std::string> &rules) |
| 214 | { |
nothing calls this directly
no test coverage detected