Commit 8f639c80 authored by Simon McVittie's avatar Simon McVittie

Imported Upstream version 1.7.10

parents c03b8e68 127ef144
This diff is collapsed.
This diff is collapsed.
D-Bus 1.7.10 (2014-01-06)
==
The “weighted companion cube” release.
This is a release candidate for D-Bus 1.8.
D-Bus Specification 0.23:
• don't require messages with no INTERFACE to be dispatched
(fd.o #68597, Simon McVittie)
• document "tcp:bind=..." and "nonce-tcp:bind=..." (fd.o #72301,
Chengwei Yang)
• define "listenable" and "connectable" addresses, and discuss
the difference (fd.o #61303, Simon McVittie)
Enhancements:
• support printing Unix file descriptors in dbus-send, dbus-monitor
(fd.o #70592, Robert Ancell)
• don't install systemd units if --disable-systemd is given
(fd.o #71818, Chengwei Yang)
Fixes:
• don't leak memory on out-of-memory while listing activatable or
active services (fd.o #71526, Radoslaw Pajak)
• fix undefined behaviour in a regression test (fd.o #69924, DreamNik)
• escape Unix socket addresses correctly (fd.o #46013, Chengwei Yang)
• on SELinux systems, don't assume that SECCLASS_DBUS, DBUS__ACQUIRE_SVC
and DBUS__SEND_MSG are numerically equal to their values in the
reference policy (fd.o #88719, osmond sun)
• define PROCESS_QUERY_LIMITED_INFORMATION if missing from MinGW < 4 headers
(fd.o #71366, Matt Fischer)
• define WIN32_LEAN_AND_MEAN to avoid conflicts between winsock.h and
winsock2.h (fd.o #71405, Matt Fischer)
• do not return failure from _dbus_read_nonce() with no error set,
preventing a potential crash (fd.o #72298, Chengwei Yang)
• on BSD systems, avoid some O(1)-per-process memory and fd leaks in kqueue,
preventing test failures (fd.o #69332, fd.o #72213; Chengwei Yang)
• fix warning spam on Hurd by not trying to set SO_REUSEADDR on Unix sockets,
which doesn't do anything anyway on at least Linux and FreeBSD
(fd.o #69492, Simon McVittie)
• fix use of TCP sockets on FreeBSD and Hurd by tolerating EINVAL from
sendmsg() with SCM_CREDS (retrying with plain send()), and looking
for credentials more correctly (fd.o #69492, Simon McVittie)
• ensure that tests run with a temporary XDG_RUNTIME_DIR to avoid
getting mixed up in XDG/systemd "user sessions" (fd.o #61301,
Simon McVittie)
• refresh cached policy rules for existing connections when bus
configuration changes (fd.o #39463, Chengwei Yang)
D-Bus 1.7.8 (2013-11-01)
==
......
This diff is collapsed.
This diff is collapsed.
......@@ -2186,7 +2186,7 @@ bus_activation_list_services (BusActivation *activation,
error:
for (j = 0; j < i; j++)
dbus_free (retval[i]);
dbus_free (retval[j]);
dbus_free (retval);
return FALSE;
......
......@@ -526,6 +526,18 @@ process_config_every_time (BusContext *context,
context->policy = bus_config_parser_steal_policy (parser);
_dbus_assert (context->policy != NULL);
/* context->connections is NULL when creating new BusContext */
if (context->connections)
{
_dbus_verbose ("Reload policy rules for completed connections\n");
retval = bus_connections_reload_policy (context->connections, error);
if (!retval)
{
_DBUS_ASSERT_ERROR_IS_SET (error);
goto failed;
}
}
/* We have to build the address backward, so that
* <listen> later in the config file have priority
*/
......@@ -894,7 +906,7 @@ bus_context_new (const DBusString *config_file,
if (!bus_selinux_full_init ())
{
bus_context_log (context, DBUS_SYSTEM_LOG_FATAL, "SELinux enabled but AVC initialization failed; check system log\n");
bus_context_log (context, DBUS_SYSTEM_LOG_FATAL, "SELinux enabled but D-Bus initialization failed; check system log\n");
}
if (!process_config_postinit (context, parser, error))
......
......@@ -1435,6 +1435,42 @@ fail:
return FALSE;
}
dbus_bool_t
bus_connections_reload_policy (BusConnections *connections,
DBusError *error)
{
BusConnectionData *d;
DBusConnection *connection;
DBusList *link;
_dbus_assert (connections != NULL);
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
for (link = _dbus_list_get_first_link (&(connections->completed));
link;
link = _dbus_list_get_next_link (&(connections->completed), link))
{
connection = link->data;
d = BUS_CONNECTION_DATA (connection);
_dbus_assert (d != NULL);
_dbus_assert (d->policy != NULL);
bus_client_policy_unref (d->policy);
d->policy = bus_context_create_client_policy (connections->context,
connection,
error);
if (d->policy == NULL)
{
_dbus_verbose ("Failed to create security policy for connection %p\n",
connection);
_DBUS_ASSERT_ERROR_IS_SET (error);
return FALSE;
}
}
return TRUE;
}
const char *
bus_connection_get_name (DBusConnection *connection)
{
......@@ -1990,12 +2026,6 @@ bus_transaction_get_context (BusTransaction *transaction)
return transaction->context;
}
BusConnections*
bus_transaction_get_connections (BusTransaction *transaction)
{
return bus_context_get_connections (transaction->context);
}
dbus_bool_t
bus_transaction_send_from_driver (BusTransaction *transaction,
DBusConnection *connection,
......
......@@ -45,6 +45,8 @@ void bus_connections_foreach_active (BusConnections
void *data);
BusContext* bus_connections_get_context (BusConnections *connections);
void bus_connections_increment_stamp (BusConnections *connections);
dbus_bool_t bus_connections_reload_policy (BusConnections *connections,
DBusError *error);
BusContext* bus_connection_get_context (DBusConnection *connection);
BusConnections* bus_connection_get_connections (DBusConnection *connection);
BusRegistry* bus_connection_get_registry (DBusConnection *connection);
......@@ -120,7 +122,6 @@ typedef void (* BusTransactionCancelFunction) (void *data);
BusTransaction* bus_transaction_new (BusContext *context);
BusContext* bus_transaction_get_context (BusTransaction *transaction);
BusConnections* bus_transaction_get_connections (BusTransaction *transaction);
dbus_bool_t bus_transaction_send (BusTransaction *transaction,
DBusConnection *connection,
DBusMessage *message);
......
......@@ -73,12 +73,12 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data)
{
kq = -1;
if (watch != NULL)
{
_dbus_loop_remove_watch (loop, watch);
{
_dbus_loop_remove_watch (loop, watch);
_dbus_watch_invalidate (watch);
_dbus_watch_unref (watch);
watch = NULL;
}
watch = NULL;
}
pid = getpid ();
_dbus_verbose ("Sending SIGHUP signal since kqueue has been closed\n");
(void) kill (pid, SIGHUP);
......@@ -87,11 +87,49 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data)
return TRUE;
}
static void _shutdown_kqueue (void *data)
{
int i;
if (kq < 0)
return;
for (i = 0; i < MAX_DIRS_TO_WATCH; i++)
{
if (fds[i] >= 0)
{
close (fds[i]);
fds[i] = -1;
}
if (dirs[i] != NULL)
{
/* dbus_free() is necessary to pass memleak check */
dbus_free (dirs[i]);
dirs[i] = NULL;
}
}
if (loop)
{
_dbus_loop_remove_watch (loop, watch);
_dbus_loop_unref (loop);
loop = NULL;
}
if (watch)
{
_dbus_watch_invalidate (watch);
_dbus_watch_unref (watch);
watch = NULL;
}
close (kq);
kq = -1;
}
static int
_init_kqueue (BusContext *context)
{
int ret = 0;
if (kq < 0)
{
......@@ -99,38 +137,61 @@ _init_kqueue (BusContext *context)
if (kq < 0)
{
_dbus_warn ("Cannot create kqueue; error '%s'\n", _dbus_strerror (errno));
goto out;
}
loop = bus_context_get_loop (context);
watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE,
_handle_kqueue_watch, NULL, NULL);
if (watch == NULL)
{
_dbus_warn ("Unable to create kqueue watch\n");
close (kq);
kq = -1;
goto out;
}
if (!_dbus_loop_add_watch (loop, watch))
{
_dbus_warn ("Unable to add reload watch to main loop");
_dbus_watch_invalidate (watch);
_dbus_watch_unref (watch);
watch = NULL;
close (kq);
kq = -1;
goto out;
}
goto out;
}
loop = bus_context_get_loop (context);
_dbus_loop_ref (loop);
watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE,
_handle_kqueue_watch, NULL, NULL);
if (watch == NULL)
{
_dbus_warn ("Unable to create kqueue watch\n");
goto out1;
}
if (!_dbus_loop_add_watch (loop, watch))
{
_dbus_warn ("Unable to add reload watch to main loop");
goto out2;
}
if (!_dbus_register_shutdown_func (_shutdown_kqueue, NULL))
{
_dbus_warn ("Unable to register shutdown function");
goto out3;
}
}
return 1;
out3:
_dbus_loop_remove_watch (loop, watch);
out2:
if (watch)
{
_dbus_watch_invalidate (watch);
_dbus_watch_unref (watch);
watch = NULL;
}
ret = 1;
out1:
if (kq >= 0)
{
close (kq);
kq = -1;
}
if (loop)
{
_dbus_loop_unref (loop);
loop = NULL;
}
out:
return ret;
return 0;
}
void
......@@ -169,12 +230,12 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
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;
}
}
new_dirs[i] = dirs[j];
fds[j] = -1;
dirs[j] = NULL;
break;
}
}
}
/* Any directory we find in "fds" with a nonzero fd must
......@@ -185,10 +246,10 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
if (fds[j] != -1)
{
close (fds[j]);
dbus_free (dirs[j]);
fds[j] = -1;
dirs[j] = NULL;
}
dbus_free (dirs[j]);
fds[j] = -1;
dirs[j] = NULL;
}
}
for (i = 0; new_dirs[i]; i++)
......@@ -196,9 +257,9 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
if (new_fds[i] == -1)
{
/* FIXME - less lame error handling for failing to add a watch;
* we may need to sleep.
*/
fd = open (new_dirs[i], O_RDONLY);
* we may need to sleep.
*/
fd = open (new_dirs[i], O_RDONLY | O_CLOEXEC);
if (fd < 0)
{
if (errno != ENOENT)
......@@ -223,18 +284,18 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
goto out;
}
new_fds[i] = fd;
new_dirs[i] = _dbus_strdup (new_dirs[i]);
if (!new_dirs[i])
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 =) )
*/
* 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;
}
}
new_fds[i] = -1;
}
}
}
num_fds = i;
......
......@@ -133,7 +133,7 @@ bus_dispatch_matches (BusTransaction *transaction,
}
/* Now dispatch to others who look interested in this message */
connections = bus_transaction_get_connections (transaction);
connections = bus_context_get_connections (context);
dbus_error_init (&tmp_error);
matchmaker = bus_context_get_matchmaker (context);
......
......@@ -44,8 +44,6 @@
#include <syslog.h>
#include <selinux/selinux.h>
#include <selinux/avc.h>
#include <selinux/av_permissions.h>
#include <selinux/flask.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
......@@ -314,8 +312,27 @@ bus_selinux_pre_init (void)
#endif
}
/*
* Private Flask definitions; the order of these constants must
* exactly match that of the structure array below!
*/
/* security dbus class constants */
#define SECCLASS_DBUS 1
/* dbus's per access vector constants */
#define DBUS__ACQUIRE_SVC 1
#define DBUS__SEND_MSG 2
#ifdef HAVE_SELINUX
static struct security_class_mapping dbus_map[] = {
{ "dbus", { "acquire_svc", "send_msg", NULL } },
{ NULL }
};
#endif /* HAVE_SELINUX */
/**
* Initialize the user space access vector cache (AVC) for D-Bus and set up
* Establish dynamic object class and permission mapping and
* initialize the user space access vector cache (AVC) for D-Bus and set up
* logging callbacks.
*/
dbus_bool_t
......@@ -334,6 +351,13 @@ bus_selinux_full_init (void)
_dbus_verbose ("SELinux is enabled in this kernel.\n");
if (selinux_set_mapping (dbus_map) < 0)
{
_dbus_warn ("Failed to set up security class mapping (selinux_set_mapping():%s).\n",
strerror (errno));
return FALSE;
}
avc_entry_ref_init (&aeref);
if (avc_init ("avc", &mem_cb, &log_cb, &thread_cb, &lock_cb) < 0)
{
......
......@@ -368,7 +368,7 @@ bus_registry_list_services (BusRegistry *registry,
error:
for (j = 0; j < i; j++)
dbus_free (retval[i]);
dbus_free (retval[j]);
dbus_free (retval);
return FALSE;
......
......@@ -48,7 +48,7 @@ bus_stats_handle_get_stats (DBusConnection *connection,
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
connections = bus_transaction_get_connections (transaction);
connections = bus_context_get_connections (transaction->context);
reply = _dbus_asv_new_method_return (message, &iter, &arr_iter);
......
......@@ -540,18 +540,18 @@ message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} "
message(" gcc coverage profiling: ${DBUS_GCOV_ENABLED} ")
message(" Building unit tests: ${DBUS_BUILD_TESTS} ")
message(" Building verbose mode: ${DBUS_ENABLE_VERBOSE_MODE} ")
message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ")
message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ")
message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ")
message(" Building bus stats API: ${DBUS_ENABLE_STATS} ")
message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} ")
message(" Building inotify support: ${DBUS_BUS_ENABLE_INOTIFY} ")
message(" Building kqueue support: ${DBUS_BUS_ENABLE_KQUEUE} ")
message(" Building kqueue support: ${DBUS_BUS_ENABLE_KQUEUE} ")
message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} ")
message(" Building XML docs: ${DBUS_ENABLE_XML_DOCS} ")
message(" Daemon executable name: ${DBUS_DAEMON_NAME}")
if (WIN32)
message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ")
message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ")
message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ")
message(" Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ")
else (WIN32)
message(" System bus socket: ${DBUS_SYSTEM_SOCKET} ")
......
......@@ -357,9 +357,6 @@
*/
#undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */
#undef PACKAGE
......
This diff is collapsed.
......@@ -3,7 +3,7 @@ AC_PREREQ([2.63])
m4_define([dbus_major_version], [1])
m4_define([dbus_minor_version], [7])
m4_define([dbus_micro_version], [8])
m4_define([dbus_micro_version], [10])
m4_define([dbus_version],
[dbus_major_version.dbus_minor_version.dbus_micro_version])
AC_INIT([dbus],[dbus_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=dbus],[dbus])
......@@ -894,8 +894,6 @@ fi
# unix:path=/foo or unix:abstract=/foo
AC_SUBST(DBUS_PATH_OR_ABSTRACT)
PKG_PROG_PKG_CONFIG
#### Sort out XML library
AC_CHECK_LIB(expat, XML_ParserCreate_MM,
......@@ -1499,7 +1497,7 @@ AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service
if test "x$with_systemdsystemunitdir" != xno; then
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$have_systemd" != "xno" -a -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
##### Set up location for system bus socket
if ! test -z "$with_system_socket"; then
......
This diff is collapsed.
......@@ -584,11 +584,11 @@ _dbus_auth_script_run (const DBusString *filename)
{
_dbus_warn ("not enough memory to call bytes_received, or can't add bytes to auth object already in end state\n");
_dbus_string_free (&to_send);
_dbus_auth_return_buffer (auth, buffer, 0);
_dbus_auth_return_buffer (auth, buffer);
goto out;
}
_dbus_auth_return_buffer (auth, buffer, _dbus_string_get_length (&to_send));
_dbus_auth_return_buffer (auth, buffer);
}
_dbus_string_free (&to_send);
......
......@@ -2533,12 +2533,10 @@ _dbus_auth_get_buffer (DBusAuth *auth,
*
* @param auth the auth conversation
* @param buffer the buffer being returned
* @param bytes_read number of new bytes added
*/
void
_dbus_auth_return_buffer (DBusAuth *auth,
DBusString *buffer,
int bytes_read)
DBusString *buffer)
{
_dbus_assert (buffer == &auth->incoming);
_dbus_assert (auth->buffer_outstanding);
......
......@@ -55,8 +55,7 @@ void _dbus_auth_bytes_sent (DBusAuth *auth,
void _dbus_auth_get_buffer (DBusAuth *auth,
DBusString **buffer);
void _dbus_auth_return_buffer (DBusAuth *auth,
DBusString *buffer,
int bytes_read);
DBusString *buffer);
void _dbus_auth_get_unused_bytes (DBusAuth *auth,
const DBusString **str);
void _dbus_auth_delete_unused_bytes (DBusAuth *auth);
......
......@@ -1774,10 +1774,13 @@ make_and_run_test_nodes (void)
start_next_test ("All values in one big toplevel %d iteration\n", 1);
{
TestTypeNode *nodes[N_VALUES];
TestTypeNode *node;
i = 0;
while ((nodes[i] = value_generator (&i)))
;
while ((node = value_generator (&i)))
{
nodes[i - 1] = node;
}
run_test_nodes (nodes, N_VALUES);
......
......@@ -856,7 +856,7 @@ _dbus_register_shutdown_func_unlocked (DBusShutdownFunction func,
* can be useful to free these internal data structures.
*
* dbus_shutdown() does NOT free memory that was returned
* to the application. It only returns libdbus-internal
* to the application. It only frees libdbus-internal
* data structures.
*
* You MUST free all memory and release all reference counts
......
......@@ -113,7 +113,15 @@ _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error)
fp = fopen (_dbus_string_get_const_data (fname), "rb");
if (!fp)
return FALSE;
{
dbus_set_error (error,
_dbus_error_from_system_errno (),
"Failed to open %s for read: %s",
_dbus_string_get_const_data (fname),
_dbus_strerror_from_errno ());
return FALSE;
}
nread = fread (buffer, 1, sizeof buffer - 1, fp);
fclose (fp);
if (!nread)
......
......@@ -1179,7 +1179,7 @@ babysit (pid_t grandchild_pid,
* If sitter_p is #NULL, no babysitter is kept.
*
* @param sitter_p return location for babysitter or #NULL
* @log_name the name under which to log messages about this process being spawned
* @param log_name the name under which to log messages about this process being spawned
* @param argv the executable and arguments
* @param env the environment, or #NULL to copy the parent's
* @param child_setup function to call in child pre-exec()
......
......@@ -999,7 +999,6 @@ _dbus_listen_unix_socket (const char *path,
int listen_fd;
struct sockaddr_un addr;
size_t path_len;
unsigned int reuseaddr;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
......@@ -1074,13 +1073,6 @@ _dbus_listen_unix_socket (const char *path,
strncpy (addr.sun_path, path, path_len);
}
reuseaddr = 1;
if (setsockopt (listen_fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr))==-1)
{
_dbus_warn ("Failed to set socket option\"%s\": %s",
path, _dbus_strerror (errno));
}
if (bind (listen_fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0)
{
dbus_set_error (error, _dbus_error_from_errno (errno),
......@@ -1572,13 +1564,19 @@ write_credentials_byte (int server_fd,
|MSG_NOSIGNAL
#endif
);
#else
bytes_written = send (server_fd, buf, 1, 0
#if HAVE_DECL_MSG_NOSIGNAL
|MSG_NOSIGNAL
/* If we HAVE_CMSGCRED, the OS still might not let us sendmsg()
* with a SOL_SOCKET/SCM_CREDS message - for instance, FreeBSD
* only allows that on AF_UNIX. Try just doing a send() instead. */
if (bytes_written < 0 && errno == EINVAL)
#endif
);
{
bytes_written = send (server_fd, buf, 1, 0
#if HAVE_DECL_MSG_NOSIGNAL
|MSG_NOSIGNAL
#endif
);
}
if (bytes_written < 0 && errno == EINTR)
goto again;
......@@ -1706,16 +1704,6 @@ _dbus_read_credentials_socket (int client_fd,
return FALSE;
}
#if defined(HAVE_CMSGCRED)
if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred))
|| cmsg.hdr.cmsg_type != SCM_CREDS)
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Message from recvmsg() was not SCM_CREDS");
return FALSE;
}
#endif
_dbus_verbose ("read credentials byte\n");
{
......@@ -1756,10 +1744,22 @@ _dbus_read_credentials_socket (int client_fd,
* which makes it better than getpeereid().
*/
struct cmsgcred *cred;
struct cmsghdr *cmsgp;
cred = (struct cmsgcred *) CMSG_DATA (&cmsg.hdr);
pid_read = cred->cmcred_pid;
uid_read = cred->cmcred_euid;
for (cmsgp = CMSG_FIRSTHDR (&msg);
cmsgp != NULL;
cmsgp = CMSG_NXTHDR (&msg, cmsgp))