Skip to content
API Documentation
BastionGuard™
FirewallInstaller.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 "FirewallInstaller.hpp"
22
24 const std::string& distro,
25 bool preferFirewalld)
26{
27 if (preferFirewalld) {
28 if (distro == "fedora" || distro == "rhel" ||
29 distro == "centos" || distro == "opensuse")
30 return "pkexec dnf install firewalld";
31
32 if (distro == "arch" || distro == "manjaro")
33 return "pkexec pacman -S firewalld";
34 }
35
36 // ufw
37 if (distro == "ubuntu" || distro == "debian")
38 return "pkexec apt install ufw";
39
40 if (distro == "arch" || distro == "manjaro")
41 return "pkexec pacman -S ufw";
42
43 return "";
44}
static std::string getInstallCommand(const std::string &distro, bool preferFirewalld=true)