While running weston with drm-backend, we check if its parent executable
name was weston-launch. In case it wasn't, we print error message and
quit.

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=60926
---
 src/compositor.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 3e24295..1ad73b2 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3491,6 +3491,10 @@ int main(int argc, char *argv[])
        char *socket_name = "wayland-0";
        int32_t version = 0;
        char *config_file;
+       int ppid;
+       FILE *proc_file;
+       char proc_name[128];
+       char parent_name[128];
 
        const struct config_key core_config_keys[] = {
                { "modules", CONFIG_KEY_STRING, &modules },
@@ -3556,6 +3560,18 @@ int main(int argc, char *argv[])
                        backend = WESTON_NATIVE_BACKEND;
        }
 
+       if (!strcmp(backend, WESTON_NATIVE_BACKEND)) {
+               ppid = getppid();
+               sprintf(proc_name, "/proc/%d/status", ppid);
+               proc_file = fopen(proc_name, "r");
+               fgets(parent_name, 128, proc_file);
+               if (!strstr(parent_name, "weston-launch")) {
+                       weston_log("fatal: drm backend should be run "
+                                  "using weston-launch binary\n");
+                       exit(EXIT_FAILURE);
+               }
+       }
+
        config_file = config_file_path("weston.ini");
        parse_config_file(config_file, cs, ARRAY_LENGTH(cs), NULL);
 
-- 
1.8.2

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to