On Tue, 18 Mar 2014, Jason Ekstrand wrote:
+static struct shared_output *
+weston_output_share(struct weston_output *output,
+ const char *path, char *const argv[])
+{
+ int sv[2];
+ char str[32];
+ pid_t pid;
+ sigset_t allsigs;
+
+ if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
+ weston_log("weston_output_share: socketpair failed: %m\n");
+ return NULL;
+ }
+
+ pid = fork();
+
+ if (pid == -1) {
+ close(sv[0]);
+ close(sv[1]);
+ weston_log("weston_output_share: fork failed: %m\n");
+ return NULL;
+ }
+
+ if (pid == 0) {
+ /* We don't want anything circular */
+ unsetenv("WAYLAND_DISPLAY");
I totally see why you do this, but it would be useful if we could pass the
server's display somehow, since the screen sharing app may want to display
a UI, e.g. to control the screen sharing. How about if this was passed as
WAYLAND_SERVER_DISPLAY?
+ unsetenv("WAYLAND_SOCKET");
+
+ /* do not give our signal mask to the new process */
+ sigfillset(&allsigs);
+ sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
+
+ /* Launch clients as the user. Do not launch clients with
+ * wrong euid. */
+ if (seteuid(getuid()) == -1) {
+ weston_log("weston_output_share: setuid failed: %m\n");
+ abort();
+ }
+
+ sv[1] = dup(sv[1]);
+ if (sv[1] == -1) {
+ weston_log("weston_output_share: dup failed: %m\n");
+ abort();
+ }
+
+ snprintf(str, sizeof str, "%d", sv[1]);
+ setenv("WAYLAND_SERVER_SOCKET", str, 1);
+
+ execv(path, argv);
+ weston_log("weston_output_share: exec failed: %m\n");
+ abort();
+ } else {
+ close(sv[1]);
+ return shared_output_create(output, sv[0]);
+ }
+
+ return NULL;
+}
---
Andrew Wedgbury <[email protected]>
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel