Revert 148351 - Make dbus file descriptor check dynamic

Without this change cros builds from outside the chroot can't run
tracing code.

BUG=None
TEST=None

Review URL: https://chromiumcodereview.appspot.com/10815083

TBR=davemoore@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10822016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148353 0039d316-1c4b-4281-b951-d872f2087c98
parent 8432c3ea
...@@ -18,7 +18,7 @@ namespace { ...@@ -18,7 +18,7 @@ namespace {
// Appends the header name and the value to |output|, if the value is // Appends the header name and the value to |output|, if the value is
// not empty. // not empty.
void AppendStringHeader(const std::string& header_name, static void AppendStringHeader(const std::string& header_name,
const std::string& header_value, const std::string& header_value,
std::string* output) { std::string* output) {
if (!header_value.empty()) { if (!header_value.empty()) {
...@@ -28,7 +28,7 @@ void AppendStringHeader(const std::string& header_name, ...@@ -28,7 +28,7 @@ void AppendStringHeader(const std::string& header_name,
// Appends the header name and the value to |output|, if the value is // Appends the header name and the value to |output|, if the value is
// nonzero. // nonzero.
void AppendUint32Header(const std::string& header_name, static void AppendUint32Header(const std::string& header_name,
uint32 header_value, uint32 header_value,
std::string* output) { std::string* output) {
if (header_value != 0) { if (header_value != 0) {
...@@ -37,15 +37,6 @@ void AppendUint32Header(const std::string& header_name, ...@@ -37,15 +37,6 @@ void AppendUint32Header(const std::string& header_name,
} }
} }
// Returns true if Unix FD passing is supported in libdbus.
// The check is done runtime rather than compile time as the libdbus
// version used at runtime may be different from the one used at compile time.
bool IsDBusTypeUnixFdSupported() {
int major = 0, minor = 0, micro = 0;
dbus_get_version(&major, &minor, &micro);
return major >= 1 && minor >= 4;
}
} // namespace } // namespace
namespace dbus { namespace dbus {
...@@ -220,7 +211,7 @@ std::string Message::ToStringInternal(const std::string& indent, ...@@ -220,7 +211,7 @@ std::string Message::ToStringInternal(const std::string& indent,
break; break;
} }
case UNIX_FD: { case UNIX_FD: {
CHECK(IsDBusTypeUnixFdSupported()); CHECK(kDBusTypeUnixFdIsSupported);
FileDescriptor file_descriptor; FileDescriptor file_descriptor;
if (!reader->PopFileDescriptor(&file_descriptor)) if (!reader->PopFileDescriptor(&file_descriptor))
...@@ -699,7 +690,7 @@ void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) { ...@@ -699,7 +690,7 @@ void MessageWriter::AppendVariantOfBasic(int dbus_type, const void* value) {
} }
void MessageWriter::AppendFileDescriptor(const FileDescriptor& value) { void MessageWriter::AppendFileDescriptor(const FileDescriptor& value) {
CHECK(IsDBusTypeUnixFdSupported()); CHECK(kDBusTypeUnixFdIsSupported);
if (!value.is_valid()) { if (!value.is_valid()) {
// NB: sending a directory potentially enables sandbox escape // NB: sending a directory potentially enables sandbox escape
...@@ -969,7 +960,7 @@ bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) { ...@@ -969,7 +960,7 @@ bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) {
} }
bool MessageReader::PopFileDescriptor(FileDescriptor* value) { bool MessageReader::PopFileDescriptor(FileDescriptor* value) {
CHECK(IsDBusTypeUnixFdSupported()); CHECK(kDBusTypeUnixFdIsSupported);
int fd = -1; int fd = -1;
const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd);
......
...@@ -28,7 +28,10 @@ class MessageWriter; ...@@ -28,7 +28,10 @@ class MessageWriter;
class MessageReader; class MessageReader;
// DBUS_TYPE_UNIX_FD was added in D-Bus version 1.4 // DBUS_TYPE_UNIX_FD was added in D-Bus version 1.4
#if !defined(DBUS_TYPE_UNIX_FD) #if defined(DBUS_TYPE_UNIX_FD)
const bool kDBusTypeUnixFdIsSupported = true;
#else
const bool kDBusTypeUnixFdIsSupported = false;
#define DBUS_TYPE_UNIX_FD ((int) 'h') #define DBUS_TYPE_UNIX_FD ((int) 'h')
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment