Skip to content
API Documentation
BastionGuard™
FirewallDetector.cpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#include "../SafeProcess.hpp"
22#include "FirewallDetector.hpp"
23#include <fstream>
24#include <cstdlib>
25
27 return ((bg_process::exists_on_path("firewall-cmd") ? 0 : 1) == 0);
28}
29
31 return ((bg_process::exists_on_path("ufw") ? 0 : 1) == 0);
32}
33
35 std::ifstream f("/etc/os-release");
36 if (!f.is_open()) return "unknown";
37
38 std::string line;
39 while (std::getline(f, line)) {
40 if (line.rfind("ID=", 0) == 0)
41 return line.substr(3);
42 }
43 return "unknown";
44}
45
FirewallType
static bool isUfwPresent()
static bool isFirewalldPresent()
static FirewallType detectFirewall()
static std::string detectDistro()
bool exists_on_path(const std::string &name)