wayland: Use shm_open(SHM_ANON) on FreeBSD
authormyfreeweb <greg@unrelenting.technology>
Tue, 19 Jun 2018 14:49:18 +0000 (14:49 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 19 Jun 2018 15:45:49 +0000 (11:45 -0400)
This functionality is similar to Linux's memfd. It creates anonymous shared memory without touching the filesystem, which allows it to work in Capsicum capability mode (sandbox).

gdk/wayland/gdkdisplay-wayland.c

index b64f2f105b0ec9ee355ba6f7bcde6547cb8bef0d..f83dd45046cc951b3975d8ecf805a8d96436719d 100644 (file)
@@ -1210,6 +1210,9 @@ open_shared_memory (void)
 
       if (force_shm_open)
         {
+#if defined (__FreeBSD__)
+          ret = shm_open (SHM_ANON, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, 0600);
+#else
           char name[NAME_MAX - 1] = "";
 
           sprintf (name, "/gdk-wayland-%x", g_random_int ());
@@ -1220,6 +1223,7 @@ open_shared_memory (void)
             shm_unlink (name);
           else if (errno == EEXIST)
             continue;
+#endif
         }
     }
   while (ret < 0 && errno == EINTR);