diff options
Diffstat (limited to 'bus')
-rw-r--r-- | bus/Makefile.in | 7 | ||||
-rw-r--r-- | bus/activation.c | 63 | ||||
-rw-r--r-- | bus/bus.c | 36 | ||||
-rw-r--r-- | bus/config-parser.c | 30 | ||||
-rw-r--r-- | bus/dbus.service.in | 1 | ||||
-rw-r--r-- | bus/dir-watch-inotify.c | 8 | ||||
-rw-r--r-- | bus/signals.c | 34 | ||||
-rw-r--r-- | bus/test-main.c | 124 |
8 files changed, 218 insertions, 85 deletions
diff --git a/bus/Makefile.in b/bus/Makefile.in index 7ea6fe64..d79ee5f6 100644 --- a/bus/Makefile.in +++ b/bus/Makefile.in @@ -56,10 +56,11 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/rc.messagebus.in $(srcdir)/session.conf.in \ $(srcdir)/system.conf.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ + $(top_srcdir)/m4/compiler.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in + $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -385,6 +386,8 @@ EXPANDED_PREFIX = @EXPANDED_PREFIX@ EXPANDED_SYSCONFDIR = @EXPANDED_SYSCONFDIR@ FGREP = @FGREP@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ 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.c b/bus/config-parser.c index 2d19f2b9..dd941e35 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 @@ -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); + } } } @@ -3243,13 +3255,13 @@ static const char *test_session_service_dir_matches[] = #ifdef DBUS_UNIX "/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/signals.c b/bus/signals.c index 6f97b2b3..c85a88df 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -135,9 +135,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) @@ -1102,6 +1129,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]); |