[glib: 2/3] tests: keyfile writability not affected by file mode for root
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] tests: keyfile writability not affected by file mode for root
- Date: Thu, 14 Feb 2019 13:18:14 +0000 (UTC)
commit 786753ac213af0052024f174701948e884522c3f
Author: Dan Nicholson <nicholson endlessm com>
Date: Sun May 11 14:38:27 2014 -0700
tests: keyfile writability not affected by file mode for root
When testing as root, changing the permissions of the keyfile will have
no effect on the writability since root bypasses these permissions. See
path_resolution(7). Skip the test in this case.
gio/tests/gsettings.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 6c37b7e70..640f3a31c 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <locale.h>
#include <libintl.h>
+#include <unistd.h>
+#include <sys/types.h>
#include <gio/gio.h>
#include <gstdio.h>
#define G_SETTINGS_ENABLE_BACKEND
@@ -1789,16 +1791,23 @@ test_keyfile (void)
g_settings_set (settings, "farewell", "s", "cheerio");
- called = FALSE;
- g_signal_connect (settings, "writable-changed::greeting", G_CALLBACK (key_changed_cb), &called);
+ /* When executing as root, changing the mode of the keyfile will have
+ * no effect on the writability of the settings.
+ */
+ if (geteuid () != 0)
+ {
+ called = FALSE;
+ g_signal_connect (settings, "writable-changed::greeting",
+ G_CALLBACK (key_changed_cb), &called);
- g_chmod ("keyfile", 0500);
- while (!called)
- g_main_context_iteration (NULL, FALSE);
- g_signal_handlers_disconnect_by_func (settings, key_changed_cb, &called);
+ g_chmod ("keyfile", 0500);
+ while (!called)
+ g_main_context_iteration (NULL, FALSE);
+ g_signal_handlers_disconnect_by_func (settings, key_changed_cb, &called);
- writable = g_settings_is_writable (settings, "greeting");
- g_assert_false (writable);
+ writable = g_settings_is_writable (settings, "greeting");
+ g_assert_false (writable);
+ }
g_key_file_free (keyfile);
g_free (data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]