weston-launch: Stat the path before opening it

This commit is contained in:
Jasper St. Pierre 2014-03-11 16:58:18 -04:00
parent 1bb9f1e333
commit 81025e37ea

View File

@ -331,6 +331,13 @@ handle_open(struct weston_launch *wl, struct msghdr *msg, ssize_t len)
goto err0;
}
if (major(s.st_rdev) != INPUT_MAJOR) {
fprintf(stderr, "Device %s is not an input device\n",
message->path);
reply.ret = -EPERM;
goto err0;
}
fd = open(message->path, message->flags);
if (fd < 0) {
fprintf(stderr, "Error opening device %s: %m\n",
@ -339,15 +346,6 @@ handle_open(struct weston_launch *wl, struct msghdr *msg, ssize_t len)
goto err0;
}
if (major(s.st_rdev) != INPUT_MAJOR) {
close(fd);
fd = -1;
fprintf(stderr, "Device %s is not an input device\n",
message->path);
reply.ret = -EPERM;
goto err0;
}
err0:
memset(&nmsg, 0, sizeof nmsg);
nmsg.msg_iov = &iov;