1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* bus.c message bus context object
4 * Copyright (C) 2003, 2004 Red Hat, Inc.
6 * Licensed under the Academic Free License version 2.1
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.
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.
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
25 #include "activation.h"
26 #include "connection.h"
30 #include "config-parser.h"
33 #include <dbus/dbus-list.h>
34 #include <dbus/dbus-hash.h>
35 #include <dbus/dbus-internals.h>
47 BusConnections *connections;
48 BusActivation *activation;
49 BusRegistry *registry;
51 BusMatchmaker *matchmaker;
52 DBusUserDatabase *user_database;
54 unsigned int fork : 1;
57 static dbus_int32_t server_data_slot = -1;
64 #define BUS_SERVER_DATA(server) (dbus_server_get_data ((server), server_data_slot))
67 server_get_context (DBusServer *server)
72 if (!dbus_server_allocate_data_slot (&server_data_slot))
75 bd = BUS_SERVER_DATA (server);
78 dbus_server_free_data_slot (&server_data_slot);
82 context = bd->context;
84 dbus_server_free_data_slot (&server_data_slot);
90 server_watch_callback (DBusWatch *watch,
91 unsigned int condition,
94 /* FIXME this can be done in dbus-mainloop.c
95 * if the code in activation.c for the babysitter
96 * watch handler is fixed.
99 return dbus_watch_handle (watch, condition);
103 add_server_watch (DBusWatch *watch,
106 DBusServer *server = data;
109 context = server_get_context (server);
111 return _dbus_loop_add_watch (context->loop,
112 watch, server_watch_callback, server,
117 remove_server_watch (DBusWatch *watch,
120 DBusServer *server = data;
123 context = server_get_context (server);
125 _dbus_loop_remove_watch (context->loop,
126 watch, server_watch_callback, server);
131 server_timeout_callback (DBusTimeout *timeout,
134 /* can return FALSE on OOM but we just let it fire again later */
135 dbus_timeout_handle (timeout);
139 add_server_timeout (DBusTimeout *timeout,
142 DBusServer *server = data;
145 context = server_get_context (server);
147 return _dbus_loop_add_timeout (context->loop,
148 timeout, server_timeout_callback, server, NULL);
152 remove_server_timeout (DBusTimeout *timeout,
155 DBusServer *server = data;
158 context = server_get_context (server);
160 _dbus_loop_remove_timeout (context->loop,
161 timeout, server_timeout_callback, server);
165 new_connection_callback (DBusServer *server,
166 DBusConnection *new_connection,
169 BusContext *context = data;
171 if (!bus_connections_setup_connection (context->connections, new_connection))
173 _dbus_verbose ("No memory to setup new connection\n");
175 /* if we don't do this, it will get unref'd without
176 * being disconnected... kind of strange really
177 * that we have to do this, people won't get it right
180 dbus_connection_disconnect (new_connection);
183 dbus_connection_set_max_received_size (new_connection,
184 context->limits.max_incoming_bytes);
186 dbus_connection_set_max_message_size (new_connection,
187 context->limits.max_message_size);
189 /* on OOM, we won't have ref'd the connection so it will die. */
193 free_server_data (void *data)
195 BusServerData *bd = data;
201 setup_server (BusContext *context,
203 char **auth_mechanisms,
208 bd = dbus_new0 (BusServerData, 1);
209 if (!dbus_server_set_data (server,
211 bd, free_server_data))
218 bd->context = context;
220 if (!dbus_server_set_auth_mechanisms (server, (const char**) auth_mechanisms))
226 dbus_server_set_new_connection_function (server,
227 new_connection_callback,
230 if (!dbus_server_set_watch_functions (server,
241 if (!dbus_server_set_timeout_functions (server,
243 remove_server_timeout,
254 /* This code only gets executed the first time the
255 config files are parsed. It is not executed
256 when config files are reloaded.*/
258 process_config_first_time_only (BusContext *context,
259 BusConfigParser *parser,
263 DBusList **addresses;
264 const char *user, *pidfile;
265 char **auth_mechanisms;
266 DBusList **auth_mechanisms_list;
270 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
273 auth_mechanisms = NULL;
275 /* Check for an existing pid file. Of course this is a race;
276 * we'd have to use fcntl() locks on the pid file to
277 * avoid that. But we want to check for the pid file
278 * before overwriting any existing sockets, etc.
280 pidfile = bus_config_parser_get_pidfile (parser);
286 _dbus_string_init_const (&u, pidfile);
288 if (_dbus_stat (&u, &stbuf, NULL))
290 dbus_set_error (error, DBUS_ERROR_FAILED,
291 "The pid file \"%s\" exists, if the message bus is not running, remove this file",
297 /* keep around the pid filename so we can delete it later */
298 context->pidfile = _dbus_strdup (pidfile);
300 /* Build an array of auth mechanisms */
302 auth_mechanisms_list = bus_config_parser_get_mechanisms (parser);
303 len = _dbus_list_get_length (auth_mechanisms_list);
309 auth_mechanisms = dbus_new0 (char*, len + 1);
310 if (auth_mechanisms == NULL)
317 link = _dbus_list_get_first_link (auth_mechanisms_list);
320 auth_mechanisms[i] = _dbus_strdup (link->data);
321 if (auth_mechanisms[i] == NULL)
326 link = _dbus_list_get_next_link (auth_mechanisms_list, link);
331 auth_mechanisms = NULL;
334 /* Listen on our addresses */
336 addresses = bus_config_parser_get_addresses (parser);
338 link = _dbus_list_get_first_link (addresses);
343 server = dbus_server_listen (link->data, error);
346 _DBUS_ASSERT_ERROR_IS_SET (error);
349 else if (!setup_server (context, server, auth_mechanisms, error))
351 _DBUS_ASSERT_ERROR_IS_SET (error);
355 if (!_dbus_list_append (&context->servers, server))
361 link = _dbus_list_get_next_link (addresses, link);
364 /* note that type may be NULL */
365 context->type = _dbus_strdup (bus_config_parser_get_type (parser));
366 if (bus_config_parser_get_type (parser) != NULL && context->type == NULL)
372 user = bus_config_parser_get_user (parser);
375 context->user = _dbus_strdup (user);
376 if (context->user == NULL)
383 context->fork = bus_config_parser_get_fork (parser);
385 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
389 dbus_free_string_array (auth_mechanisms);
393 /* This code gets executed every time the config files
394 are parsed: both during BusContext construction
397 process_config_every_time (BusContext *context,
398 BusConfigParser *parser,
399 dbus_bool_t is_reload,
402 DBusString full_address;
407 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
411 if (!_dbus_string_init (&full_address))
417 /* get our limits and timeout lengths */
418 bus_config_parser_get_limits (parser, &context->limits);
420 context->policy = bus_config_parser_steal_policy (parser);
421 _dbus_assert (context->policy != NULL);
423 /* We have to build the address backward, so that
424 * <listen> later in the config file have priority
426 link = _dbus_list_get_last_link (&context->servers);
431 addr = dbus_server_get_address (link->data);
438 if (_dbus_string_get_length (&full_address) > 0)
440 if (!_dbus_string_append (&full_address, ";"))
447 if (!_dbus_string_append (&full_address, addr))
455 link = _dbus_list_get_prev_link (&context->servers, link);
459 dbus_free (context->address);
461 if (!_dbus_string_copy_data (&full_address, &context->address))
467 /* Create activation subsystem */
470 bus_activation_unref (context->activation);
472 context->activation = bus_activation_new (context, &full_address,
473 bus_config_parser_get_service_dirs (parser),
475 if (context->activation == NULL)
477 _DBUS_ASSERT_ERROR_IS_SET (error);
481 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
485 _dbus_string_free (&full_address);
490 process_config_postinit (BusContext *context,
491 BusConfigParser *parser,
494 DBusHashTable *service_context_table;
496 service_context_table = bus_config_parser_steal_service_context_table (parser);
497 if (!bus_registry_set_service_context_table (context->registry,
498 service_context_table))
504 _dbus_hash_table_unref (service_context_table);
509 bus_context_new (const DBusString *config_file,
510 ForceForkSetting force_fork,
516 BusConfigParser *parser;
518 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
523 if (!dbus_server_allocate_data_slot (&server_data_slot))
529 context = dbus_new0 (BusContext, 1);
535 context->refcount = 1;
537 if (!_dbus_string_copy_data (config_file, &context->config_file))
543 context->loop = _dbus_loop_new ();
544 if (context->loop == NULL)
550 context->registry = bus_registry_new (context);
551 if (context->registry == NULL)
557 parser = bus_config_load (config_file, TRUE, NULL, error);
560 _DBUS_ASSERT_ERROR_IS_SET (error);
564 if (!process_config_first_time_only (context, parser, error))
566 _DBUS_ASSERT_ERROR_IS_SET (error);
569 if (!process_config_every_time (context, parser, FALSE, error))
571 _DBUS_ASSERT_ERROR_IS_SET (error);
575 /* we need another ref of the server data slot for the context
578 if (!dbus_server_allocate_data_slot (&server_data_slot))
579 _dbus_assert_not_reached ("second ref of server data slot failed");
581 context->user_database = _dbus_user_database_new ();
582 if (context->user_database == NULL)
588 /* Note that we don't know whether the print_addr_fd is
589 * one of the sockets we're using to listen on, or some
590 * other random thing. But I think the answer is "don't do
593 if (print_addr_fd >= 0)
596 const char *a = bus_context_get_address (context);
599 _dbus_assert (a != NULL);
600 if (!_dbus_string_init (&addr))
606 if (!_dbus_string_append (&addr, a) ||
607 !_dbus_string_append (&addr, "\n"))
609 _dbus_string_free (&addr);
614 bytes = _dbus_string_get_length (&addr);
615 if (_dbus_write (print_addr_fd, &addr, 0, bytes) != bytes)
617 dbus_set_error (error, DBUS_ERROR_FAILED,
618 "Printing message bus address: %s\n",
619 _dbus_strerror (errno));
620 _dbus_string_free (&addr);
624 if (print_addr_fd > 2)
625 _dbus_close (print_addr_fd, NULL);
627 _dbus_string_free (&addr);
630 context->connections = bus_connections_new (context);
631 if (context->connections == NULL)
637 context->matchmaker = bus_matchmaker_new ();
638 if (context->matchmaker == NULL)
644 /* Now become a daemon if appropriate */
645 if ((force_fork != FORK_NEVER && context->fork) || force_fork == FORK_ALWAYS)
649 if (context->pidfile)
650 _dbus_string_init_const (&u, context->pidfile);
652 if (!_dbus_become_daemon (context->pidfile ? &u : NULL,
656 _DBUS_ASSERT_ERROR_IS_SET (error);
662 /* Need to write PID file for ourselves, not for the child process */
663 if (context->pidfile != NULL)
667 _dbus_string_init_const (&u, context->pidfile);
669 if (!_dbus_write_pid_file (&u, _dbus_getpid (), error))
671 _DBUS_ASSERT_ERROR_IS_SET (error);
677 /* Write PID if requested */
678 if (print_pid_fd >= 0)
683 if (!_dbus_string_init (&pid))
689 if (!_dbus_string_append_int (&pid, _dbus_getpid ()) ||
690 !_dbus_string_append (&pid, "\n"))
692 _dbus_string_free (&pid);
697 bytes = _dbus_string_get_length (&pid);
698 if (_dbus_write (print_pid_fd, &pid, 0, bytes) != bytes)
700 dbus_set_error (error, DBUS_ERROR_FAILED,
701 "Printing message bus PID: %s\n",
702 _dbus_strerror (errno));
703 _dbus_string_free (&pid);
707 if (print_pid_fd > 2)
708 _dbus_close (print_pid_fd, NULL);
710 _dbus_string_free (&pid);
713 if (!bus_selinux_full_init ())
715 _dbus_warn ("SELinux initialization failed\n");
718 if (!process_config_postinit (context, parser, error))
720 _DBUS_ASSERT_ERROR_IS_SET (error);
724 bus_config_parser_unref (parser);
726 /* Here we change our credentials if required,
727 * as soon as we've set up our sockets and pidfile
729 if (context->user != NULL)
731 DBusCredentials creds;
734 _dbus_string_init_const (&u, context->user);
736 if (!_dbus_credentials_from_username (&u, &creds) ||
740 dbus_set_error (error, DBUS_ERROR_FAILED,
741 "Could not get UID and GID for username \"%s\"",
746 if (!_dbus_change_identity (creds.uid, creds.gid, error))
748 _DBUS_ASSERT_ERROR_IS_SET (error);
753 dbus_server_free_data_slot (&server_data_slot);
759 bus_config_parser_unref (parser);
761 bus_context_unref (context);
763 if (server_data_slot >= 0)
764 dbus_server_free_data_slot (&server_data_slot);
770 bus_context_reload_config (BusContext *context,
773 BusConfigParser *parser;
774 DBusString config_file;
778 _dbus_string_init_const (&config_file, context->config_file);
779 parser = bus_config_load (&config_file, TRUE, NULL, error);
782 _DBUS_ASSERT_ERROR_IS_SET (error);
786 if (!process_config_every_time (context, parser, TRUE, error))
788 _DBUS_ASSERT_ERROR_IS_SET (error);
791 if (!process_config_postinit (context, parser, error))
793 _DBUS_ASSERT_ERROR_IS_SET (error);
800 bus_config_parser_unref (parser);
805 shutdown_server (BusContext *context,
808 if (server == NULL ||
809 !dbus_server_get_is_connected (server))
812 if (!dbus_server_set_watch_functions (server,
816 _dbus_assert_not_reached ("setting watch functions to NULL failed");
818 if (!dbus_server_set_timeout_functions (server,
822 _dbus_assert_not_reached ("setting timeout functions to NULL failed");
824 dbus_server_disconnect (server);
828 bus_context_shutdown (BusContext *context)
832 link = _dbus_list_get_first_link (&context->servers);
835 shutdown_server (context, link->data);
837 link = _dbus_list_get_next_link (&context->servers, link);
842 bus_context_ref (BusContext *context)
844 _dbus_assert (context->refcount > 0);
845 context->refcount += 1;
851 bus_context_unref (BusContext *context)
853 _dbus_assert (context->refcount > 0);
854 context->refcount -= 1;
856 if (context->refcount == 0)
860 _dbus_verbose ("Finalizing bus context %p\n", context);
862 bus_context_shutdown (context);
864 if (context->connections)
866 bus_connections_unref (context->connections);
867 context->connections = NULL;
870 if (context->registry)
872 bus_registry_unref (context->registry);
873 context->registry = NULL;
876 if (context->activation)
878 bus_activation_unref (context->activation);
879 context->activation = NULL;
882 link = _dbus_list_get_first_link (&context->servers);
885 dbus_server_unref (link->data);
887 link = _dbus_list_get_next_link (&context->servers, link);
889 _dbus_list_clear (&context->servers);
893 bus_policy_unref (context->policy);
894 context->policy = NULL;
899 _dbus_loop_unref (context->loop);
900 context->loop = NULL;
903 if (context->matchmaker)
905 bus_matchmaker_unref (context->matchmaker);
906 context->matchmaker = NULL;
909 dbus_free (context->config_file);
910 dbus_free (context->type);
911 dbus_free (context->address);
912 dbus_free (context->user);
914 if (context->pidfile)
917 _dbus_string_init_const (&u, context->pidfile);
919 /* Deliberately ignore errors here, since there's not much
920 * we can do about it, and we're exiting anyways.
922 _dbus_delete_file (&u, NULL);
924 dbus_free (context->pidfile);
927 if (context->user_database != NULL)
928 _dbus_user_database_unref (context->user_database);
932 dbus_server_free_data_slot (&server_data_slot);
936 /* type may be NULL */
938 bus_context_get_type (BusContext *context)
940 return context->type;
944 bus_context_get_address (BusContext *context)
946 return context->address;
950 bus_context_get_registry (BusContext *context)
952 return context->registry;
956 bus_context_get_connections (BusContext *context)
958 return context->connections;
962 bus_context_get_activation (BusContext *context)
964 return context->activation;
968 bus_context_get_matchmaker (BusContext *context)
970 return context->matchmaker;
974 bus_context_get_loop (BusContext *context)
976 return context->loop;
980 bus_context_get_user_database (BusContext *context)
982 return context->user_database;
986 bus_context_allow_user (BusContext *context,
989 return bus_policy_allow_user (context->policy,
990 context->user_database,
995 bus_context_get_policy (BusContext *context)
997 return context->policy;
1001 bus_context_create_client_policy (BusContext *context,
1002 DBusConnection *connection,
1005 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1006 return bus_policy_create_client_policy (context->policy, connection,
1011 bus_context_get_activation_timeout (BusContext *context)
1014 return context->limits.activation_timeout;
1018 bus_context_get_auth_timeout (BusContext *context)
1020 return context->limits.auth_timeout;
1024 bus_context_get_max_completed_connections (BusContext *context)
1026 return context->limits.max_completed_connections;
1030 bus_context_get_max_incomplete_connections (BusContext *context)
1032 return context->limits.max_incomplete_connections;
1036 bus_context_get_max_connections_per_user (BusContext *context)
1038 return context->limits.max_connections_per_user;
1042 bus_context_get_max_pending_activations (BusContext *context)
1044 return context->limits.max_pending_activations;
1048 bus_context_get_max_services_per_connection (BusContext *context)
1050 return context->limits.max_services_per_connection;
1054 bus_context_get_max_match_rules_per_connection (BusContext *context)
1056 return context->limits.max_match_rules_per_connection;
1060 bus_context_get_max_replies_per_connection (BusContext *context)
1062 return context->limits.max_replies_per_connection;
1066 bus_context_get_reply_timeout (BusContext *context)
1068 return context->limits.reply_timeout;
1072 * addressed_recipient is the recipient specified in the message.
1074 * proposed_recipient is the recipient we're considering sending
1075 * to right this second, and may be an eavesdropper.
1077 * sender is the sender of the message.
1079 * NULL for proposed_recipient or sender definitely means the bus driver.
1081 * NULL for addressed_recipient may mean the bus driver, or may mean
1082 * no destination was specified in the message (e.g. a signal).
1085 bus_context_check_security_policy (BusContext *context,
1086 BusTransaction *transaction,
1087 DBusConnection *sender,
1088 DBusConnection *addressed_recipient,
1089 DBusConnection *proposed_recipient,
1090 DBusMessage *message,
1093 BusClientPolicy *sender_policy;
1094 BusClientPolicy *recipient_policy;
1096 dbus_bool_t requested_reply;
1098 type = dbus_message_get_type (message);
1100 /* dispatch.c was supposed to ensure these invariants */
1101 _dbus_assert (dbus_message_get_destination (message) != NULL ||
1102 type == DBUS_MESSAGE_TYPE_SIGNAL ||
1103 (sender == NULL && !bus_connection_is_active (proposed_recipient)));
1104 _dbus_assert (type == DBUS_MESSAGE_TYPE_SIGNAL ||
1105 addressed_recipient != NULL ||
1106 strcmp (dbus_message_get_destination (message), DBUS_SERVICE_DBUS) == 0);
1110 case DBUS_MESSAGE_TYPE_METHOD_CALL:
1111 case DBUS_MESSAGE_TYPE_SIGNAL:
1112 case DBUS_MESSAGE_TYPE_METHOD_RETURN:
1113 case DBUS_MESSAGE_TYPE_ERROR:
1117 _dbus_verbose ("security check disallowing message of unknown type %d\n",
1120 dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
1121 "Message bus will not accept messages of unknown type\n");
1126 requested_reply = FALSE;
1132 dest = dbus_message_get_destination (message);
1134 /* First verify the SELinux access controls. If allowed then
1135 * go on with the standard checks.
1137 if (!bus_selinux_allows_send (sender, proposed_recipient,
1138 dbus_message_type_to_string (dbus_message_get_type (message)),
1139 dbus_message_get_interface (message),
1140 dbus_message_get_member (message),
1141 dbus_message_get_error_name (message),
1142 dest ? dest : DBUS_SERVICE_DBUS))
1144 dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
1145 "An SELinux policy prevents this sender "
1146 "from sending this message to this recipient "
1147 "(rejected message had interface \"%s\" "
1148 "member \"%s\" error name \"%s\" destination \"%s\")",
1149 dbus_message_get_interface (message) ?
1150 dbus_message_get_interface (message) : "(unset)",
1151 dbus_message_get_member (message) ?
1152 dbus_message_get_member (message) : "(unset)",
1153 dbus_message_get_error_name (message) ?
1154 dbus_message_get_error_name (message) : "(unset)",
1155 dest ? dest : DBUS_SERVICE_DBUS);
1156 _dbus_verbose ("SELinux security check denying send to service\n");
1160 if (bus_connection_is_active (sender))
1162 sender_policy = bus_connection_get_policy (sender);
1163 _dbus_assert (sender_policy != NULL);
1165 /* Fill in requested_reply variable with TRUE if this is a
1166 * reply and the reply was pending.
1168 if (dbus_message_get_reply_serial (message) != 0)
1170 if (proposed_recipient != NULL /* not to the bus driver */ &&
1171 addressed_recipient == proposed_recipient /* not eavesdropping */)
1175 dbus_error_init (&error2);
1176 requested_reply = bus_connections_check_reply (bus_connection_get_connections (sender),
1178 sender, addressed_recipient, message,
1180 if (dbus_error_is_set (&error2))
1182 dbus_move_error (&error2, error);
1190 /* Policy for inactive connections is that they can only send
1191 * the hello message to the bus driver
1193 if (proposed_recipient == NULL &&
1194 dbus_message_is_method_call (message,
1195 DBUS_INTERFACE_DBUS,
1198 _dbus_verbose ("security check allowing %s message\n",
1204 _dbus_verbose ("security check disallowing non-%s message\n",
1207 dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
1208 "Client tried to send a message other than %s without being registered",
1217 sender_policy = NULL;
1219 /* If the sender is the bus driver, we assume any reply was a
1220 * requested reply as bus driver won't send bogus ones
1222 if (addressed_recipient == proposed_recipient /* not eavesdropping */ &&
1223 dbus_message_get_reply_serial (message) != 0)
1224 requested_reply = TRUE;
1227 _dbus_assert ((sender != NULL && sender_policy != NULL) ||
1228 (sender == NULL && sender_policy == NULL));
1230 if (proposed_recipient != NULL)
1232 /* only the bus driver can send to an inactive recipient (as it
1233 * owns no services, so other apps can't address it). Inactive
1234 * recipients can receive any message.
1236 if (bus_connection_is_active (proposed_recipient))
1238 recipient_policy = bus_connection_get_policy (proposed_recipient);
1239 _dbus_assert (recipient_policy != NULL);
1241 else if (sender == NULL)
1243 _dbus_verbose ("security check using NULL recipient policy for message from bus\n");
1244 recipient_policy = NULL;
1248 _dbus_assert_not_reached ("a message was somehow sent to an inactive recipient from a source other than the message bus\n");
1249 recipient_policy = NULL;
1253 recipient_policy = NULL;
1255 _dbus_assert ((proposed_recipient != NULL && recipient_policy != NULL) ||
1256 (proposed_recipient != NULL && sender == NULL && recipient_policy == NULL) ||
1257 (proposed_recipient == NULL && recipient_policy == NULL));
1259 if (sender_policy &&
1260 !bus_client_policy_check_can_send (sender_policy,
1268 dest = dbus_message_get_destination (message);
1269 dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
1270 "A security policy in place prevents this sender "
1271 "from sending this message to this recipient, "
1272 "see message bus configuration file (rejected message "
1273 "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\")",
1274 dbus_message_get_interface (message) ?
1275 dbus_message_get_interface (message) : "(unset)",
1276 dbus_message_get_member (message) ?
1277 dbus_message_get_member (message) : "(unset)",
1278 dbus_message_get_error_name (message) ?
1279 dbus_message_get_error_name (message) : "(unset)",
1280 dest ? dest : DBUS_SERVICE_DBUS);
1281 _dbus_verbose ("security policy disallowing message due to sender policy\n");
1285 if (recipient_policy &&
1286 !bus_client_policy_check_can_receive (recipient_policy,
1290 addressed_recipient, proposed_recipient,
1295 dest = dbus_message_get_destination (message);
1296 dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
1297 "A security policy in place prevents this recipient "
1298 "from receiving this message from this sender, "
1299 "see message bus configuration file (rejected message "
1300 "had interface \"%s\" member \"%s\" error name \"%s\" destination \"%s\" reply serial %u requested_reply=%d)",
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,
1308 dbus_message_get_reply_serial (message),
1310 _dbus_verbose ("security policy disallowing message due to recipient policy\n");
1314 /* See if limits on size have been exceeded */
1315 if (proposed_recipient &&
1316 dbus_connection_get_outgoing_size (proposed_recipient) >
1317 context->limits.max_outgoing_bytes)
1321 dest = dbus_message_get_destination (message);
1322 dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
1323 "The destination service \"%s\" has a full message queue",
1324 dest ? dest : (proposed_recipient ?
1325 bus_connection_get_name (proposed_recipient) :
1326 DBUS_SERVICE_DBUS));
1327 _dbus_verbose ("security policy disallowing message due to full message queue\n");
1331 if (type == DBUS_MESSAGE_TYPE_METHOD_CALL)
1333 /* Record that we will allow a reply here in the future (don't
1334 * bother if the recipient is the bus). Only the addressed recipient
1337 if (sender && addressed_recipient &&
1338 !bus_connections_expect_reply (bus_connection_get_connections (sender),
1340 sender, addressed_recipient,
1343 _dbus_verbose ("Failed to record reply expectation or problem with the message expecting a reply\n");
1348 _dbus_verbose ("security policy allowing message\n");