# HG changeset patch # User Emmanuel Gil Peyrot # Date 1422831747 -3600 # Mon Feb 02 00:02:27 2015 +0100 # Node ID 8bcab0bb9856c8090e7d08ce7b3614ca18b16d5b # Parent 582aabcce2fd2d05e9b880dad3507da0c8735955 Issue #22623: Add missing guards for some POSIX functions, and don’t harcode their support. diff -r 582aabcce2fd -r 8bcab0bb9856 Modules/clinic/pwdmodule.c.h --- a/Modules/clinic/pwdmodule.c.h Sun Feb 01 19:47:25 2015 +0100 +++ b/Modules/clinic/pwdmodule.c.h Mon Feb 02 00:02:27 2015 +0100 @@ -2,6 +2,8 @@ preserve [clinic start generated code]*/ +#if defined(HAVE_GETPWUID) + PyDoc_STRVAR(pwd_getpwuid__doc__, "getpwuid($module, uidobj, /)\n" "--\n" @@ -13,6 +15,14 @@ #define PWD_GETPWUID_METHODDEF \ {"getpwuid", (PyCFunction)pwd_getpwuid, METH_O, pwd_getpwuid__doc__}, +#endif /* defined(HAVE_GETPWUID) */ + +#ifndef PWD_GETPWUID_METHODDEF + #define PWD_GETPWUID_METHODDEF +#endif /* !defined(PWD_GETPWUID_METHODDEF) */ + +#if defined(HAVE_GETPWNAM) + PyDoc_STRVAR(pwd_getpwnam__doc__, "getpwnam($module, arg, /)\n" "--\n" @@ -43,6 +53,12 @@ return return_value; } +#endif /* defined(HAVE_GETPWNAM) */ + +#ifndef PWD_GETPWNAM_METHODDEF + #define PWD_GETPWNAM_METHODDEF +#endif /* !defined(PWD_GETPWNAM_METHODDEF) */ + #if defined(HAVE_GETPWENT) PyDoc_STRVAR(pwd_getpwall__doc__, @@ -70,4 +86,4 @@ #ifndef PWD_GETPWALL_METHODDEF #define PWD_GETPWALL_METHODDEF #endif /* !defined(PWD_GETPWALL_METHODDEF) */ -/*[clinic end generated code: output=2e23f920020a750a input=a9049054013a1b77]*/ +/*[clinic end generated code: output=75f01430a2e6c4fb input=a9049054013a1b77]*/ diff -r 582aabcce2fd -r 8bcab0bb9856 Modules/faulthandler.c --- a/Modules/faulthandler.c Sun Feb 01 19:47:25 2015 +0100 +++ b/Modules/faulthandler.c Mon Feb 02 00:02:27 2015 +0100 @@ -821,7 +821,7 @@ SetErrorMode(mode | SEM_NOGPFAULTERRORBOX); #endif -#ifdef HAVE_SYS_RESOURCE_H +#ifdef HAVE_GETRLIMIT struct rlimit rl; /* Disable creation of core dump */ diff -r 582aabcce2fd -r 8bcab0bb9856 Modules/posixmodule.c --- a/Modules/posixmodule.c Sun Feb 01 19:47:25 2015 +0100 +++ b/Modules/posixmodule.c Mon Feb 02 00:02:27 2015 +0100 @@ -154,23 +154,9 @@ #define HAVE_FSYNC 1 #define fsync _commit #else -/* Unix functions that the configure script doesn't check for */ -#define HAVE_EXECV 1 -#define HAVE_FORK 1 #if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */ #define HAVE_FORK1 1 #endif -#define HAVE_GETEGID 1 -#define HAVE_GETEUID 1 -#define HAVE_GETGID 1 -#define HAVE_GETPPID 1 -#define HAVE_GETUID 1 -#define HAVE_KILL 1 -#define HAVE_OPENDIR 1 -#define HAVE_PIPE 1 -#define HAVE_SYSTEM 1 -#define HAVE_WAIT 1 -#define HAVE_TTYNAME 1 #endif /* _MSC_VER */ #endif /* ! __WATCOMC__ || __QNX__ */ @@ -2820,6 +2806,7 @@ } +#ifdef HAVE_ACCESS /*[clinic input] os.access -> bool @@ -2990,6 +2977,7 @@ return return_value; } +#endif /* HAVE_ACCESS */ #ifndef F_OK #define F_OK 0 @@ -3063,7 +3051,7 @@ posix_error(); return ret; } -#endif +#endif /* HAVE_TTYNAME */ #ifdef HAVE_CTERMID /*[clinic input] @@ -5720,6 +5708,7 @@ #endif /* HAVE_SYSTEM */ +#ifdef HAVE_UMASK /*[clinic input] os.umask @@ -5766,6 +5755,7 @@ return posix_error(); return PyLong_FromLong((long)i); } +#endif /* HAVE_UMASK */ #ifdef MS_WINDOWS @@ -7718,6 +7708,7 @@ #endif /* HAVE_SCHED_RR_GET_INTERVAL */ +#ifdef HAVE_SCHED_YIELD /*[clinic input] os.sched_yield @@ -7750,6 +7741,7 @@ return posix_error(); Py_RETURN_NONE; } +#endif /* HAVE_SCHED_YIELD */ #ifdef HAVE_SCHED_SETAFFINITY /* The minimum number of CPUs allocated in a cpu_set_t */ @@ -16445,6 +16437,10 @@ dump buffer [clinic start generated code]*/ +#ifndef OS_ACCESS_METHODDEF + #define OS_ACCESS_METHODDEF +#endif /* !defined(OS_ACCESS_METHODDEF) */ + #ifndef OS_TTYNAME_METHODDEF #define OS_TTYNAME_METHODDEF #endif /* !defined(OS_TTYNAME_METHODDEF) */ @@ -16533,6 +16529,10 @@ #define OS_SYSTEM_METHODDEF #endif /* !defined(OS_SYSTEM_METHODDEF) */ +#ifndef OS_UMASK_METHODDEF + #define OS_UMASK_METHODDEF +#endif /* !defined(OS_UMASK_METHODDEF) */ + #ifndef OS_UNAME_METHODDEF #define OS_UNAME_METHODDEF #endif /* !defined(OS_UNAME_METHODDEF) */ @@ -16920,7 +16920,7 @@ #ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF #define OS_SET_HANDLE_INHERITABLE_METHODDEF #endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ -/*[clinic end generated code: output=52a6140b0b052ce6 input=524ce2e021e4eba6]*/ +/*[clinic end generated code: output=4c739e611e983acb input=524ce2e021e4eba6]*/ static PyMethodDef posix_methods[] = { diff -r 582aabcce2fd -r 8bcab0bb9856 Modules/pwdmodule.c --- a/Modules/pwdmodule.c Sun Feb 01 19:47:25 2015 +0100 +++ b/Modules/pwdmodule.c Mon Feb 02 00:02:27 2015 +0100 @@ -94,6 +94,7 @@ return v; } +#ifdef HAVE_GETPWUID /*[clinic input] pwd.getpwuid @@ -129,7 +130,9 @@ } return mkpwent(p); } +#endif /* HAVE_GETPWUID */ +#ifdef HAVE_GETPWNAM /*[clinic input] pwd.getpwnam @@ -163,6 +166,7 @@ Py_DECREF(bytes); return retval; } +#endif /* HAVE_GETPWNAM */ #ifdef HAVE_GETPWENT /*[clinic input] @@ -195,14 +199,12 @@ endpwent(); return d; } -#endif +#endif /* HAVE_GETPWENT */ static PyMethodDef pwd_methods[] = { PWD_GETPWUID_METHODDEF PWD_GETPWNAM_METHODDEF -#ifdef HAVE_GETPWENT PWD_GETPWALL_METHODDEF -#endif {NULL, NULL} /* sentinel */ }; diff -r 582aabcce2fd -r 8bcab0bb9856 configure --- a/configure Sun Feb 01 19:47:25 2015 +0100 +++ b/configure Mon Feb 02 00:02:27 2015 +0100 @@ -10694,28 +10694,26 @@ fi # checks for library functions -for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ - clock confstr ctermid dup3 execv faccessat fchmod fchmodat fchown fchownat \ - fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \ - futimens futimes gai_strerror getentropy \ - getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \ - getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ - if_nameindex \ - initgroups kill killpg lchmod lchown lockf linkat lstat lutimes mmap \ - memrchr mbrtowc mkdirat mkfifo \ - mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \ - posix_fallocate posix_fadvise pread \ - pthread_init pthread_kill putenv pwrite readlink readlinkat readv realpath renameat \ - select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \ - setgid sethostname \ - setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \ - sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \ - sched_rr_get_interval \ - sigaction sigaltstack siginterrupt sigpending sigrelse \ - sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \ - sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ - truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \ - wcscoll wcsftime wcsxfrm wmemcmp writev _getpty +for ac_func in alarm accept4 access setitimer getitimer \ + bind_textdomain_codeset chown clock confstr ctermid dup3 execv faccessat \ + fchmod fchmodat fchown fchownat fexecve fdopendir fork fpathconf fstatat \ + ftime ftruncate futimesat futimens futimes gai_strerror getentropy geteuid \ + getgid getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \ + getppid getpriority getresuid getresgid getrlimit getpwent getspnam getspent \ + getsid getuid getwd if_nameindex initgroups kill killpg lchmod lchown lockf \ + linkat lstat lutimes mmap memrchr mbrtowc mkdirat mkfifo mkfifoat mknod \ + mknodat mktime mremap nice openat opendir pathconf pause pipe pipe2 plock \ + poll posix_fallocate posix_fadvise pread pthread_init pthread_kill putenv \ + pwrite readlink readlinkat readv realpath renameat select sem_open \ + sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid setgid \ + sethostname setlocale setregid setreuid setresuid setresgid setsid setpgid \ + setpgrp setpriority setuid setvbuf sched_get_priority_max sched_setaffinity \ + sched_setscheduler sched_setparam sched_rr_get_interval sigaction \ + sigaltstack siginterrupt sigpending sigrelse sigtimedwait sigwait \ + sigwaitinfo snprintf strftime strlcpy symlinkat sync sysconf system \ + tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r truncate \ + ttyname umask uname unlinkat unsetenv utimensat utimes wait waitid waitpid \ + wait3 wait4 wcscoll wcsftime wcsxfrm wmemcmp writev _getpty do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff -r 582aabcce2fd -r 8bcab0bb9856 configure.ac --- a/configure.ac Sun Feb 01 19:47:25 2015 +0100 +++ b/configure.ac Mon Feb 02 00:02:27 2015 +0100 @@ -3001,28 +3001,26 @@ fi # checks for library functions -AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ - clock confstr ctermid dup3 execv faccessat fchmod fchmodat fchown fchownat \ - fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \ - futimens futimes gai_strerror getentropy \ - getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \ - getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ - if_nameindex \ - initgroups kill killpg lchmod lchown lockf linkat lstat lutimes mmap \ - memrchr mbrtowc mkdirat mkfifo \ - mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \ - posix_fallocate posix_fadvise pread \ - pthread_init pthread_kill putenv pwrite readlink readlinkat readv realpath renameat \ - select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \ - setgid sethostname \ - setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \ - sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \ - sched_rr_get_interval \ - sigaction sigaltstack siginterrupt sigpending sigrelse \ - sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \ - sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ - truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \ - wcscoll wcsftime wcsxfrm wmemcmp writev _getpty) +AC_CHECK_FUNCS(alarm accept4 access setitimer getitimer \ + bind_textdomain_codeset chown clock confstr ctermid dup3 execv faccessat \ + fchmod fchmodat fchown fchownat fexecve fdopendir fork fpathconf fstatat \ + ftime ftruncate futimesat futimens futimes gai_strerror getentropy geteuid \ + getgid getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \ + getppid getpriority getresuid getresgid getrlimit getpwent getspnam getspent \ + getsid getuid getwd if_nameindex initgroups kill killpg lchmod lchown lockf \ + linkat lstat lutimes mmap memrchr mbrtowc mkdirat mkfifo mkfifoat mknod \ + mknodat mktime mremap nice openat opendir pathconf pause pipe pipe2 plock \ + poll posix_fallocate posix_fadvise pread pthread_init pthread_kill putenv \ + pwrite readlink readlinkat readv realpath renameat select sem_open \ + sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid setgid \ + sethostname setlocale setregid setreuid setresuid setresgid setsid setpgid \ + setpgrp setpriority setuid setvbuf sched_get_priority_max sched_setaffinity \ + sched_setscheduler sched_setparam sched_rr_get_interval sigaction \ + sigaltstack siginterrupt sigpending sigrelse sigtimedwait sigwait \ + sigwaitinfo snprintf strftime strlcpy symlinkat sync sysconf system \ + tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r truncate \ + ttyname umask uname unlinkat unsetenv utimensat utimes wait waitid waitpid \ + wait3 wait4 wcscoll wcsftime wcsxfrm wmemcmp writev _getpty) AC_CHECK_DECL(dirfd, AC_DEFINE(HAVE_DIRFD, 1, diff -r 582aabcce2fd -r 8bcab0bb9856 pyconfig.h.in --- a/pyconfig.h.in Sun Feb 01 19:47:25 2015 +0100 +++ b/pyconfig.h.in Mon Feb 02 00:02:27 2015 +0100 @@ -40,6 +40,9 @@ /* Define to 1 if you have the `accept4' function. */ #undef HAVE_ACCEPT4 +/* Define to 1 if you have the `access' function. */ +#undef HAVE_ACCESS + /* Define to 1 if you have the `acosh' function. */ #undef HAVE_ACOSH @@ -338,6 +341,12 @@ /* Define to 1 if you have the `getentropy' function. */ #undef HAVE_GETENTROPY +/* Define to 1 if you have the `geteuid' function. */ +#undef HAVE_GETEUID + +/* Define to 1 if you have the `getgid' function. */ +#undef HAVE_GETGID + /* Define to 1 if you have the `getgrouplist' function. */ #undef HAVE_GETGROUPLIST @@ -386,6 +395,9 @@ /* Define to 1 if you have the `getpid' function. */ #undef HAVE_GETPID +/* Define to 1 if you have the `getppid' function. */ +#undef HAVE_GETPPID + /* Define to 1 if you have the `getpriority' function. */ #undef HAVE_GETPRIORITY @@ -398,6 +410,9 @@ /* Define to 1 if you have the `getresuid' function. */ #undef HAVE_GETRESUID +/* Define to 1 if you have the `getrlimit' function. */ +#undef HAVE_GETRLIMIT + /* Define to 1 if you have the `getsid' function. */ #undef HAVE_GETSID @@ -410,6 +425,9 @@ /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY +/* Define to 1 if you have the `getuid' function. */ +#undef HAVE_GETUID + /* Define to 1 if you have the `getwd' function. */ #undef HAVE_GETWD @@ -612,6 +630,9 @@ /* Define to 1 if you have the `openat' function. */ #undef HAVE_OPENAT +/* Define to 1 if you have the `opendir' function. */ +#undef HAVE_OPENDIR + /* Define to 1 if you have the `openpty' function. */ #undef HAVE_OPENPTY @@ -624,6 +645,9 @@ /* Define to 1 if you have the `pause' function. */ #undef HAVE_PAUSE +/* Define to 1 if you have the `pipe' function. */ +#undef HAVE_PIPE + /* Define to 1 if you have the `pipe2' function. */ #undef HAVE_PIPE2 @@ -941,6 +965,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYSEXITS_H +/* Define to 1 if you have the `system' function. */ +#undef HAVE_SYSTEM + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_AUDIOIO_H @@ -1085,6 +1112,9 @@ /* Define to 1 if you have the `truncate' function. */ #undef HAVE_TRUNCATE +/* Define to 1 if you have the `ttyname' function. */ +#undef HAVE_TTYNAME + /* Define to 1 if you don't have `tm_zone' but do have the external array `tzname'. */ #undef HAVE_TZNAME @@ -1101,6 +1131,9 @@ /* Define to 1 if the system has the type `uintptr_t'. */ #undef HAVE_UINTPTR_T +/* Define to 1 if you have the `umask' function. */ +#undef HAVE_UMASK + /* Define to 1 if you have the `uname' function. */ #undef HAVE_UNAME @@ -1130,6 +1163,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UTIME_H +/* Define to 1 if you have the `wait' function. */ +#undef HAVE_WAIT + /* Define to 1 if you have the `wait3' function. */ #undef HAVE_WAIT3