Bug 1580271: defer to xdg-open when opening files on OpenBSD r=gcp

g_app_info_get_default_for_type() will fail on OpenBSD's veiled
filesystem since we most likely don't have direct access to the binaries
that are registered as defaults for this type.  Fake it up by just
executing xdg-open via gio-launch-desktop (which we do have access to)
and letting it figure out which program to execute for this MIME type.

This has the side-effect of ignoring/losing MIME types associations
registered in firefox prefs only.

Differential Revision: https://phabricator.services.mozilla.com/D51388

--HG--
extra : moz-landing-system : lando
This commit is contained in:
joshua stein 2019-11-07 17:08:57 +00:00
Родитель 0fce47207d
Коммит 0108b2b792
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -497,7 +497,19 @@ nsGIOService::GetAppForMimeType(const nsACString& aMimeType,
return NS_ERROR_NOT_AVAILABLE;
}
#if defined(__OpenBSD__) && defined(MOZ_SANDBOX)
// g_app_info_get_default_for_type will fail on OpenBSD's veiled filesystem
// since we most likely don't have direct access to the binaries that are
// registered as defaults for this type. Fake it up by just executing
// xdg-open via gio-launch-desktop (which we do have access to) and letting
// it figure out which program to execute for this MIME type
GAppInfo* app_info = g_app_info_create_from_commandline(
"/usr/local/bin/xdg-open",
nsPrintfCString("System default for %s", content_type).get(),
G_APP_INFO_CREATE_NONE, NULL);
#else
GAppInfo* app_info = g_app_info_get_default_for_type(content_type, false);
#endif
if (app_info) {
nsGIOMimeApp* mozApp = new nsGIOMimeApp(app_info);
NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY);