commit 28f2da3
Michael Forney
·
2014-12-25 08:54:21 +0000 UTC
parent 1bd1820
launch: Don't allow opening of devices when not active
1 files changed,
+9,
-0
+9,
-0
1@@ -63,6 +63,7 @@ static struct
2 int drm_fds[16];
3 unsigned num_drm_fds;
4 int tty_fd;
5+ bool active;
6 } launcher;
7
8 static struct
9@@ -178,6 +179,7 @@ static void handle_usr1(int signal)
10 send(launcher.socket, &event, sizeof event, 0);
11 stop_devices(true);
12 ioctl(launcher.tty_fd, VT_RELDISP, 1);
13+ launcher.active = false;
14 }
15
16 static void handle_usr2(int signal)
17@@ -187,6 +189,7 @@ static void handle_usr2(int signal)
18 ioctl(launcher.tty_fd, VT_RELDISP, VT_ACKACQ);
19 start_devices();
20 send(launcher.socket, &event, sizeof event, 0);
21+ launcher.active = true;
22 }
23
24 static void forward_signal(int signal)
25@@ -230,6 +233,9 @@ static void handle_socket_data(int socket)
26 switch (major(st.st_rdev))
27 {
28 case INPUT_MAJOR:
29+ if (!launcher.active)
30+ goto fail;
31+
32 if (launcher.num_input_fds
33 == ARRAY_LENGTH(launcher.input_fds))
34 {
35@@ -270,6 +276,9 @@ static void handle_socket_data(int socket)
36
37 break;
38 case SWC_LAUNCH_REQUEST_ACTIVATE_VT:
39+ if (!launcher.active)
40+ goto fail;
41+
42 if (ioctl(launcher.tty_fd, VT_ACTIVATE, request->vt) == -1)
43 {
44 fprintf(stderr, "Could not activate VT %d: %s\n",