diff options
Diffstat (limited to 'bus')
-rw-r--r-- | bus/.gitignore | 1 | ||||
-rw-r--r-- | bus/Makefile.am | 8 | ||||
-rw-r--r-- | bus/activation.c | 63 | ||||
-rw-r--r-- | bus/bus.c | 36 | ||||
-rw-r--r-- | bus/config-parser-common.c | 4 | ||||
-rw-r--r-- | bus/config-parser-common.h | 3 | ||||
-rw-r--r-- | bus/config-parser-trivial.c | 4 | ||||
-rw-r--r-- | bus/config-parser.c | 40 | ||||
-rw-r--r-- | bus/dbus.service.in | 1 | ||||
-rw-r--r-- | bus/dir-watch-inotify.c | 8 | ||||
-rw-r--r-- | bus/driver.c | 184 | ||||
-rw-r--r-- | bus/org.freedesktop.dbus-session.plist.in | 33 | ||||
-rw-r--r-- | bus/signals.c | 34 | ||||
-rw-r--r-- | bus/test-main.c | 124 |
14 files changed, 350 insertions, 193 deletions
diff --git a/bus/.gitignore b/bus/.gitignore index bad51b1d..861dc1f5 100644 --- a/bus/.gitignore +++ b/bus/.gitignore @@ -23,3 +23,4 @@ bus-test-launch-helper bus-test-system dbus.service dbus.socket +org.freedesktop.dbus-session.plist diff --git a/bus/Makefile.am b/bus/Makefile.am index 17c0df8f..efa8ab5b 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -9,12 +9,18 @@ EFENCE= CONFIG_IN_FILES= \ session.conf.in \ - system.conf.in + system.conf.in \ + org.freedesktop.dbus-session.plist.in config_DATA= \ session.conf \ system.conf +if DBUS_ENABLE_LAUNCHD +agentdir=$(LAUNCHD_AGENT_DIR) +agent_DATA=org.freedesktop.dbus-session.plist +endif + if DBUS_USE_LIBXML XML_SOURCES=config-loader-libxml.c endif diff --git a/bus/activation.c b/bus/activation.c index ee5efa8e..7b2a72bc 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -264,6 +264,7 @@ update_desktop_file_entry (BusActivation *activation, DBusStat stat_buf; DBusString file_path; DBusError tmp_error; + dbus_bool_t retval; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -286,14 +287,14 @@ update_desktop_file_entry (BusActivation *activation, !_dbus_concat_dir_and_file (&file_path, filename)) { BUS_SET_OOM (error); - goto failed; + goto out; } if (!_dbus_stat (&file_path, &stat_buf, NULL)) { dbus_set_error (error, DBUS_ERROR_FAILED, "Can't stat the service file\n"); - goto failed; + goto out; } if (!bus_desktop_file_get_string (desktop_file, @@ -301,14 +302,18 @@ update_desktop_file_entry (BusActivation *activation, DBUS_SERVICE_NAME, &name, error)) - goto failed; + goto out; if (!bus_desktop_file_get_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_EXEC, &exec_tmp, error)) - goto failed; + goto out; + + exec = _dbus_strdup (_dbus_replace_install_prefix (exec_tmp)); + dbus_free (exec_tmp); + exec_tmp = NULL; /* user is not _required_ unless we are using system activation */ if (!bus_desktop_file_get_string (desktop_file, @@ -321,7 +326,7 @@ update_desktop_file_entry (BusActivation *activation, if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY)) { dbus_move_error (&tmp_error, error); - goto failed; + goto out; } else { @@ -344,7 +349,7 @@ update_desktop_file_entry (BusActivation *activation, if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY)) { dbus_move_error (&tmp_error, error); - goto failed; + goto out; } else { @@ -360,8 +365,6 @@ update_desktop_file_entry (BusActivation *activation, entry = _dbus_hash_table_lookup_string (s_dir->entries, _dbus_string_get_const_data (filename)); - exec = strdup (_dbus_replace_install_prefix (exec_tmp)); - if (entry == NULL) /* New file */ { /* FIXME we need a better-defined algorithm for which service file to @@ -371,14 +374,14 @@ update_desktop_file_entry (BusActivation *activation, { dbus_set_error (error, DBUS_ERROR_FAILED, "Service %s already exists in activation entry list\n", name); - goto failed; + goto out; } entry = dbus_new0 (BusActivationEntry, 1); if (entry == NULL) { BUS_SET_OOM (error); - goto failed; + goto out; } entry->name = name; @@ -387,18 +390,24 @@ update_desktop_file_entry (BusActivation *activation, entry->systemd_service = systemd_service; entry->refcount = 1; + /* ownership has been transferred to entry, do not free separately */ + name = NULL; + exec = NULL; + user = NULL; + systemd_service = NULL; + entry->s_dir = s_dir; entry->filename = _dbus_strdup (_dbus_string_get_const_data (filename)); if (!entry->filename) { BUS_SET_OOM (error); - goto failed; + goto out; } if (!_dbus_hash_table_insert_string (activation->entries, entry->name, bus_activation_entry_ref (entry))) { BUS_SET_OOM (error); - goto failed; + goto out; } if (!_dbus_hash_table_insert_string (s_dir->entries, entry->filename, bus_activation_entry_ref (entry))) @@ -406,7 +415,7 @@ update_desktop_file_entry (BusActivation *activation, /* Revert the insertion in the entries table */ _dbus_hash_table_remove_string (activation->entries, entry->name); BUS_SET_OOM (error); - goto failed; + goto out; } _dbus_verbose ("Added \"%s\" to list of services\n", entry->name); @@ -420,17 +429,26 @@ update_desktop_file_entry (BusActivation *activation, { _dbus_verbose ("The new service name \"%s\" of service file \"%s\" already in cache, ignoring\n", name, _dbus_string_get_const_data (&file_path)); - goto failed; + goto out; } + /* ownership has been transferred to entry, do not free separately */ dbus_free (entry->name); + entry->name = name; + name = NULL; + dbus_free (entry->exec); + entry->exec = exec; + exec = NULL; + dbus_free (entry->user); + entry->user = user; + user = NULL; + dbus_free (entry->systemd_service); entry->systemd_service = systemd_service; - entry->name = name; - entry->exec = exec; - entry->user = user; + systemd_service = NULL; + if (!_dbus_hash_table_insert_string (activation->entries, entry->name, bus_activation_entry_ref(entry))) { @@ -445,15 +463,12 @@ update_desktop_file_entry (BusActivation *activation, } entry->mtime = stat_buf.mtime; + retval = TRUE; - _dbus_string_free (&file_path); - bus_activation_entry_unref (entry); - - return TRUE; - -failed: +out: + /* if these have been transferred into entry, the variables will be NULL */ dbus_free (name); - dbus_free (exec_tmp); + dbus_free (exec); dbus_free (user); dbus_free (systemd_service); _dbus_string_free (&file_path); @@ -372,11 +372,20 @@ process_config_first_time_only (BusContext *context, if (!credentials) goto oom; if (!_dbus_string_append (&log_prefix, "[session ")) - goto oom; + { + _dbus_credentials_unref (credentials); + goto oom; + } if (!_dbus_credentials_to_string_append (credentials, &log_prefix)) - goto oom; + { + _dbus_credentials_unref (credentials); + goto oom; + } if (!_dbus_string_append (&log_prefix, "] ")) - goto oom; + { + _dbus_credentials_unref (credentials); + goto oom; + } _dbus_credentials_unref (credentials); } if (!_dbus_string_steal_data (&log_prefix, &context->log_prefix)) @@ -618,7 +627,6 @@ list_concat_new (DBusList **a, *result = NULL; - link = _dbus_list_get_first_link (a); for (link = _dbus_list_get_first_link (a); link; link = _dbus_list_get_next_link (a, link)) { if (!_dbus_list_append (result, link->data)) @@ -636,6 +644,24 @@ oom: return FALSE; } +static void +raise_file_descriptor_limit (BusContext *context) +{ + + /* I just picked this out of thin air; we need some extra + * descriptors for things like any internal pipes we create, + * inotify, connections to SELinux, etc. + */ + unsigned int arbitrary_extra_fds = 32; + unsigned int limit; + + limit = context->limits.max_completed_connections + + context->limits.max_incomplete_connections + + arbitrary_extra_fds; + + _dbus_request_file_descriptor_limit (limit); +} + static dbus_bool_t process_config_postinit (BusContext *context, BusConfigParser *parser, @@ -644,6 +670,8 @@ process_config_postinit (BusContext *context, DBusHashTable *service_context_table; DBusList *watched_dirs = NULL; + raise_file_descriptor_limit (context); + service_context_table = bus_config_parser_steal_service_context_table (parser); if (!bus_registry_set_service_context_table (context->registry, service_context_table)) diff --git a/bus/config-parser-common.c b/bus/config-parser-common.c index f8d75be7..c522ff49 100644 --- a/bus/config-parser-common.c +++ b/bus/config-parser-common.c @@ -49,7 +49,7 @@ bus_config_parser_element_name_to_type (const char *name) } else if (strcmp (name, "type") == 0) { - return ELEMENT_TYPE; + return ELEMENT_CONFIGTYPE; } else if (strcmp (name, "fork") == 0) { @@ -169,7 +169,7 @@ bus_config_parser_element_type_to_name (ElementType type) return "servicehelper"; case ELEMENT_INCLUDEDIR: return "includedir"; - case ELEMENT_TYPE: + case ELEMENT_CONFIGTYPE: return "type"; case ELEMENT_SELINUX: return "selinux"; diff --git a/bus/config-parser-common.h b/bus/config-parser-common.h index da745606..186bf4cf 100644 --- a/bus/config-parser-common.h +++ b/bus/config-parser-common.h @@ -41,7 +41,8 @@ typedef enum ELEMENT_SERVICEDIR, ELEMENT_SERVICEHELPER, ELEMENT_INCLUDEDIR, - ELEMENT_TYPE, + /* this is really <type>, but winioctl.h defines ELEMENT_TYPE */ + ELEMENT_CONFIGTYPE, ELEMENT_SELINUX, ELEMENT_ASSOCIATE, ELEMENT_STANDARD_SESSION_SERVICEDIRS, diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c index 59ec2ba2..f37b4fb4 100644 --- a/bus/config-parser-trivial.c +++ b/bus/config-parser-trivial.c @@ -164,7 +164,7 @@ bus_config_parser_start_element (BusConfigParser *parser, { case ELEMENT_SERVICEHELPER: case ELEMENT_USER: - case ELEMENT_TYPE: + case ELEMENT_CONFIGTYPE: /* content about to be handled */ break; @@ -277,7 +277,7 @@ bus_config_parser_content (BusConfigParser *parser, } break; - case ELEMENT_TYPE: + case ELEMENT_CONFIGTYPE: { if (!_dbus_string_copy (&content_sane, 0, &parser->bus_type, 0)) { diff --git a/bus/config-parser.c b/bus/config-parser.c index 2d19f2b9..2543162f 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -30,6 +30,7 @@ #include "selinux.h" #include <dbus/dbus-list.h> #include <dbus/dbus-internals.h> +#include <dbus/dbus-sysdeps.h> #include <string.h> typedef enum @@ -689,12 +690,12 @@ start_busconfig_child (BusConfigParser *parser, return TRUE; } - else if (element_type == ELEMENT_TYPE) + else if (element_type == ELEMENT_CONFIGTYPE) { if (!check_no_attributes (parser, "type", attribute_names, attribute_values, error)) return FALSE; - if (push_element (parser, ELEMENT_TYPE) == NULL) + if (push_element (parser, ELEMENT_CONFIGTYPE) == NULL) { BUS_SET_OOM (error); return FALSE; @@ -2001,7 +2002,7 @@ bus_config_parser_end_element (BusConfigParser *parser, case ELEMENT_INCLUDE: case ELEMENT_USER: - case ELEMENT_TYPE: + case ELEMENT_CONFIGTYPE: case ELEMENT_LISTEN: case ELEMENT_PIDFILE: case ELEMENT_AUTH: @@ -2236,8 +2237,19 @@ include_dir (BusConfigParser *parser, { if (!include_file (parser, &full_path, TRUE, error)) { - _dbus_string_free (&full_path); - goto failed; + if (dbus_error_is_set (error)) + { + /* We log to syslog unconditionally here, because this is + * the configuration parser, so we don't yet know whether + * this bus is going to want to write to syslog! (There's + * also some layer inversion going on, if we want to use + * the bus context.) */ + _dbus_system_log (DBUS_SYSTEM_LOG_INFO, + "Encountered error '%s' while parsing '%s'\n", + error->message, + _dbus_string_get_const_data (&full_path)); + dbus_error_free (error); + } } } @@ -2460,7 +2472,7 @@ bus_config_parser_content (BusConfigParser *parser, } break; - case ELEMENT_TYPE: + case ELEMENT_CONFIGTYPE: { char *s; @@ -3241,15 +3253,15 @@ process_test_equiv_subdir (const DBusString *test_base_dir, static const char *test_session_service_dir_matches[] = { #ifdef DBUS_UNIX + "/testhome/foo/.testlocal/testshare/dbus-1/services", "/testusr/testlocal/testshare/dbus-1/services", "/testusr/testshare/dbus-1/services", -#endif DBUS_DATADIR"/dbus-1/services", -#ifdef DBUS_UNIX - "/testhome/foo/.testlocal/testshare/dbus-1/services", #endif +/* will be filled in test_default_session_servicedirs() */ #ifdef DBUS_WIN NULL, + NULL, #endif NULL }; @@ -3263,6 +3275,16 @@ test_default_session_servicedirs (void) const char *common_progs; int i; +#ifdef DBUS_WIN + char buffer[1024]; + if (_dbus_get_install_root(buffer, sizeof(buffer))) + { + strcat(buffer,DBUS_DATADIR); + strcat(buffer,"/dbus-1/services"); + test_session_service_dir_matches[0] = buffer; + } +#endif + /* On Unix we don't actually use this variable, but it's easier to handle the * deallocation if we always allocate it, whether needed or not */ if (!_dbus_string_init (&progs)) diff --git a/bus/dbus.service.in b/bus/dbus.service.in index 399306f6..8b87a58e 100644 --- a/bus/dbus.service.in +++ b/bus/dbus.service.in @@ -8,3 +8,4 @@ ExecStartPre=@EXPANDED_BINDIR@/dbus-uuidgen --ensure ExecStartPre=-/bin/rm -f @DBUS_SYSTEM_PID_FILE@ ExecStart=@EXPANDED_BINDIR@/dbus-daemon --system --address=systemd: --nofork --systemd-activation ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --system --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig +OOMScoreAdjust=-900 diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index 39eff974..461b8ee3 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -259,7 +259,13 @@ _init_inotify (BusContext *context) goto out; } - _dbus_register_shutdown_func (_shutdown_inotify, NULL); + if (!_dbus_register_shutdown_func (_shutdown_inotify, NULL)) + { + _dbus_warn ("Unable to register shutdown func"); + _dbus_watch_unref (watch); + watch = NULL; + goto out; + } } ret = 1; diff --git a/bus/driver.c b/bus/driver.c index cc8d1f26..425a3d5a 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1644,11 +1644,7 @@ bus_driver_handle_get_id (DBusConnection *connection, return FALSE; } -/* For speed it might be useful to sort this in order of - * frequency of use (but doesn't matter with only a few items - * anyhow) - */ -static struct +typedef struct { const char *name; const char *in_args; @@ -1657,7 +1653,13 @@ static struct BusTransaction *transaction, DBusMessage *message, DBusError *error); -} message_handlers[] = { +} MessageHandler; + +/* For speed it might be useful to sort this in order of + * frequency of use (but doesn't matter with only a few items + * anyhow) + */ +static const MessageHandler dbus_message_handlers[] = { { "Hello", "", DBUS_TYPE_STRING_AS_STRING, @@ -1729,7 +1731,41 @@ static struct { "GetId", "", DBUS_TYPE_STRING_AS_STRING, - bus_driver_handle_get_id } + bus_driver_handle_get_id }, + { NULL, NULL, NULL, NULL } +}; + +static dbus_bool_t bus_driver_handle_introspect (DBusConnection *, + BusTransaction *, DBusMessage *, DBusError *); + +static const MessageHandler introspectable_message_handlers[] = { + { "Introspect", "", DBUS_TYPE_STRING_AS_STRING, bus_driver_handle_introspect }, + { NULL, NULL, NULL, NULL } +}; + +typedef struct { + const char *name; + const MessageHandler *message_handlers; + const char *extra_introspection; +} InterfaceHandler; + +/* These should ideally be sorted by frequency of use, although it + * probably doesn't matter with this few items */ +static InterfaceHandler interface_handlers[] = { + { DBUS_INTERFACE_DBUS, dbus_message_handlers, + " <signal name=\"NameOwnerChanged\">\n" + " <arg type=\"s\"/>\n" + " <arg type=\"s\"/>\n" + " <arg type=\"s\"/>\n" + " </signal>\n" + " <signal name=\"NameLost\">\n" + " <arg type=\"s\"/>\n" + " </signal>\n" + " <signal name=\"NameAcquired\">\n" + " <arg type=\"s\"/>\n" + " </signal>\n" }, + { DBUS_INTERFACE_INTROSPECTABLE, introspectable_message_handlers, NULL }, + { NULL, NULL, NULL } }; static dbus_bool_t @@ -1770,86 +1806,43 @@ write_args_for_direction (DBusString *xml, dbus_bool_t bus_driver_generate_introspect_string (DBusString *xml) { - int i; + const InterfaceHandler *ih; + const MessageHandler *mh; if (!_dbus_string_append (xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE)) return FALSE; if (!_dbus_string_append (xml, "<node>\n")) return FALSE; - if (!_dbus_string_append_printf (xml, " <interface name=\"%s\">\n", DBUS_INTERFACE_INTROSPECTABLE)) - return FALSE; - if (!_dbus_string_append (xml, " <method name=\"Introspect\">\n")) - return FALSE; - if (!_dbus_string_append_printf (xml, " <arg name=\"data\" direction=\"out\" type=\"%s\"/>\n", DBUS_TYPE_STRING_AS_STRING)) - return FALSE; - if (!_dbus_string_append (xml, " </method>\n")) - return FALSE; - if (!_dbus_string_append (xml, " </interface>\n")) - return FALSE; - - if (!_dbus_string_append_printf (xml, " <interface name=\"%s\">\n", - DBUS_INTERFACE_DBUS)) - return FALSE; - i = 0; - while (i < _DBUS_N_ELEMENTS (message_handlers)) + for (ih = interface_handlers; ih->name != NULL; ih++) { - - if (!_dbus_string_append_printf (xml, " <method name=\"%s\">\n", - message_handlers[i].name)) + if (!_dbus_string_append_printf (xml, " <interface name=\"%s\">\n", + ih->name)) return FALSE; - if (!write_args_for_direction (xml, message_handlers[i].in_args, TRUE)) - return FALSE; - - if (!write_args_for_direction (xml, message_handlers[i].out_args, FALSE)) - return FALSE; - - if (!_dbus_string_append (xml, " </method>\n")) - return FALSE; - - ++i; - } - - if (!_dbus_string_append_printf (xml, " <signal name=\"NameOwnerChanged\">\n")) - return FALSE; - - if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) - return FALSE; - - if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) - return FALSE; - - if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) - return FALSE; - - if (!_dbus_string_append_printf (xml, " </signal>\n")) - return FALSE; - - - - if (!_dbus_string_append_printf (xml, " <signal name=\"NameLost\">\n")) - return FALSE; - - if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) - return FALSE; - - if (!_dbus_string_append_printf (xml, " </signal>\n")) - return FALSE; - + for (mh = ih->message_handlers; mh->name != NULL; mh++) + { + if (!_dbus_string_append_printf (xml, " <method name=\"%s\">\n", + mh->name)) + return FALSE; + if (!write_args_for_direction (xml, mh->in_args, TRUE)) + return FALSE; - if (!_dbus_string_append_printf (xml, " <signal name=\"NameAcquired\">\n")) - return FALSE; + if (!write_args_for_direction (xml, mh->out_args, FALSE)) + return FALSE; - if (!_dbus_string_append_printf (xml, " <arg type=\"s\"/>\n")) - return FALSE; + if (!_dbus_string_append (xml, " </method>\n")) + return FALSE; + } - if (!_dbus_string_append_printf (xml, " </signal>\n")) - return FALSE; + if (ih->extra_introspection != NULL && + !_dbus_string_append (xml, ih->extra_introspection)) + return FALSE; - if (!_dbus_string_append (xml, " </interface>\n")) - return FALSE; + if (!_dbus_string_append (xml, " </interface>\n")) + return FALSE; + } if (!_dbus_string_append (xml, "</node>\n")) return FALSE; @@ -1926,7 +1919,9 @@ bus_driver_handle_message (DBusConnection *connection, DBusError *error) { const char *name, *sender, *interface; - int i; + const InterfaceHandler *ih; + const MessageHandler *mh; + dbus_bool_t found_interface = FALSE; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1944,57 +1939,50 @@ bus_driver_handle_message (DBusConnection *connection, return TRUE; /* we just ignore this */ } - if (dbus_message_is_method_call (message, - DBUS_INTERFACE_INTROSPECTABLE, - "Introspect")) - return bus_driver_handle_introspect (connection, transaction, message, error); - + /* may be NULL, which means "any interface will do" */ interface = dbus_message_get_interface (message); - if (interface == NULL) - interface = DBUS_INTERFACE_DBUS; _dbus_assert (dbus_message_get_member (message) != NULL); name = dbus_message_get_member (message); sender = dbus_message_get_sender (message); - if (strcmp (interface, - DBUS_INTERFACE_DBUS) != 0) - { - _dbus_verbose ("Driver got message to unknown interface \"%s\"\n", - interface); - goto unknown; - } - _dbus_verbose ("Driver got a method call: %s\n", dbus_message_get_member (message)); /* security checks should have kept this from getting here */ _dbus_assert (sender != NULL || strcmp (name, "Hello") == 0); - i = 0; - while (i < _DBUS_N_ELEMENTS (message_handlers)) + for (ih = interface_handlers; ih->name != NULL; ih++) { - if (strcmp (message_handlers[i].name, name) == 0) + if (interface != NULL && strcmp (interface, ih->name) != 0) + continue; + + found_interface = TRUE; + + for (mh = ih->message_handlers; mh->name != NULL; mh++) { + if (strcmp (mh->name, name) != 0) + continue; + _dbus_verbose ("Found driver handler for %s\n", name); - if (!dbus_message_has_signature (message, message_handlers[i].in_args)) + if (!dbus_message_has_signature (message, mh->in_args)) { _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_verbose ("Call to %s has wrong args (%s, expected %s)\n", name, dbus_message_get_signature (message), - message_handlers[i].in_args); + mh->in_args); dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, "Call to %s has wrong args (%s, expected %s)\n", name, dbus_message_get_signature (message), - message_handlers[i].in_args); + mh->in_args); _DBUS_ASSERT_ERROR_IS_SET (error); return FALSE; } - if ((* message_handlers[i].handler) (connection, transaction, message, error)) + if ((* mh->handler) (connection, transaction, message, error)) { _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_verbose ("Driver handler succeeded\n"); @@ -2007,15 +1995,13 @@ bus_driver_handle_message (DBusConnection *connection, return FALSE; } } - - ++i; } unknown: _dbus_verbose ("No driver handler for message \"%s\"\n", name); - dbus_set_error (error, DBUS_ERROR_UNKNOWN_METHOD, + dbus_set_error (error, found_interface ? DBUS_ERROR_UNKNOWN_METHOD : DBUS_ERROR_UNKNOWN_INTERFACE, "%s does not understand message %s", DBUS_SERVICE_DBUS, name); diff --git a/bus/org.freedesktop.dbus-session.plist.in b/bus/org.freedesktop.dbus-session.plist.in new file mode 100644 index 00000000..40ff370d --- /dev/null +++ b/bus/org.freedesktop.dbus-session.plist.in @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>Label</key> + <string>org.freedesktop.dbus-session</string> + + <key>ServiceIPC</key> + <true/> + + <!-- Please uncomment on 10.4; OnDemand doesn't work properly there. --> + <!-- + <key>OnDemand</key> + <false /> + --> + + <key>ProgramArguments</key> + <array> + <string>@DBUS_DAEMONDIR@/dbus-daemon</string> + <string>--nofork</string> + <string>--session</string> + </array> + + <key>Sockets</key> + <dict> + <key>unix_domain_listener</key> + <dict> + <key>SecureSocketWithKey</key> + <string>DBUS_LAUNCHD_SESSION_BUS_SOCKET</string> + </dict> + </dict> +</dict> +</plist> diff --git a/bus/signals.c b/bus/signals.c index daf85403..56a7d6c1 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -138,9 +138,36 @@ match_rule_to_string (BusMatchRule *rule) if (rule->flags & BUS_MATCH_MESSAGE_TYPE) { - /* FIXME make type readable */ - if (!_dbus_string_append_printf (&str, "type='%d'", rule->message_type)) - goto nomem; + if (rule->message_type == DBUS_MESSAGE_TYPE_INVALID) + { + if (!_dbus_string_append_printf (&str, "type='INVALID'")) + goto nomem; + } + else if (rule->message_type == DBUS_MESSAGE_TYPE_METHOD_CALL) + { + if (!_dbus_string_append_printf (&str, "type='method_call'")) + goto nomem; + } + else if (rule->message_type == DBUS_MESSAGE_TYPE_METHOD_RETURN) + { + if (!_dbus_string_append_printf (&str, "type='method_return'")) + goto nomem; + } + else if (rule->message_type == DBUS_MESSAGE_TYPE_ERROR) + { + if (!_dbus_string_append_printf (&str, "type='error'")) + goto nomem; + } + else if (rule->message_type == DBUS_MESSAGE_TYPE_SIGNAL) + { + if (!_dbus_string_append_printf (&str, "type='signal'")) + goto nomem; + } + else + { + if (!_dbus_string_append_printf (&str, "type='%d'", rule->message_type)) + goto nomem; + } } if (rule->flags & BUS_MATCH_INTERFACE) @@ -1136,6 +1163,7 @@ bus_matchmaker_new (void) else _dbus_hash_table_unref (p->rules_by_iface); } + dbus_free (matchmaker); return NULL; } diff --git a/bus/test-main.c b/bus/test-main.c index cb0ed008..cab75306 100644 --- a/bus/test-main.c +++ b/bus/test-main.c @@ -79,6 +79,7 @@ main (int argc, char **argv) { #ifdef DBUS_BUILD_TESTS const char *dir; + const char *only; DBusString test_data_dir; progname = argv[0]; @@ -88,6 +89,11 @@ main (int argc, char **argv) else dir = _dbus_getenv ("DBUS_TEST_DATA"); + if (argc > 2) + only = argv[2]; + else + only = NULL; + if (dir == NULL) { fprintf (stderr, "Must specify test data directory as argv[1] or in DBUS_TEST_DATA env variable\n"); @@ -98,55 +104,79 @@ main (int argc, char **argv) if (!_dbus_threads_init_debug ()) die ("initializing debug threads"); - - test_pre_hook (); - printf ("%s: Running expire list test\n", argv[0]); - if (!bus_expire_list_test (&test_data_dir)) - die ("expire list"); - test_post_hook (); - - test_pre_hook (); - printf ("%s: Running config file parser test\n", argv[0]); - if (!bus_config_parser_test (&test_data_dir)) - die ("parser"); - test_post_hook (); - - test_pre_hook (); - printf ("%s: Running policy test\n", argv[0]); - if (!bus_policy_test (&test_data_dir)) - die ("policy"); - test_post_hook (); - - test_pre_hook (); - printf ("%s: Running signals test\n", argv[0]); - if (!bus_signals_test (&test_data_dir)) - die ("signals"); - test_post_hook (); - - test_pre_hook (); - printf ("%s: Running SHA1 connection test\n", argv[0]); - if (!bus_dispatch_sha1_test (&test_data_dir)) - die ("sha1"); - test_post_hook (); - - test_pre_hook (); - printf ("%s: Running message dispatch test\n", argv[0]); - if (!bus_dispatch_test (&test_data_dir)) - die ("dispatch"); - test_post_hook (); - - test_pre_hook (); - printf ("%s: Running service files reloading test\n", argv[0]); - if (!bus_activation_service_reload_test (&test_data_dir)) - die ("service reload"); - test_post_hook (); + + if (only == NULL || strcmp (only, "expire-list") == 0) + { + test_pre_hook (); + printf ("%s: Running expire list test\n", argv[0]); + if (!bus_expire_list_test (&test_data_dir)) + die ("expire list"); + test_post_hook (); + } + + if (only == NULL || strcmp (only, "config-parser") == 0) + { + test_pre_hook (); + printf ("%s: Running config file parser test\n", argv[0]); + if (!bus_config_parser_test (&test_data_dir)) + die ("parser"); + test_post_hook (); + } + + if (only == NULL || strcmp (only, "policy") == 0) + { + test_pre_hook (); + printf ("%s: Running policy test\n", argv[0]); + if (!bus_policy_test (&test_data_dir)) + die ("policy"); + test_post_hook (); + } + + if (only == NULL || strcmp (only, "signals") == 0) + { + test_pre_hook (); + printf ("%s: Running signals test\n", argv[0]); + if (!bus_signals_test (&test_data_dir)) + die ("signals"); + test_post_hook (); + } + + if (only == NULL || strcmp (only, "dispatch-sha1") == 0) + { + test_pre_hook (); + printf ("%s: Running SHA1 connection test\n", argv[0]); + if (!bus_dispatch_sha1_test (&test_data_dir)) + die ("sha1"); + test_post_hook (); + } + + if (only == NULL || strcmp (only, "dispatch") == 0) + { + test_pre_hook (); + printf ("%s: Running message dispatch test\n", argv[0]); + if (!bus_dispatch_test (&test_data_dir)) + die ("dispatch"); + test_post_hook (); + } + + if (only == NULL || strcmp (only, "activation-service-reload") == 0) + { + test_pre_hook (); + printf ("%s: Running service files reloading test\n", argv[0]); + if (!bus_activation_service_reload_test (&test_data_dir)) + die ("service reload"); + test_post_hook (); + } #ifdef HAVE_UNIX_FD_PASSING - test_pre_hook (); - printf ("%s: Running unix fd passing test\n", argv[0]); - if (!bus_unix_fds_passing_test (&test_data_dir)) - die ("unix fd passing"); - test_post_hook (); + if (only == NULL || strcmp (only, "unix-fds-passing") == 0) + { + test_pre_hook (); + printf ("%s: Running unix fd passing test\n", argv[0]); + if (!bus_unix_fds_passing_test (&test_data_dir)) + die ("unix fd passing"); + test_post_hook (); + } #endif printf ("%s: Success\n", argv[0]); |