summaryrefslogtreecommitdiff
path: root/bus/activation.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2017-02-15 17:24:14 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2017-02-16 13:28:49 +0000
commit1488f02d9e34a3ef0710dace2b1e92cbc30cd99d (patch)
tree8cba257b38200cd6fc7b22a1b600655ca15f7677 /bus/activation.c
parentbe51bfe915af717aa462fc7957e5a3c6dabc746b (diff)
downloaddbus-1488f02d9e34a3ef0710dace2b1e92cbc30cd99d.tar.gz
activation test: Fix time-of-check/time-of-use bug waiting to happen
Creating a directory is atomic, stat'ing it to see whether to remove it is very much not. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99828 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Philip Withnall <withnall@endlessm.com>
Diffstat (limited to 'bus/activation.c')
-rw-r--r--bus/activation.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/bus/activation.c b/bus/activation.c
index 12113295..1a98af6d 100644
--- a/bus/activation.c
+++ b/bus/activation.c
@@ -2436,21 +2436,8 @@ out:
static dbus_bool_t
init_service_reload_test (DBusString *dir)
{
- DBusStat stat_buf;
-
- if (!_dbus_stat (dir, &stat_buf, NULL))
- {
- if (!_dbus_create_directory (dir, NULL))
- return FALSE;
- }
- else
- {
- if (!test_remove_directory (dir))
- return FALSE;
-
- if (!_dbus_create_directory (dir, NULL))
- return FALSE;
- }
+ if (!_dbus_create_directory (dir, NULL))
+ return FALSE;
/* Create one initial file */
if (!test_create_service_file (dir, SERVICE_FILE_1, SERVICE_NAME_1, "exec-1"))
@@ -2638,6 +2625,9 @@ bus_activation_service_reload_test (const DBusString *test_data_dir)
/* Do nothing? */
}
+ if (!cleanup_service_reload_test (&directory))
+ goto out;
+
/* Do OOM tests */
if (!init_service_reload_test (&directory))
_dbus_assert_not_reached ("could not initiate service reload test");