зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
d5a5d64d5d
Коммит
6b491fa02a
|
@ -27,6 +27,8 @@
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <dbus/dbus-glib-lowlevel.h>
|
#include <dbus/dbus-glib-lowlevel.h>
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsDBusRemoteService,
|
NS_IMPL_ISUPPORTS(nsDBusRemoteService,
|
||||||
nsIRemoteService)
|
nsIRemoteService)
|
||||||
|
|
||||||
|
@ -189,10 +191,17 @@ nsDBusRemoteService::Startup(const char* aAppName, const char* aProfileName)
|
||||||
if (busName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
|
if (busName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
|
||||||
busName.Truncate(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.
|
// 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");
|
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
|
// We failed completelly to get a valid bus name - just quit
|
||||||
// to prevent crash at dbus_bus_request_name().
|
// to prevent crash at dbus_bus_request_name().
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "mozilla/Base64.h"
|
#include "mozilla/Base64.h"
|
||||||
#include "nsPrintfCString.h"
|
#include "nsPrintfCString.h"
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
using mozilla::LogLevel;
|
using mozilla::LogLevel;
|
||||||
static mozilla::LazyLogModule sRemoteLm("DBusRemoteClient");
|
static mozilla::LazyLogModule sRemoteLm("DBusRemoteClient");
|
||||||
|
|
||||||
|
@ -136,11 +138,18 @@ DBusRemoteClient::GetRemoteDestinationName(const char *aProgram,
|
||||||
if (aDestinationName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
|
if (aDestinationName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
|
||||||
aDestinationName.Truncate(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.
|
// We don't have a valid busName yet - try to create a default one.
|
||||||
aDestinationName = nsPrintfCString("org.mozilla.%s.%s", aProgram,
|
aDestinationName = nsPrintfCString("org.mozilla.%s.%s", aProgram,
|
||||||
"default");
|
"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
|
// We failed completelly to get a valid bus name - just quit
|
||||||
// to prevent crash at dbus_bus_request_name().
|
// to prevent crash at dbus_bus_request_name().
|
||||||
return false;
|
return false;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче