From 0108b2b7924070907a4a5117d6eccf65f8fdd17b Mon Sep 17 00:00:00 2001 From: joshua stein Date: Thu, 7 Nov 2019 17:08:57 +0000 Subject: [PATCH] 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 --- toolkit/system/gnome/nsGIOService.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/toolkit/system/gnome/nsGIOService.cpp b/toolkit/system/gnome/nsGIOService.cpp index ef88b4eebcc2..2ffc3689a3d5 100644 --- a/toolkit/system/gnome/nsGIOService.cpp +++ b/toolkit/system/gnome/nsGIOService.cpp @@ -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);