diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-03-25 12:44:39 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-03-25 12:44:39 -0700 |
commit | df1bf4fe528a5a9eef420f78efb225e4696ac467 (patch) | |
tree | a85763c85e8449af7cb9211a01c54dbf2b1a4268 /AuLock.c | |
parent | 41c43bdf85c91293af80b0b843947380b9b3378c (diff) |
Set close-on-exec when opening files
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'AuLock.c')
-rw-r--r-- | AuLock.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -41,6 +41,10 @@ in this Software without prior written authorization from The Open Group. # define link rename #endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + int XauLockAuth ( _Xconst char *file_name, @@ -71,7 +75,8 @@ long dead) while (retries > 0) { if (creat_fd == -1) { - creat_fd = open (creat_name, O_WRONLY | O_CREAT | O_EXCL, 0600); + creat_fd = open (creat_name, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, + 0600); if (creat_fd == -1) { if (errno != EACCES && errno != EEXIST) return LOCK_ERROR; |