modesetting: Pass O_CLOEXEC when opening a DRM device

We don't want DRM file descriptors to leak to child processes.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
(cherry picked from commit 315c63c41d)
This commit is contained in:
Michel Dänzer 2018-05-18 11:23:01 +02:00 committed by Adam Jackson
parent c3a06e330b
commit a9a17581ce

View File

@ -200,12 +200,12 @@ open_hw(const char *dev)
int fd;
if (dev)
fd = open(dev, O_RDWR, 0);
fd = open(dev, O_RDWR | O_CLOEXEC, 0);
else {
dev = getenv("KMSDEVICE");
if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
if ((NULL == dev) || ((fd = open(dev, O_RDWR | O_CLOEXEC, 0)) == -1)) {
dev = "/dev/dri/card0";
fd = open(dev, O_RDWR, 0);
fd = open(dev, O_RDWR | O_CLOEXEC, 0);
}
}
if (fd == -1)