aboutsummaryrefslogtreecommitdiff
path: root/backend/session
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-02-01 09:28:36 +0100
committerGitHub <noreply@github.com>2019-02-01 09:28:36 +0100
commitd2f0efd3f5ecf9c691146e3eb66577f0ddb0bdeb (patch)
treeb8ac8f6e1166270abab191177bfa5fe2165067a1 /backend/session
parent2d65d49c5c04c350fa810e96f9c11d1aa3acfa28 (diff)
parent22faddde9e0c2c700c0692ac60d35adc43302261 (diff)
Merge pull request #1522 from emersion/logind-no-dup-leak
backend/session/logind: dup FD with CLOEXEC
Diffstat (limited to 'backend/session')
-rw-r--r--backend/session/logind.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/backend/session/logind.c b/backend/session/logind.c
index 9a1383ce..5bde16c2 100644
--- a/backend/session/logind.c
+++ b/backend/session/logind.c
@@ -294,7 +294,8 @@ error:
return 0;
}
-static int resume_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_error) {
+static int resume_device(sd_bus_message *msg, void *userdata,
+ sd_bus_error *ret_error) {
struct logind_session *session = userdata;
int ret;
@@ -309,7 +310,12 @@ static int resume_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_
if (major == DRM_MAJOR) {
struct wlr_device *dev = find_device(&session->base, makedev(major, minor));
- dup2(fd, dev->fd);
+
+ close(dev->fd);
+ if (fcntl(fd, F_DUPFD_CLOEXEC, dev->fd) < 0) {
+ wlr_log_errno(WLR_ERROR, "Failed to duplicate file descriptor");
+ goto error;
+ }
if (!session->base.active) {
session->base.active = true;