Fix Host::Launch to work in Flatpak sandboxed environment. (#252)

This commit is contained in:
Zbigniew Rębacz 2025-04-14 15:31:19 +02:00 committed by GitHub
parent 59bd635ec3
commit d08975a53d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -272,17 +272,29 @@ void Host::Launch(const char *_cmdline, bool console)
if(console)
cmdline = "/usr/bin/open " + script;
#else
String lc = ResolveHostConsole();
if(FileExists(lc))
{
if(console)
cmdline = HostConsole + " sh " + script;
if(console) {
String lc = ResolveHostConsole();
if(FileExists(lc))
{
#ifdef FLATPAK
auto real_hc = HostConsole;
real_hc.Replace(String("/run/host/"), String("/usr/"));
cmdline = FindCommand(exedirs, CMDLINE_PREFIX + real_hc + " sh " + script);
#else
cmdline = HostConsole + " sh " + script;
#endif
}
else
if(HostConsole.GetCount())
PutConsole("Warning: Terminal '" + lc + "' not found, executing in background.");
}
#ifdef FLATPAK
else {
cmdline = FindCommand(exedirs, CMDLINE_PREFIX + cmdline);
}
else
if(HostConsole.GetCount())
PutConsole("Warning: Terminal '" + lc + "' not found, executing in background.");
#endif
#endif
Buffer<char> cmd_buf(strlen(cmdline) + 1);
Vector<char *> args;