dbus-daemon.c 56.4 KB
Newer Older
1 2 3
/* Integration tests for the dbus-daemon
 *
 * Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
Simon McVittie's avatar
Simon McVittie committed
4
 * Copyright © 2010-2011 Nokia Corporation
5
 * Copyright © 2015 Collabora Ltd.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation files
 * (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <config.h>

30 31 32 33 34 35 36
#include <errno.h>
#include <string.h>

#include <dbus/dbus.h>

#include <glib.h>
#include <glib/gstdio.h>
37
#include <gio/gio.h>
38

39
#include "bus/stats.h"
40
#include "test-utils-glib.h"
41

42 43
#include <string.h>

44
#ifdef DBUS_UNIX
45
# include <unistd.h>
Simon McVittie's avatar
Simon McVittie committed
46
# include <sys/types.h>
47 48 49 50 51

# ifdef HAVE_GIO_UNIX
    /* The CMake build system doesn't know how to check for this yet */
#   include <gio/gunixfdmessage.h>
# endif
52 53
#endif

54 55 56 57 58 59 60 61 62
/* Platforms where we know that credentials-passing passes both the
 * uid and the pid. Please keep these in alphabetical order.
 *
 * These platforms should #error in _dbus_read_credentials_socket()
 * if we didn't detect their flavour of credentials-passing, since that
 * would be a regression.
 */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
  defined(__linux__) || \
63
  defined(__NetBSD__) || \
64 65 66 67 68 69 70 71 72 73 74
  defined(__OpenBSD__)
# define UNIX_USER_SHOULD_WORK
# define PID_SHOULD_WORK
#endif

/* Platforms where we know that credentials-passing passes the
 * uid, but not necessarily the pid. Again, alphabetical order please.
 *
 * These platforms should also #error in _dbus_read_credentials_socket()
 * if we didn't detect their flavour of credentials-passing.
 */
75
#if 0 /* defined(__your_platform_here__) */
76 77 78
# define UNIX_USER_SHOULD_WORK
#endif

79
typedef struct {
80 81
    gboolean skip;

82 83
    TestMainContext *ctx;

84 85 86
    DBusError e;
    GError *ge;

87
    GPid daemon_pid;
88
    gchar *address;
89 90 91 92

    DBusConnection *left_conn;

    DBusConnection *right_conn;
93
    GQueue held_messages;
94
    gboolean right_conn_echo;
95
    gboolean right_conn_hold;
96
    gboolean wait_forever_called;
97 98 99

    gchar *tmp_runtime_dir;
    gchar *saved_runtime_dir;
100 101 102 103 104 105 106
} Fixture;

static DBusHandlerResult
echo_filter (DBusConnection *connection,
    DBusMessage *message,
    void *user_data)
{
107
  Fixture *f = user_data;
108 109 110 111 112
  DBusMessage *reply;

  if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_CALL)
    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

113 114 115 116 117 118 119
  /* WaitForever() never replies, emulating a service that has got stuck */
  if (dbus_message_is_method_call (message, "com.example", "WaitForever"))
    {
      f->wait_forever_called = TRUE;
      return DBUS_HANDLER_RESULT_HANDLED;
    }

120 121 122 123 124 125 126 127
  reply = dbus_message_new_method_return (message);

  if (reply == NULL)
    g_error ("OOM");

  if (!dbus_connection_send (connection, reply, NULL))
    g_error ("OOM");

128
  dbus_clear_message (&reply);
129 130 131 132

  return DBUS_HANDLER_RESULT_HANDLED;
}

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
static DBusHandlerResult
hold_filter (DBusConnection *connection,
    DBusMessage *message,
    void *user_data)
{
  Fixture *f = user_data;

  if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_CALL)
    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

  g_queue_push_tail (&f->held_messages, dbus_message_ref (message));

  return DBUS_HANDLER_RESULT_HANDLED;
}

148 149 150 151
typedef struct {
    const char *bug_ref;
    guint min_messages;
    const char *config_file;
152
    enum { SPECIFY_ADDRESS = 0, RELY_ON_DEFAULT } connect_mode;
153 154
} Config;

155 156
static void
setup (Fixture *f,
157
    gconstpointer context)
158
{
159
  const Config *config = context;
160

161
  /* Some tests are fairly slow, so make the test timeout per-test */
162
  test_timeout_reset (1);
163

164
  f->ctx = test_main_context_get ();
165 166 167
  f->ge = NULL;
  dbus_error_init (&f->e);

168 169 170 171 172 173 174 175 176
  if (config != NULL && config->connect_mode == RELY_ON_DEFAULT)
    {
      /* this is chosen to be something needing escaping */
      f->tmp_runtime_dir = g_dir_make_tmp ("dbus=daemon=test.XXXXXX", &f->ge);
      g_assert_no_error (f->ge);

      /* we're relying on being single-threaded for this to be safe */
      f->saved_runtime_dir = g_strdup (g_getenv ("XDG_RUNTIME_DIR"));
      g_setenv ("XDG_RUNTIME_DIR", f->tmp_runtime_dir, TRUE);
177
      g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
178 179
    }

180
  f->address = test_get_dbus_daemon (config ? config->config_file : NULL,
181
                                     TEST_USER_ME, NULL,
182
                                     &f->daemon_pid);
183

184
  if (f->address == NULL)
185
    {
186 187
      f->skip = TRUE;
      return;
188
    }
189

190
  f->left_conn = test_connect_to_bus (f->ctx, f->address);
191 192 193 194 195 196 197 198

  if (config != NULL && config->connect_mode == RELY_ON_DEFAULT)
    {
      /* use the default bus for the echo service ("right"), to check that
       * it ends up on the same bus as the client ("left") */
      f->right_conn = dbus_bus_get_private (DBUS_BUS_SESSION, &f->e);
      test_assert_no_error (&f->e);

199
      test_connection_setup (f->ctx, f->right_conn);
200 201 202
    }
  else
    {
203
      f->right_conn = test_connect_to_bus (f->ctx, f->address);
204
    }
205 206 207 208 209
}

static void
add_echo_filter (Fixture *f)
{
210
  if (!dbus_connection_add_filter (f->right_conn, echo_filter, f, NULL))
211 212 213 214 215
    g_error ("OOM");

  f->right_conn_echo = TRUE;
}

216 217 218 219 220 221 222 223 224
static void
add_hold_filter (Fixture *f)
{
  if (!dbus_connection_add_filter (f->right_conn, hold_filter, f, NULL))
    g_error ("OOM");

  f->right_conn_hold = TRUE;
}

225 226 227 228 229 230 231 232 233
static void
pc_count (DBusPendingCall *pc,
    void *data)
{
  guint *received_p = data;

  (*received_p)++;
}

234 235 236 237 238 239 240 241 242 243 244
static void
pc_enqueue (DBusPendingCall *pc,
            void *data)
{
  GQueue *q = data;
  DBusMessage *m = dbus_pending_call_steal_reply (pc);

  g_test_message ("message of type %d", dbus_message_get_type (m));
  g_queue_push_tail (q, m);
}

245 246
static void
test_echo (Fixture *f,
247
    gconstpointer context)
248
{
249
  const Config *config = context;
250 251 252 253 254
  guint count = 2000;
  guint sent;
  guint received = 0;
  double elapsed;

255 256 257 258 259 260
  if (f->skip)
    return;

  if (config != NULL && config->bug_ref != NULL)
    g_test_bug (config->bug_ref);

261 262 263
  if (g_test_perf ())
    count = 100000;

264 265 266
  if (config != NULL)
    count = MAX (config->min_messages, count);

267 268 269 270 271 272 273 274 275 276 277 278 279 280
  add_echo_filter (f);

  g_test_timer_start ();

  for (sent = 0; sent < count; sent++)
    {
      DBusMessage *m = dbus_message_new_method_call (
          dbus_bus_get_unique_name (f->right_conn), "/",
          "com.example", "Spam");
      DBusPendingCall *pc;

      if (m == NULL)
        g_error ("OOM");

281 282 283
      if (!dbus_connection_send_with_reply (f->left_conn, m, &pc,
                                            DBUS_TIMEOUT_INFINITE) ||
          pc == NULL)
284 285 286 287 288 289 290 291
        g_error ("OOM");

      if (dbus_pending_call_get_completed (pc))
        pc_count (pc, &received);
      else if (!dbus_pending_call_set_notify (pc, pc_count, &received,
            NULL))
        g_error ("OOM");

292 293
      dbus_clear_pending_call (&pc);
      dbus_clear_message (&m);
294 295 296
    }

  while (received < count)
297
    test_main_context_iterate (f->ctx, TRUE);
298 299 300 301 302 303 304

  elapsed = g_test_timer_elapsed ();

  g_test_maximized_result (count / elapsed, "%u messages / %f seconds",
      count, elapsed);
}

305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
static void
test_no_reply (Fixture *f,
    gconstpointer context)
{
  const Config *config = context;
  DBusMessage *m;
  DBusPendingCall *pc;
  DBusMessage *reply = NULL;
  enum { TIMEOUT, DISCONNECT } mode;
  gboolean ok;

  if (f->skip)
    return;

  g_test_bug ("76112");

  if (config != NULL && config->config_file != NULL)
    mode = TIMEOUT;
  else
    mode = DISCONNECT;

  m = dbus_message_new_method_call (
      dbus_bus_get_unique_name (f->right_conn), "/",
      "com.example", "WaitForever");

  add_echo_filter (f);

  if (m == NULL)
    g_error ("OOM");

335 336
  /* Not using test_main_context_call_and_wait() here because we need to
   * do things with the right connection as a side-effect */
337 338 339 340 341 342
  if (!dbus_connection_send_with_reply (f->left_conn, m, &pc,
                                        DBUS_TIMEOUT_INFINITE) ||
      pc == NULL)
    g_error ("OOM");

  if (dbus_pending_call_get_completed (pc))
343 344 345
    test_pending_call_store_reply (pc, &reply);
  else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
        &reply, NULL))
346 347
    g_error ("OOM");

348 349
  dbus_clear_pending_call (&pc);
  dbus_clear_message (&m);
350 351 352 353 354 355 356 357

  if (mode == DISCONNECT)
    {
      while (!f->wait_forever_called)
        test_main_context_iterate (f->ctx, TRUE);

      dbus_connection_remove_filter (f->right_conn, echo_filter, f);
      dbus_connection_close (f->right_conn);
358
      dbus_clear_connection (&f->right_conn);
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
    }

  while (reply == NULL)
    test_main_context_iterate (f->ctx, TRUE);

  /* using inefficient string comparison for better assertion message */
  g_assert_cmpstr (
      dbus_message_type_to_string (dbus_message_get_type (reply)), ==,
      dbus_message_type_to_string (DBUS_MESSAGE_TYPE_ERROR));
  ok = dbus_set_error_from_message (&f->e, reply);
  g_assert (ok);
  g_assert_cmpstr (f->e.name, ==, DBUS_ERROR_NO_REPLY);

  if (mode == DISCONNECT)
    g_assert_cmpstr (f->e.message, ==,
        "Message recipient disconnected from message bus without replying");
  else
    g_assert_cmpstr (f->e.message, ==,
        "Message did not receive a reply (timeout by message bus)");
378

379
  dbus_clear_message (&reply);
380 381
}

Simon McVittie's avatar
Simon McVittie committed
382 383 384 385 386 387 388
static void
test_creds (Fixture *f,
    gconstpointer context)
{
  const char *unique = dbus_bus_get_unique_name (f->left_conn);
  DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
      DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetConnectionCredentials");
389
  DBusMessage *reply = NULL;
Simon McVittie's avatar
Simon McVittie committed
390 391 392 393 394 395 396
  DBusMessageIter args_iter;
  DBusMessageIter arr_iter;
  DBusMessageIter pair_iter;
  DBusMessageIter var_iter;
  enum {
      SEEN_UNIX_USER = 1,
      SEEN_PID = 2,
397 398
      SEEN_WINDOWS_SID = 4,
      SEEN_LINUX_SECURITY_LABEL = 8
Simon McVittie's avatar
Simon McVittie committed
399 400 401 402 403 404 405 406 407 408
  } seen = 0;

  if (m == NULL)
    g_error ("OOM");

  if (!dbus_message_append_args (m,
        DBUS_TYPE_STRING, &unique,
        DBUS_TYPE_INVALID))
    g_error ("OOM");

409 410
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
Simon McVittie's avatar
Simon McVittie committed
411

412
  g_assert_cmpstr (dbus_message_get_signature (reply), ==, "a{sv}");
Simon McVittie's avatar
Simon McVittie committed
413

414
  dbus_message_iter_init (reply, &args_iter);
Simon McVittie's avatar
Simon McVittie committed
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
  g_assert_cmpuint (dbus_message_iter_get_arg_type (&args_iter), ==,
      DBUS_TYPE_ARRAY);
  g_assert_cmpuint (dbus_message_iter_get_element_type (&args_iter), ==,
      DBUS_TYPE_DICT_ENTRY);
  dbus_message_iter_recurse (&args_iter, &arr_iter);

  while (dbus_message_iter_get_arg_type (&arr_iter) != DBUS_TYPE_INVALID)
    {
      const char *name;

      dbus_message_iter_recurse (&arr_iter, &pair_iter);
      g_assert_cmpuint (dbus_message_iter_get_arg_type (&pair_iter), ==,
          DBUS_TYPE_STRING);
      dbus_message_iter_get_basic (&pair_iter, &name);
      dbus_message_iter_next (&pair_iter);
      g_assert_cmpuint (dbus_message_iter_get_arg_type (&pair_iter), ==,
          DBUS_TYPE_VARIANT);
      dbus_message_iter_recurse (&pair_iter, &var_iter);

      if (g_strcmp0 (name, "UnixUserID") == 0)
        {
#ifdef G_OS_UNIX
          guint32 u32;

          g_assert (!(seen & SEEN_UNIX_USER));
          g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==,
              DBUS_TYPE_UINT32);
          dbus_message_iter_get_basic (&var_iter, &u32);
443
          g_test_message ("%s of this process is %u", name, u32);
Simon McVittie's avatar
Simon McVittie committed
444 445 446 447
          g_assert_cmpuint (u32, ==, geteuid ());
          seen |= SEEN_UNIX_USER;
#else
          g_assert_not_reached ();
Ralf Habacker's avatar
Ralf Habacker committed
448 449 450 451 452 453 454 455 456 457 458 459
#endif
        }
      else if (g_strcmp0 (name, "WindowsSID") == 0)
        {
#ifdef G_OS_WIN32
          gchar *sid;
          char *self_sid;

          g_assert (!(seen & SEEN_WINDOWS_SID));
          g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==,
              DBUS_TYPE_STRING);
          dbus_message_iter_get_basic (&var_iter, &sid);
460
          g_test_message ("%s of this process is %s", name, sid);
Ralf Habacker's avatar
Ralf Habacker committed
461 462 463 464 465 466 467 468
          if (_dbus_getsid (&self_sid, 0))
            {
              g_assert_cmpstr (self_sid, ==, sid);
              LocalFree(self_sid);
            }
          seen |= SEEN_WINDOWS_SID;
#else
          g_assert_not_reached ();
Simon McVittie's avatar
Simon McVittie committed
469 470 471 472 473 474 475 476 477 478
#endif
        }
      else if (g_strcmp0 (name, "ProcessID") == 0)
        {
          guint32 u32;

          g_assert (!(seen & SEEN_PID));
          g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==,
              DBUS_TYPE_UINT32);
          dbus_message_iter_get_basic (&var_iter, &u32);
479
          g_test_message ("%s of this process is %u", name, u32);
Simon McVittie's avatar
Simon McVittie committed
480 481 482 483 484 485 486 487 488
#ifdef G_OS_UNIX
          g_assert_cmpuint (u32, ==, getpid ());
#elif defined(G_OS_WIN32)
          g_assert_cmpuint (u32, ==, GetCurrentProcessId ());
#else
          g_assert_not_reached ();
#endif
          seen |= SEEN_PID;
        }
489 490 491 492 493 494 495 496 497 498 499 500 501 502
      else if (g_strcmp0 (name, "LinuxSecurityLabel") == 0)
        {
#ifdef __linux__
          gchar *label;
          int len;
          DBusMessageIter ay_iter;

          g_assert (!(seen & SEEN_LINUX_SECURITY_LABEL));
          g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==,
              DBUS_TYPE_ARRAY);
          dbus_message_iter_recurse (&var_iter, &ay_iter);
          g_assert_cmpuint (dbus_message_iter_get_arg_type (&ay_iter), ==,
              DBUS_TYPE_BYTE);
          dbus_message_iter_get_fixed_array (&ay_iter, &label, &len);
503
          g_test_message ("%s of this process is %s", name, label);
504 505 506 507 508 509
          g_assert_cmpuint (strlen (label) + 1, ==, len);
          seen |= SEEN_LINUX_SECURITY_LABEL;
#else
          g_assert_not_reached ();
#endif
        }
Simon McVittie's avatar
Simon McVittie committed
510 511 512 513

      dbus_message_iter_next (&arr_iter);
    }

514
#ifdef UNIX_USER_SHOULD_WORK
Simon McVittie's avatar
Simon McVittie committed
515
  g_assert (seen & SEEN_UNIX_USER);
516 517 518
#endif

#ifdef PID_SHOULD_WORK
Simon McVittie's avatar
Simon McVittie committed
519 520 521 522 523 524
  g_assert (seen & SEEN_PID);
#endif

#ifdef G_OS_WIN32
  g_assert (seen & SEEN_WINDOWS_SID);
#endif
525

526
  dbus_clear_message (&reply);
527
  dbus_clear_message (&m);
Simon McVittie's avatar
Simon McVittie committed
528 529
}

530 531 532 533 534 535 536
static void
test_processid (Fixture *f,
    gconstpointer context)
{
  const char *unique = dbus_bus_get_unique_name (f->left_conn);
  DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
      DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetConnectionUnixProcessID");
537
  DBusMessage *reply = NULL;
538 539 540 541 542 543 544 545 546 547 548
  DBusError error = DBUS_ERROR_INIT;
  guint32 pid;

  if (m == NULL)
    g_error ("OOM");

  if (!dbus_message_append_args (m,
        DBUS_TYPE_STRING, &unique,
        DBUS_TYPE_INVALID))
    g_error ("OOM");

549 550
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
551

552
  if (dbus_set_error_from_message (&error, reply))
553 554 555 556 557 558 559 560 561 562
    {
      g_assert_cmpstr (error.name, ==, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN);

#ifdef PID_SHOULD_WORK
      g_error ("Expected pid to be passed, but got %s: %s",
          error.name, error.message);
#endif

      dbus_error_free (&error);
    }
563
  else if (dbus_message_get_args (reply, &error,
564 565 566
        DBUS_TYPE_UINT32, &pid,
        DBUS_TYPE_INVALID))
    {
567
      g_assert_cmpstr (dbus_message_get_signature (reply), ==, "u");
568
      test_assert_no_error (&error);
569

570
      g_test_message ("GetConnectionUnixProcessID returned %u", pid);
571 572

#ifdef G_OS_UNIX
573
      g_assert_cmpuint (pid, ==, getpid ());
574
#elif defined(G_OS_WIN32)
575
      g_assert_cmpuint (pid, ==, GetCurrentProcessId ());
576
#else
577
      g_assert_not_reached ();
578
#endif
579 580 581
    }
  else
    {
582
      g_error ("Unexpected error: %s: %s", error.name, error.message);
583
    }
584

585
  dbus_clear_message (&reply);
586
  dbus_clear_message (&m);
587 588
}

589 590 591 592 593 594
static void
test_canonical_path_uae (Fixture *f,
    gconstpointer context)
{
  DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
      DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "UpdateActivationEnvironment");
595
  DBusMessage *reply = NULL;
596 597 598 599 600 601 602 603 604 605 606 607 608 609
  DBusMessageIter args_iter;
  DBusMessageIter arr_iter;

  if (m == NULL)
    g_error ("OOM");

  dbus_message_iter_init_append (m, &args_iter);

  /* Append an empty a{ss} (string => string dictionary). */
  if (!dbus_message_iter_open_container (&args_iter, DBUS_TYPE_ARRAY,
        "{ss}", &arr_iter) ||
      !dbus_message_iter_close_container (&args_iter, &arr_iter))
    g_error ("OOM");

610 611
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
612 613

  /* it succeeds */
614
  g_assert_cmpint (dbus_message_get_type (reply), ==,
615 616
      DBUS_MESSAGE_TYPE_METHOD_RETURN);

617
  dbus_clear_message (&reply);
618
  dbus_clear_message (&m);
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634

  /* Now try with the wrong object path */
  m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
      "/com/example/Wrong", DBUS_INTERFACE_DBUS, "UpdateActivationEnvironment");

  if (m == NULL)
    g_error ("OOM");

  dbus_message_iter_init_append (m, &args_iter);

  /* Append an empty a{ss} (string => string dictionary). */
  if (!dbus_message_iter_open_container (&args_iter, DBUS_TYPE_ARRAY,
        "{ss}", &arr_iter) ||
      !dbus_message_iter_close_container (&args_iter, &arr_iter))
    g_error ("OOM");

635 636
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
637 638

  /* it fails, yielding an error message with one string argument */
639 640
  g_assert_cmpint (dbus_message_get_type (reply), ==, DBUS_MESSAGE_TYPE_ERROR);
  g_assert_cmpstr (dbus_message_get_error_name (reply), ==,
641
      DBUS_ERROR_ACCESS_DENIED);
642
  g_assert_cmpstr (dbus_message_get_signature (reply), ==, "s");
643

644
  dbus_clear_message (&reply);
645
  dbus_clear_message (&m);
646 647
}

648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
static void
test_max_connections (Fixture *f,
    gconstpointer context)
{
  DBusError error = DBUS_ERROR_INIT;
  DBusConnection *third_conn;
  DBusConnection *failing_conn;

  if (f->skip)
    return;

  /* We have two connections already */
  g_assert (f->left_conn != NULL);
  g_assert (f->right_conn != NULL);

  /* Our configuration file sets the limit to 3 connections, either globally
   * or per uid, so this one is the last that will work */
  third_conn = test_connect_to_bus (f->ctx, f->address);

  /* This one is going to fail. We don't guarantee whether it will fail
   * now, or while registering (implementation detail: it's the latter). */
  failing_conn = dbus_connection_open_private (f->address, &error);

  if (failing_conn != NULL)
    {
      gboolean ok = dbus_bus_register (failing_conn, &error);

      g_assert (!ok);
    }

  g_assert (dbus_error_is_set (&error));
  g_assert_cmpstr (error.name, ==, DBUS_ERROR_LIMITS_EXCEEDED);

  if (failing_conn != NULL)
682
    dbus_connection_close (failing_conn);
683

684
  dbus_clear_connection (&failing_conn);
685
  dbus_connection_close (third_conn);
686
  dbus_clear_connection (&third_conn);
687 688
}

689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
static void
test_max_replies_per_connection (Fixture *f,
    gconstpointer context)
{
  GQueue received = G_QUEUE_INIT;
  GQueue errors = G_QUEUE_INIT;
  DBusMessage *m;
  DBusPendingCall *pc;
  guint i;
  DBusError error = DBUS_ERROR_INIT;

  if (f->skip)
    return;

  add_hold_filter (f);

  /* The configured limit is 3 replies per connection. */
  for (i = 0; i < 3; i++)
    {
      m = dbus_message_new_method_call (
          dbus_bus_get_unique_name (f->right_conn), "/",
          "com.example", "Spam");

      if (m == NULL)
        g_error ("OOM");

      if (!dbus_connection_send_with_reply (f->left_conn, m, &pc,
                                            DBUS_TIMEOUT_INFINITE) ||
          pc == NULL)
        g_error ("OOM");

      if (dbus_pending_call_get_completed (pc))
        pc_enqueue (pc, &received);
      else if (!dbus_pending_call_set_notify (pc, pc_enqueue, &received,
            NULL))
        g_error ("OOM");

      dbus_pending_call_unref (pc);
      dbus_message_unref (m);
    }

  while (g_queue_get_length (&f->held_messages) < 3)
    test_main_context_iterate (f->ctx, TRUE);

  g_assert_cmpuint (g_queue_get_length (&received), ==, 0);
  g_assert_cmpuint (g_queue_get_length (&errors), ==, 0);

  /* Go a couple of messages over the limit. */
  for (i = 0; i < 2; i++)
    {
      m = dbus_message_new_method_call (
          dbus_bus_get_unique_name (f->right_conn), "/",
          "com.example", "Spam");

      if (m == NULL)
        g_error ("OOM");

      if (!dbus_connection_send_with_reply (f->left_conn, m, &pc,
                                            DBUS_TIMEOUT_INFINITE) ||
          pc == NULL)
        g_error ("OOM");

      if (dbus_pending_call_get_completed (pc))
        pc_enqueue (pc, &errors);
      else if (!dbus_pending_call_set_notify (pc, pc_enqueue, &errors,
            NULL))
        g_error ("OOM");

      dbus_pending_call_unref (pc);
      dbus_message_unref (m);
    }

  /* Reply to the held messages. */
  for (m = g_queue_pop_head (&f->held_messages);
       m != NULL;
       m = g_queue_pop_head (&f->held_messages))
    {
      DBusMessage *reply = dbus_message_new_method_return (m);

      if (reply == NULL)
        g_error ("OOM");

      if (!dbus_connection_send (f->right_conn, reply, NULL))
        g_error ("OOM");

774 775
      dbus_clear_message (&m);
      dbus_clear_message (&reply);
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790
    }

  /* Wait for all 5 replies to come in. */
  while (g_queue_get_length (&received) + g_queue_get_length (&errors) < 5)
    test_main_context_iterate (f->ctx, TRUE);

  /* The first three succeeded. */
  for (i = 0; i < 3; i++)
    {
      m = g_queue_pop_head (&received);
      g_assert (m != NULL);

      if (dbus_set_error_from_message (&error, m))
        g_error ("Unexpected error: %s: %s", error.name, error.message);

791
      dbus_clear_message (&m);
792 793 794 795 796 797 798 799 800 801 802 803 804
    }

  /* The last two failed. */
  for (i = 0; i < 2; i++)
    {
      m = g_queue_pop_head (&errors);
      g_assert (m != NULL);

      if (!dbus_set_error_from_message (&error, m))
        g_error ("Unexpected success");

      g_assert_cmpstr (error.name, ==, DBUS_ERROR_LIMITS_EXCEEDED);
      dbus_error_free (&error);
805
      dbus_clear_message (&m);
806 807 808 809 810 811 812 813
    }

  g_assert_cmpuint (g_queue_get_length (&received), ==, 0);
  g_assert_cmpuint (g_queue_get_length (&errors), ==, 0);
  g_queue_clear (&received);
  g_queue_clear (&errors);
}

814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
static void
test_max_match_rules_per_connection (Fixture *f,
    gconstpointer context)
{
  DBusError error = DBUS_ERROR_INIT;

  if (f->skip)
    return;

  dbus_bus_add_match (f->left_conn, "sender='com.example.C1'", &error);
  test_assert_no_error (&error);
  dbus_bus_add_match (f->left_conn, "sender='com.example.C2'", &error);
  test_assert_no_error (&error);
  dbus_bus_add_match (f->left_conn, "sender='com.example.C3'", &error);
  test_assert_no_error (&error);

  dbus_bus_add_match (f->left_conn, "sender='com.example.C4'", &error);
  g_assert_cmpstr (error.name, ==, DBUS_ERROR_LIMITS_EXCEEDED);
  dbus_error_free (&error);

  dbus_bus_remove_match (f->left_conn, "sender='com.example.C3'", &error);
  test_assert_no_error (&error);

  dbus_bus_add_match (f->left_conn, "sender='com.example.C4'", &error);
  test_assert_no_error (&error);
}

841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879
static void
test_max_names_per_connection (Fixture *f,
    gconstpointer context)
{
  DBusError error = DBUS_ERROR_INIT;
  int ret;

  if (f->skip)
    return;

  /* The limit in the configuration file is set to 4, but we only own 3
   * names here - remember that the unique name is a name too. */

  ret = dbus_bus_request_name (f->left_conn, "com.example.C1", 0, &error);
  test_assert_no_error (&error);
  g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);

  ret = dbus_bus_request_name (f->left_conn, "com.example.C2", 0, &error);
  test_assert_no_error (&error);
  g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);

  ret = dbus_bus_request_name (f->left_conn, "com.example.C3", 0, &error);
  test_assert_no_error (&error);
  g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);

  ret = dbus_bus_request_name (f->left_conn, "com.example.C4", 0, &error);
  g_assert_cmpstr (error.name, ==, DBUS_ERROR_LIMITS_EXCEEDED);
  dbus_error_free (&error);
  g_assert_cmpint (ret, ==, -1);

  ret = dbus_bus_release_name (f->left_conn, "com.example.C3", &error);
  test_assert_no_error (&error);
  g_assert_cmpint (ret, ==, DBUS_RELEASE_NAME_REPLY_RELEASED);

  ret = dbus_bus_request_name (f->left_conn, "com.example.C4", 0, &error);
  test_assert_no_error (&error);
  g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
}

880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911
#if defined(DBUS_UNIX) && defined(HAVE_UNIX_FD_PASSING) && defined(HAVE_GIO_UNIX)

static DBusHandlerResult
wait_for_disconnected_cb (DBusConnection *client_conn,
    DBusMessage *message,
    void *data)
{
  gboolean *disconnected = data;

  if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected"))
    {
      *disconnected = TRUE;
      return DBUS_HANDLER_RESULT_HANDLED;
    }

  return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}

static const guchar partial_message[] =
{
  DBUS_LITTLE_ENDIAN,
  DBUS_MESSAGE_TYPE_METHOD_CALL,
  0, /* flags */
  1, /* version */
  0xff, 0xff, 0, 0, /* length of body = 65535 bytes */
  1, 2, 3, 4, /* cookie */
  0xff, 0xff, 0, 0, /* length of header fields array = 65535 bytes */
  42 /* pretending to be the beginning of the header fields array */
};

static void
send_all_with_fd (GSocket *socket,
912
                  const guchar *local_partial_message,
913 914 915 916 917 918
                  gsize len,
                  int fd)
{
  GSocketControlMessage *fdm = g_unix_fd_message_new ();
  GError *error = NULL;
  gssize sent;
919
  GOutputVector vector = { local_partial_message, len };
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957

  g_unix_fd_message_append_fd (G_UNIX_FD_MESSAGE (fdm), fd, &error);
  g_assert_no_error (error);

  sent = g_socket_send_message (socket, NULL, &vector, 1, &fdm, 1,
      G_SOCKET_MSG_NONE, NULL, &error);
  g_assert_no_error (error);
  g_assert_cmpint (sent, >=, 1);
  g_assert_cmpint (sent, <=, vector.size);

  while (((gsize) sent) < vector.size)
    {
      vector.size -= sent;
      vector.buffer = ((const guchar *) vector.buffer) + sent;
      sent = g_socket_send_message (socket, NULL, &vector, 1, NULL, 0,
          G_SOCKET_MSG_NONE, NULL, &error);
      g_assert_no_error (error);
      g_assert_cmpint (sent, >=, 1);
      g_assert_cmpint (sent, <=, vector.size);
    }

  g_object_unref (fdm);
}

static void
test_pending_fd_timeout (Fixture *f,
    gconstpointer context)
{
  GError *error = NULL;
  gint64 start;
  int fd;
  GSocket *socket;
  gboolean have_mem;
  gboolean disconnected = FALSE;

  if (f->skip)
    return;

958 959 960 961 962 963
  if (getuid () == 0)
    {
      g_test_skip ("Cannot test, uid 0 is immune to this limit");
      return;
    }

964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994
  have_mem = dbus_connection_add_filter (f->left_conn, wait_for_disconnected_cb,
      &disconnected, NULL);
  g_assert (have_mem);

  /* This is not API. Never do this. */

  if (!dbus_connection_get_socket (f->left_conn, &fd))
    g_error ("failed to steal fd from left connection");

  socket = g_socket_new_from_fd (fd, &error);
  g_assert_no_error (error);
  g_assert (socket != NULL);

  /* We send part of a message that contains a fd, then stop. */
  start = g_get_monotonic_time ();
  send_all_with_fd (socket, partial_message, G_N_ELEMENTS (partial_message),
                    fd);

  while (!disconnected)
    {
      test_progress ('.');
      test_main_context_iterate (f->ctx, TRUE);

      /* It should take no longer than 500ms to get disconnected. We'll
       * be generous and allow 1000ms. */
      g_assert_cmpint (g_get_monotonic_time (), <=, start + G_USEC_PER_SEC);
    }

  g_object_unref (socket);
}

995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
typedef struct
{
  const gchar *path;
  guint n_fds;
  gboolean should_work;
} CountFdsVector;

static const CountFdsVector count_fds_vectors[] =
{
  /* Deny sending if number of fds <= 2 */
  { "/test/DenySendMax2", 1, FALSE },
  { "/test/DenySendMax2", 2, FALSE },
  { "/test/DenySendMax2", 3, TRUE },
  { "/test/DenySendMax2", 4, TRUE },

  /* Deny receiving if number of fds <= 3 */
  { "/test/DenyReceiveMax3", 2, FALSE },
  { "/test/DenyReceiveMax3", 3, FALSE },
  { "/test/DenyReceiveMax3", 4, TRUE },
  { "/test/DenyReceiveMax3", 5, TRUE },

  /* Deny sending if number of fds >= 4 */
  { "/test/DenySendMin4", 2, TRUE },
  { "/test/DenySendMin4", 3, TRUE },
  { "/test/DenySendMin4", 4, FALSE },
  { "/test/DenySendMin4", 5, FALSE },

  /* Deny receiving if number of fds >= 5 */
  { "/test/DenyReceiveMin5", 3, TRUE },
  { "/test/DenyReceiveMin5", 4, TRUE },
  { "/test/DenyReceiveMin5", 5, FALSE },
  { "/test/DenyReceiveMin5", 6, FALSE },
};

static void
test_count_fds (Fixture *f,
    gconstpointer context)
{
  GQueue received = G_QUEUE_INIT;
  DBusMessage *m;
  DBusPendingCall *pc;
  guint i;
  DBusError error = DBUS_ERROR_INIT;
  const int stdin_fd = 0;

  if (f->skip)
    return;

  add_hold_filter (f);

  for (i = 0; i < G_N_ELEMENTS (count_fds_vectors); i++)
    {
      const CountFdsVector *vector = &count_fds_vectors[i];
      guint j;

      m = dbus_message_new_method_call (
          dbus_bus_get_unique_name (f->right_conn), vector->path,
          "com.example", "Spam");

      if (m == NULL)
        g_error ("OOM");

      for (j = 0; j < vector->n_fds; j++)
        {
          if (!dbus_message_append_args (m,
                                         DBUS_TYPE_UNIX_FD, &stdin_fd,
                                         DBUS_TYPE_INVALID))
            g_error ("OOM");
        }

      if (!dbus_connection_send_with_reply (f->left_conn, m, &pc,
                                            DBUS_TIMEOUT_INFINITE) ||
          pc == NULL)
        g_error ("OOM");

      if (dbus_pending_call_get_completed (pc))
        pc_enqueue (pc, &received);
      else if (!dbus_pending_call_set_notify (pc, pc_enqueue, &received,
            NULL))
        g_error ("OOM");

      dbus_pending_call_unref (pc);
      dbus_message_unref (m);

      if (vector->should_work)
        {
          DBusMessage *reply;

          while (g_queue_get_length (&f->held_messages) < 1)
            test_main_context_iterate (f->ctx, TRUE);

          g_assert_cmpint (g_queue_get_length (&f->held_messages), ==, 1);

          m = g_queue_pop_head (&f->held_messages);

          g_assert_cmpint (g_queue_get_length (&f->held_messages), ==, 0);

          reply = dbus_message_new_method_return (m);

          if (reply == NULL)
            g_error ("OOM");

          if (!dbus_connection_send (f->right_conn, reply, NULL))
            g_error ("OOM");

          dbus_message_unref (reply);
          dbus_message_unref (m);
        }

      while (g_queue_get_length (&received) < 1)
        test_main_context_iterate (f->ctx, TRUE);

      g_assert_cmpint (g_queue_get_length (&received), ==, 1);
      m = g_queue_pop_head (&received);
      g_assert (m != NULL);
      g_assert_cmpint (g_queue_get_length (&received), ==, 0);

      if (vector->should_work)
        {
          if (dbus_set_error_from_message (&error, m))
            g_error ("Unexpected error: %s: %s", error.name, error.message);

          g_test_message ("Sending %u fds to %s was not denied, as expected",
                          vector->n_fds, vector->path);
        }
      else if (!dbus_set_error_from_message (&error, m))
        {
          g_error ("Unexpected success");
        }
      else
        {
          g_assert_cmpstr (error.name, ==, DBUS_ERROR_ACCESS_DENIED);
          dbus_error_free (&error);
          g_test_message ("Sending %u fds to %s was denied, as expected",
                          vector->n_fds, vector->path);
        }

      dbus_message_unref (m);
    }
}

1136 1137
#endif

1138 1139 1140 1141
static void
test_peer_get_machine_id (Fixture *f,
                          gconstpointer context)
{
1142
  char *what_i_think;
1143 1144
  const char *what_daemon_thinks;
  DBusMessage *m = NULL;
1145
  DBusMessage *reply = NULL;
1146 1147 1148 1149 1150
  DBusError error = DBUS_ERROR_INIT;

  if (f->skip)
    return;

1151 1152 1153
  what_i_think = dbus_try_get_local_machine_id (&error);

  if (what_i_think == NULL)
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164
    {
      if (g_getenv ("DBUS_TEST_UNINSTALLED") != NULL)
        {
          /* When running unit tests during make check or make installcheck,
           * tolerate this */
          g_test_skip ("Machine UUID not available");
          return;
        }
      else
        {
          /* When running integration tests, don't tolerate it */
1165
          g_error ("%s", error.message);
1166 1167 1168 1169 1170 1171 1172 1173 1174
        }
    }

  /* Check that the dbus-daemon agrees with us. */
  m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
                                    DBUS_PATH_DBUS,
                                    DBUS_INTERFACE_PEER,
                                    "GetMachineId");

1175 1176
  if (m == NULL)
    test_oom ();
1177

1178 1179
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
1180

1181
  if (!dbus_message_get_args (reply, &error,
1182 1183 1184 1185
        DBUS_TYPE_STRING, &what_daemon_thinks,
        DBUS_TYPE_INVALID))
    g_error ("%s: %s", error.name, error.message);

1186
  g_assert_cmpstr (what_i_think, ==, what_daemon_thinks);
1187 1188 1189
  g_assert_nonnull (what_daemon_thinks);
  g_assert_cmpuint (strlen (what_daemon_thinks), ==, 32);

1190
  dbus_clear_message (&reply);
1191
  dbus_clear_message (&m);
1192
  dbus_free (what_i_think);
1193 1194 1195 1196 1197 1198
}

static void
test_peer_ping (Fixture *f,
                gconstpointer context)
{
1199
  DBusMessage *m = NULL;
1200
  DBusMessage *reply = NULL;
1201 1202 1203 1204 1205 1206 1207 1208
  DBusError error = DBUS_ERROR_INIT;

  if (f->skip)
    return;

  m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
      DBUS_PATH_DBUS, DBUS_INTERFACE_PEER, "Ping");

1209 1210
  if (m == NULL)
    test_oom ();
1211

1212 1213
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
1214

1215
  if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INVALID))
1216 1217
    g_error ("%s: %s", error.name, error.message);

1218
  dbus_clear_message (&reply);
1219
  dbus_clear_message (&m);
1220 1221
}

1222 1223 1224 1225
static void
test_get_invalid_path (Fixture *f,
                       gconstpointer context)
{
1226
  DBusMessage *m = NULL;
1227
  DBusMessage *reply = NULL;
1228 1229 1230 1231 1232 1233 1234
  DBusError error = DBUS_ERROR_INIT;
  const char *iface = DBUS_INTERFACE_DBUS;
  const char *property = "Interfaces";

  if (f->skip)
    return;

1235 1236 1237
  m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, "/",
      DBUS_INTERFACE_PROPERTIES, "Get");

1238 1239 1240 1241
  if (m == NULL ||
      !dbus_message_append_args (m,
        DBUS_TYPE_STRING, &iface,
        DBUS_TYPE_STRING, &property,
1242 1243
        DBUS_TYPE_INVALID))
    test_oom ();
1244

1245 1246
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
1247

1248
  if (!dbus_set_error_from_message (&error, reply))
1249 1250 1251 1252 1253 1254
    g_error ("Unexpected success");

  /* That object path does not have that interface */
  g_assert_cmpstr (error.name, ==, DBUS_ERROR_UNKNOWN_INTERFACE);
  dbus_error_free (&error);

1255
  dbus_clear_message (&reply);
1256
  dbus_clear_message (&m);
1257 1258 1259 1260 1261 1262
}

static void
test_get_invalid_iface (Fixture *f,
                        gconstpointer context)
{
1263
  DBusMessage *m = NULL;
1264
  DBusMessage *reply = NULL;
1265 1266 1267 1268 1269 1270 1271
  DBusError error = DBUS_ERROR_INIT;
  const char *iface = "com.example.Nope";
  const char *property = "Whatever";

  if (f->skip)
    return;

1272 1273 1274
  m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
      DBUS_PATH_DBUS, DBUS_INTERFACE_PROPERTIES, "Get");

1275 1276 1277 1278
  if (m == NULL ||
      !dbus_message_append_args (m,
        DBUS_TYPE_STRING, &iface,
        DBUS_TYPE_STRING, &property,
1279 1280
        DBUS_TYPE_INVALID))
    test_oom ();
1281

1282 1283
  reply = test_main_context_call_and_wait (f->ctx, f->left_conn, m,
      DBUS_TIMEOUT_USE_DEFAULT);
1284

1285
  if (!dbus_set_error_from_message (&error, reply))
1286 1287 1288 1289 1290
    g_error ("Unexpected success");

  g_assert_cmpstr (error.name, ==, DBUS_ERROR_UNKNOWN_INTERFACE);
  dbus_error_free (&error);

1291
  dbus_clear_message (&reply);
1292
  dbus_clear_message (&m);
1293 1294 1295