mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-07-10 00:06:08 -04:00
security_context_v1: set CLOEXEC for client FDs
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/work_items/3949
(cherry picked from commit 327f000532)
This commit is contained in:
parent
eb02e65df4
commit
d9cd649551
7 changed files with 39 additions and 19 deletions
22
util/fd.c
Normal file
22
util/fd.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <fcntl.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "util/fd.h"
|
||||
|
||||
bool set_cloexec(int fd, bool cloexec) {
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
if (flags == -1) {
|
||||
wlr_log_errno(WLR_ERROR, "fcntl failed");
|
||||
return false;
|
||||
}
|
||||
if (cloexec) {
|
||||
flags = flags | FD_CLOEXEC;
|
||||
} else {
|
||||
flags = flags & ~FD_CLOEXEC;
|
||||
}
|
||||
if (fcntl(fd, F_SETFD, flags) == -1) {
|
||||
wlr_log_errno(WLR_ERROR, "fcntl failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ wlr_files += files(
|
|||
'array.c',
|
||||
'box.c',
|
||||
'env.c',
|
||||
'fd.c',
|
||||
'global.c',
|
||||
'log.c',
|
||||
'matrix.c',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue