Skip to content
API Documentation
BastionGuard™
BastionGuard-secure-cli.cpp File Reference

Go to the source code of this file.

Functions

static void configure_graphics_backend ()
static bool has_in_path (const char *exe)
int main (int argc, char **argv)

Function Documentation

◆ configure_graphics_backend()

void configure_graphics_backend ( )
static

Definition at line 41 of file BastionGuard-secure-cli.cpp.

41 {
42 const char* wayland = std::getenv("WAYLAND_DISPLAY");
43 const char* x11 = std::getenv("DISPLAY");
44
45 if (wayland && *wayland) {
46 std::cout << _("[BastionGuard-secure] Sessione Wayland rilevata → backend Wayland.\n");
47 setenv("GDK_BACKEND", "wayland", 1);
48 setenv("OZONE_PLATFORM", "wayland", 1);
49 } else if (x11 && *x11) {
50 std::cout << _("[BastionGuard-secure] Sessione X11 rilevata → backend X11.\n");
51 setenv("GDK_BACKEND", "x11", 1);
52 setenv("OZONE_PLATFORM", "x11", 1);
53 } else {
54 std::cout << _("[BastionGuard-secure] Nessuna sessione grafica rilevata → fallback X11.\n");
55 setenv("GDK_BACKEND", "x11", 1);
56 setenv("OZONE_PLATFORM", "x11", 1);
57 }
58
59 const char* force_sw = std::getenv("BASTIONGUARD_FORCE_SOFTWARE_GL");
60 if (force_sw && std::strcmp(force_sw, "1") == 0) {
61 std::cout << _("[BastionGuard-secure] Forzo rendering software (LIBGL_ALWAYS_SOFTWARE=1)\n");
62 setenv("LIBGL_ALWAYS_SOFTWARE", "1", 1);
63 }
64}
#define _(s)

References _, and configure_graphics_backend().

Referenced by configure_graphics_backend(), and main().

◆ has_in_path()

bool has_in_path ( const char * exe)
static

Definition at line 67 of file BastionGuard-secure-cli.cpp.

67 {
68 return exe && bg_process::exists_on_path(exe);
69}
bool exists_on_path(const std::string &name)

References bg_process::exists_on_path(), and has_in_path().

Referenced by has_in_path().

◆ main()

int main ( int argc,
char ** argv )

Definition at line 74 of file BastionGuard-secure-cli.cpp.

74 {
75 setlocale(LC_ALL, "");
76 bindtextdomain("BastionGuard", LOCALEDIR);
77 bind_textdomain_codeset("BastionGuard", "UTF-8");
78 textdomain("BastionGuard");
79
80 CefMainArgs cef_args(argc, argv);
81 int rc = CefExecuteProcess(cef_args, nullptr, nullptr);
82 if (rc >= 0)
83 return rc;
84
85 const char* no_bwrap = std::getenv("BASTIONGUARD_NO_BWRAP");
86 if (!(no_bwrap && std::strcmp(no_bwrap, "1") == 0)) {
88 } else {
89 std::cerr << _("[BastionGuard-secure] Bypass dnsmasq disabilitato (BASTIONGUARD_NO_BWRAP=1)\n");
90 }
91
92 if (argc < 2) {
93 std::cerr << _("Usage: BastionGuard-secure <url>\n");
94 return 2;
95 }
96
97 const std::string url = argv[1];
98 std::cout << _("[BastionGuard-secure] URL richiesto: ") << url << "\n";
99
100
102
103 SecureList::open_if_allowed(url, argc, argv);
104
105 return 0;
106}
static void configure_graphics_backend()
#define LOCALEDIR
static bool open_if_allowed(const std::string &url, int argc, char **argv)
void reexec_inside_bwrap_with_custom_dns(int argc, char **argv)

References _, configure_graphics_backend(), LOCALEDIR, main(), SecureList::open_if_allowed(), and reexec_inside_bwrap_with_custom_dns().