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

Go to the source code of this file.

Classes

class  SecureGuiWindow

Functions

static bool load_lang_conf ()
int main (int argc, char *argv[])

Function Documentation

◆ load_lang_conf()

bool load_lang_conf ( )
static

Definition at line 294 of file BastionGuard-secure-main.cpp.

295{
296 const std::string lang_conf = Glib::get_home_dir() + "/.config/BastionGuard/lang.conf";
297 std::ifstream f(lang_conf);
298 if (!f.is_open())
299 return false;
300
301 std::string line;
302 bool any = false;
303
304 while (std::getline(f, line)) {
305 if (line.empty() || line[0] == '#')
306 continue;
307
308 auto pos = line.find('=');
309 if (pos == std::string::npos)
310 continue;
311
312 std::string key = line.substr(0, pos);
313 std::string val = line.substr(pos + 1);
314
315 auto ltrim = [](std::string& s){
316 s.erase(0, s.find_first_not_of(" \t\r\n"));
317 };
318 auto rtrim = [](std::string& s){
319 s.erase(s.find_last_not_of(" \t\r\n") + 1);
320 };
321 ltrim(key); rtrim(key);
322 ltrim(val); rtrim(val);
323
324 if (!key.empty() && !val.empty()) {
325 setenv(key.c_str(), val.c_str(), 1);
326 any = true;
327 }
328 }
329
330 return any;
331}

References load_lang_conf().

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 332 of file BastionGuard-secure-main.cpp.

332 {
333 bool loaded = load_lang_conf();
334
335 std::setlocale(LC_ALL, "");
336 bindtextdomain("BastionGuard", LOCALEDIR);
337 bind_textdomain_codeset("BastionGuard", "UTF-8");
338 textdomain("BastionGuard");
339
340 if (loaded) {
341 std::cerr << _("[Lang] Config caricata da ~/.config/BastionGuard/lang.conf") << "\n";
342 } else {
343 std::cerr << _("[Lang] Nessuna config trovata, uso locale di sistema") << "\n";
344 }
345
346 // Isola anche la GUI dei pagamenti dentro bubblewrap (Wayland o X11).
347 // Stesso meccanismo del CLI: il flag BASTIONGUARD_NO_BWRAP=1 disattiva.
348 // Importante: niente bwrap se siamo già dentro (BASTIONGUARD_IN_BWRAP=1)
349 // e niente bwrap se siamo root (Gtk e dbus user-session non lo gradiscono).
350 {
351 const char* no_bwrap = std::getenv("BASTIONGUARD_NO_BWRAP");
352 const bool bypass = (no_bwrap && std::strcmp(no_bwrap, "1") == 0);
353 if (!bypass && geteuid() != 0) {
355 // Se siamo qui, bwrap non c'era oppure ha fallito: continuiamo
356 // comunque ma loggiamo (la GUI deve sempre aprirsi).
357 }
358 }
359
360 auto app = Gtk::Application::create("org.BastionGuard.secure.gui");
361 load_style();
362 return app->make_window_and_run<SecureGuiWindow>(argc, argv);
363}
#define _(s)
static bool load_lang_conf()
#define LOCALEDIR
void reexec_inside_bwrap_with_custom_dns(int argc, char **argv)
void load_style()

References _, load_lang_conf(), load_style(), LOCALEDIR, main(), and reexec_inside_bwrap_with_custom_dns().