summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-10-23 08:01:21 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-10-27 13:49:51 +0000
commitf024e9536279b7c47fe2b1d656a86d3b3f50b716 (patch)
tree1d894b0043e6f4ac68944c86abbef50f106abfff
parent7fc8fa0c313fe8e4d64a2d24fd036b1ebb93a293 (diff)
downloadflatpak-f024e9536279b7c47fe2b1d656a86d3b3f50b716.tar.gz
Check that wayland-0 is a socket
This is a little better than just checking that the file exists. Still does not protect against a stale socket. Closes: #2258 Closes: #2271 Approved by: matthiasclasen
-rw-r--r--common/flatpak-run.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/flatpak-run.c b/common/flatpak-run.c
index 588ab034..0abca6d8 100644
--- a/common/flatpak-run.c
+++ b/common/flatpak-run.c
@@ -234,6 +234,7 @@ flatpak_run_add_wayland_args (FlatpakBwrap *bwrap)
g_autofree char *wayland_socket = NULL;
g_autofree char *sandbox_wayland_socket = NULL;
gboolean res = FALSE;
+ struct stat statbuf;
wayland_display = g_getenv ("WAYLAND_DISPLAY");
if (!wayland_display)
@@ -242,7 +243,8 @@ flatpak_run_add_wayland_args (FlatpakBwrap *bwrap)
wayland_socket = g_build_filename (g_get_user_runtime_dir (), wayland_display, NULL);
sandbox_wayland_socket = g_strdup_printf ("/run/user/%d/%s", getuid (), wayland_display);
- if (g_file_test (wayland_socket, G_FILE_TEST_EXISTS))
+ if (stat (wayland_socket, &statbuf) == 0 &&
+ (statbuf.st_mode & S_IFMT) == S_IFSOCK)
{
res = TRUE;
flatpak_bwrap_add_args (bwrap,