summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-02-22 09:48:45 -0500
committerColin Walters <walters@verbum.org>2010-02-22 09:48:45 -0500
commite1c31c73074513d96fa22b5c0355107c42720597 (patch)
treee1216637b5f52540e279f0f1f3ef9662c4437978
parent235eebdb1618ecdd0f752c9bcd92c61d17752e0b (diff)
parentfbeb13517ef667b8ed4136bcb9e52ff9924419c1 (diff)
downloaddbus-e1c31c73074513d96fa22b5c0355107c42720597.tar.gz
Merge branch 'dbus-1.2'
Conflicts: bus/bus.c bus/selinux.c configure.in
-rw-r--r--bus/bus.c44
-rw-r--r--bus/dir-watch-default.c6
-rw-r--r--bus/dir-watch-inotify.c14
-rw-r--r--bus/dir-watch-kqueue.c26
-rw-r--r--dbus/dbus-string.c15
-rw-r--r--dbus/dbus-sysdeps.h3
6 files changed, 91 insertions, 17 deletions
diff --git a/bus/bus.c b/bus/bus.c
index eefdaeb3..69203a23 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -540,11 +540,39 @@ process_config_every_time (BusContext *context,
}
static dbus_bool_t
+list_concat_new (DBusList **a,
+ DBusList **b,
+ DBusList **result)
+{
+ DBusList *link;
+
+ *result = NULL;
+
+ link = _dbus_list_get_first_link (a);
+ for (link = _dbus_list_get_first_link (a); link; link = _dbus_list_get_next_link (a, link))
+ {
+ if (!_dbus_list_append (result, link->data))
+ goto oom;
+ }
+ for (link = _dbus_list_get_first_link (b); link; link = _dbus_list_get_next_link (b, link))
+ {
+ if (!_dbus_list_append (result, link->data))
+ goto oom;
+ }
+
+ return TRUE;
+oom:
+ _dbus_list_clear (result);
+ return FALSE;
+}
+
+static dbus_bool_t
process_config_postinit (BusContext *context,
BusConfigParser *parser,
DBusError *error)
{
DBusHashTable *service_context_table;
+ DBusList *watched_dirs = NULL;
service_context_table = bus_config_parser_steal_service_context_table (parser);
if (!bus_registry_set_service_context_table (context->registry,
@@ -556,8 +584,20 @@ process_config_postinit (BusContext *context,
_dbus_hash_table_unref (service_context_table);
- /* Watch all conf directories */
- bus_set_watched_dirs (context, bus_config_parser_get_conf_dirs (parser));
+ /* We need to monitor both the configuration directories and directories
+ * containing .service files.
+ */
+ if (!list_concat_new (bus_config_parser_get_conf_dirs (parser),
+ bus_config_parser_get_service_dirs (parser),
+ &watched_dirs))
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ bus_set_watched_dirs (context, &watched_dirs);
+
+ _dbus_list_clear (&watched_dirs);
return TRUE;
}
diff --git a/bus/dir-watch-default.c b/bus/dir-watch-default.c
index ff70d080..e7f8451b 100644
--- a/bus/dir-watch-default.c
+++ b/bus/dir-watch-default.c
@@ -29,13 +29,13 @@
/* NoOp */
-void
-bus_drop_all_directory_watches (void)
+void
+bus_watch_directory (const char *dir, BusContext *context)
{
}
void
-bus_watch_directory (const char *dir, BusContext *context)
+bus_set_watched_dirs (BusContext *context, DBusList **directories)
{
}
diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c
index f457ea8e..8b70a416 100644
--- a/bus/dir-watch-inotify.c
+++ b/bus/dir-watch-inotify.c
@@ -155,8 +155,18 @@ _set_watched_dirs_internal (DBusList **directories)
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;
+ /* Not all service directories need to exist. */
+ if (errno != ENOENT)
+ {
+ _dbus_warn ("Cannot setup inotify for '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
+ goto out;
+ }
+ else
+ {
+ new_wds[i] = -1;
+ new_dirs[i] = NULL;
+ continue;
+ }
}
new_wds[i] = wd;
new_dirs[i] = _dbus_strdup (new_dirs[i]);
diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c
index 7c18a3c9..4a01b748 100644
--- a/bus/dir-watch-kqueue.c
+++ b/bus/dir-watch-kqueue.c
@@ -139,17 +139,18 @@ out:
}
void
-bus_set_watched_dir (BusContext *context, DBusList **directories)
+bus_set_watched_dirs (BusContext *context, DBusList **directories)
{
int new_fds[MAX_DIRS_TO_WATCH];
char *new_dirs[MAX_DIRS_TO_WATCH];
DBusList *link;
- int i, f, fd;
+ int i, j, f, fd;
+ struct kevent ev;
if (!_init_kqueue (context))
goto out;
- for (i = 0; i < MAX_DIRS_TO_WATCH; i++) {
+ for (i = 0; i < MAX_DIRS_TO_WATCH; i++)
{
new_fds[i] = -1;
new_dirs[i] = NULL;
@@ -203,17 +204,26 @@ bus_set_watched_dir (BusContext *context, DBusList **directories)
* we may need to sleep.
*/
fd = open (new_dirs[i], O_RDONLY);
- if (fd < 0)
+ if (fd < 0)
{
- _dbus_warn ("Cannot open directory '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
- goto out;
- }
+ if (errno != ENOENT)
+ {
+ _dbus_warn ("Cannot open directory '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
+ goto out;
+ }
+ else
+ {
+ new_fds[i] = -1;
+ new_dirs[i] = NULL;
+ continue;
+ }
+ }
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));
+ _dbus_warn ("Cannot setup a kevent for '%s'; error '%s'\n", new_dirs[i], _dbus_strerror (errno));
close (fd);
goto out;
}
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index d9cf18ed..62a64609 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -1799,7 +1799,18 @@ _dbus_string_split_on_byte (DBusString *source,
}
/**
- * Check whether a unicode char is in a valid range.
+ * Check whether a Unicode (5.2) char is in a valid range.
+ *
+ * The first check comes from the Unicode guarantee to never encode
+ * a point above 0x0010ffff, since UTF-16 couldn't represent it.
+ *
+ * The second check covers surrogate pairs (category Cs).
+ *
+ * The last two checks cover "Noncharacter": defined as:
+ * "A code point that is permanently reserved for
+ * internal use, and that should never be interchanged. In
+ * Unicode 3.1, these consist of the values U+nFFFE and U+nFFFF
+ * (where n is from 0 to 10_16) and the values U+FDD0..U+FDEF."
*
* @param Char the character
*/
@@ -1807,7 +1818,7 @@ _dbus_string_split_on_byte (DBusString *source,
((Char) < 0x110000 && \
(((Char) & 0xFFFFF800) != 0xD800) && \
((Char) < 0xFDD0 || (Char) > 0xFDEF) && \
- ((Char) & 0xFFFF) != 0xFFFF)
+ ((Char) & 0xFFFE) != 0xFFFE)
#ifdef DBUS_BUILD_TESTS
/**
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index e30a7936..4413b28f 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -490,6 +490,9 @@ unsigned long _dbus_pid_for_log (void);
*/
dbus_pid_t _dbus_getpid (void);
+dbus_bool_t _dbus_change_to_daemon_user (const char *user,
+ DBusError *error);
+
void _dbus_flush_caches (void);
/** @} */