MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / loadTableDef

Method loadTableDef

src/helper/macos/firewallcontroller.cpp:198–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198bool 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
213bool FirewallController::loadAnchor(const std::string &anchorName, const std::vector<std::string> &rules)
214{

Callers

nothing calls this directly

Calls 3

strerrorFunction · 0.85
executeCommandFunction · 0.70
writeFileFunction · 0.50

Tested by

no test coverage detected