summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2014-02-26 16:52:39 +1300
committerRobert Ancell <robert.ancell@canonical.com>2014-02-26 16:52:39 +1300
commit80f380f70228b9f7c96e8a297ad0471e2b36078c (patch)
tree7f85dabe34dcb4cf82dc3f08da22819c633f5146 /tests
parent95c76c3523b75cd4341724d4ba068bc934ef4942 (diff)
parent14f3a6269d5c2d12672b81a2f98a405d589bad37 (diff)
downloadlightdm-80f380f70228b9f7c96e8a297ad0471e2b36078c.tar.gz
Merge with trunk
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am12
-rw-r--r--tests/scripts/shared-data-dirs-autologin.conf31
-rw-r--r--tests/scripts/shared-data-dirs.conf63
-rw-r--r--tests/scripts/shared-data-greeter-to-session.conf45
-rw-r--r--tests/scripts/shared-data-invalid-user.conf30
-rw-r--r--tests/scripts/shared-data-session-to-greeter-autologin.conf56
-rw-r--r--tests/scripts/shared-data-session-to-greeter.conf66
-rw-r--r--tests/src/libsystem.c13
-rw-r--r--tests/src/test-gobject-greeter.c54
-rw-r--r--tests/src/test-runner.c39
-rw-r--r--tests/src/test-session.c56
-rwxr-xr-xtests/test-shared-data-dirs2
-rwxr-xr-xtests/test-shared-data-dirs-autologin2
-rwxr-xr-xtests/test-shared-data-greeter-to-session2
-rwxr-xr-xtests/test-shared-data-invalid-user2
-rwxr-xr-xtests/test-shared-data-session-to-greeter2
-rwxr-xr-xtests/test-shared-data-session-to-greeter-autologin2
17 files changed, 322 insertions, 155 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 734fc66e..caf765a7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -110,8 +110,10 @@ TESTS = \
test-script-hook-fail-display-setup \
test-script-hook-fail-greeter-setup \
test-script-hook-fail-session-setup \
- test-shared-data-dirs \
- test-shared-data-dirs-autologin \
+ test-shared-data-greeter-to-session \
+ test-shared-data-session-to-greeter \
+ test-shared-data-session-to-greeter-autologin \
+ test-shared-data-invalid-user \
test-upstart-autologin \
test-upstart-login \
test-dbus \
@@ -408,8 +410,10 @@ EXTRA_DIST = \
scripts/plymouth-inactive-vt.conf \
scripts/plymouth-no-seat.conf \
scripts/restart-authentication.conf \
- scripts/shared-data-dirs.conf \
- scripts/shared-data-dirs-autologin.conf \
+ scripts/shared-data-greeter-to-session.conf \
+ scripts/shared-data-invalid-user.conf \
+ scripts/shared-data-session-to-greeter.conf \
+ scripts/shared-data-session-to-greeter-autologin.conf \
scripts/script-hooks.conf \
scripts/script-hook-fail-display-setup.conf \
scripts/script-hook-fail-greeter-setup.conf \
diff --git a/tests/scripts/shared-data-dirs-autologin.conf b/tests/scripts/shared-data-dirs-autologin.conf
deleted file mode 100644
index 1783a540..00000000
--- a/tests/scripts/shared-data-dirs-autologin.conf
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Make sure we manage shared user data directories when autologin is used
-#
-
-[SeatDefaults]
-autologin-user=have-password1
-
-#?RUNNER DAEMON-START
-
-# X server starts
-#?XSERVER-0 START VT=7 SEAT=seat0
-
-# Daemon connects when X server is ready
-#?*XSERVER-0 INDICATE-READY
-#?XSERVER-0 INDICATE-READY
-#?XSERVER-0 ACCEPT-CONNECT
-
-# Session starts
-#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 DESKTOP_SESSION=default USER=have-password1
-#?XSERVER-0 ACCEPT-CONNECT
-#?SESSION-X-0 CONNECT-XSERVER
-
-# Make sure we created the directory as we started session
-#?*LIST-SHARED-DATA-DIRS
-#?RUNNER LIST-SHARED-DATA-DIRS DIRS=have-password1:1000:100:0770
-
-# Cleanup
-#?*STOP-DAEMON
-#?XSERVER-0 TERMINATE SIGNAL=15
-#?SESSION-X-0 TERMINATE SIGNAL=15
-#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/shared-data-dirs.conf b/tests/scripts/shared-data-dirs.conf
deleted file mode 100644
index 530fa26e..00000000
--- a/tests/scripts/shared-data-dirs.conf
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# Make sure we manage shared user data directories on startup and over time
-#
-
-[test-runner-config]
-# One normal, one with bad permissions, one to delete
-shared-data-dirs=have-password1:1000:100:0770 have-password2:1000:1000:0777 xxx:1004:100:0770
-
-#?RUNNER DAEMON-START
-
-# X server starts
-#?XSERVER-0 START VT=7 SEAT=seat0
-
-# Startup creation/deletion
-#?*WAIT
-#?*LIST-SHARED-DATA-DIRS
-#?RUNNER LIST-SHARED-DATA-DIRS DIRS=have-password1:1000:100:0770,have-password2:1000:1000:0777
-
-# Daemon connects when X server is ready
-#?*XSERVER-0 INDICATE-READY
-#?XSERVER-0 INDICATE-READY
-#?XSERVER-0 ACCEPT-CONNECT
-
-# Greeter starts
-#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
-#?XSERVER-0 ACCEPT-CONNECT
-#?GREETER-X-0 CONNECT-XSERVER
-#?GREETER-X-0 CONNECT-TO-DAEMON
-#?GREETER-X-0 CONNECTED-TO-DAEMON
-
-# Make sure we can create/chown a directory from the greeter
-#?*GREETER-X-0 ENSURE-SHARED-DATA-DIR USERNAME=have-password2
-#?GREETER-X-0 ENSURE-SHARED-DATA-DIR RESULT=TRUE
-#?*LIST-SHARED-DATA-DIRS
-#?RUNNER LIST-SHARED-DATA-DIRS DIRS=have-password1:1000:100:0770,have-password2:1001:100:0770,lightdm:100:100:0770
-
-# Log into account without a password
-#?*GREETER-X-0 AUTHENTICATE USERNAME=no-password1
-#?GREETER-X-0 AUTHENTICATION-COMPLETE USERNAME=no-password1 AUTHENTICATED=TRUE
-#?*GREETER-X-0 START-SESSION
-#?GREETER-X-0 TERMINATE SIGNAL=15
-
-# Session starts
-#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 DESKTOP_SESSION=default USER=no-password1
-#?XSERVER-0 ACCEPT-CONNECT
-#?SESSION-X-0 CONNECT-XSERVER
-
-# Make sure we created the directory as we started session
-#?*LIST-SHARED-DATA-DIRS
-#?RUNNER LIST-SHARED-DATA-DIRS DIRS=have-password1:1000:100:0770,have-password2:1001:100:0770,lightdm:100:100:0770,no-password1:1005:100:0770
-
-# Delete one user
-#?*DELETE-USER USERNAME=have-password1
-#?RUNNER DELETE-USER USERNAME=have-password1
-#?*WAIT
-#?*LIST-SHARED-DATA-DIRS
-#?RUNNER LIST-SHARED-DATA-DIRS DIRS=have-password2:1001:100:0770,lightdm:100:100:0770,no-password1:1005:100:0770
-
-# Cleanup
-#?*STOP-DAEMON
-#?XSERVER-0 TERMINATE SIGNAL=15
-#?SESSION-X-0 TERMINATE SIGNAL=15
-#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/shared-data-greeter-to-session.conf b/tests/scripts/shared-data-greeter-to-session.conf
new file mode 100644
index 00000000..9bdb8c17
--- /dev/null
+++ b/tests/scripts/shared-data-greeter-to-session.conf
@@ -0,0 +1,45 @@
+#
+# Make sure we can make a shared data directory to write from the greeter to the session
+#
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?XSERVER-0 ACCEPT-CONNECT
+#?GREETER-X-0 CONNECT-XSERVER
+#?GREETER-X-0 CONNECT-TO-DAEMON
+#?GREETER-X-0 CONNECTED-TO-DAEMON
+
+# Check greeter can write to data directory
+#?*GREETER-X-0 WRITE-SHARED-DATA USERNAME=no-password1 DATA=HELLO
+#?GREETER-X-0 WRITE-SHARED-DATA RESULT=TRUE
+
+# Log into account without a password
+#?*GREETER-X-0 AUTHENTICATE USERNAME=no-password1
+#?GREETER-X-0 AUTHENTICATION-COMPLETE USERNAME=no-password1 AUTHENTICATED=TRUE
+#?*GREETER-X-0 START-SESSION
+#?GREETER-X-0 TERMINATE SIGNAL=15
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 DESKTOP_SESSION=default USER=no-password1
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Check session can read from shared data directory
+#?*SESSION-X-0 READ-SHARED-DATA
+#?SESSION-X-0 READ-SHARED-DATA DATA=HELLO
+
+# Cleanup
+#?*STOP-DAEMON
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/shared-data-invalid-user.conf b/tests/scripts/shared-data-invalid-user.conf
new file mode 100644
index 00000000..7a787bc1
--- /dev/null
+++ b/tests/scripts/shared-data-invalid-user.conf
@@ -0,0 +1,30 @@
+#
+# Make sure we handle requesting an invalid user to share data with
+#
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?XSERVER-0 ACCEPT-CONNECT
+#?GREETER-X-0 CONNECT-XSERVER
+#?GREETER-X-0 CONNECT-TO-DAEMON
+#?GREETER-X-0 CONNECTED-TO-DAEMON
+
+# Try and write data to an invalid user
+#?*GREETER-X-0 WRITE-SHARED-DATA USERNAME=invalid DATA=HELLO
+#?GREETER-X-0 WRITE-SHARED-DATA ERROR=NO_SHARED_DIR
+
+# Cleanup
+#?*STOP-DAEMON
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?GREETER-X-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/shared-data-session-to-greeter-autologin.conf b/tests/scripts/shared-data-session-to-greeter-autologin.conf
new file mode 100644
index 00000000..3bff22b9
--- /dev/null
+++ b/tests/scripts/shared-data-session-to-greeter-autologin.conf
@@ -0,0 +1,56 @@
+#
+# Make sure a shared data directory is created on autologin and can be written back to the greeter
+#
+
+[SeatDefaults]
+autologin-user=have-password1
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 DESKTOP_SESSION=default USER=have-password1
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Check session can write to data directory
+#?*SESSION-X-0 WRITE-SHARED-DATA DATA=HELLO
+#?SESSION-X-0 WRITE-SHARED-DATA RESULT=TRUE
+
+# Logout session
+#?*SESSION-X-0 LOGOUT
+
+# X server stops
+#?XSERVER-0 TERMINATE SIGNAL=15
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?XSERVER-0 ACCEPT-CONNECT
+#?GREETER-X-0 CONNECT-XSERVER
+#?GREETER-X-0 CONNECT-TO-DAEMON
+#?GREETER-X-0 CONNECTED-TO-DAEMON
+
+# Check greeter can read from user
+#?*GREETER-X-0 READ-SHARED-DATA USERNAME=have-password1 DATA=HELLO
+#?GREETER-X-0 READ-SHARED-DATA DATA=HELLO
+
+# Cleanup
+#?*STOP-DAEMON
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?GREETER-X-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/shared-data-session-to-greeter.conf b/tests/scripts/shared-data-session-to-greeter.conf
new file mode 100644
index 00000000..dd00ee97
--- /dev/null
+++ b/tests/scripts/shared-data-session-to-greeter.conf
@@ -0,0 +1,66 @@
+#
+# Make sure a shared data directory is created on login and can be written back to the greeter
+#
+
+#?RUNNER DAEMON-START
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?XSERVER-0 ACCEPT-CONNECT
+#?GREETER-X-0 CONNECT-XSERVER
+#?GREETER-X-0 CONNECT-TO-DAEMON
+#?GREETER-X-0 CONNECTED-TO-DAEMON
+
+# Log into account without a password
+#?*GREETER-X-0 AUTHENTICATE USERNAME=no-password1
+#?GREETER-X-0 AUTHENTICATION-COMPLETE USERNAME=no-password1 AUTHENTICATED=TRUE
+#?*GREETER-X-0 START-SESSION
+#?GREETER-X-0 TERMINATE SIGNAL=15
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 DESKTOP_SESSION=default USER=no-password1
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Check session can write to data directory
+#?*SESSION-X-0 WRITE-SHARED-DATA DATA=HELLO
+#?SESSION-X-0 WRITE-SHARED-DATA RESULT=TRUE
+
+# Logout session
+#?*SESSION-X-0 LOGOUT
+
+# X server stops
+#?XSERVER-0 TERMINATE SIGNAL=15
+
+# X server starts
+#?XSERVER-0 START VT=7 SEAT=seat0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Greeter starts
+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?XSERVER-0 ACCEPT-CONNECT
+#?GREETER-X-0 CONNECT-XSERVER
+#?GREETER-X-0 CONNECT-TO-DAEMON
+#?GREETER-X-0 CONNECTED-TO-DAEMON
+
+# Check greeter can read from user
+#?*GREETER-X-0 READ-SHARED-DATA USERNAME=no-password1 DATA=HELLO
+#?GREETER-X-0 READ-SHARED-DATA DATA=HELLO
+
+# Cleanup
+#?*STOP-DAEMON
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?GREETER-X-0 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/src/libsystem.c b/tests/src/libsystem.c
index b4db0c35..2fdd19c1 100644
--- a/tests/src/libsystem.c
+++ b/tests/src/libsystem.c
@@ -454,17 +454,8 @@ mkdir (const char *pathname, mode_t mode)
int
chown (const char *pathname, uid_t owner, gid_t group)
{
- int (*_chown) (const char *pathname, uid_t owner, gid_t group);
- gchar *new_path = NULL;
- int result;
-
- _chown = (int (*)(const char *pathname, uid_t owner, gid_t group)) dlsym (RTLD_NEXT, "chown");
-
- new_path = redirect_path (pathname);
- result = _chown (new_path, owner, group);
- g_free (new_path);
-
- return result;
+ /* Just fake it - we're not root */
+ return 0;
}
int
diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c
index 972f2ba9..7918f490 100644
--- a/tests/src/test-gobject-greeter.c
+++ b/tests/src/test-gobject-greeter.c
@@ -203,8 +203,58 @@ request_cb (const gchar *request)
if (strcmp (name, "LOG-USER-LIST-LENGTH") == 0)
status_notify ("%s LOG-USER-LIST-LENGTH N=%d", greeter_id, lightdm_user_list_get_length (lightdm_user_list_get_instance ()));
- if (strcmp (name, "ENSURE-SHARED-DATA-DIR") == 0)
- status_notify ("%s ENSURE-SHARED-DATA-DIR RESULT=%s", greeter_id, lightdm_greeter_ensure_shared_data_dir_sync (greeter, g_hash_table_lookup (params, "USERNAME")) ? "TRUE" : "FALSE");
+ if (strcmp (name, "WRITE-SHARED-DATA") == 0)
+ {
+ gchar *dir;
+
+ dir = lightdm_greeter_ensure_shared_data_dir_sync (greeter, g_hash_table_lookup (params, "USERNAME"));
+ if (dir)
+ {
+ gchar *path;
+ FILE *f;
+
+ g_printerr ("dir='%s'\n", dir);
+
+ path = g_build_filename (dir, "data", NULL);
+ if (!(f = fopen (path, "w")) || fprintf (f, "%s", (const gchar *) g_hash_table_lookup (params, "DATA")) < 0)
+ status_notify ("%s WRITE-SHARED-DATA ERROR=%s", greeter_id, strerror (errno));
+ else
+ status_notify ("%s WRITE-SHARED-DATA RESULT=TRUE", greeter_id);
+
+ if (f)
+ fclose (f);
+ g_free (path);
+ g_free (dir);
+ }
+ else
+ status_notify ("%s WRITE-SHARED-DATA ERROR=NO_SHARED_DIR", greeter_id);
+ }
+
+ if (strcmp (name, "READ-SHARED-DATA") == 0)
+ {
+ gchar *dir;
+
+ dir = lightdm_greeter_ensure_shared_data_dir_sync (greeter, g_hash_table_lookup (params, "USERNAME"));
+ if (dir)
+ {
+ gchar *path;
+ gchar *contents = NULL;
+ GError *error = NULL;
+
+ g_printerr ("dir='%s'\n", dir);
+
+ path = g_build_filename (dir, "data", NULL);
+ if (g_file_get_contents (path, &contents, NULL, &error))
+ status_notify ("%s READ-SHARED-DATA DATA=%s", greeter_id, contents);
+ else
+ status_notify ("%s READ-SHARED-DATA ERROR=%s", greeter_id, error->message);
+ g_free (path);
+ g_free (contents);
+ g_clear_error (&error);
+ }
+ else
+ status_notify ("%s READ-SHARED-DATA ERROR=NO_SHARED_DIR", greeter_id);
+ }
if (strcmp (name, "WATCH-USER") == 0)
{
diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c
index 832ccaf0..a9bc15ac 100644
--- a/tests/src/test-runner.c
+++ b/tests/src/test-runner.c
@@ -444,45 +444,6 @@ handle_command (const gchar *command)
g_main_loop_run (loop);
g_main_loop_unref (loop);
}
- else if (strcmp (name, "LIST-SHARED-DATA-DIRS") == 0)
- {
- gchar *shared_dir;
- GDir *dir;
- const gchar *path;
- GList *paths = NULL, *link;
- GString *status;
-
- shared_dir = g_strdup_printf ("%s/var/lib/lightdm-data", temp_dir);
- dir = g_dir_open (shared_dir, 0, NULL);
- while ((path = g_dir_read_name (dir)))
- {
- gchar *full_path = g_build_filename (shared_dir, path, NULL);
- paths = g_list_insert_sorted (paths, full_path, (GCompareFunc)g_strcmp0);
- }
- g_dir_close (dir);
- g_free (shared_dir);
-
- status = g_string_new ("RUNNER LIST-SHARED-DATA-DIRS DIRS=");
- for (link = paths; link; link = link->next)
- {
- path = (const gchar *)link->data;
- GStatBuf buf;
- if (g_stat (path, &buf) != 0)
- continue;
-
- if (link != paths)
- g_string_append (status, ",");
- gchar *basename = g_path_get_basename (path);
- g_string_append_printf (status, "%s:%u:%u:0%o", basename,
- buf.st_uid, buf.st_gid,
- buf.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO));
- g_free (basename);
- }
- g_list_free_full (paths, g_free);
-
- check_status (status->str);
- g_string_free (status, TRUE);
- }
else if (strcmp (name, "LIST-SEATS") == 0)
{
GVariant *result, *value;
diff --git a/tests/src/test-session.c b/tests/src/test-session.c
index efebbb61..d7f23a91 100644
--- a/tests/src/test-session.c
+++ b/tests/src/test-session.c
@@ -153,13 +153,14 @@ request_cb (const gchar *request)
if (g_str_has_prefix (request, r))
{
const gchar *name = request + strlen (r);
- gchar *contents;
+ gchar *contents = NULL;
GError *error = NULL;
if (g_file_get_contents (name, &contents, NULL, &error))
status_notify ("%s READ FILE=%s TEXT=%s", session_id, name, contents);
else
status_notify ("%s READ FILE=%s ERROR=%s", session_id, name, error->message);
+ g_free (contents);
g_clear_error (&error);
}
g_free (r);
@@ -197,6 +198,59 @@ request_cb (const gchar *request)
g_string_free (mode_string, TRUE);
}
g_free (r);
+
+ r = g_strdup_printf ("%s WRITE-SHARED-DATA DATA=", session_id);
+ if (g_str_has_prefix (request, r))
+ {
+ const gchar *data = request + strlen (r);
+ gchar *dir;
+
+ dir = getenv ("XDG_GREETER_DATA_DIR");
+ if (dir)
+ {
+ gchar *path;
+ FILE *f;
+
+ path = g_build_filename (dir, "data", NULL);
+ if (!(f = fopen (path, "w")) || fprintf (f, "%s", data) < 0)
+ status_notify ("%s WRITE-SHARED-DATA ERROR=%s", session_id, strerror (errno));
+ else
+ status_notify ("%s WRITE-SHARED-DATA RESULT=TRUE", session_id);
+
+ if (f)
+ fclose (f);
+ g_free (path);
+ }
+ else
+ status_notify ("%s WRITE-SHARED-DATA ERROR=NO_XDG_GREETER_DATA_DIR", session_id);
+ }
+ g_free (r);
+
+ r = g_strdup_printf ("%s READ-SHARED-DATA", session_id);
+ if (strcmp (request, r) == 0)
+ {
+ gchar *dir;
+
+ dir = getenv ("XDG_GREETER_DATA_DIR");
+ if (dir)
+ {
+ gchar *path;
+ gchar *contents = NULL;
+ GError *error = NULL;
+
+ path = g_build_filename (dir, "data", NULL);
+ if (g_file_get_contents (path, &contents, NULL, &error))
+ status_notify ("%s READ-SHARED-DATA DATA=%s", session_id, contents);
+ else
+ status_notify ("%s WRITE-SHARED-DATA ERROR=%s", session_id, error->message);
+ g_free (path);
+ g_free (contents);
+ g_clear_error (&error);
+ }
+ else
+ status_notify ("%s WRITE-SHARED-DATA ERROR=NO_XDG_GREETER_DATA_DIR", session_id);
+ }
+ g_free (r);
}
int
diff --git a/tests/test-shared-data-dirs b/tests/test-shared-data-dirs
deleted file mode 100755
index e4c475e6..00000000
--- a/tests/test-shared-data-dirs
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-./src/dbus-env ./src/test-runner shared-data-dirs test-gobject-greeter
diff --git a/tests/test-shared-data-dirs-autologin b/tests/test-shared-data-dirs-autologin
deleted file mode 100755
index 710661f5..00000000
--- a/tests/test-shared-data-dirs-autologin
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-./src/dbus-env ./src/test-runner shared-data-dirs-autologin test-gobject-greeter
diff --git a/tests/test-shared-data-greeter-to-session b/tests/test-shared-data-greeter-to-session
new file mode 100755
index 00000000..ae80823c
--- /dev/null
+++ b/tests/test-shared-data-greeter-to-session
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner shared-data-greeter-to-session test-gobject-greeter
diff --git a/tests/test-shared-data-invalid-user b/tests/test-shared-data-invalid-user
new file mode 100755
index 00000000..4118ab7a
--- /dev/null
+++ b/tests/test-shared-data-invalid-user
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner shared-data-invalid-user test-gobject-greeter
diff --git a/tests/test-shared-data-session-to-greeter b/tests/test-shared-data-session-to-greeter
new file mode 100755
index 00000000..3effe573
--- /dev/null
+++ b/tests/test-shared-data-session-to-greeter
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner shared-data-session-to-greeter test-gobject-greeter
diff --git a/tests/test-shared-data-session-to-greeter-autologin b/tests/test-shared-data-session-to-greeter-autologin
new file mode 100755
index 00000000..94072b4b
--- /dev/null
+++ b/tests/test-shared-data-session-to-greeter-autologin
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner shared-data-session-to-greeter-autologin test-gobject-greeter