Coverage report for bus/bus.c.gcov
-: 0:Source:bus.c
-: 0:Graph:bus.gcno
-: 0:Data:bus.gcda
-: 0:Runs:10122
-: 0:Programs:2
-: 1:/* -*- mode: C; c-file-style: "gnu" -*- */
-: 2:/* bus.c message bus context object
-: 3: *
-: 4: * Copyright (C) 2003, 2004 Red Hat, Inc.
-: 5: *
-: 6: * Licensed under the Academic Free License version 2.1
-: 7: *
-: 8: * This program is free software; you can redistribute it and/or modify
-: 9: * it under the terms of the GNU General Public License as published by
-: 10: * the Free Software Foundation; either version 2 of the License, or
-: 11: * (at your option) any later version.
-: 12: *
-: 13: * This program is distributed in the hope that it will be useful,
-: 14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
-: 15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-: 16: * GNU General Public License for more details.
-: 17: *
-: 18: * You should have received a copy of the GNU General Public License
-: 19: * along with this program; if not, write to the Free Software
-: 20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-: 21: *
-: 22: */
-: 23:
-: 24:#include "bus.h"
-: 25:#include "activation.h"
-: 26:#include "connection.h"
-: 27:#include "services.h"
-: 28:#include "utils.h"
-: 29:#include "policy.h"
-: 30:#include "config-parser.h"
-: 31:#include "signals.h"
-: 32:#include "selinux.h"
-: 33:#include "dir-watch.h"
-: 34:#include <dbus/dbus-list.h>
-: 35:#include <dbus/dbus-hash.h>
-: 36:#include <dbus/dbus-internals.h>
-: 37:
-: 38:struct BusContext
-: 39:{
-: 40: int refcount;
-: 41: char *config_file;
-: 42: char *type;
-: 43: char *address;
-: 44: char *pidfile;
-: 45: char *user;
-: 46: DBusLoop *loop;
-: 47: DBusList *servers;
-: 48: BusConnections *connections;
-: 49: BusActivation *activation;
-: 50: BusRegistry *registry;
-: 51: BusPolicy *policy;
-: 52: BusMatchmaker *matchmaker;
-: 53: DBusUserDatabase *user_database;
-: 54: BusLimits limits;
-: 55: unsigned int fork : 1;
-: 56:};
-: 57:
-: 58:static dbus_int32_t server_data_slot = -1;
-: 59:
-: 60:typedef struct
-: 61:{
-: 62: BusContext *context;
-: 63:} BusServerData;
-: 64:
-: 65:#define BUS_SERVER_DATA(server) (dbus_server_get_data ((server), server_data_slot))
-: 66:
-: 67:static BusContext*
-: 68:server_get_context (DBusServer *server)
function server_get_context called 6 returned 100% blocks executed 70%
6: 69:{
-: 70: BusContext *context;
-: 71: BusServerData *bd;
-: 72:
6: 73: if (!dbus_server_allocate_data_slot (&server_data_slot))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 74: return NULL;
-: 75:
6: 76: bd = BUS_SERVER_DATA (server);
call 0 returned 100%
6: 77: if (bd == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 78: {
#####: 79: dbus_server_free_data_slot (&server_data_slot);
call 0 never executed
#####: 80: return NULL;
-: 81: }
-: 82:
6: 83: context = bd->context;
-: 84:
6: 85: dbus_server_free_data_slot (&server_data_slot);
call 0 returned 100%
-: 86:
6: 87: return context;
-: 88:}
-: 89:
-: 90:static dbus_bool_t
-: 91:server_watch_callback (DBusWatch *watch,
-: 92: unsigned int condition,
-: 93: void *data)
function server_watch_callback called 2467 returned 100% blocks executed 100%
2467: 94:{
-: 95: /* FIXME this can be done in dbus-mainloop.c
-: 96: * if the code in activation.c for the babysitter
-: 97: * watch handler is fixed.
-: 98: */
-: 99:
2467: 100: return dbus_watch_handle (watch, condition);
call 0 returned 100%
-: 101:}
-: 102:
-: 103:static dbus_bool_t
-: 104:add_server_watch (DBusWatch *watch,
-: 105: void *data)
function add_server_watch called 3 returned 100% blocks executed 100%
3: 106:{
3: 107: DBusServer *server = data;
-: 108: BusContext *context;
-: 109:
3: 110: context = server_get_context (server);
call 0 returned 100%
-: 111:
3: 112: return _dbus_loop_add_watch (context->loop,
call 0 returned 100%
-: 113: watch, server_watch_callback, server,
-: 114: NULL);
-: 115:}
-: 116:
-: 117:static void
-: 118:remove_server_watch (DBusWatch *watch,
-: 119: void *data)
function remove_server_watch called 3 returned 100% blocks executed 100%
3: 120:{
3: 121: DBusServer *server = data;
-: 122: BusContext *context;
-: 123:
3: 124: context = server_get_context (server);
call 0 returned 100%
-: 125:
3: 126: _dbus_loop_remove_watch (context->loop,
call 0 returned 100%
-: 127: watch, server_watch_callback, server);
3: 128:}
-: 129:
-: 130:
-: 131:static void
-: 132:server_timeout_callback (DBusTimeout *timeout,
-: 133: void *data)
function server_timeout_callback called 0 returned 0% blocks executed 0%
#####: 134:{
-: 135: /* can return FALSE on OOM but we just let it fire again later */
#####: 136: dbus_timeout_handle (timeout);
call 0 never executed
#####: 137:}
-: 138:
-: 139:static dbus_bool_t
-: 140:add_server_timeout (DBusTimeout *timeout,
-: 141: void *data)
function add_server_timeout called 0 returned 0% blocks executed 0%
#####: 142:{
#####: 143: DBusServer *server = data;
-: 144: BusContext *context;
-: 145:
#####: 146: context = server_get_context (server);
call 0 never executed
-: 147:
#####: 148: return _dbus_loop_add_timeout (context->loop,
call 0 never executed
-: 149: timeout, server_timeout_callback, server, NULL);
-: 150:}
-: 151:
-: 152:static void
-: 153:remove_server_timeout (DBusTimeout *timeout,
-: 154: void *data)
function remove_server_timeout called 0 returned 0% blocks executed 0%
#####: 155:{
#####: 156: DBusServer *server = data;
-: 157: BusContext *context;
-: 158:
#####: 159: context = server_get_context (server);
call 0 never executed
-: 160:
#####: 161: _dbus_loop_remove_timeout (context->loop,
call 0 never executed
-: 162: timeout, server_timeout_callback, server);
#####: 163:}
-: 164:
-: 165:static void
-: 166:new_connection_callback (DBusServer *server,
-: 167: DBusConnection *new_connection,
-: 168: void *data)
function new_connection_callback called 7902 returned 100% blocks executed 100%
7902: 169:{
7902: 170: BusContext *context = data;
-: 171:
7902: 172: if (!bus_connections_setup_connection (context->connections, new_connection))
call 0 returned 100%
branch 1 taken 1% (fallthrough)
branch 2 taken 99%
-: 173: {
91: 174: _dbus_verbose ("No memory to setup new connection\n");
call 0 returned 100%
-: 175:
-: 176: /* if we don't do this, it will get unref'd without
-: 177: * being disconnected... kind of strange really
-: 178: * that we have to do this, people won't get it right
-: 179: * in general.
-: 180: */
91: 181: dbus_connection_close (new_connection);
call 0 returned 100%
-: 182: }
-: 183:
7902: 184: dbus_connection_set_max_received_size (new_connection,
call 0 returned 100%
-: 185: context->limits.max_incoming_bytes);
-: 186:
7902: 187: dbus_connection_set_max_message_size (new_connection,
call 0 returned 100%
-: 188: context->limits.max_message_size);
-: 189:
-: 190: /* on OOM, we won't have ref'd the connection so it will die. */
7902: 191:}
-: 192:
-: 193:static void
-: 194:free_server_data (void *data)
function free_server_data called 5 returned 100% blocks executed 100%
5: 195:{
5: 196: BusServerData *bd = data;
-: 197:
5: 198: dbus_free (bd);
call 0 returned 100%
5: 199:}
-: 200:
-: 201:static dbus_bool_t
-: 202:setup_server (BusContext *context,
-: 203: DBusServer *server,
-: 204: char **auth_mechanisms,
-: 205: DBusError *error)
function setup_server called 5 returned 100% blocks executed 57%
5: 206:{
-: 207: BusServerData *bd;
-: 208:
5: 209: bd = dbus_new0 (BusServerData, 1);
call 0 returned 100%
5: 210: if (!dbus_server_set_data (server,
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 211: server_data_slot,
-: 212: bd, free_server_data))
-: 213: {
#####: 214: dbus_free (bd);
call 0 never executed
#####: 215: BUS_SET_OOM (error);
call 0 never executed
#####: 216: return FALSE;
-: 217: }
-: 218:
5: 219: bd->context = context;
-: 220:
5: 221: if (!dbus_server_set_auth_mechanisms (server, (const char**) auth_mechanisms))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 222: {
#####: 223: BUS_SET_OOM (error);
call 0 never executed
#####: 224: return FALSE;
-: 225: }
-: 226:
5: 227: dbus_server_set_new_connection_function (server,
call 0 returned 100%
-: 228: new_connection_callback,
-: 229: context, NULL);
-: 230:
5: 231: if (!dbus_server_set_watch_functions (server,
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 232: add_server_watch,
-: 233: remove_server_watch,
-: 234: NULL,
-: 235: server,
-: 236: NULL))
-: 237: {
#####: 238: BUS_SET_OOM (error);
call 0 never executed
#####: 239: return FALSE;
-: 240: }
-: 241:
5: 242: if (!dbus_server_set_timeout_functions (server,
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 243: add_server_timeout,
-: 244: remove_server_timeout,
-: 245: NULL,
-: 246: server, NULL))
-: 247: {
#####: 248: BUS_SET_OOM (error);
call 0 never executed
#####: 249: return FALSE;
-: 250: }
-: 251:
5: 252: return TRUE;
-: 253:}
-: 254:
-: 255:/* This code only gets executed the first time the
-: 256: config files are parsed. It is not executed
-: 257: when config files are reloaded.*/
-: 258:static dbus_bool_t
-: 259:process_config_first_time_only (BusContext *context,
-: 260: BusConfigParser *parser,
-: 261: DBusError *error)
function process_config_first_time_only called 3 returned 100% blocks executed 61%
3: 262:{
-: 263: DBusList *link;
-: 264: DBusList **addresses;
-: 265: const char *user, *pidfile;
-: 266: char **auth_mechanisms;
-: 267: DBusList **auth_mechanisms_list;
-: 268: int len;
-: 269: dbus_bool_t retval;
-: 270:
3: 271: _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 100% (fallthrough)
branch 4 taken 0%
call 5 returned 100%
-: 272:
3: 273: retval = FALSE;
3: 274: auth_mechanisms = NULL;
-: 275:
-: 276: /* Check for an existing pid file. Of course this is a race;
-: 277: * we'd have to use fcntl() locks on the pid file to
-: 278: * avoid that. But we want to check for the pid file
-: 279: * before overwriting any existing sockets, etc.
-: 280: */
3: 281: pidfile = bus_config_parser_get_pidfile (parser);
call 0 returned 100%
3: 282: if (pidfile != NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 283: {
-: 284: DBusString u;
-: 285: DBusStat stbuf;
-: 286:
#####: 287: _dbus_string_init_const (&u, pidfile);
call 0 never executed
-: 288:
#####: 289: if (_dbus_stat (&u, &stbuf, NULL))
call 0 never executed
branch 1 never executed
branch 2 never executed
-: 290: {
#####: 291: dbus_set_error (error, DBUS_ERROR_FAILED,
call 0 never executed
-: 292: "The pid file \"%s\" exists, if the message bus is not running, remove this file",
-: 293: pidfile);
#####: 294: goto failed;
-: 295: }
-: 296: }
-: 297:
-: 298: /* keep around the pid filename so we can delete it later */
3: 299: context->pidfile = _dbus_strdup (pidfile);
call 0 returned 100%
-: 300:
-: 301: /* Build an array of auth mechanisms */
-: 302:
3: 303: auth_mechanisms_list = bus_config_parser_get_mechanisms (parser);
call 0 returned 100%
3: 304: len = _dbus_list_get_length (auth_mechanisms_list);
call 0 returned 100%
-: 305:
3: 306: if (len > 0)
branch 0 taken 33% (fallthrough)
branch 1 taken 67%
-: 307: {
-: 308: int i;
-: 309:
1: 310: auth_mechanisms = dbus_new0 (char*, len + 1);
call 0 returned 100%
1: 311: if (auth_mechanisms == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 312: {
#####: 313: BUS_SET_OOM (error);
call 0 never executed
#####: 314: goto failed;
-: 315: }
-: 316:
1: 317: i = 0;
1: 318: link = _dbus_list_get_first_link (auth_mechanisms_list);
call 0 returned 100%
3: 319: while (link != NULL)
branch 0 taken 50%
branch 1 taken 50% (fallthrough)
-: 320: {
1: 321: auth_mechanisms[i] = _dbus_strdup (link->data);
call 0 returned 100%
1: 322: if (auth_mechanisms[i] == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 323: {
#####: 324: BUS_SET_OOM (error);
call 0 never executed
#####: 325: goto failed;
-: 326: }
1: 327: link = _dbus_list_get_next_link (auth_mechanisms_list, link);
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 328: }
-: 329: }
-: 330: else
-: 331: {
2: 332: auth_mechanisms = NULL;
-: 333: }
-: 334:
-: 335: /* Listen on our addresses */
-: 336:
3: 337: addresses = bus_config_parser_get_addresses (parser);
call 0 returned 100%
-: 338:
3: 339: link = _dbus_list_get_first_link (addresses);
call 0 returned 100%
11: 340: while (link != NULL)
branch 0 taken 63%
branch 1 taken 38% (fallthrough)
-: 341: {
-: 342: DBusServer *server;
-: 343:
5: 344: server = dbus_server_listen (link->data, error);
call 0 returned 100%
5: 345: if (server == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 346: {
#####: 347: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 348: goto failed;
-: 349: }
5: 350: else if (!setup_server (context, server, auth_mechanisms, error))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 351: {
#####: 352: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 353: goto failed;
-: 354: }
-: 355:
5: 356: if (!_dbus_list_append (&context->servers, server))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 357: {
#####: 358: BUS_SET_OOM (error);
call 0 never executed
#####: 359: goto failed;
-: 360: }
-: 361:
5: 362: link = _dbus_list_get_next_link (addresses, link);
branch 0 taken 40% (fallthrough)
branch 1 taken 60%
-: 363: }
-: 364:
-: 365: /* note that type may be NULL */
3: 366: context->type = _dbus_strdup (bus_config_parser_get_type (parser));
call 0 returned 100%
call 1 returned 100%
3: 367: if (bus_config_parser_get_type (parser) != NULL && context->type == NULL)
call 0 returned 100%
branch 1 taken 33% (fallthrough)
branch 2 taken 67%
branch 3 taken 0% (fallthrough)
branch 4 taken 100%
-: 368: {
#####: 369: BUS_SET_OOM (error);
call 0 never executed
#####: 370: goto failed;
-: 371: }
-: 372:
3: 373: user = bus_config_parser_get_user (parser);
call 0 returned 100%
3: 374: if (user != NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 375: {
#####: 376: context->user = _dbus_strdup (user);
call 0 never executed
#####: 377: if (context->user == NULL)
branch 0 never executed
branch 1 never executed
-: 378: {
#####: 379: BUS_SET_OOM (error);
call 0 never executed
#####: 380: goto failed;
-: 381: }
-: 382: }
-: 383:
3: 384: context->fork = bus_config_parser_get_fork (parser);
call 0 returned 100%
-: 385:
3: 386: _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 100% (fallthrough)
branch 4 taken 0%
call 5 returned 100%
3: 387: retval = TRUE;
-: 388:
3: 389: failed:
3: 390: dbus_free_string_array (auth_mechanisms);
call 0 returned 100%
3: 391: return retval;
-: 392:}
-: 393:
-: 394:/* This code gets executed every time the config files
-: 395: are parsed: both during BusContext construction
-: 396: and on reloads. */
-: 397:static dbus_bool_t
-: 398:process_config_every_time (BusContext *context,
-: 399: BusConfigParser *parser,
-: 400: dbus_bool_t is_reload,
-: 401: DBusError *error)
function process_config_every_time called 3 returned 100% blocks executed 66%
3: 402:{
-: 403: DBusString full_address;
-: 404: DBusList *link;
-: 405:
-: 406: dbus_bool_t retval;
-: 407:
3: 408: _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 100% (fallthrough)
branch 4 taken 0%
call 5 returned 100%
-: 409:
3: 410: retval = FALSE;
-: 411:
3: 412: if (!_dbus_string_init (&full_address))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 413: {
#####: 414: BUS_SET_OOM (error);
call 0 never executed
#####: 415: return FALSE;
-: 416: }
-: 417:
-: 418: /* get our limits and timeout lengths */
3: 419: bus_config_parser_get_limits (parser, &context->limits);
call 0 returned 100%
-: 420:
3: 421: context->policy = bus_config_parser_steal_policy (parser);
call 0 returned 100%
3: 422: _dbus_assert (context->policy != NULL);
call 0 returned 100%
-: 423:
-: 424: /* We have to build the address backward, so that
-: 425: * <listen> later in the config file have priority
-: 426: */
3: 427: link = _dbus_list_get_last_link (&context->servers);
call 0 returned 100%
11: 428: while (link != NULL)
branch 0 taken 63%
branch 1 taken 38% (fallthrough)
-: 429: {
-: 430: char *addr;
-: 431:
5: 432: addr = dbus_server_get_address (link->data);
call 0 returned 100%
5: 433: if (addr == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 434: {
#####: 435: BUS_SET_OOM (error);
call 0 never executed
#####: 436: goto failed;
-: 437: }
-: 438:
5: 439: if (_dbus_string_get_length (&full_address) > 0)
call 0 returned 100%
branch 1 taken 40% (fallthrough)
branch 2 taken 60%
-: 440: {
2: 441: if (!_dbus_string_append (&full_address, ";"))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 442: {
#####: 443: BUS_SET_OOM (error);
call 0 never executed
#####: 444: goto failed;
-: 445: }
-: 446: }
-: 447:
5: 448: if (!_dbus_string_append (&full_address, addr))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 449: {
#####: 450: BUS_SET_OOM (error);
call 0 never executed
#####: 451: goto failed;
-: 452: }
-: 453:
5: 454: dbus_free (addr);
call 0 returned 100%
-: 455:
5: 456: link = _dbus_list_get_prev_link (&context->servers, link);
branch 0 taken 40% (fallthrough)
branch 1 taken 60%
-: 457: }
-: 458:
3: 459: if (is_reload)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 460: dbus_free (context->address);
call 0 never executed
-: 461:
3: 462: if (!_dbus_string_copy_data (&full_address, &context->address))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 463: {
#####: 464: BUS_SET_OOM (error);
call 0 never executed
#####: 465: goto failed;
-: 466: }
-: 467:
-: 468: /* Create activation subsystem */
-: 469:
3: 470: if (is_reload)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 471: bus_activation_unref (context->activation);
call 0 never executed
-: 472:
3: 473: context->activation = bus_activation_new (context, &full_address,
call 0 returned 100%
call 1 returned 100%
-: 474: bus_config_parser_get_service_dirs (parser),
-: 475: error);
3: 476: if (context->activation == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 477: {
#####: 478: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 479: goto failed;
-: 480: }
-: 481:
-: 482: /* Drop existing conf-dir watches (if applicable) */
-: 483:
3: 484: if (is_reload)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 485: bus_drop_all_directory_watches ();
call 0 never executed
-: 486:
3: 487: _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 100% (fallthrough)
branch 4 taken 0%
call 5 returned 100%
3: 488: retval = TRUE;
-: 489:
3: 490: failed:
3: 491: _dbus_string_free (&full_address);
call 0 returned 100%
3: 492: return retval;
-: 493:}
-: 494:
-: 495:static dbus_bool_t
-: 496:process_config_postinit (BusContext *context,
-: 497: BusConfigParser *parser,
-: 498: DBusError *error)
function process_config_postinit called 3 returned 100% blocks executed 80%
3: 499:{
-: 500: DBusHashTable *service_context_table;
-: 501:
3: 502: service_context_table = bus_config_parser_steal_service_context_table (parser);
call 0 returned 100%
3: 503: if (!bus_registry_set_service_context_table (context->registry,
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 504: service_context_table))
-: 505: {
#####: 506: BUS_SET_OOM (error);
call 0 never executed
#####: 507: return FALSE;
-: 508: }
-: 509:
3: 510: _dbus_hash_table_unref (service_context_table);
call 0 returned 100%
-: 511:
-: 512: /* Watch all conf directories */
3: 513: _dbus_list_foreach (bus_config_parser_get_conf_dirs (parser),
call 0 returned 100%
call 1 returned 100%
-: 514: (DBusForeachFunction) bus_watch_directory,
-: 515: NULL);
-: 516:
3: 517: return TRUE;
-: 518:}
-: 519:
-: 520:BusContext*
-: 521:bus_context_new (const DBusString *config_file,
-: 522: ForceForkSetting force_fork,
-: 523: int print_addr_fd,
-: 524: int print_pid_fd,
-: 525: DBusError *error)
function bus_context_new called 3 returned 100% blocks executed 42%
3: 526:{
-: 527: BusContext *context;
-: 528: BusConfigParser *parser;
-: 529:
3: 530: _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 100% (fallthrough)
branch 4 taken 0%
call 5 returned 100%
-: 531:
3: 532: context = NULL;
3: 533: parser = NULL;
-: 534:
3: 535: if (!dbus_server_allocate_data_slot (&server_data_slot))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 536: {
#####: 537: BUS_SET_OOM (error);
call 0 never executed
#####: 538: return NULL;
-: 539: }
-: 540:
3: 541: context = dbus_new0 (BusContext, 1);
call 0 returned 100%
3: 542: if (context == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 543: {
#####: 544: BUS_SET_OOM (error);
call 0 never executed
#####: 545: goto failed;
-: 546: }
3: 547: context->refcount = 1;
-: 548:
3: 549: if (!_dbus_string_copy_data (config_file, &context->config_file))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 550: {
#####: 551: BUS_SET_OOM (error);
call 0 never executed
#####: 552: goto failed;
-: 553: }
-: 554:
3: 555: context->loop = _dbus_loop_new ();
call 0 returned 100%
3: 556: if (context->loop == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 557: {
#####: 558: BUS_SET_OOM (error);
call 0 never executed
#####: 559: goto failed;
-: 560: }
-: 561:
3: 562: context->registry = bus_registry_new (context);
call 0 returned 100%
3: 563: if (context->registry == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 564: {
#####: 565: BUS_SET_OOM (error);
call 0 never executed
#####: 566: goto failed;
-: 567: }
-: 568:
3: 569: parser = bus_config_load (config_file, TRUE, NULL, error);
call 0 returned 100%
3: 570: if (parser == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 571: {
#####: 572: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 573: goto failed;
-: 574: }
-: 575:
3: 576: if (!process_config_first_time_only (context, parser, error))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 577: {
#####: 578: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 579: goto failed;
-: 580: }
3: 581: if (!process_config_every_time (context, parser, FALSE, error))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 582: {
#####: 583: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 584: goto failed;
-: 585: }
-: 586:
-: 587: /* we need another ref of the server data slot for the context
-: 588: * to own
-: 589: */
3: 590: if (!dbus_server_allocate_data_slot (&server_data_slot))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 591: _dbus_assert_not_reached ("second ref of server data slot failed");
call 0 never executed
-: 592:
3: 593: context->user_database = _dbus_user_database_new ();
call 0 returned 100%
3: 594: if (context->user_database == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 595: {
#####: 596: BUS_SET_OOM (error);
call 0 never executed
#####: 597: goto failed;
-: 598: }
-: 599:
-: 600: /* Note that we don't know whether the print_addr_fd is
-: 601: * one of the sockets we're using to listen on, or some
-: 602: * other random thing. But I think the answer is "don't do
-: 603: * that then"
-: 604: */
3: 605: if (print_addr_fd >= 0)
branch 0 taken 33% (fallthrough)
branch 1 taken 67%
-: 606: {
-: 607: DBusString addr;
1: 608: const char *a = bus_context_get_address (context);
call 0 returned 100%
-: 609: int bytes;
-: 610:
1: 611: _dbus_assert (a != NULL);
call 0 returned 100%
1: 612: if (!_dbus_string_init (&addr))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 613: {
#####: 614: BUS_SET_OOM (error);
call 0 never executed
#####: 615: goto failed;
-: 616: }
-: 617:
1: 618: if (!_dbus_string_append (&addr, a) ||
call 0 returned 100%
branch 1 taken 100% (fallthrough)
branch 2 taken 0%
call 3 returned 100%
branch 4 taken 0% (fallthrough)
branch 5 taken 100%
-: 619: !_dbus_string_append (&addr, "\n"))
-: 620: {
#####: 621: _dbus_string_free (&addr);
call 0 never executed
#####: 622: BUS_SET_OOM (error);
call 0 never executed
#####: 623: goto failed;
-: 624: }
-: 625:
1: 626: bytes = _dbus_string_get_length (&addr);
call 0 returned 100%
1: 627: if (_dbus_write (print_addr_fd, &addr, 0, bytes) != bytes)
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 628: {
#####: 629: dbus_set_error (error, DBUS_ERROR_FAILED,
call 0 never executed
call 1 never executed
call 2 never executed
-: 630: "Printing message bus address: %s\n",
-: 631: _dbus_strerror (errno));
#####: 632: _dbus_string_free (&addr);
call 0 never executed
#####: 633: goto failed;
-: 634: }
-: 635:
1: 636: if (print_addr_fd > 2)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
1: 637: _dbus_close (print_addr_fd, NULL);
call 0 returned 100%
-: 638:
1: 639: _dbus_string_free (&addr);
call 0 returned 100%
-: 640: }
-: 641:
3: 642: context->connections = bus_connections_new (context);
call 0 returned 100%
3: 643: if (context->connections == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 644: {
#####: 645: BUS_SET_OOM (error);
call 0 never executed
#####: 646: goto failed;
-: 647: }
-: 648:
3: 649: context->matchmaker = bus_matchmaker_new ();
call 0 returned 100%
3: 650: if (context->matchmaker == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 651: {
#####: 652: BUS_SET_OOM (error);
call 0 never executed
#####: 653: goto failed;
-: 654: }
-: 655:
-: 656: /* Now become a daemon if appropriate */
4: 657: if ((force_fork != FORK_NEVER && context->fork) || force_fork == FORK_ALWAYS)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
branch 4 taken 33% (fallthrough)
branch 5 taken 67%
-: 658: {
-: 659: DBusString u;
-: 660:
1: 661: if (context->pidfile)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 662: _dbus_string_init_const (&u, context->pidfile);
call 0 never executed
-: 663:
1: 664: if (!_dbus_become_daemon (context->pidfile ? &u : NULL,
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
call 2 returned 100%
branch 3 taken 0% (fallthrough)
branch 4 taken 100%
-: 665: print_pid_fd,
-: 666: error))
-: 667: {
#####: 668: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 669: goto failed;
-: 670: }
-: 671: }
-: 672: else
-: 673: {
-: 674: /* Need to write PID file for ourselves, not for the child process */
2: 675: if (context->pidfile != NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 676: {
-: 677: DBusString u;
-: 678:
#####: 679: _dbus_string_init_const (&u, context->pidfile);
call 0 never executed
-: 680:
#####: 681: if (!_dbus_write_pid_file (&u, _dbus_getpid (), error))
call 0 never executed
call 1 never executed
branch 2 never executed
branch 3 never executed
-: 682: {
#####: 683: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 684: goto failed;
-: 685: }
-: 686: }
-: 687: }
-: 688:
-: 689: /* Write PID if requested */
3: 690: if (print_pid_fd >= 0)
branch 0 taken 33% (fallthrough)
branch 1 taken 67%
-: 691: {
-: 692: DBusString pid;
-: 693: int bytes;
-: 694:
1: 695: if (!_dbus_string_init (&pid))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 696: {
#####: 697: BUS_SET_OOM (error);
call 0 never executed
#####: 698: goto failed;
-: 699: }
-: 700:
1: 701: if (!_dbus_string_append_int (&pid, _dbus_getpid ()) ||
call 0 returned 100%
call 1 returned 100%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
call 4 returned 100%
branch 5 taken 0% (fallthrough)
branch 6 taken 100%
-: 702: !_dbus_string_append (&pid, "\n"))
-: 703: {
#####: 704: _dbus_string_free (&pid);
call 0 never executed
#####: 705: BUS_SET_OOM (error);
call 0 never executed
#####: 706: goto failed;
-: 707: }
-: 708:
1: 709: bytes = _dbus_string_get_length (&pid);
call 0 returned 100%
1: 710: if (_dbus_write (print_pid_fd, &pid, 0, bytes) != bytes)
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 711: {
#####: 712: dbus_set_error (error, DBUS_ERROR_FAILED,
call 0 never executed
call 1 never executed
call 2 never executed
-: 713: "Printing message bus PID: %s\n",
-: 714: _dbus_strerror (errno));
#####: 715: _dbus_string_free (&pid);
call 0 never executed
#####: 716: goto failed;
-: 717: }
-: 718:
1: 719: if (print_pid_fd > 2)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
1: 720: _dbus_close (print_pid_fd, NULL);
call 0 returned 100%
-: 721:
1: 722: _dbus_string_free (&pid);
call 0 returned 100%
-: 723: }
-: 724:
3: 725: if (!bus_selinux_full_init ())
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 726: {
#####: 727: _dbus_warn ("SELinux initialization failed\n");
call 0 never executed
-: 728: }
-: 729:
3: 730: if (!process_config_postinit (context, parser, error))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 731: {
#####: 732: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 733: goto failed;
-: 734: }
-: 735:
3: 736: if (parser != NULL)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 737: {
3: 738: bus_config_parser_unref (parser);
call 0 returned 100%
3: 739: parser = NULL;
-: 740: }
-: 741:
-: 742: /* Here we change our credentials if required,
-: 743: * as soon as we've set up our sockets and pidfile
-: 744: */
3: 745: if (context->user != NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 746: {
-: 747: DBusCredentials creds;
-: 748: DBusString u;
-: 749:
#####: 750: _dbus_string_init_const (&u, context->user);
call 0 never executed
-: 751:
#####: 752: if (!_dbus_credentials_from_username (&u, &creds) ||
call 0 never executed
branch 1 never executed
branch 2 never executed
-: 753: creds.uid < 0 ||
-: 754: creds.gid < 0)
-: 755: {
#####: 756: dbus_set_error (error, DBUS_ERROR_FAILED,
call 0 never executed
-: 757: "Could not get UID and GID for username \"%s\"",
-: 758: context->user);
#####: 759: goto failed;
-: 760: }
-: 761:
#####: 762: if (!_dbus_change_identity (creds.uid, creds.gid, error))
call 0 never executed
branch 1 never executed
branch 2 never executed
-: 763: {
#####: 764: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 765: goto failed;
-: 766: }
-: 767: }
-: 768:
3: 769: dbus_server_free_data_slot (&server_data_slot);
call 0 returned 100%
-: 770:
3: 771: return context;
-: 772:
#####: 773: failed:
#####: 774: if (parser != NULL)
branch 0 never executed
branch 1 never executed
#####: 775: bus_config_parser_unref (parser);
call 0 never executed
#####: 776: if (context != NULL)
branch 0 never executed
branch 1 never executed
#####: 777: bus_context_unref (context);
call 0 never executed
-: 778:
#####: 779: if (server_data_slot >= 0)
branch 0 never executed
branch 1 never executed
#####: 780: dbus_server_free_data_slot (&server_data_slot);
call 0 never executed
-: 781:
#####: 782: return NULL;
-: 783:}
-: 784:
-: 785:dbus_bool_t
-: 786:bus_context_reload_config (BusContext *context,
-: 787: DBusError *error)
function bus_context_reload_config called 0 returned 0% blocks executed 0%
#####: 788:{
-: 789: BusConfigParser *parser;
-: 790: DBusString config_file;
-: 791: dbus_bool_t ret;
-: 792:
-: 793: /* Flush the user database cache */
#####: 794: _dbus_user_database_flush(context->user_database);
call 0 never executed
-: 795:
#####: 796: ret = FALSE;
#####: 797: _dbus_string_init_const (&config_file, context->config_file);
call 0 never executed
#####: 798: parser = bus_config_load (&config_file, TRUE, NULL, error);
call 0 never executed
#####: 799: if (parser == NULL)
branch 0 never executed
branch 1 never executed
-: 800: {
#####: 801: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 802: goto failed;
-: 803: }
-: 804:
#####: 805: if (!process_config_every_time (context, parser, TRUE, error))
call 0 never executed
branch 1 never executed
branch 2 never executed
-: 806: {
#####: 807: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 808: goto failed;
-: 809: }
#####: 810: if (!process_config_postinit (context, parser, error))
call 0 never executed
branch 1 never executed
branch 2 never executed
-: 811: {
#####: 812: _DBUS_ASSERT_ERROR_IS_SET (error);
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
#####: 813: goto failed;
-: 814: }
#####: 815: ret = TRUE;
-: 816:
#####: 817: failed:
#####: 818: if (parser != NULL)
branch 0 never executed
branch 1 never executed
#####: 819: bus_config_parser_unref (parser);
call 0 never executed
#####: 820: return ret;
-: 821:}
-: 822:
-: 823:static void
-: 824:shutdown_server (BusContext *context,
-: 825: DBusServer *server)
function shutdown_server called 6 returned 100% blocks executed 83%
6: 826:{
6: 827: if (server == NULL ||
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 17% (fallthrough)
branch 4 taken 83%
-: 828: !dbus_server_get_is_connected (server))
1: 829: return;
-: 830:
5: 831: if (!dbus_server_set_watch_functions (server,
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 832: NULL, NULL, NULL,
-: 833: context,
-: 834: NULL))
#####: 835: _dbus_assert_not_reached ("setting watch functions to NULL failed");
call 0 never executed
-: 836:
5: 837: if (!dbus_server_set_timeout_functions (server,
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 838: NULL, NULL, NULL,
-: 839: context,
-: 840: NULL))
#####: 841: _dbus_assert_not_reached ("setting timeout functions to NULL failed");
call 0 never executed
-: 842:
5: 843: dbus_server_disconnect (server);
call 0 returned 100%
-: 844:}
-: 845:
-: 846:void
-: 847:bus_context_shutdown (BusContext *context)
function bus_context_shutdown called 4 returned 100% blocks executed 100%
4: 848:{
-: 849: DBusList *link;
-: 850:
4: 851: link = _dbus_list_get_first_link (&context->servers);
call 0 returned 100%
14: 852: while (link != NULL)
branch 0 taken 60%
branch 1 taken 40% (fallthrough)
-: 853: {
6: 854: shutdown_server (context, link->data);
call 0 returned 100%
-: 855:
6: 856: link = _dbus_list_get_next_link (&context->servers, link);
branch 0 taken 33% (fallthrough)
branch 1 taken 67%
-: 857: }
4: 858:}
-: 859:
-: 860:BusContext *
-: 861:bus_context_ref (BusContext *context)
function bus_context_ref called 0 returned 0% blocks executed 0%
#####: 862:{
#####: 863: _dbus_assert (context->refcount > 0);
call 0 never executed
#####: 864: context->refcount += 1;
-: 865:
#####: 866: return context;
-: 867:}
-: 868:
-: 869:void
-: 870:bus_context_unref (BusContext *context)
function bus_context_unref called 3 returned 100% blocks executed 93%
3: 871:{
3: 872: _dbus_assert (context->refcount > 0);
call 0 returned 100%
3: 873: context->refcount -= 1;
-: 874:
3: 875: if (context->refcount == 0)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 876: {
-: 877: DBusList *link;
-: 878:
3: 879: _dbus_verbose ("Finalizing bus context %p\n", context);
call 0 returned 100%
-: 880:
3: 881: bus_context_shutdown (context);
call 0 returned 100%
-: 882:
3: 883: if (context->connections)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 884: {
3: 885: bus_connections_unref (context->connections);
call 0 returned 100%
3: 886: context->connections = NULL;
-: 887: }
-: 888:
3: 889: if (context->registry)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 890: {
3: 891: bus_registry_unref (context->registry);
call 0 returned 100%
3: 892: context->registry = NULL;
-: 893: }
-: 894:
3: 895: if (context->activation)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 896: {
3: 897: bus_activation_unref (context->activation);
call 0 returned 100%
3: 898: context->activation = NULL;
-: 899: }
-: 900:
3: 901: link = _dbus_list_get_first_link (&context->servers);
call 0 returned 100%
11: 902: while (link != NULL)
branch 0 taken 63%
branch 1 taken 38% (fallthrough)
-: 903: {
5: 904: dbus_server_unref (link->data);
call 0 returned 100%
-: 905:
5: 906: link = _dbus_list_get_next_link (&context->servers, link);
branch 0 taken 40% (fallthrough)
branch 1 taken 60%
-: 907: }
3: 908: _dbus_list_clear (&context->servers);
call 0 returned 100%
-: 909:
3: 910: if (context->policy)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 911: {
3: 912: bus_policy_unref (context->policy);
call 0 returned 100%
3: 913: context->policy = NULL;
-: 914: }
-: 915:
3: 916: if (context->loop)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 917: {
3: 918: _dbus_loop_unref (context->loop);
call 0 returned 100%
3: 919: context->loop = NULL;
-: 920: }
-: 921:
3: 922: if (context->matchmaker)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 923: {
3: 924: bus_matchmaker_unref (context->matchmaker);
call 0 returned 100%
3: 925: context->matchmaker = NULL;
-: 926: }
-: 927:
3: 928: dbus_free (context->config_file);
call 0 returned 100%
3: 929: dbus_free (context->type);
call 0 returned 100%
3: 930: dbus_free (context->address);
call 0 returned 100%
3: 931: dbus_free (context->user);
call 0 returned 100%
-: 932:
3: 933: if (context->pidfile)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 934: {
-: 935: DBusString u;
#####: 936: _dbus_string_init_const (&u, context->pidfile);
call 0 never executed
-: 937:
-: 938: /* Deliberately ignore errors here, since there's not much
-: 939: * we can do about it, and we're exiting anyways.
-: 940: */
#####: 941: _dbus_delete_file (&u, NULL);
call 0 never executed
-: 942:
#####: 943: dbus_free (context->pidfile);
call 0 never executed
-: 944: }
-: 945:
3: 946: if (context->user_database != NULL)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
3: 947: _dbus_user_database_unref (context->user_database);
call 0 returned 100%
-: 948:
3: 949: dbus_free (context);
call 0 returned 100%
-: 950:
3: 951: dbus_server_free_data_slot (&server_data_slot);
call 0 returned 100%
-: 952: }
3: 953:}
-: 954:
-: 955:/* type may be NULL */
-: 956:const char*
-: 957:bus_context_get_type (BusContext *context)
function bus_context_get_type called 2923 returned 100% blocks executed 100%
2923: 958:{
2923: 959: return context->type;
-: 960:}
-: 961:
-: 962:const char*
-: 963:bus_context_get_address (BusContext *context)
function bus_context_get_address called 1 returned 100% blocks executed 100%
1: 964:{
1: 965: return context->address;
-: 966:}
-: 967:
-: 968:BusRegistry*
-: 969:bus_context_get_registry (BusContext *context)
function bus_context_get_registry called 14625 returned 100% blocks executed 100%
14625: 970:{
14625: 971: return context->registry;
-: 972:}
-: 973:
-: 974:BusConnections*
-: 975:bus_context_get_connections (BusContext *context)
function bus_context_get_connections called 29069 returned 100% blocks executed 100%
29069: 976:{
29069: 977: return context->connections;
-: 978:}
-: 979:
-: 980:BusActivation*
-: 981:bus_context_get_activation (BusContext *context)
function bus_context_get_activation called 14346 returned 100% blocks executed 100%
14346: 982:{
14346: 983: return context->activation;
-: 984:}
-: 985:
-: 986:BusMatchmaker*
-: 987:bus_context_get_matchmaker (BusContext *context)
function bus_context_get_matchmaker called 35641 returned 100% blocks executed 100%
35641: 988:{
35641: 989: return context->matchmaker;
-: 990:}
-: 991:
-: 992:DBusLoop*
-: 993:bus_context_get_loop (BusContext *context)
function bus_context_get_loop called 1268938 returned 100% blocks executed 100%
1268938: 994:{
1268938: 995: return context->loop;
-: 996:}
-: 997:
-: 998:DBusUserDatabase*
-: 999:bus_context_get_user_database (BusContext *context)
function bus_context_get_user_database called 0 returned 0% blocks executed 0%
#####: 1000:{
#####: 1001: return context->user_database;
-: 1002:}
-: 1003:
-: 1004:dbus_bool_t
-: 1005:bus_context_allow_user (BusContext *context,
-: 1006: unsigned long uid)
function bus_context_allow_user called 6210 returned 100% blocks executed 100%
6210: 1007:{
6210: 1008: return bus_policy_allow_user (context->policy,
call 0 returned 100%
-: 1009: context->user_database,
-: 1010: uid);
-: 1011:}
-: 1012:
-: 1013:BusPolicy *
-: 1014:bus_context_get_policy (BusContext *context)
function bus_context_get_policy called 0 returned 0% blocks executed 0%
#####: 1015:{
#####: 1016: return context->policy;
-: 1017:}
-: 1018:
-: 1019:BusClientPolicy*
-: 1020:bus_context_create_client_policy (BusContext *context,
-: 1021: DBusConnection *connection,
-: 1022: DBusError *error)
function bus_context_create_client_policy called 6145 returned 100% blocks executed 88%
6145: 1023:{
6145: 1024: _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 100% (fallthrough)
branch 4 taken 0%
call 5 returned 100%
6145: 1025: return bus_policy_create_client_policy (context->policy, connection,
call 0 returned 100%
-: 1026: error);
-: 1027:}
-: 1028:
-: 1029:int
-: 1030:bus_context_get_activation_timeout (BusContext *context)
function bus_context_get_activation_timeout called 4566 returned 100% blocks executed 100%
4566: 1031:{
-: 1032:
4566: 1033: return context->limits.activation_timeout;
-: 1034:}
-: 1035:
-: 1036:int
-: 1037:bus_context_get_auth_timeout (BusContext *context)
function bus_context_get_auth_timeout called 7814 returned 100% blocks executed 100%
7814: 1038:{
7814: 1039: return context->limits.auth_timeout;
-: 1040:}
-: 1041:
-: 1042:int
-: 1043:bus_context_get_max_completed_connections (BusContext *context)
function bus_context_get_max_completed_connections called 6184 returned 100% blocks executed 100%
6184: 1044:{
6184: 1045: return context->limits.max_completed_connections;
-: 1046:}
-: 1047:
-: 1048:int
-: 1049:bus_context_get_max_incomplete_connections (BusContext *context)
function bus_context_get_max_incomplete_connections called 7811 returned 100% blocks executed 100%
7811: 1050:{
7811: 1051: return context->limits.max_incomplete_connections;
-: 1052:}
-: 1053:
-: 1054:int
-: 1055:bus_context_get_max_connections_per_user (BusContext *context)
function bus_context_get_max_connections_per_user called 6184 returned 100% blocks executed 100%
6184: 1056:{
6184: 1057: return context->limits.max_connections_per_user;
-: 1058:}
-: 1059:
-: 1060:int
-: 1061:bus_context_get_max_pending_activations (BusContext *context)
function bus_context_get_max_pending_activations called 5237 returned 100% blocks executed 100%
5237: 1062:{
5237: 1063: return context->limits.max_pending_activations;
-: 1064:}
-: 1065:
-: 1066:int
-: 1067:bus_context_get_max_services_per_connection (BusContext *context)
function bus_context_get_max_services_per_connection called 1950 returned 100% blocks executed 100%
1950: 1068:{
1950: 1069: return context->limits.max_services_per_connection;
-: 1070:}
-: 1071:
-: 1072:int
-: 1073:bus_context_get_max_match_rules_per_connection (BusContext *context)
function bus_context_get_max_match_rules_per_connection called 3328 returned 100% blocks executed 100%
3328: 1074:{
3328: 1075: return context->limits.max_match_rules_per_connection;
-: 1076:}
-: 1077:
-: 1078:int
-: 1079:bus_context_get_max_replies_per_connection (BusContext *context)
function bus_context_get_max_replies_per_connection called 1579 returned 100% blocks executed 100%
1579: 1080:{
1579: 1081: return context->limits.max_replies_per_connection;
-: 1082:}
-: 1083:
-: 1084:int
-: 1085:bus_context_get_reply_timeout (BusContext *context)
function bus_context_get_reply_timeout called 3 returned 100% blocks executed 100%
3: 1086:{
3: 1087: return context->limits.reply_timeout;
-: 1088:}
-: 1089:
-: 1090:/*
-: 1091: * addressed_recipient is the recipient specified in the message.
-: 1092: *
-: 1093: * proposed_recipient is the recipient we're considering sending
-: 1094: * to right this second, and may be an eavesdropper.
-: 1095: *
-: 1096: * sender is the sender of the message.
-: 1097: *
-: 1098: * NULL for proposed_recipient or sender definitely means the bus driver.
-: 1099: *
-: 1100: * NULL for addressed_recipient may mean the bus driver, or may mean
-: 1101: * no destination was specified in the message (e.g. a signal).
-: 1102: */
-: 1103:dbus_bool_t
-: 1104:bus_context_check_security_policy (BusContext *context,
-: 1105: BusTransaction *transaction,
-: 1106: DBusConnection *sender,
-: 1107: DBusConnection *addressed_recipient,
-: 1108: DBusConnection *proposed_recipient,
-: 1109: DBusMessage *message,
-: 1110: DBusError *error)
function bus_context_check_security_policy called 118715 returned 100% blocks executed 63%
118715: 1111:{
-: 1112: BusClientPolicy *sender_policy;
-: 1113: BusClientPolicy *recipient_policy;
-: 1114: int type;
-: 1115: dbus_bool_t requested_reply;
-: 1116:
118715: 1117: type = dbus_message_get_type (message);
call 0 returned 100%
-: 1118:
-: 1119: /* dispatch.c was supposed to ensure these invariants */
118715: 1120: _dbus_assert (dbus_message_get_destination (message) != NULL ||
call 0 returned 100%
branch 1 taken 29% (fallthrough)
branch 2 taken 71%
branch 3 taken 0% (fallthrough)
branch 4 taken 100%
branch 5 never executed
branch 6 never executed
call 7 never executed
branch 8 never executed
branch 9 never executed
call 10 returned 100%
-: 1121: type == DBUS_MESSAGE_TYPE_SIGNAL ||
-: 1122: (sender == NULL && !bus_connection_is_active (proposed_recipient)));
118715: 1123: _dbus_assert (type == DBUS_MESSAGE_TYPE_SIGNAL ||
branch 0 taken 59% (fallthrough)
branch 1 taken 41%
branch 2 taken 68% (fallthrough)
branch 3 taken 32%
call 4 returned 100%
call 5 returned 100%
branch 6 taken 100% (fallthrough)
branch 7 taken 0%
call 8 returned 100%
-: 1124: addressed_recipient != NULL ||
-: 1125: strcmp (dbus_message_get_destination (message), DBUS_SERVICE_DBUS) == 0);
-: 1126:
118715: 1127: switch (type)
branch 0 taken 100%
branch 1 taken 0%
-: 1128: {
-: 1129: case DBUS_MESSAGE_TYPE_METHOD_CALL:
-: 1130: case DBUS_MESSAGE_TYPE_SIGNAL:
-: 1131: case DBUS_MESSAGE_TYPE_METHOD_RETURN:
-: 1132: case DBUS_MESSAGE_TYPE_ERROR:
-: 1133: break;
-: 1134:
-: 1135: default:
#####: 1136: _dbus_verbose ("security check disallowing message of unknown type %d\n",
call 0 never executed
-: 1137: type);
-: 1138:
#####: 1139: dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
call 0 never executed
-: 1140: "Message bus will not accept messages of unknown type\n");
-: 1141:
#####: 1142: return FALSE;
-: 1143: }
-: 1144:
118715: 1145: requested_reply = FALSE;
-: 1146:
118715: 1147: if (sender != NULL)
branch 0 taken 46%
branch 1 taken 54%
-: 1148: {
-: 1149: const char *dest;
-: 1150:
54033: 1151: dest = dbus_message_get_destination (message);
call 0 returned 100%
-: 1152:
-: 1153: /* First verify the SELinux access controls. If allowed then
-: 1154: * go on with the standard checks.
-: 1155: */
54033: 1156: if (!bus_selinux_allows_send (sender, proposed_recipient,
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
call 3 returned 100%
call 4 returned 100%
call 5 returned 100%
call 6 returned 100%
call 7 returned 100%
branch 8 taken 0% (fallthrough)
branch 9 taken 100%
-: 1157: dbus_message_type_to_string (dbus_message_get_type (message)),
-: 1158: dbus_message_get_interface (message),
-: 1159: dbus_message_get_member (message),
-: 1160: dbus_message_get_error_name (message),
-: 1161: dest ? dest : DBUS_SERVICE_DBUS, error))
-: 1162: {
-: 1163:
#####: 1164: if (dbus_error_is_set (error) &&
call 0 never executed
branch 1 never executed
branch 2 never executed
call 3 never executed
branch 4 never executed
branch 5 never executed
-: 1165: dbus_error_has_name (error, DBUS_ERROR_NO_MEMORY))
-: 1166: {
#####: 1167: return FALSE;
-: 1168: }
-: 1169:
-: 1170:
#####: 1171: dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
branch 0 never executed
branch 1 never executed
call 2 never executed
branch 3 never executed
branch 4 never executed
call 5 never executed
call 6 never executed
branch 7 never executed
branch 8 never executed
call 9 never executed
call 10 never executed
branch 11 never executed
branch 12 never executed
call 13 never executed
call 14 never executed
-: 1172: "An SELinux policy prevents this sender "
-: 1173: "from sending this message to this recipient "
-: 1174: "(rejected message had interface \"%s\" "
-: 1175: "member \"%s\" error name \"%s\" destination \"%s\")",
-: 1176: dbus_message_get_interface (message) ?
-: 1177: dbus_message_get_interface (message) : "(unset)",
-: 1178: dbus_message_get_member (message) ?
-: 1179: dbus_message_get_member (message) : "(unset)",
-: 1180: dbus_message_get_error_name (message) ?
-: 1181: dbus_message_get_error_name (message) : "(unset)",
-: 1182: dest ? dest : DBUS_SERVICE_DBUS);
#####: 1183: _dbus_verbose ("SELinux security check denying send to service\n");
call 0 never executed
#####: 1184: return FALSE;
-: 1185: }
-: 1186:
54033: 1187: if (bus_connection_is_active (sender))
call 0 returned 100%
branch 1 taken 89% (fallthrough)
branch 2 taken 11%
-: 1188: {
47849: 1189: sender_policy = bus_connection_get_policy (sender);
call 0 returned 100%
47849: 1190: _dbus_assert (sender_policy != NULL);
call 0 returned 100%
-: 1191:
-: 1192: /* Fill in requested_reply variable with TRUE if this is a
-: 1193: * reply and the reply was pending.
-: 1194: */
47849: 1195: if (dbus_message_get_reply_serial (message) != 0)
call 0 returned 100%
branch 1 taken 1% (fallthrough)
branch 2 taken 99%
-: 1196: {
13: 1197: if (proposed_recipient != NULL /* not to the bus driver */ &&
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
branch 2 taken 31% (fallthrough)
branch 3 taken 69%
-: 1198: addressed_recipient == proposed_recipient /* not eavesdropping */)
-: 1199: {
-: 1200: DBusError error2;
-: 1201:
4: 1202: dbus_error_init (&error2);
call 0 returned 100%
4: 1203: requested_reply = bus_connections_check_reply (bus_connection_get_connections (sender),
call 0 returned 100%
call 1 returned 100%
-: 1204: transaction,
-: 1205: sender, addressed_recipient, message,
-: 1206: &error2);
4: 1207: if (dbus_error_is_set (&error2))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 1208: {
#####: 1209: dbus_move_error (&error2, error);
call 0 never executed
#####: 1210: return FALSE;
-: 1211: }
-: 1212: }
-: 1213: }
-: 1214: }
-: 1215: else
-: 1216: {
-: 1217: /* Policy for inactive connections is that they can only send
-: 1218: * the hello message to the bus driver
-: 1219: */
6184: 1220: if (proposed_recipient == NULL &&
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 100% (fallthrough)
branch 4 taken 0%
-: 1221: dbus_message_is_method_call (message,
-: 1222: DBUS_INTERFACE_DBUS,
-: 1223: "Hello"))
-: 1224: {
6184: 1225: _dbus_verbose ("security check allowing %s message\n",
call 0 returned 100%
-: 1226: "Hello");
6184: 1227: return TRUE;
-: 1228: }
-: 1229: else
-: 1230: {
#####: 1231: _dbus_verbose ("security check disallowing non-%s message\n",
call 0 never executed
-: 1232: "Hello");
-: 1233:
#####: 1234: dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
call 0 never executed
-: 1235: "Client tried to send a message other than %s without being registered",
-: 1236: "Hello");
-: 1237:
#####: 1238: return FALSE;
-: 1239: }
-: 1240: }
-: 1241: }
-: 1242: else
-: 1243: {
64682: 1244: sender_policy = NULL;
-: 1245:
-: 1246: /* If the sender is the bus driver, we assume any reply was a
-: 1247: * requested reply as bus driver won't send bogus ones
-: 1248: */
64682: 1249: if (addressed_recipient == proposed_recipient /* not eavesdropping */ &&
branch 0 taken 47% (fallthrough)
branch 1 taken 53%
call 2 returned 100%
branch 3 taken 53% (fallthrough)
branch 4 taken 47%
-: 1250: dbus_message_get_reply_serial (message) != 0)
15948: 1251: requested_reply = TRUE;
-: 1252: }
-: 1253:
112531: 1254: _dbus_assert ((sender != NULL && sender_policy != NULL) ||
branch 0 taken 43% (fallthrough)
branch 1 taken 57%
branch 2 taken 0% (fallthrough)
branch 3 taken 100%
branch 4 taken 100% (fallthrough)
branch 5 taken 0%
branch 6 taken 100% (fallthrough)
branch 7 taken 0%
call 8 returned 100%
-: 1255: (sender == NULL && sender_policy == NULL));
-: 1256:
112531: 1257: if (proposed_recipient != NULL)
branch 0 taken 92% (fallthrough)
branch 1 taken 8%
-: 1258: {
-: 1259: /* only the bus driver can send to an inactive recipient (as it
-: 1260: * owns no services, so other apps can't address it). Inactive
-: 1261: * recipients can receive any message.
-: 1262: */
103445: 1263: if (bus_connection_is_active (proposed_recipient))
call 0 returned 100%
branch 1 taken 100% (fallthrough)
branch 2 taken 0%
-: 1264: {
103445: 1265: recipient_policy = bus_connection_get_policy (proposed_recipient);
call 0 returned 100%
103445: 1266: _dbus_assert (recipient_policy != NULL);
call 0 returned 100%
-: 1267: }
#####: 1268: else if (sender == NULL)
branch 0 never executed
branch 1 never executed
-: 1269: {
#####: 1270: _dbus_verbose ("security check using NULL recipient policy for message from bus\n");
call 0 never executed
#####: 1271: recipient_policy = NULL;
-: 1272: }
-: 1273: else
-: 1274: {
#####: 1275: _dbus_assert_not_reached ("a message was somehow sent to an inactive recipient from a source other than the message bus\n");
call 0 never executed
-: 1276: recipient_policy = NULL;
-: 1277: }
-: 1278: }
-: 1279: else
9086: 1280: recipient_policy = NULL;
-: 1281:
112531: 1282: _dbus_assert ((proposed_recipient != NULL && recipient_policy != NULL) ||
branch 0 taken 92% (fallthrough)
branch 1 taken 8%
branch 2 taken 0% (fallthrough)
branch 3 taken 100%
branch 4 taken 0% (fallthrough)
branch 5 taken 100%
branch 6 never executed
branch 7 never executed
branch 8 never executed
branch 9 never executed
branch 10 taken 100% (fallthrough)
branch 11 taken 0%
branch 12 taken 100% (fallthrough)
branch 13 taken 0%
call 14 returned 100%
-: 1283: (proposed_recipient != NULL && sender == NULL && recipient_policy == NULL) ||
-: 1284: (proposed_recipient == NULL && recipient_policy == NULL));
-: 1285:
112531: 1286: if (sender_policy &&
branch 0 taken 43% (fallthrough)
branch 1 taken 57%
call 2 returned 100%
branch 3 taken 1% (fallthrough)
branch 4 taken 99%
-: 1287: !bus_client_policy_check_can_send (sender_policy,
-: 1288: context->registry,
-: 1289: requested_reply,
-: 1290: proposed_recipient,
-: 1291: message))
-: 1292: {
-: 1293: const char *dest;
-: 1294:
9: 1295: dest = dbus_message_get_destination (message);
call 0 returned 100%
9: 1296: dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
call 2 returned 100%
branch 3 taken 0% (fallthrough)
branch 4 taken 100%
call 5 never executed
call 6 returned 100%
branch 7 taken 0% (fallthrough)
branch 8 taken 100%
call 9 never executed
call 10 returned 100%
branch 11 taken 0% (fallthrough)
branch 12 taken 100%
call 13 never executed
call 14 returned 100%
-: 1297: "A security policy in place prevents this sender "
-: 1298: "from sending this message to this recipient, "
-: 1299: "see message bus configuration file (rejected message "
-: 1300: "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\")",
-: 1301: dbus_message_get_interface (message) ?
-: 1302: dbus_message_get_interface (message) : "(unset)",
-: 1303: dbus_message_get_member (message) ?
-: 1304: dbus_message_get_member (message) : "(unset)",
-: 1305: dbus_message_get_error_name (message) ?
-: 1306: dbus_message_get_error_name (message) : "(unset)",
-: 1307: dest ? dest : DBUS_SERVICE_DBUS);
9: 1308: _dbus_verbose ("security policy disallowing message due to sender policy\n");
call 0 returned 100%
9: 1309: return FALSE;
-: 1310: }
-: 1311:
112522: 1312: if (recipient_policy &&
branch 0 taken 92% (fallthrough)
branch 1 taken 8%
call 2 returned 100%
branch 3 taken 36% (fallthrough)
branch 4 taken 64%
-: 1313: !bus_client_policy_check_can_receive (recipient_policy,
-: 1314: context->registry,
-: 1315: requested_reply,
-: 1316: sender,
-: 1317: addressed_recipient, proposed_recipient,
-: 1318: message))
-: 1319: {
-: 1320: const char *dest;
-: 1321:
37171: 1322: dest = dbus_message_get_destination (message);
call 0 returned 100%
37171: 1323: dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
call 0 returned 100%
branch 1 taken 100% (fallthrough)
branch 2 taken 0%
call 3 returned 100%
branch 4 taken 0% (fallthrough)
branch 5 taken 100%
call 6 never executed
call 7 returned 100%
branch 8 taken 100% (fallthrough)
branch 9 taken 0%
call 10 returned 100%
call 11 returned 100%
branch 12 taken 100% (fallthrough)
branch 13 taken 0%
call 14 returned 100%
call 15 returned 100%
-: 1324: "A security policy in place prevents this recipient "
-: 1325: "from receiving this message from this sender, "
-: 1326: "see message bus configuration file (rejected message "
-: 1327: "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\" reply serial %u requested_reply=%d)",
-: 1328: dbus_message_get_interface (message) ?
-: 1329: dbus_message_get_interface (message) : "(unset)",
-: 1330: dbus_message_get_member (message) ?
-: 1331: dbus_message_get_member (message) : "(unset)",
-: 1332: dbus_message_get_error_name (message) ?
-: 1333: dbus_message_get_error_name (message) : "(unset)",
-: 1334: dest ? dest : DBUS_SERVICE_DBUS,
-: 1335: dbus_message_get_reply_serial (message),
-: 1336: requested_reply);
37171: 1337: _dbus_verbose ("security policy disallowing message due to recipient policy\n");
call 0 returned 100%
37171: 1338: return FALSE;
-: 1339: }
-: 1340:
-: 1341: /* See if limits on size have been exceeded */
75351: 1342: if (proposed_recipient &&
branch 0 taken 88% (fallthrough)
branch 1 taken 12%
call 2 returned 100%
branch 3 taken 0% (fallthrough)
branch 4 taken 100%
-: 1343: dbus_connection_get_outgoing_size (proposed_recipient) >
-: 1344: context->limits.max_outgoing_bytes)
-: 1345: {
-: 1346: const char *dest;
-: 1347:
#####: 1348: dest = dbus_message_get_destination (message);
call 0 never executed
#####: 1349: dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
branch 0 never executed
branch 1 never executed
branch 2 never executed
branch 3 never executed
call 4 never executed
call 5 never executed
-: 1350: "The destination service \"%s\" has a full message queue",
-: 1351: dest ? dest : (proposed_recipient ?
-: 1352: bus_connection_get_name (proposed_recipient) :
-: 1353: DBUS_SERVICE_DBUS));
#####: 1354: _dbus_verbose ("security policy disallowing message due to full message queue\n");
call 0 never executed
#####: 1355: return FALSE;
-: 1356: }
-: 1357:
75351: 1358: if (type == DBUS_MESSAGE_TYPE_METHOD_CALL)
branch 0 taken 14% (fallthrough)
branch 1 taken 86%
-: 1359: {
-: 1360: /* Record that we will allow a reply here in the future (don't
-: 1361: * bother if the recipient is the bus). Only the addressed recipient
-: 1362: * may reply.
-: 1363: */
10665: 1364: if (sender && addressed_recipient &&
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
branch 2 taken 15% (fallthrough)
branch 3 taken 85%
call 4 returned 100%
call 5 returned 100%
branch 6 taken 1% (fallthrough)
branch 7 taken 99%
-: 1365: !bus_connections_expect_reply (bus_connection_get_connections (sender),
-: 1366: transaction,
-: 1367: sender, addressed_recipient,
-: 1368: message, error))
-: 1369: {
15: 1370: _dbus_verbose ("Failed to record reply expectation or problem with the message expecting a reply\n");
call 0 returned 100%
15: 1371: return FALSE;
-: 1372: }
-: 1373: }
-: 1374:
75336: 1375: _dbus_verbose ("security policy allowing message\n");
call 0 returned 100%
75336: 1376: return TRUE;
-: 1377:}