weston-launch: Stat the path before opening it
This commit is contained in:
parent
1bb9f1e333
commit
81025e37ea
1 changed files with 7 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue