diff options
Diffstat (limited to 'src/lib/eina')
-rw-r--r-- | src/lib/eina/eina_file.c | 21 | ||||
-rw-r--r-- | src/lib/eina/eina_mmap.c | 6 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c index cc53f65cce..068aa12e14 100644 --- a/src/lib/eina/eina_file.c +++ b/src/lib/eina/eina_file.c | |||
@@ -802,19 +802,28 @@ eina_file_open(const char *path, Eina_Bool shared) | |||
802 | if (!filename) return NULL; | 802 | if (!filename) return NULL; |
803 | 803 | ||
804 | if (shared) | 804 | if (shared) |
805 | { | ||
805 | #ifdef HAVE_SHM_OPEN | 806 | #ifdef HAVE_SHM_OPEN |
806 | fd = shm_open(filename, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); | 807 | fd = shm_open(filename, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); |
808 | if ((fd != -1) && (!eina_file_close_on_exec(fd, EINA_TRUE))) | ||
809 | goto on_error; | ||
807 | #else | 810 | #else |
808 | goto on_error; | 811 | goto on_error; |
809 | #endif | 812 | #endif |
813 | } | ||
810 | else | 814 | else |
811 | fd = open(filename, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); | 815 | { |
816 | #ifdef HAVE_OPEN_CLOEXEC | ||
817 | fd = open(filename, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO | O_CLOEXEC); | ||
818 | #else | ||
819 | fd = open(filename, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO); | ||
820 | if ((fd != -1) && (!eina_file_close_on_exec(fd, EINA_TRUE))) | ||
821 | goto on_error; | ||
822 | #endif | ||
823 | } | ||
812 | 824 | ||
813 | if (fd < 0) goto on_error; | 825 | if (fd < 0) goto on_error; |
814 | 826 | ||
815 | if (!eina_file_close_on_exec(fd, EINA_TRUE)) | ||
816 | goto on_error; | ||
817 | |||
818 | if (fstat(fd, &file_stat)) | 827 | if (fstat(fd, &file_stat)) |
819 | goto on_error; | 828 | goto on_error; |
820 | 829 | ||
diff --git a/src/lib/eina/eina_mmap.c b/src/lib/eina/eina_mmap.c index 11d8804759..23386dac1d 100644 --- a/src/lib/eina/eina_mmap.c +++ b/src/lib/eina/eina_mmap.c | |||
@@ -198,10 +198,16 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled) | |||
198 | /* no zero page device - open it */ | 198 | /* no zero page device - open it */ |
199 | if (_eina_mmap_zero_fd < 0) | 199 | if (_eina_mmap_zero_fd < 0) |
200 | { | 200 | { |
201 | #ifdef HAVE_OPEN_CLOEXEC | ||
202 | _eina_mmap_zero_fd = open("/dev/zero", O_RDWR | O_CLOEXEC); | ||
203 | /* if we don;'t have one - fail to set up mmap safety */ | ||
204 | if (_eina_mmap_zero_fd < 0) return EINA_FALSE; | ||
205 | #else | ||
201 | _eina_mmap_zero_fd = open("/dev/zero", O_RDWR); | 206 | _eina_mmap_zero_fd = open("/dev/zero", O_RDWR); |
202 | /* if we don;'t have one - fail to set up mmap safety */ | 207 | /* if we don;'t have one - fail to set up mmap safety */ |
203 | if (_eina_mmap_zero_fd < 0) return EINA_FALSE; | 208 | if (_eina_mmap_zero_fd < 0) return EINA_FALSE; |
204 | eina_file_close_on_exec(_eina_mmap_zero_fd, EINA_TRUE); | 209 | eina_file_close_on_exec(_eina_mmap_zero_fd, EINA_TRUE); |
210 | #endif | ||
205 | } | 211 | } |
206 | /* set up signal handler for SIGBUS */ | 212 | /* set up signal handler for SIGBUS */ |
207 | sa.sa_sigaction = _eina_mmap_safe_sigbus; | 213 | sa.sa_sigaction = _eina_mmap_safe_sigbus; |