Merge branch 'dbus-1.2'

Conflicts:
	bus/bus.c
	bus/selinux.c
	configure.in
This commit is contained in:
Colin Walters 2010-02-22 09:48:45 -05:00
commit e1c31c7307
6 changed files with 91 additions and 17 deletions

View file

@ -539,12 +539,40 @@ process_config_every_time (BusContext *context,
return retval;
}
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;
}

View file

@ -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)
{
}

View file

@ -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]);

View file

@ -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;
}

View file

@ -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
/**

View file

@ -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);
/** @} */