diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-03-25 13:13:44 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-03-25 13:13:44 -0700 |
commit | 20b6672a6d7d5531ff1db1e5af762c052bf883bf (patch) | |
tree | 0583025a2025a3729544ae9d2f4ea0e25bf1361c /src | |
parent | 8f8a0a4f798bddcf402fecb0ac60e18f027ff276 (diff) |
Set close-on-exec when opening files
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/maprules.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/maprules.c b/src/maprules.c index 20470f9..bd83f71 100644 --- a/src/maprules.c +++ b/src/maprules.c @@ -51,6 +51,11 @@ #include "XKBfileInt.h" #include "XKBrules.h" +#ifdef O_CLOEXEC +#define FOPEN_CLOEXEC "e" +#else +#define FOPEN_CLOEXEC "" +#endif #ifdef DEBUG #define PR_DEBUG(s) fprintf(stderr,s) @@ -1040,10 +1045,10 @@ XkbRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules) strcpy(buf, base); } - file = fopen(buf, "r"); + file = fopen(buf, "r" FOPEN_CLOEXEC); if ((!file) && (locale)) { /* fallback if locale was specified */ strcpy(buf, base); - file = fopen(buf, "r"); + file = fopen(buf, "r" FOPEN_CLOEXEC); } if (!file) return False; @@ -1245,11 +1250,11 @@ XkbRF_LoadDescriptionsByName(char *base, char *locale, XkbRF_RulesPtr rules) snprintf(buf, sizeof(buf), "%s.lst", base); } - file = fopen(buf, "r"); + file = fopen(buf, "r" FOPEN_CLOEXEC); if ((!file) && (locale)) { /* fallback if locale was specified */ snprintf(buf, sizeof(buf), "%s.lst", base); - file = fopen(buf, "r"); + file = fopen(buf, "r" FOPEN_CLOEXEC); } if (!file) return False; |