]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix os.set_inheritable() on Android
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 19 May 2016 14:46:18 +0000 (16:46 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 19 May 2016 14:46:18 +0000 (16:46 +0200)
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.

Misc/ACKS
Misc/NEWS
Python/fileutils.c

index dda42cad4ef04f1de93d59968df8f42e178a9021..810036e519d939388abc0ccdb0cd2b860de7094d 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -110,6 +110,7 @@ Neal Becker
 Robin Becker
 Torsten Becker
 Bill Bedford
+Michał Bednarski
 Ian Beer
 Stefan Behnel
 Reimer Behrends
index 8d91d7882a9afa33b7f07a747743f94d77f6b13b..fcfcd4f5514ea09d819184367b4123229dbfad60 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -123,6 +123,10 @@ Core and Builtins
 Library
 -------
 
+- 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.
+
 - Issue #27014: Fix infinite recursion using typing.py.  Thanks to Kalle Tuure!
 
 - Issue #14132: Fix urllib.request redirect handling when the target only has
index 06d632a28e6236ba557289246a5e2a894184c807..8987ce5a0e8c130da225d00d98f6558dd3aa3796 100644 (file)
@@ -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 */