screen-share: Allow fullscreen shell command to be configured

I've updated this based on comments, simplifying the command handling.

Currently the screen-share module uses a hard-coded command to start the
fullscreen shell server. This patch causes the module to read the command from
the weston config file (from the "command" key in the "screen-share" section).
The default value remains the same (i.e. to run weston with the RDP backend and
fullscreen shell), but is now located in the weston config file.

As well as allowing the arguments to the fullscreen shell server to be changed,
this also permits an alternative fullscreen shell server to be used if required,
without needing to recompile. Since the command is run as the user running
weston, this should not pose any additional security risk.

Signed-off-by: Andrew Wedgbury <andrew.wedgbury@realvnc.com>
dev
Andrew Wedgbury 11 years ago committed by Jason Ekstrand
parent 8202d72054
commit dfd9d0de96
  1. 44
      src/screen-share.c
  2. 3
      weston.ini.in

@ -32,6 +32,7 @@
#include <signal.h>
#include <linux/input.h>
#include <errno.h>
#include <ctype.h>
#include <wayland-client.h>
@ -101,6 +102,11 @@ struct ss_shm_buffer {
pixman_image_t *pm_image;
};
struct screen_share {
struct weston_compositor *compositor;
char *command;
};
static void
ss_seat_handle_pointer_enter(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface,
@ -982,13 +988,18 @@ shared_output_destroy(struct shared_output *so)
}
static struct shared_output *
weston_output_share(struct weston_output *output,
const char *path, char *const argv[])
weston_output_share(struct weston_output *output, const char* command)
{
int sv[2];
char str[32];
pid_t pid;
sigset_t allsigs;
char *const argv[] = {
"/bin/sh",
"-c",
(char*)command,
NULL
};
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
weston_log("weston_output_share: socketpair failed: %m\n");
@ -1025,7 +1036,7 @@ weston_output_share(struct weston_output *output,
snprintf(str, sizeof str, "%d", sv[1]);
setenv("WAYLAND_SERVER_SOCKET", str, 1);
execv(path, argv);
execv(argv[0], argv);
weston_log("weston_output_share: exec failed: %m\n");
abort();
} else {
@ -1056,7 +1067,7 @@ share_output_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
void *data)
{
struct weston_output *output;
const char *path = BINDIR "/weston";
struct screen_share *ss = data;
if (!seat->pointer) {
weston_log("Cannot pick output: Seat does not have pointer\n");
@ -1071,23 +1082,28 @@ share_output_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
return;
}
char *const argv[] = {
"weston",
"--backend=rdp-backend.so",
"--shell=fullscreen-shell.so",
"--no-clients-resize",
NULL
};
weston_output_share(output, path, argv);
weston_output_share(output, ss->command);
}
WL_EXPORT int
module_init(struct weston_compositor *compositor,
int *argc, char *argv[])
{
struct screen_share *ss;
struct weston_config_section *section;
ss = zalloc(sizeof *ss);
if (ss == NULL)
return -1;
ss->compositor = compositor;
section = weston_config_get_section(compositor->config, "screen-share",
NULL, NULL);
weston_config_section_get_string(section, "command", &ss->command, "");
weston_compositor_add_key_binding(compositor, KEY_S,
MODIFIER_CTRL | MODIFIER_ALT,
share_output_binding, compositor);
share_output_binding, ss);
return 0;
}

@ -65,3 +65,6 @@ path=@libexecdir@/weston-keyboard
#constant_accel_factor = 50
#min_accel_factor = 0.16
#max_accel_factor = 1.0
[screen-share]
command=@bindir@/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize

Loading…
Cancel
Save