Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 Benjamin Franzke |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and |
| 5 | * its documentation for any purpose is hereby granted without fee, provided |
| 6 | * that the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation, and that the name of the copyright holders not be used in |
| 9 | * advertising or publicity pertaining to distribution of the software |
| 10 | * without specific, written prior permission. The copyright holders make |
| 11 | * no representations about the suitability of this software for any |
| 12 | * purpose. It is provided "as is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 21 | */ |
| 22 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 23 | #include "config.h" |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <assert.h> |
Kristian Høgsberg | f280770 | 2013-07-23 11:43:03 -0700 | [diff] [blame] | 29 | #include <poll.h> |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 30 | #include <errno.h> |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 31 | #include <termios.h> |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 32 | |
| 33 | #include <error.h> |
| 34 | #include <getopt.h> |
| 35 | |
| 36 | #include <sys/types.h> |
| 37 | #include <sys/ioctl.h> |
| 38 | #include <sys/stat.h> |
| 39 | #include <sys/wait.h> |
| 40 | #include <sys/socket.h> |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 41 | #include <sys/signalfd.h> |
| 42 | #include <signal.h> |
| 43 | #include <unistd.h> |
| 44 | #include <fcntl.h> |
| 45 | |
| 46 | #include <termios.h> |
| 47 | #include <linux/vt.h> |
| 48 | #include <linux/major.h> |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 49 | #include <linux/kd.h> |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 50 | |
| 51 | #include <pwd.h> |
| 52 | #include <grp.h> |
| 53 | #include <security/pam_appl.h> |
| 54 | |
| 55 | #include <xf86drm.h> |
| 56 | |
| 57 | #ifdef HAVE_SYSTEMD_LOGIN |
| 58 | #include <systemd/sd-login.h> |
| 59 | #endif |
| 60 | |
| 61 | #include "weston-launch.h" |
| 62 | |
Kristian Høgsberg | 1ff5109 | 2013-09-17 14:03:42 -0700 | [diff] [blame] | 63 | #define DRM_MAJOR 226 |
| 64 | |
Quentin Glidic | ff32309 | 2013-05-17 16:20:37 +0200 | [diff] [blame] | 65 | #define MAX_ARGV_SIZE 256 |
| 66 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 67 | struct weston_launch { |
| 68 | struct pam_conv pc; |
| 69 | pam_handle_t *ph; |
| 70 | int tty; |
| 71 | int ttynr; |
| 72 | int sock[2]; |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 73 | int drm_fd; |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 74 | struct termios terminal_attributes; |
| 75 | int kb_mode; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 76 | struct passwd *pw; |
| 77 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 78 | int signalfd; |
| 79 | |
| 80 | pid_t child; |
| 81 | int verbose; |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 82 | char *new_user; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 83 | }; |
| 84 | |
Kristian Høgsberg | 9e14091 | 2012-04-10 01:26:18 -0400 | [diff] [blame] | 85 | union cmsg_data { unsigned char b[4]; int fd; }; |
| 86 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 87 | static gid_t * |
| 88 | read_groups(void) |
| 89 | { |
| 90 | int n; |
| 91 | gid_t *groups; |
| 92 | |
| 93 | n = getgroups(0, NULL); |
Rob Bradford | 40be7b4 | 2012-12-05 18:47:11 +0000 | [diff] [blame] | 94 | |
| 95 | if (n < 0) { |
| 96 | fprintf(stderr, "Unable to retrieve groups: %m\n"); |
| 97 | return NULL; |
| 98 | } |
| 99 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 100 | groups = malloc(n * sizeof(gid_t)); |
| 101 | if (!groups) |
| 102 | return NULL; |
| 103 | |
| 104 | if (getgroups(n, groups) < 0) { |
Rob Bradford | 40be7b4 | 2012-12-05 18:47:11 +0000 | [diff] [blame] | 105 | fprintf(stderr, "Unable to retrieve groups: %m\n"); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 106 | free(groups); |
| 107 | return NULL; |
| 108 | } |
| 109 | return groups; |
| 110 | } |
| 111 | |
| 112 | static int |
| 113 | weston_launch_allowed(struct weston_launch *wl) |
| 114 | { |
| 115 | struct group *gr; |
| 116 | gid_t *groups; |
| 117 | int i; |
| 118 | #ifdef HAVE_SYSTEMD_LOGIN |
| 119 | char *session, *seat; |
| 120 | int err; |
| 121 | #endif |
| 122 | |
| 123 | if (getuid() == 0) |
| 124 | return 1; |
| 125 | |
| 126 | gr = getgrnam("weston-launch"); |
| 127 | if (gr) { |
| 128 | groups = read_groups(); |
| 129 | if (groups) { |
| 130 | for (i = 0; groups[i]; ++i) { |
| 131 | if (groups[i] == gr->gr_gid) { |
| 132 | free(groups); |
| 133 | return 1; |
| 134 | } |
| 135 | } |
| 136 | free(groups); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | #ifdef HAVE_SYSTEMD_LOGIN |
| 141 | err = sd_pid_get_session(getpid(), &session); |
| 142 | if (err == 0 && session) { |
| 143 | if (sd_session_is_active(session) && |
| 144 | sd_session_get_seat(session, &seat) == 0) { |
| 145 | free(seat); |
| 146 | free(session); |
| 147 | return 1; |
| 148 | } |
| 149 | free(session); |
| 150 | } |
| 151 | #endif |
| 152 | |
| 153 | return 0; |
| 154 | } |
| 155 | |
| 156 | static int |
| 157 | pam_conversation_fn(int msg_count, |
| 158 | const struct pam_message **messages, |
| 159 | struct pam_response **responses, |
| 160 | void *user_data) |
| 161 | { |
| 162 | return PAM_SUCCESS; |
| 163 | } |
| 164 | |
| 165 | static int |
| 166 | setup_pam(struct weston_launch *wl) |
| 167 | { |
| 168 | int err; |
| 169 | |
| 170 | wl->pc.conv = pam_conversation_fn; |
| 171 | wl->pc.appdata_ptr = wl; |
| 172 | |
| 173 | err = pam_start("login", wl->pw->pw_name, &wl->pc, &wl->ph); |
John Kåre Alsaker | 5b90d8f | 2012-10-12 12:25:05 +0200 | [diff] [blame] | 174 | if (err != PAM_SUCCESS) { |
| 175 | fprintf(stderr, "failed to start pam transaction: %d: %s\n", |
| 176 | err, pam_strerror(wl->ph, err)); |
| 177 | return -1; |
| 178 | } |
| 179 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 180 | err = pam_set_item(wl->ph, PAM_TTY, ttyname(wl->tty)); |
| 181 | if (err != PAM_SUCCESS) { |
| 182 | fprintf(stderr, "failed to set PAM_TTY item: %d: %s\n", |
| 183 | err, pam_strerror(wl->ph, err)); |
| 184 | return -1; |
| 185 | } |
| 186 | |
| 187 | err = pam_open_session(wl->ph, 0); |
| 188 | if (err != PAM_SUCCESS) { |
| 189 | fprintf(stderr, "failed to open pam session: %d: %s\n", |
| 190 | err, pam_strerror(wl->ph, err)); |
| 191 | return -1; |
| 192 | } |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | static int |
| 198 | setup_launcher_socket(struct weston_launch *wl) |
| 199 | { |
Kristian Høgsberg | bf3c374 | 2013-09-18 11:01:48 -0700 | [diff] [blame] | 200 | if (socketpair(AF_LOCAL, SOCK_SEQPACKET, 0, wl->sock) < 0) |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 201 | error(1, errno, "socketpair failed"); |
| 202 | |
Kristian Høgsberg | f45b1e8 | 2013-09-18 11:00:56 -0700 | [diff] [blame] | 203 | if (fcntl(wl->sock[0], F_SETFD, FD_CLOEXEC) < 0) |
| 204 | error(1, errno, "fcntl failed"); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 205 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | static int |
| 210 | setup_signals(struct weston_launch *wl) |
| 211 | { |
Philipp Brüschweiler | ff25312 | 2013-03-09 19:38:56 +0100 | [diff] [blame] | 212 | int ret; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 213 | sigset_t mask; |
| 214 | struct sigaction sa; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 215 | |
| 216 | memset(&sa, 0, sizeof sa); |
| 217 | sa.sa_handler = SIG_DFL; |
| 218 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
Philipp Brüschweiler | ff25312 | 2013-03-09 19:38:56 +0100 | [diff] [blame] | 219 | ret = sigaction(SIGCHLD, &sa, NULL); |
| 220 | assert(ret == 0); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 221 | |
Kristian Høgsberg | 18684d4 | 2013-07-22 11:59:18 -0700 | [diff] [blame] | 222 | sa.sa_handler = SIG_IGN; |
| 223 | sa.sa_flags = 0; |
| 224 | sigaction(SIGHUP, &sa, NULL); |
| 225 | |
Philipp Brüschweiler | ff25312 | 2013-03-09 19:38:56 +0100 | [diff] [blame] | 226 | ret = sigemptyset(&mask); |
| 227 | assert(ret == 0); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 228 | sigaddset(&mask, SIGCHLD); |
| 229 | sigaddset(&mask, SIGINT); |
| 230 | sigaddset(&mask, SIGTERM); |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 231 | sigaddset(&mask, SIGUSR1); |
| 232 | sigaddset(&mask, SIGUSR2); |
Philipp Brüschweiler | ff25312 | 2013-03-09 19:38:56 +0100 | [diff] [blame] | 233 | ret = sigprocmask(SIG_BLOCK, &mask, NULL); |
| 234 | assert(ret == 0); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 235 | |
| 236 | wl->signalfd = signalfd(-1, &mask, SFD_NONBLOCK | SFD_CLOEXEC); |
| 237 | if (wl->signalfd < 0) |
| 238 | return -errno; |
| 239 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 240 | return 0; |
| 241 | } |
| 242 | |
| 243 | static void |
| 244 | setenv_fd(const char *env, int fd) |
| 245 | { |
| 246 | char buf[32]; |
| 247 | |
| 248 | snprintf(buf, sizeof buf, "%d", fd); |
| 249 | setenv(env, buf, 1); |
| 250 | } |
| 251 | |
| 252 | static int |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 253 | send_reply(struct weston_launch *wl, int reply) |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 254 | { |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 255 | int len; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 256 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 257 | do { |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 258 | len = send(wl->sock[0], &reply, sizeof reply, 0); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 259 | } while (len < 0 && errno == EINTR); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 260 | |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 261 | return len; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static int |
| 265 | handle_open(struct weston_launch *wl, struct msghdr *msg, ssize_t len) |
| 266 | { |
| 267 | int fd = -1, ret = -1; |
| 268 | char control[CMSG_SPACE(sizeof(fd))]; |
| 269 | struct cmsghdr *cmsg; |
| 270 | struct stat s; |
| 271 | struct msghdr nmsg; |
| 272 | struct iovec iov; |
| 273 | struct weston_launcher_open *message; |
Kristian Høgsberg | 9e14091 | 2012-04-10 01:26:18 -0400 | [diff] [blame] | 274 | union cmsg_data *data; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 275 | |
| 276 | message = msg->msg_iov->iov_base; |
| 277 | if ((size_t)len < sizeof(*message)) |
| 278 | goto err0; |
| 279 | |
| 280 | /* Ensure path is null-terminated */ |
| 281 | ((char *) message)[len-1] = '\0'; |
| 282 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 283 | fd = open(message->path, message->flags); |
Rob Bradford | d33f2b0 | 2013-05-20 16:55:10 +0100 | [diff] [blame] | 284 | if (fd < 0) { |
| 285 | fprintf(stderr, "Error opening device %s: %m\n", |
| 286 | message->path); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 287 | goto err0; |
Rob Bradford | d33f2b0 | 2013-05-20 16:55:10 +0100 | [diff] [blame] | 288 | } |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 289 | |
Kristian Høgsberg | 6a7c849 | 2013-09-18 22:14:09 -0700 | [diff] [blame^] | 290 | if (fstat(fd, &s) < 0) { |
| 291 | close(fd); |
| 292 | fd = -1; |
| 293 | fprintf(stderr, "Failed to stat %s\n", message->path); |
| 294 | goto err0; |
| 295 | } |
| 296 | |
Kristian Høgsberg | 1ff5109 | 2013-09-17 14:03:42 -0700 | [diff] [blame] | 297 | if (major(s.st_rdev) != INPUT_MAJOR && |
| 298 | major(s.st_rdev) != DRM_MAJOR) { |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 299 | close(fd); |
| 300 | fd = -1; |
Kristian Høgsberg | 1ff5109 | 2013-09-17 14:03:42 -0700 | [diff] [blame] | 301 | fprintf(stderr, "Device %s is not an input or drm device\n", |
Rob Bradford | d33f2b0 | 2013-05-20 16:55:10 +0100 | [diff] [blame] | 302 | message->path); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 303 | goto err0; |
| 304 | } |
| 305 | |
| 306 | err0: |
| 307 | memset(&nmsg, 0, sizeof nmsg); |
| 308 | nmsg.msg_iov = &iov; |
| 309 | nmsg.msg_iovlen = 1; |
| 310 | if (fd != -1) { |
| 311 | nmsg.msg_control = control; |
| 312 | nmsg.msg_controllen = sizeof control; |
| 313 | cmsg = CMSG_FIRSTHDR(&nmsg); |
| 314 | cmsg->cmsg_level = SOL_SOCKET; |
| 315 | cmsg->cmsg_type = SCM_RIGHTS; |
| 316 | cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); |
Kristian Høgsberg | 9e14091 | 2012-04-10 01:26:18 -0400 | [diff] [blame] | 317 | data = (union cmsg_data *) CMSG_DATA(cmsg); |
| 318 | data->fd = fd; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 319 | nmsg.msg_controllen = cmsg->cmsg_len; |
| 320 | ret = 0; |
| 321 | } |
| 322 | iov.iov_base = &ret; |
| 323 | iov.iov_len = sizeof ret; |
| 324 | |
| 325 | if (wl->verbose) |
| 326 | fprintf(stderr, "weston-launch: opened %s: ret: %d, fd: %d\n", |
| 327 | message->path, ret, fd); |
| 328 | do { |
| 329 | len = sendmsg(wl->sock[0], &nmsg, 0); |
| 330 | } while (len < 0 && errno == EINTR); |
| 331 | |
| 332 | if (len < 0) |
| 333 | return -1; |
| 334 | |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 335 | if (major(s.st_rdev) == DRM_MAJOR) |
| 336 | wl->drm_fd = fd; |
| 337 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | static int |
| 342 | handle_socket_msg(struct weston_launch *wl) |
| 343 | { |
| 344 | char control[CMSG_SPACE(sizeof(int))]; |
| 345 | char buf[BUFSIZ]; |
| 346 | struct msghdr msg; |
| 347 | struct iovec iov; |
| 348 | int ret = -1; |
| 349 | ssize_t len; |
| 350 | struct weston_launcher_message *message; |
| 351 | |
| 352 | memset(&msg, 0, sizeof(msg)); |
| 353 | iov.iov_base = buf; |
| 354 | iov.iov_len = sizeof buf; |
| 355 | msg.msg_iov = &iov; |
| 356 | msg.msg_iovlen = 1; |
| 357 | msg.msg_control = control; |
| 358 | msg.msg_controllen = sizeof control; |
| 359 | |
| 360 | do { |
| 361 | len = recvmsg(wl->sock[0], &msg, 0); |
| 362 | } while (len < 0 && errno == EINTR); |
| 363 | |
| 364 | if (len < 1) |
| 365 | return -1; |
| 366 | |
| 367 | message = (void *) buf; |
| 368 | switch (message->opcode) { |
| 369 | case WESTON_LAUNCHER_OPEN: |
| 370 | ret = handle_open(wl, &msg, len); |
| 371 | break; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | return ret; |
| 375 | } |
| 376 | |
| 377 | static void |
| 378 | quit(struct weston_launch *wl, int status) |
| 379 | { |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 380 | struct vt_mode mode = { 0 }; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 381 | int err; |
| 382 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 383 | close(wl->signalfd); |
| 384 | close(wl->sock[0]); |
| 385 | |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 386 | if (wl->new_user) { |
| 387 | err = pam_close_session(wl->ph, 0); |
| 388 | if (err) |
| 389 | fprintf(stderr, "pam_close_session failed: %d: %s\n", |
| 390 | err, pam_strerror(wl->ph, err)); |
| 391 | pam_end(wl->ph, err); |
| 392 | } |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 393 | |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 394 | if (ioctl(wl->tty, KDSKBMODE, wl->kb_mode)) |
| 395 | fprintf(stderr, "failed to restore keyboard mode: %m\n"); |
| 396 | |
| 397 | if (ioctl(wl->tty, KDSETMODE, KD_TEXT)) |
| 398 | fprintf(stderr, "failed to set KD_TEXT mode on tty: %m\n"); |
| 399 | |
| 400 | if (tcsetattr(wl->tty, TCSANOW, &wl->terminal_attributes) < 0) |
| 401 | fprintf(stderr, |
| 402 | "could not restore terminal to canonical mode\n"); |
| 403 | |
| 404 | mode.mode = VT_AUTO; |
| 405 | if (ioctl(wl->tty, VT_SETMODE, &mode) < 0) |
| 406 | fprintf(stderr, "could not reset vt handling\n"); |
| 407 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 408 | exit(status); |
| 409 | } |
| 410 | |
| 411 | static int |
| 412 | handle_signal(struct weston_launch *wl) |
| 413 | { |
| 414 | struct signalfd_siginfo sig; |
Philipp Brüschweiler | 7a3ec74 | 2013-03-10 15:14:01 +0100 | [diff] [blame] | 415 | int pid, status, ret; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 416 | |
| 417 | if (read(wl->signalfd, &sig, sizeof sig) != sizeof sig) { |
| 418 | error(0, errno, "reading signalfd failed"); |
| 419 | return -1; |
| 420 | } |
| 421 | |
| 422 | switch (sig.ssi_signo) { |
| 423 | case SIGCHLD: |
| 424 | pid = waitpid(-1, &status, 0); |
| 425 | if (pid == wl->child) { |
| 426 | wl->child = 0; |
Philipp Brüschweiler | 7a3ec74 | 2013-03-10 15:14:01 +0100 | [diff] [blame] | 427 | if (WIFEXITED(status)) |
| 428 | ret = WEXITSTATUS(status); |
| 429 | else if (WIFSIGNALED(status)) |
| 430 | /* |
| 431 | * If weston dies because of signal N, we |
| 432 | * return 10+N. This is distinct from |
| 433 | * weston-launch dying because of a signal |
| 434 | * (128+N). |
| 435 | */ |
| 436 | ret = 10 + WTERMSIG(status); |
| 437 | else |
| 438 | ret = 0; |
| 439 | quit(wl, ret); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 440 | } |
| 441 | break; |
| 442 | case SIGTERM: |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 443 | case SIGINT: |
| 444 | if (wl->child) |
Kristian Høgsberg | 1a81abb | 2013-06-17 15:23:20 -0400 | [diff] [blame] | 445 | kill(wl->child, sig.ssi_signo); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 446 | break; |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 447 | case SIGUSR1: |
| 448 | send_reply(wl, WESTON_LAUNCHER_DEACTIVATE); |
| 449 | drmDropMaster(wl->drm_fd); |
| 450 | ioctl(wl->tty, VT_RELDISP, 1); |
| 451 | break; |
| 452 | case SIGUSR2: |
| 453 | ioctl(wl->tty, VT_RELDISP, VT_ACKACQ); |
| 454 | drmSetMaster(wl->drm_fd); |
| 455 | send_reply(wl, WESTON_LAUNCHER_ACTIVATE); |
| 456 | break; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 457 | default: |
| 458 | return -1; |
| 459 | } |
| 460 | |
| 461 | return 0; |
| 462 | } |
| 463 | |
| 464 | static int |
| 465 | setup_tty(struct weston_launch *wl, const char *tty) |
| 466 | { |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 467 | struct termios raw_attributes; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 468 | struct stat buf; |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 469 | struct vt_mode mode = { 0 }; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 470 | char *t; |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 471 | int ret; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 472 | |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 473 | if (!wl->new_user) { |
| 474 | wl->tty = STDIN_FILENO; |
| 475 | } else if (tty) { |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 476 | t = ttyname(STDIN_FILENO); |
| 477 | if (t && strcmp(t, tty) == 0) |
| 478 | wl->tty = STDIN_FILENO; |
| 479 | else |
| 480 | wl->tty = open(tty, O_RDWR | O_NOCTTY); |
| 481 | } else { |
| 482 | int tty0 = open("/dev/tty0", O_WRONLY | O_CLOEXEC); |
| 483 | char filename[16]; |
| 484 | |
| 485 | if (tty0 < 0) |
Tiago Vignatti | 314db6e | 2012-04-17 20:10:11 +0300 | [diff] [blame] | 486 | error(1, errno, "could not open tty0"); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 487 | |
| 488 | if (ioctl(tty0, VT_OPENQRY, &wl->ttynr) < 0 || wl->ttynr == -1) |
| 489 | error(1, errno, "failed to find non-opened console"); |
| 490 | |
| 491 | snprintf(filename, sizeof filename, "/dev/tty%d", wl->ttynr); |
| 492 | wl->tty = open(filename, O_RDWR | O_NOCTTY); |
| 493 | close(tty0); |
| 494 | } |
| 495 | |
| 496 | if (wl->tty < 0) |
| 497 | error(1, errno, "failed to open tty"); |
| 498 | |
| 499 | if (tty) { |
| 500 | if (fstat(wl->tty, &buf) < 0) |
| 501 | error(1, errno, "stat %s failed", tty); |
| 502 | |
| 503 | if (major(buf.st_rdev) != TTY_MAJOR) |
| 504 | error(1, 0, "invalid tty device: %s", tty); |
| 505 | |
| 506 | wl->ttynr = minor(buf.st_rdev); |
| 507 | } |
| 508 | |
Kristian Høgsberg | 81b4963 | 2013-09-17 22:43:22 -0700 | [diff] [blame] | 509 | if (tcgetattr(wl->tty, &wl->terminal_attributes) < 0) |
| 510 | error(1, errno, "could not get terminal attributes: %m\n"); |
| 511 | |
| 512 | /* Ignore control characters and disable echo */ |
| 513 | raw_attributes = wl->terminal_attributes; |
| 514 | cfmakeraw(&raw_attributes); |
| 515 | |
| 516 | /* Fix up line endings to be normal (cfmakeraw hoses them) */ |
| 517 | raw_attributes.c_oflag |= OPOST | OCRNL; |
| 518 | |
| 519 | if (tcsetattr(wl->tty, TCSANOW, &raw_attributes) < 0) |
| 520 | error(1, errno, "could not put terminal into raw mode: %m\n"); |
| 521 | |
| 522 | ioctl(wl->tty, KDGKBMODE, &wl->kb_mode); |
| 523 | ret = ioctl(wl->tty, KDSKBMODE, K_OFF); |
| 524 | if (ret) |
| 525 | ret = ioctl(wl->tty, KDSKBMODE, K_RAW); |
| 526 | if (ret) |
| 527 | error(1, errno, "failed to set keyboard mode on tty: %m\n"); |
| 528 | |
| 529 | ret = ioctl(wl->tty, KDSETMODE, KD_GRAPHICS); |
| 530 | if (ret) |
| 531 | error(1, errno, "failed to set KD_GRAPHICS mode on tty: %m\n"); |
| 532 | |
Kristian Høgsberg | 1eb482d | 2013-09-17 22:15:37 -0700 | [diff] [blame] | 533 | mode.mode = VT_PROCESS; |
| 534 | mode.relsig = SIGUSR1; |
| 535 | mode.acqsig = SIGUSR2; |
| 536 | if (ioctl(wl->tty, VT_SETMODE, &mode) < 0) |
| 537 | error(1, errno, "failed to take control of vt handling\n"); |
| 538 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 539 | return 0; |
| 540 | } |
| 541 | |
| 542 | static void |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 543 | setup_session(struct weston_launch *wl) |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 544 | { |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 545 | char **env; |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 546 | char *term; |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 547 | int i; |
| 548 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 549 | if (wl->tty != STDIN_FILENO) { |
| 550 | if (setsid() < 0) |
| 551 | error(1, errno, "setsid failed"); |
| 552 | if (ioctl(wl->tty, TIOCSCTTY, 0) < 0) |
| 553 | error(1, errno, "TIOCSCTTY failed - tty is in use"); |
| 554 | } |
| 555 | |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 556 | term = getenv("TERM"); |
| 557 | clearenv(); |
Rob Bradford | 7ac9f73 | 2013-08-09 11:30:38 +0100 | [diff] [blame] | 558 | if (term) |
| 559 | setenv("TERM", term, 1); |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 560 | setenv("USER", wl->pw->pw_name, 1); |
| 561 | setenv("LOGNAME", wl->pw->pw_name, 1); |
| 562 | setenv("HOME", wl->pw->pw_dir, 1); |
| 563 | setenv("SHELL", wl->pw->pw_shell, 1); |
| 564 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 565 | env = pam_getenvlist(wl->ph); |
| 566 | if (env) { |
| 567 | for (i = 0; env[i]; ++i) { |
| 568 | if (putenv(env[i]) < 0) |
| 569 | error(0, 0, "putenv %s failed", env[i]); |
| 570 | } |
| 571 | free(env); |
| 572 | } |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | static void |
Peter Hutterer | 34be060 | 2013-08-06 12:10:09 +1000 | [diff] [blame] | 576 | drop_privileges(struct weston_launch *wl) |
| 577 | { |
| 578 | if (setgid(wl->pw->pw_gid) < 0 || |
| 579 | #ifdef HAVE_INITGROUPS |
| 580 | initgroups(wl->pw->pw_name, wl->pw->pw_gid) < 0 || |
| 581 | #endif |
| 582 | setuid(wl->pw->pw_uid) < 0) |
| 583 | error(1, errno, "dropping privileges failed"); |
| 584 | } |
| 585 | |
| 586 | static void |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 587 | launch_compositor(struct weston_launch *wl, int argc, char *argv[]) |
| 588 | { |
| 589 | char *child_argv[MAX_ARGV_SIZE]; |
Eduardo Lima | d0357bb | 2013-07-30 10:43:41 -0700 | [diff] [blame] | 590 | sigset_t mask; |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 591 | int i; |
| 592 | |
| 593 | if (wl->verbose) |
| 594 | printf("weston-launch: spawned weston with pid: %d\n", getpid()); |
| 595 | if (wl->new_user) |
| 596 | setup_session(wl); |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 597 | |
Peter Hutterer | 34be060 | 2013-08-06 12:10:09 +1000 | [diff] [blame] | 598 | drop_privileges(wl); |
| 599 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 600 | if (wl->tty != STDIN_FILENO) |
| 601 | setenv_fd("WESTON_TTY_FD", wl->tty); |
| 602 | |
| 603 | setenv_fd("WESTON_LAUNCHER_SOCK", wl->sock[1]); |
| 604 | |
| 605 | unsetenv("DISPLAY"); |
| 606 | |
Kristian Høgsberg | 73c60ab | 2013-07-30 09:45:04 -0700 | [diff] [blame] | 607 | /* Do not give our signal mask to the new process. */ |
| 608 | sigemptyset(&mask); |
| 609 | sigaddset(&mask, SIGTERM); |
| 610 | sigaddset(&mask, SIGCHLD); |
| 611 | sigaddset(&mask, SIGINT); |
| 612 | sigprocmask(SIG_UNBLOCK, &mask, NULL); |
| 613 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 614 | child_argv[0] = wl->pw->pw_shell; |
| 615 | child_argv[1] = "-l"; |
| 616 | child_argv[2] = "-c"; |
| 617 | child_argv[3] = BINDIR "/weston \"$@\""; |
| 618 | child_argv[4] = "weston"; |
| 619 | for (i = 0; i < argc; ++i) |
| 620 | child_argv[5 + i] = argv[i]; |
| 621 | child_argv[5 + i] = NULL; |
| 622 | |
| 623 | execv(child_argv[0], child_argv); |
| 624 | error(1, errno, "exec failed"); |
| 625 | } |
| 626 | |
| 627 | static void |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 628 | help(const char *name) |
| 629 | { |
| 630 | fprintf(stderr, "Usage: %s [args...] [-- [weston args..]]\n", name); |
| 631 | fprintf(stderr, " -u, --user Start session as specified username\n"); |
Tiago Vignatti | 314db6e | 2012-04-17 20:10:11 +0300 | [diff] [blame] | 632 | fprintf(stderr, " -t, --tty Start session on alternative tty\n"); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 633 | fprintf(stderr, " -v, --verbose Be verbose\n"); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 634 | fprintf(stderr, " -h, --help Display this help message\n"); |
| 635 | } |
| 636 | |
| 637 | int |
| 638 | main(int argc, char *argv[]) |
| 639 | { |
| 640 | struct weston_launch wl; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 641 | int i, c; |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 642 | char *tty = NULL; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 643 | struct option opts[] = { |
| 644 | { "user", required_argument, NULL, 'u' }, |
| 645 | { "tty", required_argument, NULL, 't' }, |
| 646 | { "verbose", no_argument, NULL, 'v' }, |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 647 | { "help", no_argument, NULL, 'h' }, |
| 648 | { 0, 0, NULL, 0 } |
| 649 | }; |
| 650 | |
| 651 | memset(&wl, 0, sizeof wl); |
| 652 | |
Kristian Høgsberg | ab49994 | 2013-07-19 21:26:24 -0700 | [diff] [blame] | 653 | while ((c = getopt_long(argc, argv, "u:t::vh", opts, &i)) != -1) { |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 654 | switch (c) { |
| 655 | case 'u': |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 656 | wl.new_user = optarg; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 657 | if (getuid() != 0) |
| 658 | error(1, 0, "Permission denied. -u allowed for root only"); |
| 659 | break; |
| 660 | case 't': |
| 661 | tty = optarg; |
| 662 | break; |
| 663 | case 'v': |
| 664 | wl.verbose = 1; |
| 665 | break; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 666 | case 'h': |
Scott Moreau | cc9acfc | 2013-01-21 23:40:59 -0700 | [diff] [blame] | 667 | help("weston-launch"); |
Siddharth Heroor | d6be88b | 2013-03-12 02:36:52 +0530 | [diff] [blame] | 668 | exit(EXIT_FAILURE); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 669 | } |
| 670 | } |
| 671 | |
Ander Conselvan de Oliveira | 9bdfc48 | 2013-05-22 22:55:33 +0300 | [diff] [blame] | 672 | if ((argc - optind) > (MAX_ARGV_SIZE - 6)) |
Quentin Glidic | ff32309 | 2013-05-17 16:20:37 +0200 | [diff] [blame] | 673 | error(1, E2BIG, "Too many arguments to pass to weston"); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 674 | |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 675 | if (wl.new_user) |
| 676 | wl.pw = getpwnam(wl.new_user); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 677 | else |
| 678 | wl.pw = getpwuid(getuid()); |
| 679 | if (wl.pw == NULL) |
| 680 | error(1, errno, "failed to get username"); |
| 681 | |
| 682 | if (!weston_launch_allowed(&wl)) |
Tiago Vignatti | 314db6e | 2012-04-17 20:10:11 +0300 | [diff] [blame] | 683 | error(1, 0, "Permission denied. You should either:\n" |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 684 | #ifdef HAVE_SYSTEMD_LOGIN |
| 685 | " - run from an active and local (systemd) session.\n" |
| 686 | #else |
| 687 | " - enable systemd session support for weston-launch.\n" |
| 688 | #endif |
Tiago Vignatti | 314db6e | 2012-04-17 20:10:11 +0300 | [diff] [blame] | 689 | " - or add yourself to the 'weston-launch' group."); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 690 | |
| 691 | if (setup_tty(&wl, tty) < 0) |
Siddharth Heroor | d6be88b | 2013-03-12 02:36:52 +0530 | [diff] [blame] | 692 | exit(EXIT_FAILURE); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 693 | |
Kristian Høgsberg | 636156d | 2013-07-22 10:35:47 -0700 | [diff] [blame] | 694 | if (wl.new_user && setup_pam(&wl) < 0) |
Siddharth Heroor | d6be88b | 2013-03-12 02:36:52 +0530 | [diff] [blame] | 695 | exit(EXIT_FAILURE); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 696 | |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 697 | if (setup_launcher_socket(&wl) < 0) |
Siddharth Heroor | d6be88b | 2013-03-12 02:36:52 +0530 | [diff] [blame] | 698 | exit(EXIT_FAILURE); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 699 | |
| 700 | if (setup_signals(&wl) < 0) |
Siddharth Heroor | d6be88b | 2013-03-12 02:36:52 +0530 | [diff] [blame] | 701 | exit(EXIT_FAILURE); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 702 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 703 | wl.child = fork(); |
| 704 | if (wl.child == -1) { |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 705 | error(1, errno, "fork failed"); |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 706 | exit(EXIT_FAILURE); |
| 707 | } |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 708 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 709 | if (wl.child == 0) |
| 710 | launch_compositor(&wl, argc - optind, argv + optind); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 711 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 712 | close(wl.sock[1]); |
| 713 | if (wl.tty != STDIN_FILENO) |
| 714 | close(wl.tty); |
Quentin Glidic | 735302e | 2013-06-19 15:27:11 +0200 | [diff] [blame] | 715 | |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 716 | while (1) { |
Kristian Høgsberg | f280770 | 2013-07-23 11:43:03 -0700 | [diff] [blame] | 717 | struct pollfd fds[2]; |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 718 | int n; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 719 | |
Kristian Høgsberg | f280770 | 2013-07-23 11:43:03 -0700 | [diff] [blame] | 720 | fds[0].fd = wl.sock[0]; |
| 721 | fds[0].events = POLLIN; |
| 722 | fds[1].fd = wl.signalfd; |
| 723 | fds[1].events = POLLIN; |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 724 | |
Kristian Høgsberg | f280770 | 2013-07-23 11:43:03 -0700 | [diff] [blame] | 725 | n = poll(fds, 2, -1); |
| 726 | if (n < 0) |
| 727 | error(0, errno, "poll failed"); |
| 728 | if (fds[0].revents & POLLIN) |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 729 | handle_socket_msg(&wl); |
Kristian Høgsberg | f280770 | 2013-07-23 11:43:03 -0700 | [diff] [blame] | 730 | if (fds[1].revents) |
Kristian Høgsberg | ca70f2f | 2013-07-19 21:25:20 -0700 | [diff] [blame] | 731 | handle_signal(&wl); |
Benjamin Franzke | bfeda13 | 2012-01-30 14:04:04 +0100 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | return 0; |
| 735 | } |