diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2016-05-19 16:46:18 +0200 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2016-05-19 16:46:18 +0200 |
| commit | 8d71071ea6f52e02e6623315e7dc40da8eb35728 (patch) | |
| tree | 941b87c9b9b2dc58c782fef9390893a62234e2bf /Python/fileutils.c | |
| parent | f1c7728faffcf3537d65291abb940de8a765f57b (diff) | |
| download | cpython-8d71071ea6f52e02e6623315e7dc40da8eb35728.tar.gz | |
Fix os.set_inheritable() on Android
Issue #27057: Fix os.set_inheritable() on Android, ioctl() is blocked by
SELinux and fails with EACCESS. The function now falls back to fcntl().
Patch written by Micha? Bednarski.
Diffstat (limited to 'Python/fileutils.c')
| -rw-r--r-- | Python/fileutils.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c index 06d632a28e..8987ce5a0e 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -856,7 +856,7 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works) return 0; } - if (errno != ENOTTY) { + if (errno != ENOTTY && errno != EACCES) { if (raise) PyErr_SetFromErrno(PyExc_OSError); return -1; @@ -865,7 +865,12 @@ set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works) /* Issue #22258: Here, ENOTTY means "Inappropriate ioctl for device". The ioctl is declared but not supported by the kernel. Remember that ioctl() doesn't work. It is the case on - Illumos-based OS for example. */ + Illumos-based OS for example. + + Issue #27057: When SELinux policy disallows ioctl it will fail + with EACCES. While FIOCLEX is safe operation it may be + unavailable because ioctl was denied altogether. + This can be the case on Android. */ ioctl_works = 0; } /* fallback to fcntl() if ioctl() does not work */ |
