| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Fix libc thread safety issues with :mod:`os` by replacing ``getlogin`` with | ||
| 2 | + ``getlogin_r`` re-entrant version. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9548,6 +9548,24 @@ os_getlogin_impl(PyObject *module) | |||
| 9548 | 9548 | } | |
| 9549 | 9549 | else | |
| 9550 | 9550 | result = PyErr_SetFromWindowsErr(GetLastError()); | |
| 9551 | + #elif defined (HAVE_GETLOGIN_R) | ||
| 9552 | + # if defined (HAVE_MAXLOGNAME) | ||
| 9553 | + char name[MAXLOGNAME + 1]; | ||
| 9554 | + # elif defined (HAVE_UT_NAMESIZE) | ||
| 9555 | + char name[UT_NAMESIZE + 1]; | ||
| 9556 | + # else | ||
| 9557 | + char name[256]; | ||
| 9558 | + # endif | ||
| 9559 | + int err = getlogin_r(name, sizeof(name)); | ||
| 9560 | + if (err) { | ||
| 9561 | + int old_errno = errno; | ||
| 9562 | + errno = -err; | ||
| 9563 | + posix_error(); | ||
| 9564 | + errno = old_errno; | ||
| 9565 | + } | ||
| 9566 | + else { | ||
| 9567 | + result = PyUnicode_DecodeFSDefault(name); | ||
| 9568 | + } | ||
| 9551 | 9569 | #else | |
| 9552 | 9570 | char *name; | |
| 9553 | 9571 | int old_errno = errno; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5219,7 +5219,7 @@ AC_CHECK_FUNCS([ \ | |||
| 5219 | 5219 | faccessat fchmod fchmodat fchown fchownat fdopendir fdwalk fexecve \ | |
| 5220 | 5220 | fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \ | |
| 5221 | 5221 | gai_strerror getegid geteuid getgid getgrent getgrgid getgrgid_r \ | |
| 5222 | - getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin \ | ||
| 5222 | + getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin getlogin_r \ | ||
| 5223 | 5223 | getpeername getpgid getpid getppid getpriority _getpty \ | |
| 5224 | 5224 | getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid getspent \ | |
| 5225 | 5225 | getspnam getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \ | |
@@ -5538,6 +5538,18 @@ PY_CHECK_FUNC([setgroups], [ | |||
| 5538 | 5538 | #endif | |
| 5539 | 5539 | ]) | |
| 5540 | 5540 | ||
| 5541 | + AC_CHECK_DECL([MAXLOGNAME], | ||
| 5542 | + [AC_DEFINE([HAVE_MAXLOGNAME], [1], | ||
| 5543 | + [Define if you have the 'MAXLOGNAME' constant.])], | ||
| 5544 | + [], | ||
| 5545 | + [@%:@include <sys/params.h>]) | ||
| 5546 | + | ||
| 5547 | + AC_CHECK_DECLS([UT_NAMESIZE], | ||
| 5548 | + [AC_DEFINE([HAVE_UT_NAMESIZE], [1], | ||
| 5549 | + [Define if you have the 'HAVE_UT_NAMESIZE' constant.])], | ||
| 5550 | + [], | ||
| 5551 | + [@%:@include <utmp.h>]) | ||
| 5552 | + | ||
| 5541 | 5553 | # check for openpty, login_tty, and forkpty | |
| 5542 | 5554 | ||
| 5543 | 5555 | AC_CHECK_FUNCS([openpty], [], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -267,6 +267,10 @@ | |||
| 267 | 267 | */ | |
| 268 | 268 | #undef HAVE_DECL_TZNAME | |
| 269 | 269 | ||
| 270 | + /* Define to 1 if you have the declaration of 'UT_NAMESIZE', and to 0 if you | ||
| 271 | + don't. */ | ||
| 272 | + #undef HAVE_DECL_UT_NAMESIZE | ||
| 273 | + | ||
| 270 | 274 | /* Define to 1 if you have the device macros. */ | |
| 271 | 275 | #undef HAVE_DEVICE_MACROS | |
| 272 | 276 | ||
@@ -539,6 +543,9 @@ | |||
| 539 | 543 | /* Define to 1 if you have the 'getlogin' function. */ | |
| 540 | 544 | #undef HAVE_GETLOGIN | |
| 541 | 545 | ||
| 546 | + /* Define to 1 if you have the 'getlogin_r' function. */ | ||
| 547 | + #undef HAVE_GETLOGIN_R | ||
| 548 | + | ||
| 542 | 549 | /* Define to 1 if you have the 'getnameinfo' function. */ | |
| 543 | 550 | #undef HAVE_GETNAMEINFO | |
| 544 | 551 | ||
@@ -807,6 +814,9 @@ | |||
| 807 | 814 | /* Define this if you have the makedev macro. */ | |
| 808 | 815 | #undef HAVE_MAKEDEV | |
| 809 | 816 | ||
| 817 | + /* Define if you have the 'MAXLOGNAME' constant. */ | ||
| 818 | + #undef HAVE_MAXLOGNAME | ||
| 819 | + | ||
| 810 | 820 | /* Define to 1 if you have the 'mbrtowc' function. */ | |
| 811 | 821 | #undef HAVE_MBRTOWC | |
| 812 | 822 | ||
@@ -1575,6 +1585,9 @@ | |||
| 1575 | 1585 | /* Define to 1 if you have the <utmp.h> header file. */ | |
| 1576 | 1586 | #undef HAVE_UTMP_H | |
| 1577 | 1587 | ||
| 1588 | + /* Define if you have the 'HAVE_UT_NAMESIZE' constant. */ | ||
| 1589 | + #undef HAVE_UT_NAMESIZE | ||
| 1590 | + | ||
| 1578 | 1591 | /* Define to 1 if you have the 'uuid_create' function. */ | |
| 1579 | 1592 | #undef HAVE_UUID_CREATE | |
| 1580 | 1593 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments