diff options
46 files changed, 2135 insertions, 799 deletions
@@ -321,8 +321,22 @@ rules are: No reviewer should approve a patch without these attributes, and failure on these points is grounds for reverting the patch. -The reviewer group that can approve patches: Havoc Pennington, Michael -Meeks, Alex Larsson, Zack Rusin, Joe Shaw, Mikael Hallendal, Richard -Hult, Owen Fraser-Green, Olivier Andrieu, Colin Walters, Thiago -Macieira, John Palmieri, Scott James Remnant. +The reviewer group that can approve patches: + +Havoc Pennington <hp@pobox.net> +Michael Meeks <michael.meeks@novell.com> +Alexander Larsson <alexl@redhat.com> +Zack Rusin <zack@kde.org> +Joe Shaw <joe@assbarn.com> +Mikael Hallendal <micke@imendio.com> +Richard Hult <richard@imendio.com> +Owen Fraser-Green <owen@discobabe.net> +Olivier Andrieu <oliv__a@users.sourceforge.net> +Colin Walters <walters@verbum.org> +Thiago Macieira <thiago@kde.org> +John Palmieri <johnp@redhat.com> +Scott James Remnant <scott@netsplit.com> +Will Thompson <will.thompson@collabora.co.uk> +Simon McVittie <simon.mcvittie@collabora.co.uk> + diff --git a/bus/Makefile.am b/bus/Makefile.am index b1ee36c8..c44fe6a7 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -3,7 +3,7 @@ configdir=$(sysconfdir)/dbus-1 INCLUDES=-I$(top_srcdir) $(DBUS_BUS_CFLAGS) @PIE_CFLAGS@ \ -DDBUS_SYSTEM_CONFIG_FILE=\""$(configdir)/system.conf"\" \ - -DDAEMON_NAME=\"dbus-daemon\" -DDBUS_COMPILATION + -DDBUS_COMPILATION EFENCE= @@ -103,8 +103,8 @@ dbus_daemon_launch_helper_SOURCES= \ $(LAUNCH_HELPER_SOURCES) dbus_daemon_launch_helper_LDADD= \ - $(DBUS_LAUNCHER_LIBS) \ - $(top_builddir)/dbus/libdbus-convenience.la + $(top_builddir)/dbus/libdbus-convenience.la \ + $(DBUS_LAUNCHER_LIBS) dbus_daemon_launch_helper_LDFLAGS=@R_DYNAMIC_LDFLAG@ @SECTION_LDFLAGS@ @@ -115,8 +115,8 @@ dbus_daemon_launch_helper_test_SOURCES= \ $(LAUNCH_HELPER_SOURCES) dbus_daemon_launch_helper_test_LDADD= \ - $(DBUS_LAUNCHER_LIBS) \ - $(top_builddir)/dbus/libdbus-convenience.la + $(top_builddir)/dbus/libdbus-convenience.la \ + $(DBUS_LAUNCHER_LIBS) dbus_daemon_launch_helper_test_LDFLAGS=@R_DYNAMIC_LDFLAG@ @SECTION_LDFLAGS@ dbus_daemon_launch_helper_test_CPPFLAGS= \ @@ -129,8 +129,8 @@ bus_test_launch_helper_SOURCES= \ $(LAUNCH_HELPER_SOURCES) bus_test_launch_helper_LDADD= \ - $(DBUS_LAUNCHER_LIBS) \ - $(top_builddir)/dbus/libdbus-convenience.la + $(top_builddir)/dbus/libdbus-convenience.la \ + $(DBUS_LAUNCHER_LIBS) bus_test_launch_helper_LDFLAGS=@R_DYNAMIC_LDFLAG@ @SECTION_LDFLAGS@ bus_test_launch_helper_CPPFLAGS= \ diff --git a/bus/activation.c b/bus/activation.c index 00caac27..0a28df16 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -735,74 +735,56 @@ out: return retval; } -BusActivation* -bus_activation_new (BusContext *context, - const DBusString *address, - DBusList **directories, - DBusError *error) +dbus_bool_t +bus_activation_reload (BusActivation *activation, + const DBusString *address, + DBusList **directories, + DBusError *error) { - BusActivation *activation; DBusList *link; char *dir; - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - activation = dbus_new0 (BusActivation, 1); - if (activation == NULL) - { - BUS_SET_OOM (error); - return NULL; - } - - activation->refcount = 1; - activation->context = context; - activation->n_pending_activations = 0; - + + if (activation->server_address != NULL) + dbus_free (activation->server_address); if (!_dbus_string_copy_data (address, &activation->server_address)) { BUS_SET_OOM (error); goto failed; } - + + if (activation->entries != NULL) + _dbus_hash_table_unref (activation->entries); activation->entries = _dbus_hash_table_new (DBUS_HASH_STRING, NULL, (DBusFreeFunction)bus_activation_entry_unref); if (activation->entries == NULL) - { - BUS_SET_OOM (error); - goto failed; - } - - activation->pending_activations = _dbus_hash_table_new (DBUS_HASH_STRING, NULL, - (DBusFreeFunction)bus_pending_activation_unref); - - if (activation->pending_activations == NULL) { BUS_SET_OOM (error); goto failed; } + if (activation->directories != NULL) + _dbus_hash_table_unref (activation->directories); activation->directories = _dbus_hash_table_new (DBUS_HASH_STRING, NULL, (DBusFreeFunction)bus_service_directory_unref); - - if (activation->directories == NULL) + + if (activation->directories == NULL) { BUS_SET_OOM (error); goto failed; } - - /* Load service files */ + link = _dbus_list_get_first_link (directories); while (link != NULL) { BusServiceDirectory *s_dir; - + dir = _dbus_strdup ((const char *) link->data); if (!dir) { BUS_SET_OOM (error); goto failed; } - + s_dir = dbus_new0 (BusServiceDirectory, 1); if (!s_dir) { @@ -813,7 +795,7 @@ bus_activation_new (BusContext *context, s_dir->refcount = 1; s_dir->dir_c = dir; - + s_dir->entries = _dbus_hash_table_new (DBUS_HASH_STRING, NULL, (DBusFreeFunction)bus_activation_entry_unref); @@ -833,8 +815,8 @@ bus_activation_new (BusContext *context, /* only fail on OOM, it is ok if we can't read the directory */ if (!update_directory (activation, s_dir, error)) - { - if (dbus_error_has_name (error, DBUS_ERROR_NO_MEMORY)) + { + if (dbus_error_has_name (error, DBUS_ERROR_NO_MEMORY)) goto failed; else dbus_error_free (error); @@ -843,10 +825,52 @@ bus_activation_new (BusContext *context, link = _dbus_list_get_next_link (directories, link); } + return TRUE; + failed: + return FALSE; +} + +BusActivation* +bus_activation_new (BusContext *context, + const DBusString *address, + DBusList **directories, + DBusError *error) +{ + BusActivation *activation; + DBusList *link; + char *dir; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + activation = dbus_new0 (BusActivation, 1); + if (activation == NULL) + { + BUS_SET_OOM (error); + return NULL; + } + + activation->refcount = 1; + activation->context = context; + activation->n_pending_activations = 0; + + if (!bus_activation_reload (activation, address, directories, error)) + goto failed; + + /* Initialize this hash table once, we don't want to lose pending + * activations on reload. */ + activation->pending_activations = _dbus_hash_table_new (DBUS_HASH_STRING, NULL, + (DBusFreeFunction)bus_pending_activation_unref); + + if (activation->pending_activations == NULL) + { + BUS_SET_OOM (error); + goto failed; + } + activation->environment = _dbus_hash_table_new (DBUS_HASH_STRING, (DBusFreeFunction) dbus_free, (DBusFreeFunction) dbus_free); - + if (activation->environment == NULL) { BUS_SET_OOM (error); diff --git a/bus/activation.h b/bus/activation.h index 2dff812a..03bfed28 100644 --- a/bus/activation.h +++ b/bus/activation.h @@ -32,6 +32,10 @@ BusActivation* bus_activation_new (BusContext *context, const DBusString *address, DBusList **directories, DBusError *error); +dbus_bool_t bus_activation_reload (BusActivation *activation, + const DBusString *address, + DBusList **directories, + DBusError *error); BusActivation* bus_activation_ref (BusActivation *activation); void bus_activation_unref (BusActivation *activation); @@ -444,6 +444,8 @@ process_config_every_time (BusContext *context, /* get our limits and timeout lengths */ bus_config_parser_get_limits (parser, &context->limits); + if (context->policy) + bus_policy_unref (context->policy); context->policy = bus_config_parser_steal_policy (parser); _dbus_assert (context->policy != NULL); @@ -507,26 +509,24 @@ process_config_every_time (BusContext *context, dbus_free(context->servicehelper); context->servicehelper = s; } - + /* Create activation subsystem */ - new_activation = bus_activation_new (context, &full_address, - dirs, error); - if (new_activation == NULL) + if (context->activation) + { + if (!bus_activation_reload (context->activation, &full_address, dirs, error)) + goto failed; + } + else + { + context->activation = bus_activation_new (context, &full_address, dirs, error); + } + + if (context->activation == NULL) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; } - if (is_reload) - bus_activation_unref (context->activation); - - context->activation = new_activation; - - /* Drop existing conf-dir watches (if applicable) */ - - if (is_reload) - bus_drop_all_directory_watches (); - _DBUS_ASSERT_ERROR_IS_CLEAR (error); retval = TRUE; @@ -557,9 +557,7 @@ process_config_postinit (BusContext *context, _dbus_hash_table_unref (service_context_table); /* Watch all conf directories */ - _dbus_list_foreach (bus_config_parser_get_conf_dirs (parser), - (DBusForeachFunction) bus_watch_directory, - context); + bus_set_watched_dirs (context, bus_config_parser_get_conf_dirs (parser)); return TRUE; } @@ -594,7 +592,7 @@ bus_context_new (const DBusString *config_file, context->refcount = 1; _dbus_generate_uuid (&context->uuid); - + if (!_dbus_string_copy_data (config_file, &context->config_file)) { BUS_SET_OOM (error); diff --git a/bus/dir-watch-default.c b/bus/dir-watch-default.c index 6f8f1e99..ff70d080 100644 --- a/bus/dir-watch-default.c +++ b/bus/dir-watch-default.c @@ -38,3 +38,7 @@ void bus_watch_directory (const char *dir, BusContext *context) { } + +void bus_set_watched_dirs(BusContext *context, DBusList **dirs) +{ +} diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index ee580d74..f457ea8e 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -33,6 +33,7 @@ #include <errno.h> #include <dbus/dbus-internals.h> +#include <dbus/dbus-list.h> #include <dbus/dbus-watch.h> #include "dir-watch.h" @@ -42,6 +43,7 @@ /* use a static array to avoid handling OOM */ static int wds[MAX_DIRS_TO_WATCH]; +static char *dirs[MAX_DIRS_TO_WATCH]; static int num_wds = 0; static int inotify_fd = -1; static DBusWatch *watch = NULL; @@ -89,81 +91,173 @@ _handle_inotify_watch (DBusWatch *passed_watch, unsigned int flags, void *data) return TRUE; } -void -bus_watch_directory (const char *dir, BusContext *context) +#include <stdio.h> + +static void +_set_watched_dirs_internal (DBusList **directories) { - int wd; + int new_wds[MAX_DIRS_TO_WATCH]; + char *new_dirs[MAX_DIRS_TO_WATCH]; + DBusList *link; + int i, j, wd; - _dbus_assert (dir != NULL); + for (i = 0; i < MAX_DIRS_TO_WATCH; i++) + { + new_wds[i] = -1; + new_dirs[i] = NULL; + } - if (inotify_fd == -1) { -#ifdef HAVE_INOTIFY_INIT1 - inotify_fd = inotify_init1 (IN_CLOEXEC); -#else - inotify_fd = inotify_init (); -#endif - if (inotify_fd <= 0) { - _dbus_warn ("Cannot initialize inotify\n"); - goto out; - } - loop = bus_context_get_loop (context); - - watch = _dbus_watch_new (inotify_fd, DBUS_WATCH_READABLE, TRUE, - _handle_inotify_watch, NULL, NULL); - - if (watch == NULL) - { - _dbus_warn ("Unable to create inotify watch\n"); - goto out; - } - - if (!_dbus_loop_add_watch (loop, watch, _inotify_watch_callback, - NULL, NULL)) - { - _dbus_warn ("Unable to add reload watch to main loop"); - _dbus_watch_unref (watch); - watch = NULL; - goto out; - } - } - - if (num_wds >= MAX_DIRS_TO_WATCH ) + i = 0; + link = _dbus_list_get_first_link (directories); + while (link != NULL) { - _dbus_warn ("Cannot watch config directory '%s'. Already watching %d directories\n", dir, MAX_DIRS_TO_WATCH); - goto out; + new_dirs[i++] = (char *)link->data; + link = _dbus_list_get_next_link (directories, link); } - wd = inotify_add_watch (inotify_fd, dir, IN_CLOSE_WRITE | IN_DELETE | IN_MOVED_TO | IN_MOVED_FROM); - if (wd < 0) + /* Look for directories in both the old and new sets, if + * we find one, move its data into the new set. + */ + for (i = 0; new_dirs[i]; i++) { - _dbus_warn ("Cannot setup inotify for '%s'; error '%s'\n", dir, _dbus_strerror (errno)); - goto out; + for (j = 0; j < num_wds; j++) + { + if (dirs[j] && strcmp (new_dirs[i], dirs[j]) == 0) + { + new_wds[i] = wds[j]; + new_dirs[i] = dirs[j]; + wds[j] = -1; + dirs[j] = NULL; + break; + } + } } - wds[num_wds++] = wd; - _dbus_verbose ("Added watch on config directory '%s'\n", dir); + /* Any directories we find in "wds" with a nonzero fd must + * not be in the new set, so perform cleanup now. + */ + for (j = 0; j < num_wds; j++) + { + if (wds[j] != -1) + { + inotify_rm_watch (inotify_fd, wds[j]); + dbus_free (dirs[j]); + wds[j] = -1; + dirs[j] = NULL; + } + } - out: - ; + for (i = 0; new_dirs[i]; i++) + { + if (new_wds[i] == -1) + { + /* FIXME - less lame error handling for failing to add a watch; we may need to sleep. */ + wd = inotify_add_watch (inotify_fd, new_dirs[i], IN_CLOSE_WRITE | IN_DELETE | IN_MOVED_TO | IN_MOVED_FROM); + if (wd < 0) + { + _dbus_warn ("Cannot setup inotify for '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno)); + goto out; + } + new_wds[i] = wd; + new_dirs[i] = _dbus_strdup (new_dirs[i]); + if (!new_dirs[i]) + { + /* FIXME have less lame handling for OOM, we just silently fail to + * watch. (In reality though, the whole OOM handling in dbus is stupid + * but we won't go into that in this comment =) ) + */ + inotify_rm_watch (inotify_fd, wd); + new_wds[i] = -1; + } + } + } + + num_wds = i; + + for (i = 0; i < MAX_DIRS_TO_WATCH; i++) + { + wds[i] = new_wds[i]; + dirs[i] = new_dirs[i]; + } + + out:; } -void -bus_drop_all_directory_watches (void) +#include <stdio.h> +static void +_shutdown_inotify (void *data) { - int ret; + DBusList *empty = NULL; + + if (inotify_fd == -1) + return; + _set_watched_dirs_internal (&empty); + + close (inotify_fd); + inotify_fd = -1; if (watch != NULL) { _dbus_loop_remove_watch (loop, watch, _inotify_watch_callback, NULL); _dbus_watch_unref (watch); - watch = NULL; + _dbus_loop_unref (loop); } + watch = NULL; + loop = NULL; +} - _dbus_verbose ("Dropping all watches on config directories\n"); - ret = close (inotify_fd); - if (ret) - _dbus_verbose ("Error dropping watches: '%s'\n", _dbus_strerror(errno)); +static int +_init_inotify (BusContext *context) +{ + int ret = 0; - num_wds = 0; - inotify_fd = -1; + if (inotify_fd == -1) + { +#ifdef HAVE_INOTIFY_INIT1 + inotify_fd = inotify_init1 (IN_CLOEXEC); +#else + inotify_fd = inotify_init (); +#endif + if (inotify_fd <= 0) + { + _dbus_warn ("Cannot initialize inotify\n"); + goto out; + } + loop = bus_context_get_loop (context); + _dbus_loop_ref (loop); + + watch = _dbus_watch_new (inotify_fd, DBUS_WATCH_READABLE, TRUE, + _handle_inotify_watch, NULL, NULL); + + if (watch == NULL) + { + _dbus_warn ("Unable to create inotify watch\n"); + goto out; + } + + if (!_dbus_loop_add_watch (loop, watch, _inotify_watch_callback, + NULL, NULL)) + { + _dbus_warn ("Unable to add reload watch to main loop"); + _dbus_watch_unref (watch); + watch = NULL; + goto out; + } + + _dbus_register_shutdown_func (_shutdown_inotify, NULL); + } + + ret = 1; + +out: + return ret; +} + +void +bus_set_watched_dirs (BusContext *context, DBusList **directories) +{ + if (!_init_inotify (context)) + return; + + _set_watched_dirs_internal (directories); } diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c index 16741dd0..7c18a3c9 100644 --- a/bus/dir-watch-kqueue.c +++ b/bus/dir-watch-kqueue.c @@ -37,12 +37,14 @@ #include <dbus/dbus-watch.h> #include <dbus/dbus-internals.h> +#include <dbus/dbus-list.h> #include "dir-watch.h" #define MAX_DIRS_TO_WATCH 128 static int kq = -1; static int fds[MAX_DIRS_TO_WATCH]; +static char *dirs[MAX_DIRS_TO_WATCH]; static int num_fds = 0; static DBusWatch *watch = NULL; static DBusLoop *loop = NULL; @@ -90,13 +92,10 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data) return TRUE; } -void -bus_watch_directory (const char *dir, BusContext *context) +static int +_init_kqueue (BusContext *context) { - int fd; - struct kevent ev; - - _dbus_assert (dir != NULL); + int ret = 0; if (kq < 0) { @@ -133,49 +132,114 @@ bus_watch_directory (const char *dir, BusContext *context) } } - if (num_fds >= MAX_DIRS_TO_WATCH ) + ret = 1; + +out: + return ret; +} + +void +bus_set_watched_dir (BusContext *context, DBusList **directories) +{ + int new_fds[MAX_DIRS_TO_WATCH]; + char *new_dirs[MAX_DIRS_TO_WATCH]; + DBusList *link; + int i, f, fd; + + if (!_init_kqueue (context)) + goto out; + + for (i = 0; i < MAX_DIRS_TO_WATCH; i++) { { - _dbus_warn ("Cannot watch config directory '%s'. Already watching %d directories\n", dir, MAX_DIRS_TO_WATCH); - goto out; + new_fds[i] = -1; + new_dirs[i] = NULL; } - fd = open (dir, O_RDONLY); - if (fd < 0) + i = 0; + link = _dbus_list_get_first_link (directories); + while (link != NULL) { - _dbus_warn ("Cannot open directory '%s'; error '%s'\n", dir, _dbus_strerror (errno)); - goto out; + new_dirs[i++] = (char *)link->data; + link = _dbus_list_get_next_link (directories, link); } - EV_SET (&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, - NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_RENAME, 0, 0); - if (kevent (kq, &ev, 1, NULL, 0, NULL) == -1) + /* Look for directories in both the old and new sets, if + * we find one, move its data into the new set. + */ + for (i = 0; new_dirs[i]; i++) { - _dbus_warn ("Cannot setup a kevent for '%s'; error '%s'\n", dir, _dbus_strerror (errno)); - close (fd); - goto out; + for (j = 0; i < num_fds; j++) + { + if (dirs[j] && strcmp (new_dirs[i], dirs[j]) == 0) + { + new_fds[i] = fds[j]; + new_dirs[i] = dirs[j]; + fds[j] = -1; + dirs[j] = NULL; + break; + } + } } - fds[num_fds++] = fd; - _dbus_verbose ("Added kqueue watch on config directory '%s'\n", dir); - - out: - ; -} - -void -bus_drop_all_directory_watches (void) -{ - int i; - - _dbus_verbose ("Dropping all watches on config directories\n"); + /* Any directory we find in "fds" with a nonzero fd must + * not be in the new set, so perform cleanup now. + */ + for (j = 0; j < num_fds; j++) + { + if (fds[j] != -1) + { + close (fds[j]); + dbus_free (dirs[j]); + fds[j] = -1; + dirs[j] = NULL; + } + } - for (i = 0; i < num_fds; i++) + for (i = 0; new_dirs[i]; i++) { - if (close (fds[i]) != 0) + if (new_fds[i] == -1) { - _dbus_verbose ("Error closing fd %d for config directory watch\n", fds[i]); + /* FIXME - less lame error handling for failing to add a watch; + * we may need to sleep. + */ + fd = open (new_dirs[i], O_RDONLY); + if (fd < 0) + { + _dbus_warn ("Cannot open directory '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno)); + goto out; + } + + EV_SET (&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, + NOTE_DELETE | NOTE_EXTEND | NOTE_WRITE | NOTE_RENAME, 0, 0); + if (kevent (kq, &ev, 1, NULL, 0, NULL) == -1) + { + _dbus_warn ("Cannot setup a kevent for '%s'; error '%s'\n", dir, _dbus_strerror (errno)); + close (fd); + goto out; + } + + new_fds[i] = fd; + new_dirs[i] = _dbus_strdup (new_dirs[i]); + if (!new_dirs[i]) + { + /* FIXME have less lame handling for OOM, we just silently fail to + * watch. (In reality though, the whole OOM handling in dbus is + * stupid but we won't go into that in this comment =) ) + */ + close (fd); + new_fds[i] = -1; + } } } - num_fds = 0; + num_fds = i; + + for (i = 0; i < MAX_DIRS_TO_WATCH; i++) + { + fds[i] = new_fds[i]; + dirs[i] = new_dirs[i]; + } + + out: + ; } diff --git a/bus/dir-watch.h b/bus/dir-watch.h index 8e322a6e..b44529e5 100644 --- a/bus/dir-watch.h +++ b/bus/dir-watch.h @@ -26,10 +26,15 @@ #ifndef DIR_WATCH_H #define DIR_WATCH_H -/* setup a watch on a directory (OS dependent, may be a NOP) */ -void bus_watch_directory (const char *directory, BusContext *context); - -/* drop all the watches previously set up by bus_config_watch_directory (OS dependent, may be a NOP) */ -void bus_drop_all_directory_watches (void); +/** + * Update the set of directories to monitor for changes. The + * operating-system-specific implementation of this function should + * avoid creating a window where a directory in both the + * old and new set isn't monitored. + * + * @param context The bus context + * @param dirs List of strings which are directory paths + */ +void bus_set_watched_dirs (BusContext *context, DBusList **dirs); #endif /* DIR_WATCH_H */ @@ -74,7 +74,7 @@ signal_handler (int sig) static void usage (void) { - fprintf (stderr, DAEMON_NAME " [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork] [--introspect]\n"); + fprintf (stderr, DBUS_DAEMON_NAME " [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork] [--introspect]\n"); exit (1); } @@ -298,7 +298,6 @@ main (int argc, char **argv) } else if (strcmp (arg, "--session") == 0) { - is_session_bus = TRUE; check_two_config_files (&config_file, "session"); if (!_dbus_append_session_config_file (&config_file)) @@ -455,6 +454,9 @@ main (int argc, char **argv) exit (1); } + is_session_bus = bus_context_get_type(context) != NULL + && strcmp(bus_context_get_type(context),"session") == 0; + if (is_session_bus) _dbus_daemon_publish_session_bus_address (bus_context_get_address (context)); diff --git a/bus/messagebus.in b/bus/messagebus.in index b55d6e6d..1f1004b1 100755 --- a/bus/messagebus.in +++ b/bus/messagebus.in @@ -2,7 +2,7 @@ # # messagebus: The D-BUS systemwide message bus # -# chkconfig: 345 97 03 +# chkconfig: 345 22 85 # description: This is a daemon which broadcasts notifications of system events \ # and other messages. See http://www.freedesktop.org/software/dbus/ # diff --git a/bus/selinux.c b/bus/selinux.c index df9a00b1..996cf1d8 100644 --- a/bus/selinux.c +++ b/bus/selinux.c @@ -22,6 +22,9 @@ */ #include <dbus/dbus-internals.h> #include <dbus/dbus-string.h> +#ifndef DBUS_WIN +#include <dbus/dbus-userdb.h> +#endif #include "selinux.h" #include "services.h" #include "policy.h" @@ -44,7 +47,9 @@ #include <signal.h> #include <stdarg.h> #include <stdio.h> +#include <grp.h> #ifdef HAVE_LIBAUDIT +#include <cap-ng.h> #include <libaudit.h> #endif /* HAVE_LIBAUDIT */ #endif /* HAVE_SELINUX */ @@ -143,13 +148,17 @@ log_callback (const char *fmt, ...) #ifdef HAVE_LIBAUDIT if (audit_fd >= 0) { - char buf[PATH_MAX*2]; + capng_get_caps_process(); + if (capng_have_capability(CAPNG_EFFECTIVE, CAP_AUDIT_WRITE)) + { + char buf[PATH_MAX*2]; - /* FIXME: need to change this to show real user */ - vsnprintf(buf, sizeof(buf), fmt, ap); - audit_log_user_avc_message(audit_fd, AUDIT_USER_AVC, buf, NULL, NULL, + /* FIXME: need to change this to show real user */ + vsnprintf(buf, sizeof(buf), fmt, ap); + audit_log_user_avc_message(audit_fd, AUDIT_USER_AVC, buf, NULL, NULL, NULL, getuid()); - return; + return; + } } #endif /* HAVE_LIBAUDIT */ @@ -1010,3 +1019,74 @@ bus_selinux_shutdown (void) #endif /* HAVE_SELINUX */ } +/* The !HAVE_LIBAUDIT case lives in dbus-sysdeps-util-unix.c */ +#ifdef HAVE_LIBAUDIT +/** + * Changes the user and group the bus is running as. + * + * @param user the user to become + * @param error return location for errors + * @returns #FALSE on failure + */ +dbus_bool_t +_dbus_change_to_daemon_user (const char *user, + DBusError *error) +{ + dbus_uid_t uid; + dbus_gid_t gid; + DBusString u; + + _dbus_string_init_const (&u, user); + + if (!_dbus_get_user_id_and_primary_group (&u, &uid, &gid)) + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "User '%s' does not appear to exist?", + user); + return FALSE; + } + + /* If we were root */ + if (_dbus_geteuid () == 0) + { + int rc; + + capng_clear (CAPNG_SELECT_BOTH); + capng_update (CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, + CAP_AUDIT_WRITE); + rc = capng_change_id (uid, gid, 0); + if (rc) + { + switch (rc) { + default: + dbus_set_error (error, DBUS_ERROR_FAILED, + "Failed to drop capabilities: %s\n", + _dbus_strerror (errno)); + break; + case -4: + dbus_set_error (error, _dbus_error_from_errno (errno), + "Failed to set GID to %lu: %s", gid, + _dbus_strerror (errno)); + break; + case -5: + _dbus_warn ("Failed to drop supplementary groups: %s\n", + _dbus_strerror (errno)); + break; + case -6: + dbus_set_error (error, _dbus_error_from_errno (errno), + "Failed to set UID to %lu: %s", uid, + _dbus_strerror (errno)); + break; + case -7: + dbus_set_error (error, _dbus_error_from_errno (errno), + "Failed to unset keep-capabilities: %s\n", + _dbus_strerror (errno)); + break; + } + return FALSE; + } + } + + return TRUE; +} +#endif diff --git a/bus/signals.c b/bus/signals.c index b020a76c..dbfbb5c2 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -1018,25 +1018,173 @@ bus_match_rule_parse (DBusConnection *matches_go_to, return rule; } +typedef struct RulePool RulePool; +struct RulePool +{ + /* Maps non-NULL interface names to non-NULL (DBusList **)s */ + DBusHashTable *rules_by_iface; + + /* List of BusMatchRules which don't specify an interface */ + DBusList *rules_without_iface; +}; + struct BusMatchmaker { int refcount; - DBusList *all_rules; + /* Pools of rules, grouped by the type of message they match. 0 + * (DBUS_MESSAGE_TYPE_INVALID) represents rules that do not specify a message + * type. + */ + RulePool rules_by_type[DBUS_NUM_MESSAGE_TYPES]; }; +static void +rule_list_free (DBusList **rules) +{ + while (*rules != NULL) + { + BusMatchRule *rule; + + rule = (*rules)->data; + bus_match_rule_unref (rule); + _dbus_list_remove_link (rules, *rules); + } +} + +static void +rule_list_ptr_free (DBusList **list) +{ + /* We have to cope with NULL because the hash table frees the "existing" + * value (which is NULL) when creating a new table entry... + */ + if (list != NULL) + { + rule_list_free (list); + dbus_free (list); + } +} + BusMatchmaker* bus_matchmaker_new (void) { BusMatchmaker *matchmaker; + int i; matchmaker = dbus_new0 (BusMatchmaker, 1); if (matchmaker == NULL) return NULL; matchmaker->refcount = 1; - + + for (i = DBUS_MESSAGE_TYPE_INVALID; i < DBUS_NUM_MESSAGE_TYPES; i++) + { + RulePool *p = matchmaker->rules_by_type + i; + + p->rules_by_iface = _dbus_hash_table_new (DBUS_HASH_STRING, + dbus_free, (DBusFreeFunction) rule_list_ptr_free); + + if (p->rules_by_iface == NULL) + goto nomem; + } + return matchmaker; + + nomem: + for (i = DBUS_MESSAGE_TYPE_INVALID; i < DBUS_NUM_MESSAGE_TYPES; i++) + { + RulePool *p = matchmaker->rules_by_type + i; + + if (p->rules_by_iface == NULL) + break; + else + _dbus_hash_table_unref (p->rules_by_iface); + } + + return NULL; +} + +static DBusList ** +bus_matchmaker_get_rules (BusMatchmaker *matchmaker, + int message_type, + const char *interface, + dbus_bool_t create) +{ + RulePool *p; + + _dbus_assert (message_type >= 0); + _dbus_assert (message_type < DBUS_NUM_MESSAGE_TYPES); + + _dbus_verbose ("Looking up rules for message_type %d, interface %s\n", + message_type, + interface != NULL ? interface : "<null>"); + + p = matchmaker->rules_by_type + message_type; + + if (interface == NULL) + { + return &p->rules_without_iface; + } + else + { + DBusList **list; + + list = _dbus_hash_table_lookup_string (p->rules_by_iface, interface); + + if (list == NULL && create) + { + char *dupped_interface; + + list = dbus_new0 (DBusList *, 1); + if (list == NULL) + return NULL; + + dupped_interface = _dbus_strdup (interface); + if (dupped_interface == NULL) + { + dbus_free (list); + return NULL; + } + + _dbus_verbose ("Adding list for type %d, iface %s\n", message_type, + interface); + + if (!_dbus_hash_table_insert_string (p->rules_by_iface, + dupped_interface, list)) + { + dbus_free (list); + dbus_free (dupped_interface); + return NULL; + } + } + + return list; + } +} + +static void +bus_matchmaker_gc_rules (BusMatchmaker *matchmaker, + int message_type, + const char *interface, + DBusList **rules) +{ + RulePool *p; + + if (interface == NULL) + return; + + if (*rules != NULL) + return; + + _dbus_verbose ("GCing HT entry for message_type %u, interface %s\n", + message_type, interface); + + p = matchmaker->rules_by_type + message_type; + + _dbus_assert (_dbus_hash_table_lookup_string (p->rules_by_iface, interface) + == rules); + + _dbus_hash_table_remove_string (p->rules_by_iface, interface); } BusMatchmaker * @@ -1057,14 +1205,14 @@ bus_matchmaker_unref (BusMatchmaker *matchmaker) matchmaker->refcount -= 1; if (matchmaker->refcount == 0) { - while (matchmaker->all_rules != NULL) + int i; + + for (i = DBUS_MESSAGE_TYPE_INVALID; i < DBUS_NUM_MESSAGE_TYPES; i++) { - BusMatchRule *rule; + RulePool *p = matchmaker->rules_by_type + i; - rule = matchmaker->all_rules->data; - bus_match_rule_unref (rule); - _dbus_list_remove_link (&matchmaker->all_rules, - matchmaker->all_rules); + _dbus_hash_table_unref (p->rules_by_iface); + rule_list_free (&p->rules_without_iface); } dbus_free (matchmaker); @@ -1076,17 +1224,31 @@ dbus_bool_t bus_matchmaker_add_rule (BusMatchmaker *matchmaker, BusMatchRule *rule) { + DBusList **rules; + _dbus_assert (bus_connection_is_active (rule->matches_go_to)); - if (!_dbus_list_append (&matchmaker->all_rules, rule)) + _dbus_verbose ("Adding rule with message_type %d, interface %s\n", + rule->message_type, + rule->interface != NULL ? rule->interface : "<null>"); + + rules = bus_matchmaker_get_rules (matchmaker, rule->message_type, + rule->interface, TRUE); + + if (rules == NULL) + return FALSE; + + if (!_dbus_list_append (rules, rule)) return FALSE; if (!bus_connection_add_match_rule (rule->matches_go_to, rule)) { - _dbus_list_remove_last (&matchmaker->all_rules, rule); + _dbus_list_remove_last (rules, rule); + bus_matchmaker_gc_rules (matchmaker, rule->message_type, + rule->interface, rules); return FALSE; } - + bus_match_rule_ref (rule); #ifdef DBUS_ENABLE_VERBOSE_MODE @@ -1171,13 +1333,13 @@ match_rule_equal (BusMatchRule *a, } static void -bus_matchmaker_remove_rule_link (BusMatchmaker *matchmaker, +bus_matchmaker_remove_rule_link (DBusList **rules, DBusList *link) { BusMatchRule *rule = link->data; bus_connection_remove_match_rule (rule->matches_go_to, rule); - _dbus_list_remove_link (&matchmaker->all_rules, link); + _dbus_list_remove_link (rules, link); #ifdef DBUS_ENABLE_VERBOSE_MODE { @@ -1196,8 +1358,25 @@ void bus_matchmaker_remove_rule (BusMatchmaker *matchmaker, BusMatchRule *rule) { + DBusList **rules; + + _dbus_verbose ("Removing rule with message_type %d, interface %s\n", + rule->message_type, + rule->interface != NULL ? rule->interface : "<null>"); + bus_connection_remove_match_rule (rule->matches_go_to, rule); - _dbus_list_remove (&matchmaker->all_rules, rule); + + rules = bus_matchmaker_get_rules (matchmaker, rule->message_type, + rule->interface, FALSE); + + /* We should only be asked to remove a rule by identity right after it was + * added, so there should be a list for it. + */ + _dbus_assert (rules != NULL); + + _dbus_list_remove (rules, rule); + bus_matchmaker_gc_rules (matchmaker, rule->message_type, rule->interface, + rules); #ifdef DBUS_ENABLE_VERBOSE_MODE { @@ -1218,29 +1397,38 @@ bus_matchmaker_remove_rule_by_value (BusMatchmaker *matchmaker, BusMatchRule *value, DBusError *error) { - /* FIXME this is an unoptimized linear scan */ + DBusList **rules; + DBusList *link = NULL; - DBusList *link; + _dbus_verbose ("Removing rule by value with message_type %d, interface %s\n", + value->message_type, + value->interface != NULL ? value->interface : "<null>"); - /* we traverse backward because bus_connection_remove_match_rule() - * removes the most-recently-added rule - */ - link = _dbus_list_get_last_link (&matchmaker->all_rules); - while (link != NULL) + rules = bus_matchmaker_get_rules (matchmaker, value->message_type, + value->interface, FALSE); + + if (rules != NULL) { - BusMatchRule *rule; - DBusList *prev; + /* we traverse backward because bus_connection_remove_match_rule() + * removes the most-recently-added rule + */ + link = _dbus_list_get_last_link (rules); + while (link != NULL) + { + BusMatchRule *rule; + DBusList *prev; - rule = link->data; - prev = _dbus_list_get_prev_link (&matchmaker->all_rules, link); + rule = link->data; + prev = _dbus_list_get_prev_link (rules, link); - if (match_rule_equal (rule, value)) - { - bus_matchmaker_remove_rule_link (matchmaker, link); - break; - } + if (match_rule_equal (rule, value)) + { + bus_matchmaker_remove_rule_link (rules, link); + break; + } - link = prev; + link = prev; + } } if (link == NULL) @@ -1250,38 +1438,30 @@ bus_matchmaker_remove_rule_by_value (BusMatchmaker *matchmaker, return FALSE; } + bus_matchmaker_gc_rules (matchmaker, value->message_type, value->interface, + rules); + return TRUE; } -void -bus_matchmaker_disconnected (BusMatchmaker *matchmaker, - DBusConnection *disconnected) +static void +rule_list_remove_by_connection (DBusList **rules, + DBusConnection *connection) { DBusList *link; - /* FIXME - * - * This scans all match rules on the bus. We could avoid that - * for the rules belonging to the connection, since we keep - * a list of those; but for the rules that just refer to - * the connection we'd need to do something more elaborate. - * - */ - - _dbus_assert (bus_connection_is_active (disconnected)); - - link = _dbus_list_get_first_link (&matchmaker->all_rules); + link = _dbus_list_get_first_link (rules); while (link != NULL) { BusMatchRule *rule; DBusList *next; rule = link->data; - next = _dbus_list_get_next_link (&matchmaker->all_rules, link); + next = _dbus_list_get_next_link (rules, link); - if (rule->matches_go_to == disconnected) + if (rule->matches_go_to == connection) { - bus_matchmaker_remove_rule_link (matchmaker, link); + bus_matchmaker_remove_rule_link (rules, link); } else if (((rule->flags & BUS_MATCH_SENDER) && *rule->sender == ':') || ((rule->flags & BUS_MATCH_DESTINATION) && *rule->destination == ':')) @@ -1292,7 +1472,7 @@ bus_matchmaker_disconnected (BusMatchmaker *matchmaker, */ const char *name; - name = bus_connection_get_name (disconnected); + name = bus_connection_get_name (connection); _dbus_assert (name != NULL); /* because we're an active connection */ if (((rule->flags & BUS_MATCH_SENDER) && @@ -1300,7 +1480,7 @@ bus_matchmaker_disconnected (BusMatchmaker *matchmaker, ((rule->flags & BUS_MATCH_DESTINATION) && strcmp (rule->destination, name) == 0)) { - bus_matchmaker_remove_rule_link (matchmaker, link); + bus_matchmaker_remove_rule_link (rules, link); } } @@ -1308,6 +1488,44 @@ bus_matchmaker_disconnected (BusMatchmaker *matchmaker, } } +void +bus_matchmaker_disconnected (BusMatchmaker *matchmaker, + DBusConnection *connection) +{ + int i; + + /* FIXME + * + * This scans all match rules on the bus. We could avoid that + * for the rules belonging to the connection, since we keep + * a list of those; but for the rules that just refer to + * the connection we'd need to do something more elaborate. + */ + + _dbus_assert (bus_connection_is_active (connection)); + + _dbus_verbose ("Removing all rules for connection %p\n", connection); + + for (i = DBUS_MESSAGE_TYPE_INVALID; i < DBUS_NUM_MESSAGE_TYPES; i++) + { + RulePool *p = matchmaker->rules_by_type + i; + DBusHashIter iter; + + rule_list_remove_by_connection (&p->rules_without_iface, connection); + + _dbus_hash_iter_init (p->rules_by_iface, &iter); + while (_dbus_hash_iter_next (&iter)) + { + DBusList **items = _dbus_hash_iter_get_value (&iter); + + rule_list_remove_by_connection (items, connection); + + if (*items == NULL) + _dbus_hash_iter_remove_entry (&iter); + } + } +} + static dbus_bool_t connection_is_primary_owner (DBusConnection *connection, const char *service_name) @@ -1333,8 +1551,11 @@ static dbus_bool_t match_rule_matches (BusMatchRule *rule, DBusConnection *sender, DBusConnection *addressed_recipient, - DBusMessage *message) + DBusMessage *message, + BusMatchFlags already_matched) { + int flags; + /* All features of the match rule are AND'd together, * so FALSE if any of them don't match. */ @@ -1343,8 +1564,11 @@ match_rule_matches (BusMatchRule *rule, * or for addressed_recipient may mean a message with no * specific recipient (i.e. a signal) */ - - if (rule->flags & BUS_MATCH_MESSAGE_TYPE) + + /* Don't bother re-matching features we've already checked implicitly. */ + flags = rule->flags & (~already_matched); + + if (flags & BUS_MATCH_MESSAGE_TYPE) { _dbus_assert (rule->message_type != DBUS_MESSAGE_TYPE_INVALID); @@ -1352,7 +1576,7 @@ match_rule_matches (BusMatchRule *rule, return FALSE; } - if (rule->flags & BUS_MATCH_INTERFACE) + if (flags & BUS_MATCH_INTERFACE) { const char *iface; @@ -1366,7 +1590,7 @@ match_rule_matches (BusMatchRule *rule, return FALSE; } - if (rule->flags & BUS_MATCH_MEMBER) + if (flags & BUS_MATCH_MEMBER) { const char *member; @@ -1380,7 +1604,7 @@ match_rule_matches (BusMatchRule *rule, return FALSE; } - if (rule->flags & BUS_MATCH_SENDER) + if (flags & BUS_MATCH_SENDER) { _dbus_assert (rule->sender != NULL); @@ -1397,7 +1621,7 @@ match_rule_matches (BusMatchRule *rule, } } - if (rule->flags & BUS_MATCH_DESTINATION) + if (flags & BUS_MATCH_DESTINATION) { const char *destination; @@ -1420,7 +1644,7 @@ match_rule_matches (BusMatchRule *rule, } } - if (rule->flags & BUS_MATCH_PATH) + if (flags & BUS_MATCH_PATH) { const char *path; @@ -1434,7 +1658,7 @@ match_rule_matches (BusMatchRule *rule, return FALSE; } - if (rule->flags & BUS_MATCH_ARGS) + if (flags & BUS_MATCH_ARGS) { int i; DBusMessageIter iter; @@ -1504,38 +1728,19 @@ match_rule_matches (BusMatchRule *rule, return TRUE; } -dbus_bool_t -bus_matchmaker_get_recipients (BusMatchmaker *matchmaker, - BusConnections *connections, - DBusConnection *sender, - DBusConnection *addressed_recipient, - DBusMessage *message, - DBusList **recipients_p) +static dbus_bool_t +get_recipients_from_list (DBusList **rules, + DBusConnection *sender, + DBusConnection *addressed_recipient, + DBusMessage *message, + DBusList **recipients_p) { - /* FIXME for now this is a wholly unoptimized linear search */ - /* Guessing the important optimization is to skip the signal-related - * match lists when processing method call and exception messages. - * So separate match rule lists for signals? - */ - DBusList *link; - _dbus_assert (*recipients_p == NULL); - - /* This avoids sending same message to the same connection twice. - * Purpose of the stamp instead of a bool is to avoid iterating over - * all connections resetting the bool each time. - */ - bus_connections_increment_stamp (connections); - - /* addressed_recipient is already receiving the message, don't add to list. - * NULL addressed_recipient means either bus driver, or this is a signal - * and thus lacks a specific addressed_recipient. - */ - if (addressed_recipient != NULL) - bus_connection_mark_stamp (addressed_recipient); + if (rules == NULL) + return TRUE; - link = _dbus_list_get_first_link (&matchmaker->all_rules); + link = _dbus_list_get_first_link (rules); while (link != NULL) { BusMatchRule *rule; @@ -1545,23 +1750,24 @@ bus_matchmaker_get_recipients (BusMatchmaker *matchmaker, #ifdef DBUS_ENABLE_VERBOSE_MODE { char *s = match_rule_to_string (rule); - + _dbus_verbose ("Checking whether message matches rule %s for connection %p\n", s, rule->matches_go_to); dbus_free (s); } #endif - + if (match_rule_matches (rule, - sender, addressed_recipient, message)) + sender, addressed_recipient, message, + BUS_MATCH_MESSAGE_TYPE | BUS_MATCH_INTERFACE)) { _dbus_verbose ("Rule matched\n"); - + /* Append to the list if we haven't already */ if (bus_connection_mark_stamp (rule->matches_go_to)) { if (!_dbus_list_append (recipients_p, rule->matches_go_to)) - goto nomem; + return FALSE; } #ifdef DBUS_ENABLE_VERBOSE_MODE else @@ -1571,14 +1777,72 @@ bus_matchmaker_get_recipients (BusMatchmaker *matchmaker, #endif /* DBUS_ENABLE_VERBOSE_MODE */ } - link = _dbus_list_get_next_link (&matchmaker->all_rules, link); + link = _dbus_list_get_next_link (rules, link); } return TRUE; +} - nomem: - _dbus_list_clear (recipients_p); - return FALSE; +dbus_bool_t +bus_matchmaker_get_recipients (BusMatchmaker *matchmaker, + BusConnections *connections, + DBusConnection *sender, + DBusConnection *addressed_recipient, + DBusMessage *message, + DBusList **recipients_p) +{ + int type; + const char *interface; + DBusList **neither, **just_type, **just_iface, **both; + + _dbus_assert (*recipients_p == NULL); + + /* This avoids sending same message to the same connection twice. + * Purpose of the stamp instead of a bool is to avoid iterating over + * all connections resetting the bool each time. + */ + bus_connections_increment_stamp (connections); + + /* addressed_recipient is already receiving the message, don't add to list. + * NULL addressed_recipient means either bus driver, or this is a signal + * and thus lacks a specific addressed_recipient. + */ + if (addressed_recipient != NULL) + bus_connection_mark_stamp (addressed_recipient); + + type = dbus_message_get_type (message); + interface = dbus_message_get_interface (message); + + neither = bus_matchmaker_get_rules (matchmaker, DBUS_MESSAGE_TYPE_INVALID, + NULL, FALSE); + just_type = just_iface = both = NULL; + + if (interface != NULL) + just_iface = bus_matchmaker_get_rules (matchmaker, + DBUS_MESSAGE_TYPE_INVALID, interface, FALSE); + + if (type > DBUS_MESSAGE_TYPE_INVALID && type < DBUS_NUM_MESSAGE_TYPES) + { + just_type = bus_matchmaker_get_rules (matchmaker, type, NULL, FALSE); + + if (interface != NULL) + both = bus_matchmaker_get_rules (matchmaker, type, interface, FALSE); + } + + if (!(get_recipients_from_list (neither, sender, addressed_recipient, + message, recipients_p) && + get_recipients_from_list (just_iface, sender, addressed_recipient, + message, recipients_p) && + get_recipients_from_list (just_type, sender, addressed_recipient, + message, recipients_p) && + get_recipients_from_list (both, sender, addressed_recipient, + message, recipients_p))) + { + _dbus_list_clear (recipients_p); + return FALSE; + } + + return TRUE; } #ifdef DBUS_BUILD_TESTS @@ -1943,7 +2207,7 @@ check_matches (dbus_bool_t expected_to_match, _dbus_assert (rule != NULL); /* We can't test sender/destination rules since we pass NULL here */ - matched = match_rule_matches (rule, NULL, NULL, message); + matched = match_rule_matches (rule, NULL, NULL, message, 0); if (matched != expected_to_match) { diff --git a/bus/signals.h b/bus/signals.h index 4ea10755..eeb1d2d0 100644 --- a/bus/signals.h +++ b/bus/signals.h @@ -77,7 +77,7 @@ dbus_bool_t bus_matchmaker_remove_rule_by_value (BusMatchmaker *matchmaker, void bus_matchmaker_remove_rule (BusMatchmaker *matchmaker, BusMatchRule *rule); void bus_matchmaker_disconnected (BusMatchmaker *matchmaker, - DBusConnection *disconnected); + DBusConnection *connection); dbus_bool_t bus_matchmaker_get_recipients (BusMatchmaker *matchmaker, BusConnections *connections, DBusConnection *sender, diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index d0a290cc..a9c6af5e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -45,16 +45,9 @@ find_package(LibXml2) find_package(LibExpat) find_package(X11) - -OPTION(DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON) - -if (MINGW) - set (DBUS_VA_COPY_AS_ARRAY 1) -endif (MINGW) -if (MSVC) - set (DBUS_HAVE_VA_COPY 1) - set (DBUS_VA_COPY_AS_ARRAY 0) -endif (MSVC) +if(NOT WIN32) + OPTION(DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON) +endif(NOT WIN32) # do config checks INCLUDE(ConfigureChecks.cmake) @@ -70,48 +63,44 @@ if(VCS) set(DBUS_VERBOSE_C_S 1) endif(VCS) -if(MSVC) - # controll folders in msvc projects - include(ProjectSourceGroup) - if(NOT GROUP_CODE) - #set(GROUP_CODE split) #cmake default - set(GROUP_CODE flat) - endif(NOT GROUP_CODE) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) - - - # Use the highest warning level - if (WALL) - set(WALL 1 CACHE TYPE STRING FORCE) - set(CMAKE_CXX_WARNING_LEVEL 4 CACHE TYPE STRING FORCE) - - if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") - endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - - if(CMAKE_C_FLAGS MATCHES "/W[0-4]") - STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - else(CMAKE_C_FLAGS MATCHES "/W[0-4]") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") - endif(CMAKE_C_FLAGS MATCHES "/W[0-4]") - else (WALL) - set(CMAKE_CXX_WARNING_LEVEL 3 CACHE TYPE STRING FORCE) - endif (WALL) - - SET(MSVC_W_ERROR " /we4028 /we4013 /we4133 /we4047 /we4031 /we4002 /we4003 /we4114") - SET(MSVC_W_DISABLE " /wd4127 /wd4090 /wd4101 /wd4244") - - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") - - # used by executables, CMAKE_DEBUG_POSTFIX does not handle this case - #set (CMAKE_EXE_POSTFIX "d") - -endif(MSVC) if(WIN32) - set (CMAKE_DEBUG_POSTFIX "d") + set(CMAKE_DEBUG_POSTFIX "d") + if(MSVC) + # controll folders in msvc projects + include(ProjectSourceGroup) + if(NOT GROUP_CODE) + #set(GROUP_CODE split) #cmake default + set(GROUP_CODE flat) + endif(NOT GROUP_CODE) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) + + + # Use the highest warning level + if (WALL) + set(WALL 1 CACHE TYPE STRING FORCE) + set(CMAKE_CXX_WARNING_LEVEL 4 CACHE TYPE STRING FORCE) + + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") + endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + + if(CMAKE_C_FLAGS MATCHES "/W[0-4]") + STRING(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + else(CMAKE_C_FLAGS MATCHES "/W[0-4]") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") + endif(CMAKE_C_FLAGS MATCHES "/W[0-4]") + else (WALL) + set(CMAKE_CXX_WARNING_LEVEL 3 CACHE TYPE STRING FORCE) + endif (WALL) + + SET(MSVC_W_ERROR " /we4028 /we4013 /we4133 /we4047 /we4031 /we4002 /we4003 /we4114") + SET(MSVC_W_DISABLE " /wd4127 /wd4090 /wd4101 /wd4244") + + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /FIconfig.h ${MSVC_W_ERROR} ${MSVC_W_DISABLE}") + endif(MSVC) endif(WIN32) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") @@ -200,39 +189,28 @@ ENABLE_TESTING() ########### basic vars ############### if (DBUSDIR) - set(DBUS_INSTALL_DIR "${DBUSDIR}" CACHE TYPE STRING) -else (DBUSDIR) - set(DBUS_INSTALL_DIR "$ENV{DBUSDIR}" CACHE TYPE STRING) + set(DBUS_INSTALL_DIR "${DBUSDIR}") endif (DBUSDIR) - -if (NOT DBUS_INSTALL_DIR) - set(DBUS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE TYPE STRING) -endif (NOT DBUS_INSTALL_DIR) - -# TODO: setting EXPANDED_... has nothing to do with DBUS_INSTALL_SYSTEM_LIBS -if (DBUS_INSTALL_SYSTEM_LIBS) - set(prefix ${DBUS_INSTALL_DIR}) - set(exec_prefix ${prefix}) - set(EXPANDED_LIBDIR ${DBUS_INSTALL_DIR}/lib) - set(EXPANDED_INCLUDEDIR ${DBUS_INSTALL_DIR}/include) - set(EXPANDED_BINDIR ${DBUS_INSTALL_DIR}/bin) - set(EXPANDED_SYSCONFDIR ${DBUS_INSTALL_DIR}/etc) - set(EXPANDED_DATADIR ${DBUS_INSTALL_DIR}/data) - set(DBUS_BINDIR ${EXPANDED_BINDIR}) - set(DBUS_MACHINE_UUID_FILE ${DBUS_INSTALL_DIR}/lib/dbus/machine-id) -else (DBUS_INSTALL_SYSTEM_LIBS) - set(EXPANDED_INCLUDEDIR ${CMAKE_SOURCE_DIR}/include) - set(EXPANDED_DATADIR ${CMAKE_BINARY_DIR}/test/data) - if (MSVC_IDE) - set(EXPANDED_BINDIR ${CMAKE_BINARY_DIR}/bin/debug) - else (MSVC_IDE) - set(EXPANDED_BINDIR ${CMAKE_BINARY_DIR}/bin) - endif (MSVC_IDE) - set(DBUS_BINDIR ${EXPANDED_BINDIR}) - set(DBUS_MACHINE_UUID_FILE ${CMAKE_BINARY_DIR}/lib/dbus/machine-id) -endif (DBUS_INSTALL_SYSTEM_LIBS) - -set (DBUS_DAEMONDIR ${EXPANDED_BINDIR}) +if ($ENV{DBUSDIR}) + set(DBUS_INSTALL_DIR "$ENV{DBUSDIR}") +endif ($ENV{DBUSDIR}) + +if (DBUS_INSTALL_DIR) + set(CMAKE_INSTALL_PREFIX "${DBUS_INSTALL_DIR}" CACHE TYPE PATH FORCE) +else (DBUS_INSTALL_DIR) + set(DBUS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}") +endif (DBUS_INSTALL_DIR) + +set(prefix ${DBUS_INSTALL_DIR}) +set(exec_prefix ${prefix}) +set(EXPANDED_LIBDIR ${DBUS_INSTALL_DIR}/lib) +set(EXPANDED_INCLUDEDIR ${DBUS_INSTALL_DIR}/include) +set(EXPANDED_BINDIR ${DBUS_INSTALL_DIR}/bin) +set(EXPANDED_SYSCONFDIR ${DBUS_INSTALL_DIR}/etc) +set(EXPANDED_DATADIR ${DBUS_INSTALL_DIR}/data) +set(DBUS_MACHINE_UUID_FILE ${DBUS_INSTALL_DIR}/lib/dbus/machine-id) +set(DBUS_BINDIR ${EXPANDED_BINDIR}) +set(DBUS_DAEMONDIR ${EXPANDED_BINDIR}) ########### command line options ############### # TODO: take check from configure.in @@ -249,8 +227,10 @@ if(DBUS_USE_OUTPUT_DEBUG_STRING) add_definitions(-DDBUS_USE_OUTPUT_DEBUG_STRING) endif(DBUS_USE_OUTPUT_DEBUG_STRING) -# win32 dbus service support - this support is not complete -OPTION(DBUS_SERVICE "enable dbus service installer" OFF) +if(WIN32) + # win32 dbus service support - this support is not complete + OPTION(DBUS_SERVICE "enable dbus service installer" OFF) +endif(WIN32) #AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) OPTION(DBUS_ENABLE_ANSI "enable -ansi -pedantic gcc flags" OFF) @@ -271,19 +251,19 @@ OPTION(DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF) #AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes) OPTION(DBUS_DISABLE_CHECKS "Disable public API sanity checking" OFF) -#AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no) -OPTION(DBUS_GCOV_ENABLED "compile with coverage profiling instrumentation (gcc only)" OFF) -if(DBUS_GCOV_ENABLED) - if(NOT MSVC) - add_definitions(-fprofile-arcs -ftest-coverage) - # FIXME!!!! - ## remove optimization -# CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'` - endif(NOT MSVC) -endif(DBUS_GCOV_ENABLED) +if(NOT MSVC) + #AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no) + OPTION(DBUS_GCOV_ENABLED "compile with coverage profiling instrumentation (gcc only)" OFF) + if(DBUS_GCOV_ENABLED) + add_definitions(-fprofile-arcs -ftest-coverage) + # FIXME!!!! + ## remove optimization + # CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'` + endif(DBUS_GCOV_ENABLED) +endif(NOT MSVC) #AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto) -#abstract sockets missing +# -> moved before include(ConfigureChecks.cmake) #AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto) #selinux missing @@ -479,7 +459,7 @@ else (WIN32) set (DBUS_DATADIR ${EXPANDED_DATADIR}) endif (WIN32) -set (DAEMON_NAME dbus-daemon) +set(DBUS_DAEMON_NAME dbus-daemon CACHE STRING "The name of the dbus daemon executable") ########### create config.h ############### @@ -499,24 +479,6 @@ add_definitions(-DHAVE_CONFIG_H=1) add_definitions(${DBUS_BUS_CFLAGS} -DDBUS_API_SUBJECT_TO_CHANGE) -option(splitlib "split library into dbus-lib-client, dbus-lib-generic, and dbus-lib-util, no installing possible" OFF) -if(splitlib AND MSVC) - # does not work with GCC/ld - set(DBUS_1 dbus-lib-client dbus-lib-generic dbus-lib-util) - message(STATUS "") - message(STATUS "dbus library is splitted into dbus-lib-client, dbus-lib-generic, and dbus-lib-util") - message(STATUS "installing is not possible") - message(STATUS "disable splitting: -Dsplitlib=0") - message(STATUS "") -else(splitlib AND MSVC) - message(STATUS "") - message(STATUS "for better code reading the dbus library could be splitted into three libraries:") - message(STATUS "dbus-lib-client, dbus-lib-generic, and dbus-lib-util (installing is then not possible)") - message(STATUS "enable splitting: -Dsplitlib=1") - message(STATUS "") - set(DBUS_1 dbus-1) -endif(splitlib AND MSVC) - if (DBUS_BUILD_TESTS) # set variables used for the .in files (substituted by configure_file) in test/data: set(TEST_VALID_SERVICE_DIR ${CMAKE_BINARY_DIR}/test/data/valid-service-files) @@ -548,14 +510,15 @@ GET_FILENAME_COMPONENT(CXX_COMPILER ${CMAKE_CXX_COMPILER} NAME) message(" D-BUS ${DBUS_VERSION} ") message(" =========== ") message(" ") -message(" prefix: ${prefix} ") -message(" exec_prefix: ${exec_prefix} ") -message(" libdir: ${EXPANDED_LIBDIR} ") -message(" bindir: ${EXPANDED_BINDIR} ") -message(" sysconfdir: ${EXPANDED_SYSCONFDIR} ") -message(" localstatedir: ${EXPANDED_LOCALSTATEDIR} ") -message(" datadir: ${EXPANDED_DATADIR} ") +message(" install prefix: ${prefix} ") +message(" install exec_prefix: ${exec_prefix} ") +message(" install libdir: ${EXPANDED_LIBDIR} ") +message(" install bindir: ${EXPANDED_BINDIR} ") +message(" install sysconfdir: ${EXPANDED_SYSCONFDIR} ") +#message(" install localstatedir: ${EXPANDED_LOCALSTATEDIR} ") +message(" install datadir: ${EXPANDED_DATADIR} ") message(" source code location: ${DBUS_SOURCE_DIR} ") +message(" build dir: ${CMAKE_BINARY_DIR} ") message(" c compiler: ${C_COMPILER} ") message(" cflags: ${CMAKE_C_FLAGS} ") message(" cflags debug: ${CMAKE_C_FLAGS_DEBUG} ") @@ -584,6 +547,7 @@ message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} " #message(" Building XML docs: ${enable_xml_docs} ") #message(" Gettext libs (empty OK): ${INTLLIBS} ") message(" Using XML parser: ${XML_LIB} ") +message(" Daemon executable name: ${DBUS_DAEMON_NAME}") if (WIN32) message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") message(" Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} ") diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 1e83d809..35f3e1f9 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -90,7 +90,8 @@ if(MSVC) SET(DBUS_VA_COPY_FUNC "_DBUS_VA_COPY_ASSIGN";) else(MSVC) write_file("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c" "#include <stdarg.h> - void f (int i, ...) { + #include <stdlib.h> + static void f (int i, ...) { va_list args1, args2; va_start (args1, i); va_copy (args2, args1); @@ -111,7 +112,8 @@ if(DBUS_HAVE_VA_COPY) SET(DBUS_VA_COPY_FUNC va_copy CACHE STRING "va_copy function") else(DBUS_HAVE_VA_COPY) write_file("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c" "#include <stdarg.h> - void f (int i, ...) { + #include <stdlib.h> + static void f (int i, ...) { va_list args1, args2; va_start (args1, i); __va_copy (args2, args1); diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 059b8417..f7f29db3 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -76,19 +76,12 @@ set (BUS_SOURCES ) include_directories(${XML_INCLUDE_DIR}) -SET (LIBS ${XML_LIBRARY}) - -if(splitlib AND MSVC) - add_library(bus-lib STATIC ${BUS_SOURCES}) - add_executable(dbus-daemon ${BUS_DIR}/main.c) - target_link_libraries(dbus-daemon ${DBUS_1} ${LIBS} bus-lib) -else(splitlib AND MSVC) - add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c) - target_link_libraries(dbus-daemon ${DBUS_1} ${LIBS}) -endif(splitlib AND MSVC) -if(WIN32) - set_target_properties(dbus-daemon PROPERTIES DEBUG_POSTFIX d) -endif(WIN32) + +set(DBUS_LIBRARIES dbus-1 dbus-internal) + +add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c) +target_link_libraries(dbus-daemon ${DBUS_LIBRARIES} ${XML_LIBRARY}) +set_target_properties(dbus-daemon PROPERTIES OUTPUT_NAME ${DBUS_DAEMON_NAME}) install_targets(/bin dbus-daemon) install_files(/etc FILES ${config_DATA}) @@ -102,36 +95,13 @@ if (DBUS_SERVICE) ) add_executable(dbus-service ${dbus_service_SOURCES} ) - target_link_libraries(dbus-service ${DBUS_1} ${LIBS}) + target_link_libraries(dbus-service ${DBUS_LIBRARIES} ${XML_LIBRARY}) install_targets(/bin dbus-service ) - if(WIN32) - set_target_properties(dbus-service PROPERTIES DEBUG_POSTFIX d) - endif(WIN32) endif (DBUS_SERVICE) -## note that TESTS has special meaning (stuff to use in make check) -## so if adding tests not to be run in make check, don't add them to -## TESTS -#if DBUS_BUILD_TESTS -#TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus -#TESTS=bus-test -#else -#TESTS= -#endif - -## we use noinst_PROGRAMS not check_PROGRAMS so that we build -## even when not doing "make check" -#noinst_PROGRAMS=$(TESTS) - if (DBUS_BUILD_TESTS) - if(splitlib AND MSVC) - add_executable(bus-test ${BUS_DIR}/test-main.c) - target_link_libraries(bus-test ${DBUS_1} ${LIBS} bus-lib) - else(splitlib AND MSVC) - add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c) - target_link_libraries(bus-test ${DBUS_1} ${LIBS}) - endif(splitlib AND MSVC) - #install_targets(/bin bus-test) + add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c) + target_link_libraries(bus-test ${DBUS_LIBRARIES} ${XML_LIBRARY}) add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_BINARY_DIR}/test/data) endif (DBUS_BUILD_TESTS) @@ -163,15 +133,15 @@ set(LAUNCH_HELPER_SOURCES ${XML_SOURCES} if(NOT WIN32) # TODO PENDING(kdab) fix build on windows (activation-helper.c) add_executable(dbus-daemon-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c ) - target_link_libraries(dbus-daemon-launch-helper ${DBUS_1} ${LIBS} ) + target_link_libraries(dbus-daemon-launch-helper ${DBUS_LIBRARIES} ${XML_LIBRARY} ) add_executable(dbus-daemon-launch-helper-test ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/activation-helper-bin.c) set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST") - target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_1} ${LIBS} ) + target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_LIBRARIES} ${XML_LIBRARY} ) add_executable(bus-test-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") - target_link_libraries(bus-test-launch-helper ${DBUS_1} ${LIBS} ) + target_link_libraries(bus-test-launch-helper ${DBUS_LIBRARIES} ${XML_LIBRARY} ) add_test(bus-test-launch-helper ${EXECUTABLE_OUTPUT_PATH}/bus-test-launch-helper ) endif(NOT WIN32) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index db383712..bc40ec29 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -11,7 +11,7 @@ #cmakedefine DBUS_BINDIR "@DBUS_BINDIR@" #cmakedefine DBUS_SYSTEM_CONFIG_FILE "@DBUS_SYSTEM_CONFIG_FILE@" #cmakedefine DBUS_SESSION_CONFIG_FILE "@DBUS_SESSION_CONFIG_FILE@" -#cmakedefine DAEMON_NAME "@DAEMON_NAME@" +#cmakedefine DBUS_DAEMON_NAME "@DBUS_DAEMON_NAME@" #cmakedefine DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@" #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@" //#cmakedefine DBUS_SESSION_BUS_DEFAULT_ADDRESS "@DBUS_SESSION_BUS_DEFAULT_ADDRESS@" @@ -24,6 +24,8 @@ #cmakedefine DBUS_VERSION ((@DBUS_MAJOR_VERSION@ << 16) | (@DBUS_MINOR_VERSION@ << 8) | (@DBUS_MICRO_VERSION@)) #cmakedefine DBUS_VERSION_STRING "@DBUS_VERSION_STRING@" +#define VERSION DBUS_VERSION_STRING + // test binaries /* Full path to test file test/test-exit in builddir */ #define TEST_BUS_BINARY "@TEST_BUS_BINARY@" diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 04e3b249..762783b5 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -1,7 +1,5 @@ project(dbus-lib) -#INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) -DDBUS_COMPILATION - SET(DBUS_DIR ${CMAKE_SOURCE_DIR}/../dbus) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-arch-deps.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/dbus-arch-deps.h ) @@ -23,7 +21,6 @@ set (dbusinclude_HEADERS ${DBUS_DIR}/dbus-server.h ${DBUS_DIR}/dbus-shared.h ${DBUS_DIR}/dbus-signature.h - ${DBUS_DIR}/dbus-spawn.h ${DBUS_DIR}/dbus-threads.h ${DBUS_DIR}/dbus-types.h dbus-arch-deps.h @@ -167,7 +164,7 @@ set (DBUS_UTIL_SOURCES ${DBUS_DIR}/dbus-message-util.c ${DBUS_DIR}/dbus-shell.c ${DBUS_DIR}/dbus-string-util.c - ${DBUS_DIR}/dbus-sysdeps-util.c + ${DBUS_DIR}/dbus-sysdeps-util.c ) if (DBUS_BUILD_TESTS) @@ -192,23 +189,21 @@ if (WIN32) ${DBUS_DIR}/dbus-sysdeps-win.c ${DBUS_DIR}/dbus-pipe-win.c ${DBUS_DIR}/dbus-sysdeps-thread-win.c - ${DBUS_DIR}/dbus-spawn-win.c ) set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} ${DBUS_DIR}/dbus-sockets-win.h ${DBUS_DIR}/dbus-sysdeps-win.h ) set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES} + ${DBUS_DIR}/dbus-spawn-win.c ${DBUS_DIR}/dbus-sysdeps-util-win.c ) - set (LIBS ${LIBS} ws2_32 advapi32 netapi32) else (WIN32) set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} ${DBUS_DIR}/dbus-file-unix.c ${DBUS_DIR}/dbus-pipe-unix.c ${DBUS_DIR}/dbus-sysdeps-unix.c ${DBUS_DIR}/dbus-sysdeps-pthread.c - ${DBUS_DIR}/dbus-spawn.c ${DBUS_DIR}/dbus-userdb.c ) set (DBUS_SHARED_HEADERS ${DBUS_SHARED_HEADERS} @@ -218,6 +213,7 @@ else (WIN32) ${DBUS_DIR}/dbus-userdb.h ) set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES} + ${DBUS_DIR}/dbus-spawn.c ${DBUS_DIR}/dbus-userdb-util.c ${DBUS_DIR}/dbus-sysdeps-util-unix.c ) @@ -246,74 +242,84 @@ if (MSVC) set_source_files_properties(versioninfo.rc COMPILE_FLAGS "-D__LINE__=1") endif (MSVC) -if(MSVC AND splitlib) - set(DBUS_LIB_TYPE STATIC) -elseif(MSVC AND splitlib) - set(DBUS_LIB_TYPE SHARED) -endif(MSVC AND splitlib) +if(MSVC_IDE) + project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS) + project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS) + project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES) +endif(MSVC_IDE) +### Client library -if(splitlib AND MSVC) - # code for the client library and daemon/tests - add_library(dbus-lib-generic ${DBUS_LIB_TYPE} ${DBUS_SHARED_SOURCES} ${DBUS_SHARED_HEADERS}) - - # code only for daemon/tests - add_library(dbus-lib-util ${DBUS_LIB_TYPE} ${DBUS_UTIL_SOURCES} ${DBUS_UTIL_HEADERS}) - - # code for the client library - add_library(dbus-lib-client ${DBUS_LIB_TYPE} ${DBUS_LIB_SOURCES} ${DBUS_LIB_HEADERS}) - - target_link_libraries(dbus-lib-generic ${LIBS}) - target_link_libraries(dbus-lib-util ${LIBS}) - target_link_libraries(dbus-lib-client ${LIBS}) - - if(MSVC_IDE) - project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS) - project_source_group(${GROUP_CODE} DBUS_SHARED_SOURCES DBUS_SHARED_HEADERS) - project_source_group(${GROUP_CODE} DBUS_UTIL_SOURCES DBUS_UTIL_SOURCES) - endif(MSVC_IDE) -else(splitlib AND MSVC) - # all code into one library - add_library(dbus-1 ${DBUS_LIB_TYPE} ${libdbus_SOURCES} ${libdbus_HEADERS} ) - target_link_libraries(dbus-1 ${LIBS}) - +if(WIN32) + file(READ "${DBUS_DIR}/dbus-1-symbols.def.in" DBUS_CLIENT_EXPORTS) + if (DBUS_BUILD_TESTS) + file(READ "${DBUS_DIR}/dbus-1-testsymbols.def.in" DBUS_CLIENT_TEST_EXPORTS) + else(DBUS_BUILD_TESTS) + set(DBUS_CLIENT_TEST_EXPORTS ) + endif(DBUS_BUILD_TESTS) + if (DBUS_ENABLE_VERBOSE_MODE) + file(READ "${DBUS_DIR}/dbus-1-verbosesymbols.def.in" DBUS_VERBOSE_EXPORTS) + else(DBUS_ENABLE_VERBOSE_MODE) + set(DBUS_VERBOSE_EXPORTS ) + endif(DBUS_ENABLE_VERBOSE_MODE) if(MSVC) - set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_RELWITHDEBINFO /def:"${DBUS_DIR}/dbus-1.def") - set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_RELEASE /def:"${DBUS_DIR}/dbus-1.def") - set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_MINSIZEREL /def:"${DBUS_DIR}/dbus-1.def") - set_target_properties(dbus-1 PROPERTIES LINK_FLAGS_DEBUG /def:"${DBUS_DIR}/dbus-1.def") + set(DBUS_LIB_DEF "${CMAKE_BINARY_DIR}/dbus-1.def") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.def.cmake" ${DBUS_LIB_DEF}) + list(APPEND DBUS_LIB_SOURCES ${DBUS_LIB_DEF}) + else(MSVC) + # Doesn't cmake support recursive expansion ? Would make the code below simpler... + if(CMAKE_BUILD_TYPE STREQUAL Debug) + set(LIBDBUS_1_NAME "libdbus-1${CMAKE_DEBUG_POSTFIX}") + else(CMAKE_BUILD_TYPE STREQUAL Debug) + set(LIBDBUS_1_NAME "libdbus-1${CMAKE_RELEASE_POSTFIX}") + endif(CMAKE_BUILD_TYPE STREQUAL Debug) + set(DBUS_LIBRARY_HEADER "LIBRARY ${LIBDBUS_1_NAME}.dll") + set(DBUS_LIB_DEF "${CMAKE_BINARY_DIR}/${LIBDBUS_1_NAME}.def") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-1.def.cmake" ${DBUS_LIB_DEF}) endif(MSVC) - if(MSVC_IDE) - project_source_group(${GROUP_CODE} libdbus_SOURCES libdbus_HEADERS) - endif(MSVC_IDE) -endif(splitlib AND MSVC) +endif(WIN32) + +add_library(dbus-1 SHARED + ${DBUS_LIB_SOURCES} + ${DBUS_SHARED_SOURCES} + ${DBUS_LIB_HEADERS} + ${DBUS_SHARED_HEADERS}) +if(WIN32) + target_link_libraries(dbus-1 ws2_32 advapi32 netapi32) +endif(WIN32) +install_targets(/lib dbus-1 ) +install_files(/include/dbus FILES ${dbusinclude_HEADERS}) +if(WIN32 AND NOT MSVC) + install_files(/lib FILES ${DBUS_LIB_DEF}) +endif(WIN32 AND NOT MSVC) -if(NOT splitlib) - install_targets(/lib dbus-1 ) - install_files(/include/dbus FILES ${dbusinclude_HEADERS}) -endif(NOT splitlib) +### Internal library, used for the daemon, tools and tests, compiled statically. -#ADD_EXECUTABLE(dbus-example dbus-example.c) -#target_link_libraries(${CMAKE_SOURCE_DIR}/../dbus/dbus-example dbus-1) -#install_targets(/bin dbus-example ) +if(WIN32) + file(READ "${DBUS_DIR}/dbus-internal-symbols.def.in" DBUS_INTERNAL_EXPORTS) + if (DBUS_BUILD_TESTS) + file(READ "${DBUS_DIR}/dbus-internal-testsymbols.def.in" DBUS_INTERNAL_TEST_EXPORTS) + else(DBUS_BUILD_TESTS) + set(DBUS_INTERNAL_TEST_EXPORTS ) + endif(DBUS_BUILD_TESTS) + set(DBUS_INTERNAL_DEF "${CMAKE_BINARY_DIR}/dbus-internal.def") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/dbus-internal.def.cmake" ${DBUS_INTERNAL_DEF}) + if(MSVC) + list(APPEND DBUS_UTIL_SOURCES ${DBUS_INTERNAL_DEF}) + endif(MSVC) +endif(WIN32) -## note that TESTS has special meaning (stuff to use in make check) -## so if adding tests not to be run in make check, don't add them to -## TESTS -#if DBUS_BUILD_TESTS -#TESTS_ENVIRONMENT=DBUS_TEST_DATA=$(top_builddir)/test/data DBUS_TEST_HOMEDIR=$(top_builddir)/dbus -#TESTS=dbus-test -#else -#TESTS= -#endif +add_library(dbus-internal STATIC + ${DBUS_UTIL_SOURCES} + ${DBUS_UTIL_HEADERS}) +target_link_libraries(dbus-internal dbus-1) if (DBUS_BUILD_TESTS) set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus") ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c) - target_link_libraries(dbus-test ${DBUS_1} ${LIBS}) + target_link_libraries(dbus-test dbus-1 dbus-internal) add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data) - #install_targets(/bin dbus-test) ENDIF (DBUS_BUILD_TESTS) if (UNIX) diff --git a/cmake/dbus/dbus-1.def.cmake b/cmake/dbus/dbus-1.def.cmake new file mode 100644 index 00000000..0979b7a8 --- /dev/null +++ b/cmake/dbus/dbus-1.def.cmake @@ -0,0 +1,5 @@ +@DBUS_LIBRARY_HEADER@ +EXPORTS +@DBUS_CLIENT_EXPORTS@ +@DBUS_CLIENT_TEST_EXPORTS@ +@DBUS_VERBOSE_EXPORTS@
\ No newline at end of file diff --git a/cmake/dbus/dbus-internal.def.cmake b/cmake/dbus/dbus-internal.def.cmake new file mode 100644 index 00000000..da4ed89b --- /dev/null +++ b/cmake/dbus/dbus-internal.def.cmake @@ -0,0 +1,3 @@ +EXPORTS +@DBUS_INTERNAL_EXPORTS@ +@DBUS_INTERNAL_TEST_EXPORTS@ diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index a84bfd1c..ad8dbf82 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -1,39 +1,9 @@ project(test) -#if HAVE_GLIB -# GLIB_SUBDIR=glib -#endif -#if HAVE_PYTHON -# PYTHON_SUBDIR=python -#endif -#if HAVE_QTESTLIB -# QT_SUBDIR=qt -#endif +set(DBUS_LIBRARIES dbus-1 dbus-internal) add_subdirectory( name-test ) -#SUBDIRS=name-test $(GLIB_SUBDIR) $(PYTHON_SUBDIR) $(QT_SUBDIR) -#DIST_SUBDIRS=glib python qt name-test - -#INCLUDES=-I$(top_srcdir) $(DBUS_test-CFLAGS) - -#if (DBUS_BUILD_TESTS) -## break-loader removed for now -#test-BINARIES=test-service test-names test-shell-service shell-test spawn-test test-segfault test-exit test-sleep-forever - -#enable stand alone make check test -#TESTS=shell-test -#else -#test-BINARIES= -#TESTS= -#endif - -#if DBUS_GCOV_ENABLED -#GCOV_BINARIES=decode-gcov -#else -#GCOV_BINARIES= -#endif - set (test-service_SOURCES ${CMAKE_SOURCE_DIR}/../test/test-service.c ${CMAKE_SOURCE_DIR}/../test/test-utils.c @@ -81,35 +51,33 @@ set (decode_gcov_SOURCES ) add_executable(test-service ${test-service_SOURCES}) -target_link_libraries(test-service ${DBUS_1}) +target_link_libraries(test-service ${DBUS_LIBRARIES}) add_executable(test-names ${test-names_SOURCES}) -target_link_libraries(test-names ${DBUS_1}) +target_link_libraries(test-names ${DBUS_LIBRARIES}) add_executable(shell-test ${shell-test_SOURCES}) -target_link_libraries(shell-test ${DBUS_1}) +target_link_libraries(shell-test ${DBUS_LIBRARIES}) ADD_TEST(shell-test ${EXECUTABLE_OUTPUT_PATH}/shell-test${EXT}) add_executable(test-shell-service ${test-shell-service_SOURCES}) -target_link_libraries(test-shell-service ${DBUS_1}) +target_link_libraries(test-shell-service ${DBUS_LIBRARIES}) add_executable(spawn-test ${spawn-test_SOURCES}) -target_link_libraries(spawn-test ${DBUS_1}) +target_link_libraries(spawn-test ${DBUS_LIBRARIES}) add_executable(test-exit ${test-exit_SOURCES}) -target_link_libraries(test-exit ${DBUS_1}) +target_link_libraries(test-exit ${DBUS_LIBRARIES}) add_executable(test-segfault ${test-segfault_SOURCES}) -target_link_libraries(test-segfault ${DBUS_1}) +target_link_libraries(test-segfault ${DBUS_LIBRARIES}) add_executable(test-sleep-forever ${test-sleep-forever_SOURCES}) -target_link_libraries(test-sleep-forever ${DBUS_1}) +target_link_libraries(test-sleep-forever ${DBUS_LIBRARIES}) #add_executable(decode-gcov ${decode_gcov_SOURCES}) -#target_link_libraries(decode-gcov ${DBUS_1}) +#target_link_libraries(decode-gcov ${DBUS_LIBRARIES}) -#EXTRA_DIST= -# ### keep these in creation order, i.e. uppermost dirs first set (TESTDIRS test/data diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index 45683a73..df6d178b 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -6,17 +6,15 @@ add_definitions(-DDBUS_COMPILATION) # there is also a test-names executable, don't know if this is the same add_executable(test-names2 ${NAMEtest-DIR}/test-names.c) -target_link_libraries(test-names2 ${DBUS_1}) +target_link_libraries(test-names2 ${DBUS_LIBRARIES}) ADD_TEST(test-names2 ${EXECUTABLE_OUTPUT_PATH}/test-names2) add_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c) -target_link_libraries(test-pending-call-dispatch ${DBUS_1}) -#install_targets(/bin test-pending-call-dispatch) +target_link_libraries(test-pending-call-dispatch ${DBUS_LIBRARIES}) ADD_TEST(test-pending-call-dispatch ${EXECUTABLE_OUTPUT_PATH}/test-pending-call-dispatch) add_executable(test-thread-init ${NAMEtest-DIR}/test-threads-init.c) -target_link_libraries(test-thread-init ${DBUS_1}) -#install_targets(/bin test-thread-init) +target_link_libraries(test-thread-init ${DBUS_LIBRARIES}) ADD_TEST(test-thread-init ${EXECUTABLE_OUTPUT_PATH}/test-thread-init) endif (DBUS_BUILD_TESTS) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 4f8c50a0..1068074f 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -1,5 +1,7 @@ project(tools) +set(DBUS_LIBRARIES dbus-1 dbus-internal) + set (dbus_send_SOURCES ../../tools/dbus-print-message.c ../../tools/dbus-print-message.h @@ -42,7 +44,7 @@ set (dbus_viewer_SOURCES ) add_executable(dbus-send ${dbus_send_SOURCES}) -target_link_libraries(dbus-send ${DBUS_1}) +target_link_libraries(dbus-send ${DBUS_LIBRARIES}) install_targets(/bin dbus-send ) add_executable(dbus-launch ${dbus_launch_SOURCES}) @@ -53,9 +55,5 @@ endif (DBUS_BUILD_X11) install_targets(/bin dbus-launch ) add_executable(dbus-monitor ${dbus_monitor_SOURCES}) -target_link_libraries(dbus-monitor ${DBUS_1}) +target_link_libraries(dbus-monitor ${DBUS_LIBRARIES}) install_targets(/bin dbus-monitor ) - -if(WIN32) - set_target_properties(dbus-send dbus-launch dbus-monitor PROPERTIES DEBUG_POSTFIX d) -endif(WIN32)
\ No newline at end of file diff --git a/configure.in b/configure.in index 1f2c8969..c037ec39 100644 --- a/configure.in +++ b/configure.in @@ -25,6 +25,8 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext d ## must come before we use the $USE_MAINTAINER_MODE variable later AM_MAINTAINER_MODE +AC_DEFINE_UNQUOTED(DBUS_DAEMON_NAME,"dbus-daemon",[Name of executable]) + # libtool versioning - this applies to libdbus # # See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details @@ -64,6 +66,7 @@ AC_ISC_POSIX AC_HEADER_STDC AC_C_INLINE AM_PROG_LIBTOOL +AC_PROG_MKDIR_P # Set some internal variables depending on the platform for later use. dbus_win=no @@ -876,7 +879,7 @@ else AC_CHECK_LIB(audit, audit_log_user_avc_message, have_libaudit=yes, have_libaudit=no) if test x$have_libaudit = xyes ; then - AC_CHECK_LIB(cap, cap_set_proc, + AC_CHECK_LIB(cap-ng, capng_clear, have_libaudit=yes, have_libaudit=no) fi fi @@ -884,8 +887,7 @@ fi AM_CONDITIONAL(HAVE_LIBAUDIT, test x$have_libaudit = xyes) if test x$have_libaudit = xyes ; then - SELINUX_LIBS="$SELINUX_LIBS -laudit" - LIBS="-lcap $LIBS" + SELINUX_LIBS="$SELINUX_LIBS -laudit -lcap-ng" AC_DEFINE(HAVE_LIBAUDIT,1,[audit daemon SELinux support]) fi @@ -1402,30 +1404,39 @@ AC_DEFINE_UNQUOTED(DBUS_LIBEXECDIR,"$DBUS_LIBEXECDIR", [Directory for installing #### Tell tests where to find certain stuff in builddir DBUS_PWD=`pwd` +# Useful in a cross-compilation environment, where the tests are run on the host system. +AC_ARG_WITH(dbus-test-dir, AS_HELP_STRING([--with-dbus-test-dir=[dirname]],[path where the tests tools are available]), + DBUS_PWD=$withval) AC_DEFUN([TEST_PATH], [ TEST_$1=${DBUS_PWD}/test/$2 AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1", [Full path to test file test/$2 in builddir]) AC_SUBST(TEST_$1) ]) +AC_DEFUN([TEST_PROG], [ +TEST_$1=${DBUS_PWD}/test/$2 +AC_DEFINE_UNQUOTED(TEST_$1, "$TEST_$1$EXEEXT", + [Full path to test file test/$2 in builddir]) +AC_SUBST(TEST_$1) +]) TEST_PATH(VALID_SERVICE_DIR, data/valid-service-files) TEST_PATH(INVALID_SERVICE_DIR, data/invalid-service-files) TEST_PATH(VALID_SERVICE_SYSTEM_DIR, data/valid-service-files-system) TEST_PATH(INVALID_SERVICE_SYSTEM_DIR, data/invalid-service-files-system) -TEST_PATH(SERVICE_BINARY, test-service) -TEST_PATH(SHELL_SERVICE_BINARY, test-shell-service) -TEST_PATH(EXIT_BINARY, test-exit) -TEST_PATH(SEGFAULT_BINARY, test-segfault) -TEST_PATH(SLEEP_FOREVER_BINARY, test-sleep-forever) -TEST_PATH(PRIVSERVER_BINARY, name-test/test-privserver) - -AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, "$DBUS_PWD/bus/dbus-daemon", +TEST_PROG(SERVICE_BINARY, test-service) +TEST_PROG(SHELL_SERVICE_BINARY, test-shell-service) +TEST_PROG(EXIT_BINARY, test-exit) +TEST_PROG(SEGFAULT_BINARY, test-segfault) +TEST_PROG(SLEEP_FOREVER_BINARY, test-sleep-forever) +TEST_PROG(PRIVSERVER_BINARY, name-test/test-privserver) + +AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, "$DBUS_PWD/bus/dbus-daemon$EXEEXT", [Full path to the daemon in the builddir]) AC_SUBST(TEST_BUS_BINARY) ## Export the non-setuid external helper -TEST_LAUNCH_HELPER_BINARY="$DBUS_PWD/bus/dbus-daemon-launch-helper-test" +TEST_LAUNCH_HELPER_BINARY="$DBUS_PWD/bus/dbus-daemon-launch-helper-test$EXEEXT" AC_SUBST(TEST_LAUNCH_HELPER_BINARY) AC_DEFINE_UNQUOTED(DBUS_TEST_LAUNCH_HELPER_BINARY, "$TEST_LAUNCH_HELPER_BINARY", [Full path to the launch helper test program in the builddir]) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index b2a98797..3e733fac 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -23,6 +23,10 @@ SUFFIXES = rc dbus_res = versioninfo.o dbus_res_ldflag = -Wl,$(dbus_res) no_undefined = -no-undefined + + +### FIXME use the .def.in files depending on the current config +### or combine them in a single .def file as done in the cmake build export_symbols = -export-symbols $(srcdir)/dbus-1.def install-def-file: @@ -109,7 +113,6 @@ dbusinclude_HEADERS= \ dbus-server.h \ dbus-shared.h \ dbus-signature.h \ - dbus-spawn.h \ dbus-threads.h \ dbus-types.h @@ -251,6 +254,7 @@ noinst_LTLIBRARIES=libdbus-convenience.la libdbus_1_la_LIBADD= $(DBUS_CLIENT_LIBS) libdbus_1_la_LDFLAGS= $(export_symbols) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -no-undefined @R_DYNAMIC_LDFLAG@ @PIC_LDFLAGS@ +libdbus_convenience_la_LIBADD=$(DBUS_CLIENT_LIBS) libdbus_convenience_la_LDFLAGS=@R_DYNAMIC_LDFLAG@ ## note that TESTS has special meaning (stuff to use in make check) diff --git a/dbus/dbus-1-symbols.def.in b/dbus/dbus-1-symbols.def.in new file mode 100644 index 00000000..23989556 --- /dev/null +++ b/dbus/dbus-1-symbols.def.in @@ -0,0 +1,747 @@ +_dbus_abort +_dbus_accept +_dbus_address_append_escaped +_dbus_append_keyring_directory_for_credentials +_dbus_append_session_config_file +_dbus_append_system_config_file +_dbus_append_user_from_current_process +_dbus_atomic_dec +_dbus_atomic_inc +_dbus_auth_bytes_sent +_dbus_auth_client_new +_dbus_auth_decode_data +_dbus_auth_delete_unused_bytes +_dbus_auth_do_work +_dbus_auth_encode_data +_dbus_auth_get_buffer +_dbus_auth_get_bytes_to_send +_dbus_auth_get_guid_from_server +_dbus_auth_get_identity +_dbus_auth_get_unused_bytes +_dbus_auth_needs_decoding +_dbus_auth_needs_encoding +_dbus_auth_ref +_dbus_auth_return_buffer +_dbus_auth_server_new +_dbus_auth_set_context +_dbus_auth_set_credentials +_dbus_auth_set_mechanisms +_dbus_auth_unref +_dbus_bus_notify_shared_connection_disconnected_unlocked +_dbus_check_dir_is_private_to_user +_dbus_check_is_valid_bus_name +_dbus_check_is_valid_error_name +_dbus_check_is_valid_interface +_dbus_check_is_valid_member +_dbus_check_is_valid_path +_dbus_check_is_valid_signature +_dbus_close_socket +_dbus_concat_dir_and_file +_dbus_condvar_free +_dbus_condvar_free_at_location +_dbus_condvar_new +_dbus_condvar_new_at_location +_dbus_condvar_wait +_dbus_condvar_wait_timeout +_dbus_condvar_wake_all +_dbus_condvar_wake_one +_dbus_connect_tcp_socket +_dbus_connection_add_timeout_unlocked +_dbus_connection_add_watch_unlocked +_dbus_connection_block_pending_call +_dbus_connection_close_if_only_one_ref +_dbus_connection_close_possibly_shared +_dbus_connection_do_iteration_unlocked +_dbus_connection_get_message_to_send +_dbus_connection_handle_watch +_dbus_connection_has_messages_to_send_unlocked +_dbus_connection_lock +_dbus_connection_message_sent +_dbus_connection_new_for_transport +_dbus_connection_queue_received_message_link +_dbus_connection_queue_synthesized_message_link +_dbus_connection_ref_unlocked +_dbus_connection_remove_pending_call +_dbus_connection_remove_timeout_unlocked +_dbus_connection_remove_watch_unlocked +_dbus_connection_send_and_unlock +_dbus_connection_toggle_timeout_unlocked +_dbus_connection_toggle_watch_unlocked +_dbus_connection_unlock +_dbus_connection_unref_unlocked +_dbus_counter_new +_dbus_counter_ref +_dbus_counter_set_notify +_dbus_counter_unref +_dbus_create_directory +_dbus_create_file_exclusively +_dbus_credentials_add_credential +_dbus_credentials_add_credentials +_dbus_credentials_add_from_current_process +_dbus_credentials_add_from_user +_dbus_credentials_add_unix_pid +_dbus_credentials_add_unix_uid +_dbus_credentials_add_windows_sid +_dbus_credentials_are_anonymous +_dbus_credentials_are_empty +_dbus_credentials_are_superset +_dbus_credentials_clear +_dbus_credentials_copy +_dbus_credentials_get_unix_pid +_dbus_credentials_get_unix_uid +_dbus_credentials_get_windows_sid +_dbus_credentials_include +_dbus_credentials_new +_dbus_credentials_new_from_current_process +_dbus_credentials_ref +_dbus_credentials_same_user +_dbus_credentials_unref +_dbus_current_generation DATA +_dbus_daemon_publish_session_bus_address +_dbus_daemon_unpublish_session_bus_address +_dbus_data_slot_allocator_alloc +_dbus_data_slot_allocator_free +_dbus_data_slot_allocator_init +_dbus_data_slot_list_clear +_dbus_data_slot_list_free +_dbus_data_slot_list_get +_dbus_data_slot_list_init +_dbus_data_slot_list_set +_dbus_decompose_path +_dbus_delete_directory +_dbus_delete_file +_dbus_disable_sigpipe +_dbus_dup_string_array +_dbus_error_from_errno +_dbus_exit +_dbus_fd_set_close_on_exec +_dbus_file_get_contents +_dbus_first_type_in_signature +_dbus_first_type_in_signature_c_str +_dbus_flush_caches +_dbus_full_duplex_pipe +_dbus_generate_pseudorandom_bytes_buffer +_dbus_generate_random_ascii +_dbus_generate_random_bytes +_dbus_generate_random_bytes_buffer +_dbus_generate_uuid +_dbus_get_autolaunch_address +_dbus_get_config_file_name +_dbus_get_current_time +_dbus_get_environment +_dbus_get_is_errno_eagain_or_ewouldblock +_dbus_get_is_errno_eintr +_dbus_get_is_errno_enomem +_dbus_get_is_errno_nonzero +_dbus_get_local_machine_uuid_encoded +_dbus_get_standard_session_servicedirs +_dbus_get_standard_system_servicedirs +_dbus_get_tmpdir +_dbus_getenv +_dbus_getpid +_dbus_hash_iter_get_int_key +_dbus_hash_iter_get_string_key +_dbus_hash_iter_get_ulong_key +_dbus_hash_iter_get_value +_dbus_hash_iter_init +_dbus_hash_iter_lookup +_dbus_hash_iter_next +_dbus_hash_iter_remove_entry +_dbus_hash_iter_set_value +_dbus_hash_table_free_preallocated_entry +_dbus_hash_table_get_n_entries +_dbus_hash_table_insert_int +_dbus_hash_table_insert_string +_dbus_hash_table_insert_string_preallocated +_dbus_hash_table_insert_ulong +_dbus_hash_table_lookup_int +_dbus_hash_table_lookup_string +_dbus_hash_table_lookup_ulong +_dbus_hash_table_new +_dbus_hash_table_preallocate_entry +_dbus_hash_table_ref +_dbus_hash_table_remove_all +_dbus_hash_table_remove_int +_dbus_hash_table_remove_string +_dbus_hash_table_remove_ulong +_dbus_hash_table_unref +_dbus_header_byteswap +_dbus_header_copy +_dbus_header_create +_dbus_header_delete_field +_dbus_header_free +_dbus_header_get_field_basic +_dbus_header_get_field_raw +_dbus_header_get_flag +_dbus_header_get_message_type +_dbus_header_get_serial +_dbus_header_have_message_untrusted +_dbus_header_init +_dbus_header_load +_dbus_header_reinit +_dbus_header_set_field_basic +_dbus_header_set_serial +_dbus_header_toggle_flag +_dbus_header_update_lengths +_dbus_keyring_get_best_key +_dbus_keyring_get_hex_key +_dbus_keyring_is_for_credentials +_dbus_keyring_new_for_credentials +_dbus_keyring_ref +_dbus_keyring_unref +_dbus_keyring_validate_context +_dbus_list_alloc_link +_dbus_list_append +_dbus_list_append_link +_dbus_list_clear +_dbus_list_copy +_dbus_list_find_last +_dbus_list_foreach +_dbus_list_free_link +_dbus_list_get_first +_dbus_list_get_first_link +_dbus_list_get_last +_dbus_list_get_last_link +_dbus_list_get_length +_dbus_list_insert_after +_dbus_list_insert_after_link +_dbus_list_insert_before_link +_dbus_list_length_is_one +_dbus_list_pop_first +_dbus_list_pop_first_link +_dbus_list_pop_last +_dbus_list_prepend +_dbus_list_prepend_link +_dbus_list_remove +_dbus_list_remove_last +_dbus_list_remove_link +_dbus_list_unlink +_dbus_listen_tcp_socket +_dbus_lock_atomic DATA +_dbus_lock_bus DATA +_dbus_lock_bus_datas DATA +_dbus_lock_connection_slots DATA +_dbus_lock_list DATA +_dbus_lock_machine_uuid DATA +_dbus_lock_message_cache DATA +_dbus_lock_message_slots DATA +_dbus_lock_pending_call_slots DATA +_dbus_lock_server_slots DATA +_dbus_lock_shared_connections DATA +_dbus_lock_shutdown_funcs DATA +_dbus_lock_sid_atom_cache DATA +_dbus_lock_system_users DATA +_dbus_lock_win_fds DATA +_dbus_make_file_world_readable +_dbus_marshal_byteswap +_dbus_marshal_read_basic +_dbus_marshal_read_uint32 +_dbus_marshal_set_basic +_dbus_marshal_set_uint32 +_dbus_marshal_skip_array +_dbus_marshal_skip_basic +_dbus_marshal_write_basic +_dbus_marshal_write_fixed_multi +_dbus_mem_pool_alloc +_dbus_mem_pool_dealloc +_dbus_mem_pool_free +_dbus_mem_pool_new +_dbus_memdup +_dbus_message_get_network_data +_dbus_message_iter_get_args_valist +_dbus_message_loader_get_buffer +_dbus_message_loader_get_is_corrupted +_dbus_message_loader_get_max_message_size +_dbus_message_loader_new +_dbus_message_loader_peek_message +_dbus_message_loader_pop_message +_dbus_message_loader_pop_message_link +_dbus_message_loader_putback_message_link +_dbus_message_loader_queue_messages +_dbus_message_loader_ref +_dbus_message_loader_return_buffer +_dbus_message_loader_set_max_message_size +_dbus_message_loader_unref +_dbus_mutex_free +_dbus_mutex_free_at_location +_dbus_mutex_lock +_dbus_mutex_new +_dbus_mutex_new_at_location +_dbus_mutex_unlock +_dbus_no_memory_message +_dbus_object_tree_dispatch_and_unlock +_dbus_object_tree_free_all_unlocked +_dbus_object_tree_get_user_data_unlocked +_dbus_object_tree_list_registered_and_unlock +_dbus_object_tree_new +_dbus_object_tree_ref +_dbus_object_tree_register +_dbus_object_tree_unref +_dbus_object_tree_unregister_and_unlock +_dbus_pack_uint32 +_dbus_pending_call_complete +_dbus_pending_call_get_completed_unlocked +_dbus_pending_call_get_connection_and_lock +_dbus_pending_call_get_connection_unlocked +_dbus_pending_call_get_reply_serial_unlocked +_dbus_pending_call_get_timeout_unlocked +_dbus_pending_call_is_timeout_added_unlocked +_dbus_pending_call_new_unlocked +_dbus_pending_call_queue_timeout_error_unlocked +_dbus_pending_call_ref_unlocked +_dbus_pending_call_set_data_unlocked +_dbus_pending_call_set_reply_serial_unlocked +_dbus_pending_call_set_reply_unlocked +_dbus_pending_call_set_timeout_added_unlocked +_dbus_pending_call_set_timeout_error_unlocked +_dbus_pending_call_unref_and_unlock +_dbus_pid_for_log +_dbus_pipe_close +_dbus_pipe_init +_dbus_pipe_init_stdout +_dbus_pipe_invalidate +_dbus_pipe_is_stdout_or_stderr +_dbus_pipe_is_valid +_dbus_pipe_write +_dbus_poll +_dbus_print_backtrace +_dbus_printf_string_upper_bound +_dbus_read_credentials_socket +_dbus_read_local_machine_uuid +_dbus_read_socket +_dbus_read_uuid_file +_dbus_real_assert +_dbus_real_assert_not_reached +_dbus_register_shutdown_func +_dbus_return_if_fail_warning_format +_dbus_send_credentials_socket +_dbus_server_add_timeout +_dbus_server_add_watch +_dbus_server_finalize_base +_dbus_server_init_base +_dbus_server_listen_platform_specific +_dbus_server_listen_socket +_dbus_server_new_for_socket +_dbus_server_new_for_tcp_socket +_dbus_server_ref_unlocked +_dbus_server_remove_timeout +_dbus_server_remove_watch +_dbus_server_socket_own_filename +_dbus_server_toggle_timeout +_dbus_server_toggle_watch +_dbus_server_unref_unlocked +_dbus_set_bad_address +_dbus_set_errno_to_zero +_dbus_set_fd_nonblocking +_dbus_setenv +_dbus_sha_compute +_dbus_sha_final +_dbus_sha_init +_dbus_sha_update +_dbus_sleep_milliseconds +_dbus_split_paths_and_append +_dbus_strdup +_dbus_strerror +_dbus_strerror_from_errno +_dbus_string_align_length +_dbus_string_alloc_space +_dbus_string_append +_dbus_string_append_byte +_dbus_string_append_byte_as_hex +_dbus_string_append_int +_dbus_string_append_len +_dbus_string_append_printf +_dbus_string_append_printf_valist +_dbus_string_append_uint +_dbus_string_array_contains +_dbus_string_chop_white +_dbus_string_copy +_dbus_string_copy_data +_dbus_string_copy_len +_dbus_string_copy_to_buffer +_dbus_string_delete +_dbus_string_equal +_dbus_string_equal_c_str +_dbus_string_equal_len +_dbus_string_equal_substring +_dbus_string_find +_dbus_string_find_blank +_dbus_string_find_eol +_dbus_string_find_to +_dbus_string_free +_dbus_string_get_byte +_dbus_string_get_const_data +_dbus_string_get_const_data_len +_dbus_string_get_data +_dbus_string_get_data_len +_dbus_string_get_length +_dbus_string_hex_decode +_dbus_string_hex_encode +_dbus_string_init +_dbus_string_init_const +_dbus_string_init_const_len +_dbus_string_init_preallocated +_dbus_string_insert_2_aligned +_dbus_string_insert_4_aligned +_dbus_string_insert_8_aligned +_dbus_string_insert_alignment +_dbus_string_insert_byte +_dbus_string_insert_bytes +_dbus_string_lengthen +_dbus_string_move +_dbus_string_move_len +_dbus_string_parse_int +_dbus_string_parse_uint +_dbus_string_pop_line +_dbus_string_replace_len +_dbus_string_save_to_file +_dbus_string_set_byte +_dbus_string_set_length +_dbus_string_shorten +_dbus_string_skip_blank +_dbus_string_skip_white +_dbus_string_skip_white_reverse +_dbus_string_split_on_byte +_dbus_string_steal_data +_dbus_string_validate_ascii +_dbus_string_validate_nul +_dbus_string_validate_utf8 +_dbus_string_zero +_dbus_swap_array +_dbus_threads_init_platform_specific +_dbus_timeout_list_add_timeout +_dbus_timeout_list_free +_dbus_timeout_list_new +_dbus_timeout_list_remove_timeout +_dbus_timeout_list_set_functions +_dbus_timeout_list_toggle_timeout +_dbus_timeout_new +_dbus_timeout_ref +_dbus_timeout_set_enabled +_dbus_timeout_set_interval +_dbus_timeout_unref +_dbus_transport_disconnect +_dbus_transport_do_iteration +_dbus_transport_finalize_base +_dbus_transport_get_address +_dbus_transport_get_adt_audit_session_data +_dbus_transport_get_dispatch_status +_dbus_transport_get_is_anonymous +_dbus_transport_get_is_authenticated +_dbus_transport_get_is_connected +_dbus_transport_get_max_message_size +_dbus_transport_get_max_received_size +_dbus_transport_get_server_id +_dbus_transport_get_socket_fd +_dbus_transport_get_unix_process_id +_dbus_transport_get_unix_user +_dbus_transport_get_windows_user +_dbus_transport_handle_watch +_dbus_transport_init_base +_dbus_transport_new_for_socket +_dbus_transport_new_for_tcp_socket +_dbus_transport_open +_dbus_transport_open_platform_specific +_dbus_transport_open_socket +_dbus_transport_queue_messages +_dbus_transport_ref +_dbus_transport_set_allow_anonymous +_dbus_transport_set_auth_mechanisms +_dbus_transport_set_connection +_dbus_transport_set_max_message_size +_dbus_transport_set_max_received_size +_dbus_transport_set_unix_user_function +_dbus_transport_set_windows_user_function +_dbus_transport_unref +_dbus_type_get_alignment +_dbus_type_is_valid +_dbus_type_reader_delete +_dbus_type_reader_get_array_length +_dbus_type_reader_get_current_type +_dbus_type_reader_get_element_type +_dbus_type_reader_get_signature +_dbus_type_reader_get_value_pos +_dbus_type_reader_greater_than +_dbus_type_reader_has_next +_dbus_type_reader_init +_dbus_type_reader_init_types_only +_dbus_type_reader_next +_dbus_type_reader_read_basic +_dbus_type_reader_read_fixed_multi +_dbus_type_reader_read_raw +_dbus_type_reader_recurse +_dbus_type_reader_set_basic +_dbus_type_signature_next +_dbus_type_to_string +_dbus_type_writer_add_types +_dbus_type_writer_append_array +_dbus_type_writer_init +_dbus_type_writer_init_types_delayed +_dbus_type_writer_init_values_only +_dbus_type_writer_recurse +_dbus_type_writer_remove_types +_dbus_type_writer_set_enabled +_dbus_type_writer_unrecurse +_dbus_type_writer_write_basic +_dbus_type_writer_write_fixed_multi +_dbus_type_writer_write_reader +_dbus_type_writer_write_reader_partial +_dbus_unpack_uint16 +_dbus_unpack_uint32 +_dbus_uuid_encode +_dbus_validate_body_with_reason +_dbus_validate_bus_name +_dbus_validate_error_name +_dbus_validate_interface +_dbus_validate_member +_dbus_validate_path +_dbus_validate_signature +_dbus_validate_signature_with_reason +_dbus_verbose_bytes +_dbus_verbose_bytes_of_string +_dbus_warn +_dbus_warn_check_failed +_dbus_watch_invalidate +_dbus_watch_list_add_watch +_dbus_watch_list_free +_dbus_watch_list_new +_dbus_watch_list_remove_watch +_dbus_watch_list_set_functions +_dbus_watch_list_toggle_watch +_dbus_watch_new +_dbus_watch_ref +_dbus_watch_sanitize_condition +_dbus_watch_set_handler +_dbus_watch_unref +_dbus_win_account_to_sid +_dbus_win_set_error_from_win_error +_dbus_win_startup_winsock +_dbus_win_utf16_to_utf8 +_dbus_win_utf8_to_utf16 +_dbus_win_warn_win_error +_dbus_write_socket +_dbus_write_socket_two +dbus_address_entries_free +dbus_address_entry_get_method +dbus_address_entry_get_value +dbus_address_escape_value +dbus_address_unescape_value +dbus_bus_add_match +dbus_bus_get +dbus_bus_get_id +dbus_bus_get_private +dbus_bus_get_unique_name +dbus_bus_get_unix_user +dbus_bus_name_has_owner +dbus_bus_register +dbus_bus_release_name +dbus_bus_remove_match +dbus_bus_request_name +dbus_bus_set_unique_name +dbus_bus_start_service_by_name +dbus_connection_add_filter +dbus_connection_allocate_data_slot +dbus_connection_borrow_message +dbus_connection_can_send_type +dbus_connection_close +dbus_connection_dispatch +dbus_connection_flush +dbus_connection_free_data_slot +dbus_connection_free_preallocated_send +dbus_connection_get_adt_audit_session_data +dbus_connection_get_data +dbus_connection_get_dispatch_status +dbus_connection_get_is_anonymous +dbus_connection_get_is_authenticated +dbus_connection_get_is_connected +dbus_connection_get_max_message_size +dbus_connection_get_max_message_unix_fds +dbus_connection_get_max_received_size +dbus_connection_get_max_received_unix_fds +dbus_connection_get_object_path_data +dbus_connection_get_outgoing_size +dbus_connection_get_outgoing_unix_fds +dbus_connection_get_server_id +dbus_connection_get_socket +dbus_connection_get_unix_fd +dbus_connection_get_unix_process_id +dbus_connection_get_unix_user +dbus_connection_get_windows_user +dbus_connection_has_messages_to_send +dbus_connection_list_registered +dbus_connection_open +dbus_connection_open_private +dbus_connection_pop_message +dbus_connection_preallocate_send +dbus_connection_read_write +dbus_connection_read_write_dispatch +dbus_connection_ref +dbus_connection_register_fallback +dbus_connection_register_object_path +dbus_connection_remove_filter +dbus_connection_return_message +dbus_connection_send +dbus_connection_send_preallocated +dbus_connection_send_with_reply +dbus_connection_send_with_reply_and_block +dbus_connection_set_allow_anonymous +dbus_connection_set_change_sigpipe +dbus_connection_set_data +dbus_connection_set_dispatch_status_function +dbus_connection_set_exit_on_disconnect +dbus_connection_set_max_message_size +dbus_connection_set_max_message_unix_fds +dbus_connection_set_max_received_size +dbus_connection_set_max_received_unix_fds +dbus_connection_set_route_peer_messages +dbus_connection_set_timeout_functions +dbus_connection_set_unix_user_function +dbus_connection_set_wakeup_main_function +dbus_connection_set_watch_functions +dbus_connection_set_windows_user_function +dbus_connection_steal_borrowed_message +dbus_connection_try_register_fallback +dbus_connection_try_register_object_path +dbus_connection_unref +dbus_connection_unregister_object_path +dbus_error_free +dbus_error_has_name +dbus_error_init +dbus_error_is_set +dbus_free +dbus_free_string_array +dbus_get_local_machine_id +dbus_get_version +dbus_malloc +dbus_malloc0 +dbus_message_allocate_data_slot +dbus_message_append_args +dbus_message_append_args_valist +dbus_message_contains_unix_fds +dbus_message_copy +dbus_message_demarshal +dbus_message_demarshal_bytes_needed +dbus_message_free_data_slot +dbus_message_get_args +dbus_message_get_args_valist +dbus_message_get_auto_start +dbus_message_get_data +dbus_message_get_destination +dbus_message_get_error_name +dbus_message_get_interface +dbus_message_get_member +dbus_message_get_no_reply +dbus_message_get_path +dbus_message_get_path_decomposed +dbus_message_get_reply_serial +dbus_message_get_sender +dbus_message_get_serial +dbus_message_get_signature +dbus_message_get_type +dbus_message_has_destination +dbus_message_has_interface +dbus_message_has_member +dbus_message_has_path +dbus_message_has_sender +dbus_message_has_signature +dbus_message_is_error +dbus_message_is_method_call +dbus_message_is_signal +dbus_message_iter_abandon_container +dbus_message_iter_append_basic +dbus_message_iter_append_fixed_array +dbus_message_iter_close_container +dbus_message_iter_get_arg_type +dbus_message_iter_get_array_len +dbus_message_iter_get_basic +dbus_message_iter_get_element_type +dbus_message_iter_get_fixed_array +dbus_message_iter_get_signature +dbus_message_iter_has_next +dbus_message_iter_init +dbus_message_iter_init_append +dbus_message_iter_next +dbus_message_iter_open_container +dbus_message_iter_recurse +dbus_message_lock +dbus_message_marshal +dbus_message_new +dbus_message_new_error +dbus_message_new_error_printf +dbus_message_new_method_call +dbus_message_new_method_return +dbus_message_new_signal +dbus_message_ref +dbus_message_set_auto_start +dbus_message_set_data +dbus_message_set_destination +dbus_message_set_error_name +dbus_message_set_interface +dbus_message_set_member +dbus_message_set_no_reply +dbus_message_set_path +dbus_message_set_reply_serial +dbus_message_set_sender +dbus_message_set_serial +dbus_message_type_from_string +dbus_message_type_to_string +dbus_message_unref +dbus_move_error +dbus_parse_address +dbus_pending_call_allocate_data_slot +dbus_pending_call_block +dbus_pending_call_cancel +dbus_pending_call_free_data_slot +dbus_pending_call_get_completed +dbus_pending_call_get_data +dbus_pending_call_ref +dbus_pending_call_set_data +dbus_pending_call_set_notify +dbus_pending_call_steal_reply +dbus_pending_call_unref +dbus_realloc +dbus_server_allocate_data_slot +dbus_server_disconnect +dbus_server_free_data_slot +dbus_server_get_address +dbus_server_get_data +dbus_server_get_id +dbus_server_get_is_connected +dbus_server_listen +dbus_server_ref +dbus_server_set_auth_mechanisms +dbus_server_set_data +dbus_server_set_new_connection_function +dbus_server_set_timeout_functions +dbus_server_set_watch_functions +dbus_server_unref +dbus_set_error +dbus_set_error_const +dbus_set_error_from_message +dbus_shutdown +dbus_signature_iter_get_current_type +dbus_signature_iter_get_element_type +dbus_signature_iter_get_signature +dbus_signature_iter_init +dbus_signature_iter_next +dbus_signature_iter_recurse +dbus_signature_validate +dbus_signature_validate_single +dbus_threads_init +dbus_threads_init_default +dbus_timeout_get_data +dbus_timeout_get_enabled +dbus_timeout_get_interval +dbus_timeout_handle +dbus_timeout_set_data +dbus_type_is_basic +dbus_type_is_container +dbus_type_is_fixed +dbus_watch_get_data +dbus_watch_get_enabled +dbus_watch_get_fd +dbus_watch_get_flags +dbus_watch_get_socket +dbus_watch_get_unix_fd +dbus_watch_handle +dbus_watch_set_data diff --git a/dbus/dbus-1-testsymbols.def.in b/dbus/dbus-1-testsymbols.def.in new file mode 100644 index 00000000..ce7731bf --- /dev/null +++ b/dbus/dbus-1-testsymbols.def.in @@ -0,0 +1,55 @@ +_dbus_address_test +_dbus_auth_script_run +_dbus_connection_queue_received_message +_dbus_connection_test_get_locks +_dbus_data_slot_test +_dbus_decrement_fail_alloc_counter +_dbus_disable_mem_pools +_dbus_get_fail_alloc_counter +_dbus_get_fail_alloc_failures +_dbus_get_malloc_blocks_outstanding +_dbus_hash_iter_get_two_strings_key +_dbus_hash_table_insert_pointer +_dbus_hash_table_insert_two_strings +_dbus_hash_table_lookup_pointer +_dbus_hash_table_lookup_two_strings +_dbus_hash_table_remove_pointer +_dbus_hash_table_remove_two_strings +_dbus_hash_test +_dbus_header_field_to_string +_dbus_keyring_test +_dbus_list_insert_before +_dbus_list_pop_last_link +_dbus_list_test +_dbus_marshal_header_test +_dbus_marshal_read_fixed_multi +_dbus_marshal_test +_dbus_mem_pool_test +_dbus_memory_test +_dbus_misc_test +_dbus_object_tree_test +_dbus_pending_call_test +_dbus_server_debug_pipe_new +_dbus_server_listen_debug_pipe +_dbus_server_test +_dbus_set_fail_alloc_counter +_dbus_set_fail_alloc_failures +_dbus_sha_test +_dbus_signature_test +_dbus_string_append_4_aligned +_dbus_string_append_8_aligned +_dbus_string_append_double +_dbus_string_append_unichar +_dbus_string_compact +_dbus_string_copy_data_len +_dbus_string_delete_first_word +_dbus_string_delete_leading_blanks +_dbus_string_get_unichar +_dbus_string_lock +_dbus_string_parse_double +_dbus_string_starts_with_c_str +_dbus_string_steal_data_len +_dbus_test_oom_handling +_dbus_threads_init_debug +_dbus_transport_debug_pipe_new +_dbus_transport_open_debug_pipe diff --git a/dbus/dbus-1-verbosesymbols.def.in b/dbus/dbus-1-verbosesymbols.def.in new file mode 100644 index 00000000..ee5411c8 --- /dev/null +++ b/dbus/dbus-1-verbosesymbols.def.in @@ -0,0 +1,3 @@ +_dbus_is_verbose_real +_dbus_verbose_real +_dbus_verbose_reset_real diff --git a/dbus/dbus-1.def b/dbus/dbus-1.def index a06f68fc..722cd280 100644 --- a/dbus/dbus-1.def +++ b/dbus/dbus-1.def @@ -29,20 +29,9 @@ _dbus_auth_server_new _dbus_auth_set_context _dbus_auth_set_credentials _dbus_auth_set_mechanisms -_dbus_auth_test _dbus_auth_unref -_dbus_babysitter_get_child_exited -_dbus_babysitter_get_child_exit_status -_dbus_babysitter_kill_child -_dbus_babysitter_ref -_dbus_babysitter_set_child_exit_error -_dbus_babysitter_set_watch_functions -_dbus_babysitter_unref -_dbus_become_daemon _dbus_bus_notify_shared_connection_disconnected_unlocked -_dbus_change_to_daemon_user _dbus_check_dir_is_private_to_user -_dbus_check_fdleaks _dbus_check_is_valid_bus_name _dbus_check_is_valid_error_name _dbus_check_is_valid_interface @@ -50,7 +39,6 @@ _dbus_check_is_valid_member _dbus_check_is_valid_path _dbus_check_is_valid_signature _dbus_close_socket -_dbus_command_for_pid _dbus_concat_dir_and_file _dbus_condvar_free _dbus_condvar_free_at_location @@ -112,7 +100,6 @@ _dbus_credentials_new _dbus_credentials_new_from_current_process _dbus_credentials_ref _dbus_credentials_same_user -_dbus_credentials_test _dbus_credentials_unref _dbus_current_generation DATA _dbus_daemon_publish_session_bus_address @@ -130,9 +117,6 @@ _dbus_decompose_path _dbus_decrement_fail_alloc_counter _dbus_delete_directory _dbus_delete_file -_dbus_directory_close -_dbus_directory_get_next_file -_dbus_directory_open _dbus_disable_mem_pools _dbus_disable_sigpipe _dbus_dup_string_array @@ -161,7 +145,6 @@ _dbus_get_is_errno_enomem _dbus_get_is_errno_nonzero _dbus_get_local_machine_uuid_encoded _dbus_get_malloc_blocks_outstanding -_dbus_get_oom_wait _dbus_get_standard_session_servicedirs _dbus_get_standard_system_servicedirs _dbus_get_tmpdir @@ -220,7 +203,6 @@ _dbus_header_set_field_basic _dbus_header_set_serial _dbus_header_toggle_flag _dbus_header_update_lengths -_dbus_init_system_log _dbus_is_verbose_real _dbus_keyring_get_best_key _dbus_keyring_get_hex_key @@ -260,7 +242,6 @@ _dbus_list_remove_link _dbus_list_test _dbus_list_unlink _dbus_listen_tcp_socket -_dbus_lm_strerror _dbus_lock_atomic DATA _dbus_lock_bus DATA _dbus_lock_bus_datas DATA @@ -276,34 +257,17 @@ _dbus_lock_shutdown_funcs DATA _dbus_lock_sid_atom_cache DATA _dbus_lock_system_users DATA _dbus_lock_win_fds DATA -_dbus_log_info -_dbus_log_security -_dbus_loop_add_timeout -_dbus_loop_add_watch -_dbus_loop_dispatch -_dbus_loop_iterate -_dbus_loop_new -_dbus_loop_queue_dispatch -_dbus_loop_quit -_dbus_loop_ref -_dbus_loop_remove_timeout -_dbus_loop_remove_watch -_dbus_loop_run -_dbus_loop_unref _dbus_make_file_world_readable _dbus_marshal_byteswap -_dbus_marshal_byteswap_test _dbus_marshal_header_test _dbus_marshal_read_basic _dbus_marshal_read_fixed_multi _dbus_marshal_read_uint32 -_dbus_marshal_recursive_test _dbus_marshal_set_basic _dbus_marshal_set_uint32 _dbus_marshal_skip_array _dbus_marshal_skip_basic _dbus_marshal_test -_dbus_marshal_validate_test _dbus_marshal_write_basic _dbus_marshal_write_fixed_multi _dbus_mem_pool_alloc @@ -313,10 +277,6 @@ _dbus_mem_pool_new _dbus_mem_pool_test _dbus_memdup _dbus_memory_test -_dbus_message_contains_unix_fds -_dbus_message_data_free -_dbus_message_data_iter_get_and_next -_dbus_message_data_iter_init _dbus_message_get_network_data _dbus_message_iter_get_args_valist _dbus_message_loader_get_buffer @@ -332,7 +292,6 @@ _dbus_message_loader_ref _dbus_message_loader_return_buffer _dbus_message_loader_set_max_message_size _dbus_message_loader_unref -_dbus_message_test _dbus_misc_test _dbus_mutex_free _dbus_mutex_free_at_location @@ -352,9 +311,6 @@ _dbus_object_tree_test _dbus_object_tree_unref _dbus_object_tree_unregister_and_unlock _dbus_pack_uint32 -_dbus_parse_unix_group_from_config -_dbus_parse_unix_user_from_config -_dbus_path_is_absolute _dbus_pending_call_complete _dbus_pending_call_get_completed_unlocked _dbus_pending_call_get_connection_and_lock @@ -415,21 +371,15 @@ _dbus_set_errno_to_zero _dbus_set_fail_alloc_counter _dbus_set_fail_alloc_failures _dbus_set_fd_nonblocking -_dbus_set_signal_handler _dbus_setenv _dbus_sha_compute _dbus_sha_final _dbus_sha_init _dbus_sha_test _dbus_sha_update -_dbus_shell_parse_argv -_dbus_shell_unquote _dbus_signature_test _dbus_sleep_milliseconds -_dbus_spawn_async_with_babysitter -_dbus_spawn_test _dbus_split_paths_and_append -_dbus_stat _dbus_strdup _dbus_strerror _dbus_strerror_from_errno @@ -457,14 +407,12 @@ _dbus_string_copy_to_buffer _dbus_string_delete _dbus_string_delete_first_word _dbus_string_delete_leading_blanks -_dbus_string_ends_with_c_str _dbus_string_equal _dbus_string_equal_c_str _dbus_string_equal_len _dbus_string_equal_substring _dbus_string_find _dbus_string_find_blank -_dbus_string_find_byte_backward _dbus_string_find_eol _dbus_string_find_to _dbus_string_free @@ -473,7 +421,6 @@ _dbus_string_get_const_data _dbus_string_get_const_data_len _dbus_string_get_data _dbus_string_get_data_len -_dbus_string_get_dirname _dbus_string_get_length _dbus_string_get_unichar _dbus_string_hex_decode @@ -508,13 +455,11 @@ _dbus_string_split_on_byte _dbus_string_starts_with_c_str _dbus_string_steal_data _dbus_string_steal_data_len -_dbus_string_test _dbus_string_validate_ascii _dbus_string_validate_nul _dbus_string_validate_utf8 _dbus_string_zero _dbus_swap_array -_dbus_sysdeps_test _dbus_test_oom_handling _dbus_threads_init_debug _dbus_threads_init_platform_specific @@ -567,7 +512,6 @@ _dbus_transport_unref _dbus_type_get_alignment _dbus_type_is_valid _dbus_type_reader_delete -_dbus_type_reader_equal_values _dbus_type_reader_get_array_length _dbus_type_reader_get_current_type _dbus_type_reader_get_element_type @@ -598,9 +542,6 @@ _dbus_type_writer_write_basic _dbus_type_writer_write_fixed_multi _dbus_type_writer_write_reader _dbus_type_writer_write_reader_partial -_dbus_unix_groups_from_uid -_dbus_unix_user_is_at_console -_dbus_unix_user_is_process_owner _dbus_unpack_uint16 _dbus_unpack_uint32 _dbus_uuid_encode @@ -616,8 +557,6 @@ _dbus_verbose_bytes _dbus_verbose_bytes_of_string _dbus_verbose_real _dbus_verbose_reset_real -_dbus_verify_daemon_user -_dbus_wait_for_memory _dbus_warn _dbus_warn_check_failed _dbus_watch_invalidate @@ -638,8 +577,6 @@ _dbus_win_startup_winsock _dbus_win_utf16_to_utf8 _dbus_win_utf8_to_utf16 _dbus_win_warn_win_error -_dbus_windows_user_is_process_owner -_dbus_write_pid_to_file_and_pipe _dbus_write_socket _dbus_write_socket_two dbus_address_entries_free @@ -728,19 +665,13 @@ dbus_error_is_set dbus_free dbus_free_string_array dbus_get_local_machine_id -dbus_internal_do_not_use_foreach_message_file -dbus_internal_do_not_use_generate_bodies -dbus_internal_do_not_use_load_message_file -dbus_internal_do_not_use_run_tests -dbus_internal_do_not_use_try_message_data -dbus_internal_do_not_use_try_message_file dbus_malloc dbus_malloc0 dbus_message_allocate_data_slot dbus_message_append_args dbus_message_append_args_valist -dbus_message_copy dbus_message_contains_unix_fds +dbus_message_copy dbus_message_demarshal dbus_message_free_data_slot dbus_message_get_args diff --git a/dbus/dbus-internal-symbols.def.in b/dbus/dbus-internal-symbols.def.in new file mode 100644 index 00000000..1132b100 --- /dev/null +++ b/dbus/dbus-internal-symbols.def.in @@ -0,0 +1,48 @@ +_dbus_babysitter_get_child_exited +_dbus_babysitter_get_child_exit_status +_dbus_babysitter_kill_child +_dbus_babysitter_ref +_dbus_babysitter_set_child_exit_error +_dbus_babysitter_set_watch_functions +_dbus_babysitter_unref +_dbus_become_daemon +_dbus_change_to_daemon_user +_dbus_command_for_pid +_dbus_directory_close +_dbus_directory_get_next_file +_dbus_directory_open +_dbus_get_oom_wait +_dbus_init_system_log +_dbus_lm_strerror +_dbus_log_info +_dbus_log_security +_dbus_loop_add_timeout +_dbus_loop_add_watch +_dbus_loop_dispatch +_dbus_loop_iterate +_dbus_loop_new +_dbus_loop_queue_dispatch +_dbus_loop_quit +_dbus_loop_ref +_dbus_loop_remove_timeout +_dbus_loop_remove_watch +_dbus_loop_run +_dbus_loop_unref +_dbus_parse_unix_group_from_config +_dbus_parse_unix_user_from_config +_dbus_path_is_absolute +_dbus_set_signal_handler +_dbus_shell_parse_argv +_dbus_shell_unquote +_dbus_spawn_async_with_babysitter +_dbus_stat +_dbus_string_ends_with_c_str +_dbus_string_find_byte_backward +_dbus_string_get_dirname +_dbus_unix_groups_from_uid +_dbus_unix_user_is_at_console +_dbus_unix_user_is_process_owner +_dbus_verify_daemon_user +_dbus_wait_for_memory +_dbus_windows_user_is_process_owner +_dbus_write_pid_to_file_and_pipe diff --git a/dbus/dbus-internal-testsymbols.def.in b/dbus/dbus-internal-testsymbols.def.in new file mode 100644 index 00000000..05dd4e66 --- /dev/null +++ b/dbus/dbus-internal-testsymbols.def.in @@ -0,0 +1,19 @@ +_dbus_auth_test +_dbus_credentials_test +_dbus_marshal_byteswap_test +_dbus_marshal_recursive_test +_dbus_marshal_validate_test +_dbus_message_data_free +_dbus_message_data_iter_get_and_next +_dbus_message_data_iter_init +_dbus_message_test +_dbus_spawn_test +_dbus_string_test +_dbus_sysdeps_test +_dbus_type_reader_equal_values +dbus_internal_do_not_use_foreach_message_file +dbus_internal_do_not_use_generate_bodies +dbus_internal_do_not_use_load_message_file +dbus_internal_do_not_use_run_tests +dbus_internal_do_not_use_try_message_data +dbus_internal_do_not_use_try_message_file diff --git a/dbus/dbus-pipe-win.c b/dbus/dbus-pipe-win.c index c2917c68..79865735 100644 --- a/dbus/dbus-pipe-win.c +++ b/dbus/dbus-pipe-win.c @@ -28,6 +28,7 @@ #include "dbus-pipe.h" #include <io.h> +#include <errno.h> /** * write data to a pipe. diff --git a/dbus/dbus-protocol.h b/dbus/dbus-protocol.h index a2284ee5..17798e94 100644 --- a/dbus/dbus-protocol.h +++ b/dbus/dbus-protocol.h @@ -239,6 +239,8 @@ extern "C" { /** Message type of a signal message, see dbus_message_get_type() */ #define DBUS_MESSAGE_TYPE_SIGNAL 4 +#define DBUS_NUM_MESSAGE_TYPES 5 + /* Header flags */ /** If set, this flag means that the sender of a message does not care about getting diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index b7a8b992..d9cf18ed 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -2311,7 +2311,6 @@ _dbus_string_equal (const DBusString *a, return TRUE; } -#ifdef DBUS_BUILD_TESTS /** * Tests two DBusString for equality up to the given length. * The strings may be shorter than the given length. @@ -2356,7 +2355,6 @@ _dbus_string_equal_len (const DBusString *a, return TRUE; } -#endif /* DBUS_BUILD_TESTS */ /** * Tests two sub-parts of two DBusString for equality. The specified diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 0d3e999b..1c72327f 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1550,7 +1550,7 @@ _dbus_read_credentials_socket (int client_fd, #elif defined(HAVE_CMSGCRED) struct cmsgcred *cred; - cred = (struct cmsgcred *) CMSG_DATA (&cmsg); + cred = (struct cmsgcred *) CMSG_DATA (&cmsg.hdr); pid_read = cred->cmcred_pid; uid_read = cred->cmcred_euid; #elif defined(LOCAL_CREDS) @@ -2348,7 +2348,8 @@ _dbus_poll (DBusPollFD *fds, } /** - * Get current time, as in gettimeofday(). + * Get current time, as in gettimeofday(). Use the monotonic clock if + * available, to avoid problems when the system time changes. * * @param tv_sec return location for number of seconds * @param tv_usec return location for number of microseconds (thousandths) @@ -2359,12 +2360,22 @@ _dbus_get_current_time (long *tv_sec, { struct timeval t; +#ifdef HAVE_MONOTONIC_CLOCK + struct timespec ts; + clock_gettime (CLOCK_MONOTONIC, &ts); + + if (tv_sec) + *tv_sec = ts.tv_sec; + if (tv_usec) + *tv_usec = ts.tv_nsec / 1000; +#else gettimeofday (&t, NULL); if (tv_sec) *tv_sec = t.tv_sec; if (tv_usec) *tv_usec = t.tv_usec; +#endif } /** diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index d969d0a0..688ec19d 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -44,12 +44,6 @@ #include <dirent.h> #include <sys/un.h> #include <syslog.h> -#include <syslog.h> -#ifdef HAVE_LIBAUDIT -#include <sys/prctl.h> -#include <sys/capability.h> -#include <libaudit.h> -#endif /* HAVE_LIBAUDIT */ #ifdef HAVE_SYS_SYSLIMITS_H #include <sys/syslimits.h> @@ -309,6 +303,9 @@ _dbus_verify_daemon_user (const char *user) return _dbus_get_user_id_and_primary_group (&u, NULL, NULL); } + +/* The HAVE_LIBAUDIT case lives in selinux.c */ +#ifndef HAVE_LIBAUDIT /** * Changes the user and group the bus is running as. * @@ -323,13 +320,9 @@ _dbus_change_to_daemon_user (const char *user, dbus_uid_t uid; dbus_gid_t gid; DBusString u; -#ifdef HAVE_LIBAUDIT - dbus_bool_t we_were_root; - cap_t new_caps; -#endif - + _dbus_string_init_const (&u, user); - + if (!_dbus_get_user_id_and_primary_group (&u, &uid, &gid)) { dbus_set_error (error, DBUS_ERROR_FAILED, @@ -337,59 +330,7 @@ _dbus_change_to_daemon_user (const char *user, user); return FALSE; } - -#ifdef HAVE_LIBAUDIT - we_were_root = _dbus_geteuid () == 0; - new_caps = NULL; - /* have a tmp set of caps that we use to transition to the usr/grp dbus should - * run as ... doesn't really help. But keeps people happy. - */ - - if (we_were_root) - { - cap_value_t new_cap_list[] = { CAP_AUDIT_WRITE }; - cap_value_t tmp_cap_list[] = { CAP_AUDIT_WRITE, CAP_SETUID, CAP_SETGID }; - cap_t tmp_caps = cap_init(); - - if (!tmp_caps || !(new_caps = cap_init ())) - { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Failed to initialize drop of capabilities: %s\n", - _dbus_strerror (errno)); - if (tmp_caps) - cap_free (tmp_caps); - - return FALSE; - } - - /* assume these work... */ - cap_set_flag (new_caps, CAP_PERMITTED, 1, new_cap_list, CAP_SET); - cap_set_flag (new_caps, CAP_EFFECTIVE, 1, new_cap_list, CAP_SET); - cap_set_flag (tmp_caps, CAP_PERMITTED, 3, tmp_cap_list, CAP_SET); - cap_set_flag (tmp_caps, CAP_EFFECTIVE, 3, tmp_cap_list, CAP_SET); - - if (prctl (PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) - { - dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to set keep-capabilities: %s\n", - _dbus_strerror (errno)); - cap_free (tmp_caps); - goto fail; - } - - if (cap_set_proc (tmp_caps) == -1) - { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Failed to drop capabilities: %s\n", - _dbus_strerror (errno)); - cap_free (tmp_caps); - goto fail; - } - cap_free (tmp_caps); - } -#endif /* HAVE_LIBAUDIT */ - /* setgroups() only works if we are a privileged process, * so we don't return error on failure; the only possible * failure is that we don't have perms to do it. @@ -400,7 +341,7 @@ _dbus_change_to_daemon_user (const char *user, if (setgroups (0, NULL) < 0) _dbus_warn ("Failed to drop supplementary groups: %s\n", _dbus_strerror (errno)); - + /* Set GID first, or the setuid may remove our permission * to change the GID */ @@ -409,54 +350,20 @@ _dbus_change_to_daemon_user (const char *user, dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to set GID to %lu: %s", gid, _dbus_strerror (errno)); - goto fail; + return FALSE; } - + if (setuid (uid) < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to set UID to %lu: %s", uid, _dbus_strerror (errno)); - goto fail; - } - -#ifdef HAVE_LIBAUDIT - if (we_were_root) - { - if (cap_set_proc (new_caps)) - { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Failed to drop capabilities: %s\n", - _dbus_strerror (errno)); - goto fail; - } - cap_free (new_caps); - - /* should always work, if it did above */ - if (prctl (PR_SET_KEEPCAPS, 0, 0, 0, 0) == -1) - { - dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to unset keep-capabilities: %s\n", - _dbus_strerror (errno)); - return FALSE; - } + return FALSE; } -#endif - - return TRUE; - fail: -#ifdef HAVE_LIBAUDIT - if (!we_were_root) - { - /* should always work, if it did above */ - prctl (PR_SET_KEEPCAPS, 0, 0, 0, 0); - cap_free (new_caps); - } -#endif - - return FALSE; + return TRUE; } +#endif /* !HAVE_LIBAUDIT */ void _dbus_init_system_log (void) @@ -1113,7 +1020,7 @@ _dbus_string_get_dirname (const DBusString *filename, static void string_squash_nonprintable (DBusString *str) { - char *buf; + unsigned char *buf; int i, len; buf = _dbus_string_get_data (str); diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 38c49528..ad6c5d11 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -276,31 +276,12 @@ _dbus_close_socket (int fd, void _dbus_fd_set_close_on_exec (int handle) { -#ifdef ENABLE_DBUSSOCKET - DBusSocket *s; - if (handle < 0) - return; - - _dbus_lock_sockets(); - - _dbus_handle_to_socket_unlocked (handle, &s); - s->close_on_exec = TRUE; - - _dbus_unlock_sockets(); -#else - /* TODO unic code. - int val; - - val = fcntl (fd, F_GETFD, 0); - - if (val < 0) - return; - - val |= FD_CLOEXEC; - - fcntl (fd, F_SETFD, val); - */ -#endif + if ( !SetHandleInformation( (HANDLE) handle, + HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE, + 0 /*disable both flags*/ ) ) + { + _dbus_win_warn_win_error ("Disabling socket handle inheritance failed:", GetLastError()); + } } /** @@ -2616,11 +2597,7 @@ _dbus_get_autolaunch_address (DBusString *address, LPSTR lpFile; char dbus_exe_path[MAX_PATH]; char dbus_args[MAX_PATH * 2]; -#ifdef _DEBUG - const char * daemon_name = "dbus-daemond.exe"; -#else - const char * daemon_name = "dbus-daemon.exe"; -#endif + const char * daemon_name = DBUS_DAEMON_NAME ".exe"; mutex = _dbus_global_lock ( cDBusAutolaunchMutex ); @@ -2859,8 +2836,13 @@ _dbus_get_install_root(char *prefix, int len) //folder's name happens to end with the *bytes* //"\\bin"... (I.e. the second byte of some Han character and then //the Latin "bin", but that is not likely I think... - if (lastSlash - prefix > 3 && strncmp(lastSlash - 4, "\\bin", 4) == 0) + if (lastSlash - prefix >= 4 && strnicmp(lastSlash - 4, "\\bin", 4) == 0) lastSlash[-3] = 0; + else if (lastSlash - prefix >= 10 && strnicmp(lastSlash - 10, "\\bin\\debug", 10) == 0) + lastSlash[-9] = 0; + else if (lastSlash - prefix >= 12 && strnicmp(lastSlash - 12, "\\bin\\release", 12) == 0) + lastSlash[-11] = 0; + return TRUE; } diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 1f4c3a25..c27f999e 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -49,6 +49,9 @@ _DBUS_DEFINE_GLOBAL_LOCK (system_users); #ifdef DBUS_WIN #include <stdlib.h> +#elif (defined __APPLE__) +# include <crt_externs.h> +# define environ (*_NSGetEnviron()) #else extern char **environ; #endif diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 5a153c6a..bfa4c435 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -226,7 +226,8 @@ static DBusString process_homedir; static void shutdown_system_db (void *data) { - _dbus_user_database_unref (system_db); + if (system_db != NULL) + _dbus_user_database_unref (system_db); system_db = NULL; _dbus_string_free (&process_username); _dbus_string_free (&process_homedir); @@ -345,7 +346,8 @@ _dbus_user_database_flush_system (void) { _dbus_user_database_lock_system (); - _dbus_user_database_flush (system_db); + if (system_db != NULL) + _dbus_user_database_flush (system_db); _dbus_user_database_unlock_system (); } diff --git a/doc/Makefile.am b/doc/Makefile.am index e1c8e4dc..f76335f6 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,5 +1,7 @@ EXTRA_DIST= \ busconfig.dtd \ + diagram.png \ + diagram.svg \ introspect.dtd \ dbus-faq.xml \ dbus-specification.xml \ @@ -7,7 +9,8 @@ EXTRA_DIST= \ dbus-tutorial.xml \ dcop-howto.txt \ file-boilerplate.c \ - introspect.xsl + introspect.xsl \ + system-activation.txt HTML_FILES= \ dbus-faq.html \ @@ -18,7 +21,7 @@ HTML_FILES= \ if DBUS_XML_DOCS_ENABLED all-local: $(HTML_FILES) -EXTRA_DIST += $(HTML_FILES) system-activation.txt +EXTRA_DIST += $(HTML_FILES) dbus-specification.html: dbus-specification.xml $(XMLTO) html-nochunks $< diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index be9c9ffb..cad1e71b 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" standalone="no"?> +<?xml version="1.0" standalone="no" ?> <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ @@ -7,8 +7,8 @@ <article id="index"> <articleinfo> <title>D-Bus Specification</title> - <releaseinfo>Version 0.12</releaseinfo> - <date>7 November 2006</date> + <releaseinfo>Version 0.13</releaseinfo> + <date>23 Dezember 2009</date> <authorgroup> <author> <firstname>Havoc</firstname> @@ -2425,6 +2425,98 @@ length path name. Names which were shorter than the fixed length would be padded by Nul bytes. </para> + <para> + Unix domain sockets are not available on windows. + </para> + <sect3 id="transports-unix-domain-sockets-addresses"> + <title>Server Address Format</title> + <para> + Unix domain socket addresses are identified by the "unix:" prefix + and support the following key/value pairs: + </para> + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Name</entry> + <entry>Values</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>path</entry> + <entry>(path)</entry> + <entry>path of the unix domain socket. If set, the "tmpdir" and "abstract" key must not be set.</entry> + </row> + <row> + <entry>tmpdir</entry> + <entry>(path)</entry> + <entry>temporary directory in which a socket file with a random file name starting with 'dbus-' will be created by the server. This key can only be used in server addresses, not in client addresses. If set, the "path" and "abstract" key must not be set.</entry> + </row> + <row> + <entry>abstract</entry> + <entry>(string)</entry> + <entry>unique string (path) in the abstract namespace. If set, the "path" or "tempdir" key must not be set.</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </sect3> + </sect2> + <sect2 id="transports-tcp-sockets"> + <title>TCP Sockets</title> + <para> + The tcp transport provides TCP/IP based connections between clients + located on the same or different hosts. + </para> + <para> + Using tcp transport without any additional secure authentification mechanismus + over a network is unsecure. + </para> + <para> + Windows notes: Because of the tcp stack on windows does not provide sending + credentials over a tcp connection, the EXTERNAL authentification + mechanismus does not work. + </para> + <sect3 id="transports-tcp-sockets-addresses"> + <title>Server Address Format</title> + <para> + TCP/IP socket addresses are identified by the "tcp:" prefix + and support the following key/value pairs: + </para> + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Name</entry> + <entry>Values</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>host</entry> + <entry>(string)</entry> + <entry>dns name or ip address</entry> + </row> + <row> + <entry>port</entry> + <entry>(number)</entry> + <entry>The tcp port the server will open. A zero value let the server + choose a free port provided from the underlaying operating system. + libdbus is able to retrieve the real used port from the server. + </entry> + </row> + <row> + <entry>family</entry> + <entry>(string)</entry> + <entry>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </sect3> </sect2> <sect2 id="transports-nonce-tcp-sockets"> <title>Nonce-secured TCP Sockets</title> @@ -2457,6 +2549,49 @@ key-value pair and send it over the socket. After that, the transport behaves like an unsecured tcp transport. </para> + <sect3 id="transports-nonce-tcp-sockets-addresses"> + <title>Server Address Format</title> + <para> + Nonce TCP/IP socket addresses uses the "nonce-tcp:" prefix + and support the following key/value pairs: + </para> + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Name</entry> + <entry>Values</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>host</entry> + <entry>(string)</entry> + <entry>dns name or ip address</entry> + </row> + <row> + <entry>port</entry> + <entry>(number)</entry> + <entry>The tcp port the server will open. A zero value let the server + choose a free port provided from the underlaying operating system. + libdbus is able to retrieve the real used port from the server. + </entry> + </row> + <row> + <entry>family</entry> + <entry>(string)</entry> + <entry>If set, provide the type of socket family either "ipv4" or "ipv6". If unset, the family is unspecified.</entry> + </row> + <row> + <entry>noncefile</entry> + <entry>(path)</entry> + <entry>file location containing the secret</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </sect3> </sect2> </sect1> diff --git a/test/test-service.c b/test/test-service.c index 2bd2dbc8..93f59f1e 100644 --- a/test/test-service.c +++ b/test/test-service.c @@ -411,7 +411,9 @@ main (int argc, name = argv[1]; #ifndef DBUS_WIN do_fork = strcmp (argv[2], "fork") == 0; -#endif +#else + do_fork = FALSE; +#endif } /* The bare minimum for simulating a program "daemonizing"; the intent @@ -428,6 +430,7 @@ main (int argc, sleep (1); } #endif + dbus_error_init (&error); connection = dbus_bus_get (DBUS_BUS_STARTER, &error); if (connection == NULL) diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index 352a28d8..140238e9 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ +#include <config.h> #include <windows.h> #include <stdio.h> #include <string.h> @@ -90,12 +91,9 @@ int main(int argc,char **argv) showConsole = 1; #endif GetModuleFileName(NULL,dbusDaemonPath,sizeof(dbusDaemonPath)); - -#ifdef _DEBUG - daemon_name = "dbus-daemond.exe"; -#else - daemon_name = "dbus-daemon.exe"; -#endif + + daemon_name = DBUS_DAEMON_NAME ".exe"; + if ((p = _mbsrchr (dbusDaemonPath, '\\'))) { *(p+1)= '\0'; @@ -134,7 +132,7 @@ int main(int argc,char **argv) if (result == 0) { if (verbose) - fprintf(stderr, "Could not start dbus-daemon error=%d",GetLastError()); + fprintf(stderr, "Could not start " DBUS_DAEMON_NAME ". error=%d",GetLastError()); return 4; } diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 912afba8..d3553e81 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -405,6 +405,7 @@ signal_handler (int sig) #ifdef SIGHUP case SIGHUP: #endif + case SIGINT: case SIGTERM: got_sighup = TRUE; break; @@ -429,6 +430,7 @@ kill_bus_when_session_ends (void) act.sa_flags = 0; sigaction (SIGHUP, &act, NULL); sigaction (SIGTERM, &act, NULL); + sigaction (SIGINT, &act, NULL); #ifdef DBUS_BUILD_X11 x11_init(); diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index 873108bc..c3681289 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -33,8 +33,6 @@ #include <time.h> -#include <signal.h> - #include "dbus-print-message.h" #ifdef DBUS_WIN @@ -214,6 +212,13 @@ main (int argc, char *argv[]) int i = 0, j = 0, numFilters = 0; char **filters = NULL; + + /* Set stdout to be unbuffered; this is basically so that if people + * do dbus-monitor > file, then send SIGINT via Control-C, they + * don't lose the last chunk of messages. + */ + setvbuf (stdout, NULL, _IOLBF, 0); + for (i = 1; i < argc; i++) { char *arg = argv[i]; @@ -339,10 +344,7 @@ main (int argc, char *argv[]) exit (1); } - /* we handle SIGINT so exit() is reached and flushes stdout */ - signal (SIGINT, sigint_handler); - while (dbus_connection_read_write_dispatch(connection, -1) - && !sigint_received) + while (dbus_connection_read_write_dispatch(connection, -1)) ; exit (0); lose: |