Bug 1472611 - Don't link DBus 1.5.12 symbol dbus_validate_bus_name(), r=stransky

MozReview-Commit-ID: 6scVh8DOex2

--HG--
extra : rebase_source : d66577a13d06b1a1bdcd1ec0e25fd1dc75d84a1e
This commit is contained in:
ozoder 2018-07-04 09:24:34 +02:00
Родитель d5a5d64d5d
Коммит 6b491fa02a
2 изменённых файлов: 22 добавлений и 4 удалений

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

@ -27,6 +27,8 @@
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <dlfcn.h>
NS_IMPL_ISUPPORTS(nsDBusRemoteService,
nsIRemoteService)
@ -189,10 +191,17 @@ nsDBusRemoteService::Startup(const char* aAppName, const char* aProfileName)
if (busName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
busName.Truncate(DBUS_MAXIMUM_NAME_LENGTH);
static auto sDBusValidateBusName =
(bool (*)(const char *, DBusError *))
dlsym(RTLD_DEFAULT, "dbus_validate_bus_name");
if (!sDBusValidateBusName) {
return NS_ERROR_FAILURE;
}
// We don't have a valid busName yet - try to create a default one.
if (!dbus_validate_bus_name(busName.get(), nullptr)) {
if (!sDBusValidateBusName(busName.get(), nullptr)) {
busName = nsPrintfCString("org.mozilla.%s.%s", mAppName.get(), "default");
if (!dbus_validate_bus_name(busName.get(), nullptr)) {
if (!sDBusValidateBusName(busName.get(), nullptr)) {
// We failed completelly to get a valid bus name - just quit
// to prevent crash at dbus_bus_request_name().
return NS_ERROR_FAILURE;

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

@ -12,6 +12,8 @@
#include "mozilla/Base64.h"
#include "nsPrintfCString.h"
#include <dlfcn.h>
using mozilla::LogLevel;
static mozilla::LazyLogModule sRemoteLm("DBusRemoteClient");
@ -136,11 +138,18 @@ DBusRemoteClient::GetRemoteDestinationName(const char *aProgram,
if (aDestinationName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
aDestinationName.Truncate(DBUS_MAXIMUM_NAME_LENGTH);
if (!dbus_validate_bus_name(aDestinationName.get(), nullptr)) {
static auto sDBusValidateBusName =
(bool (*)(const char *, DBusError *))
dlsym(RTLD_DEFAULT, "dbus_validate_bus_name");
if (!sDBusValidateBusName) {
return false
}
if (!sDBusValidateBusName(aDestinationName.get(), nullptr)) {
// We don't have a valid busName yet - try to create a default one.
aDestinationName = nsPrintfCString("org.mozilla.%s.%s", aProgram,
"default");
if (!dbus_validate_bus_name(aDestinationName.get(), nullptr)) {
if (!sDBusValidateBusName(aDestinationName.get(), nullptr)) {
// We failed completelly to get a valid bus name - just quit
// to prevent crash at dbus_bus_request_name().
return false;