[PATCH fullscreen-shell v5 18/18] Add a screen sharing plugin

Andrew Wedgbury andrew.wedgbury at realvnc.com
Wed Apr 2 08:15:54 PDT 2014


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 <andrew.wedgbury at realvnc.com>



More information about the wayland-devel mailing list