Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0e93138

Browse filesBrowse files
committed
Check for MAXLOGNAME and UT_NAMESIZE in configure and use them (in that order)
if available, falling back to a hard-coded maximum login name length of 255 if neither is available.
1 parent 434c1a0 commit 0e93138
Copy full SHA for 0e93138

File tree

Expand file treeCollapse file tree

4 files changed

+54
-3
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+54
-3
lines changed

‎Modules/posixmodule.c

Copy file name to clipboardExpand all lines: Modules/posixmodule.c
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9539,15 +9539,21 @@ os_getlogin_impl(PyObject *module)
95399539
else
95409540
result = PyErr_SetFromWindowsErr(GetLastError());
95419541
#elif defined (HAVE_GETLOGIN_R)
9542-
/* AFAIK the maximum length should be 32, but this is not checkable */
9543-
char name[64];
9542+
# if defined (HAVE_MAXLOGNAME)
9543+
char name[MAXLOGNAME + 1];
9544+
# elif defined (HAVE_UT_NAMESIZE)
9545+
char name[UT_NAMESIZE + 1];
9546+
# else
9547+
char name[256];
9548+
# endif
95449549
int err = getlogin_r(name, sizeof(name));
95459550
if (err) {
95469551
int old_errno = errno;
95479552
errno = -err;
95489553
posix_error();
95499554
errno = old_errno;
9550-
} else {
9555+
}
9556+
else {
95519557
result = PyUnicode_DecodeFSDefault(name);
95529558
}
95539559
#else

‎configure

Copy file name to clipboardExpand all lines: configure
+27Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎configure.ac

Copy file name to clipboardExpand all lines: configure.ac
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5427,6 +5427,18 @@ PY_CHECK_FUNC([setgroups], [
54275427
#endif
54285428
])
54295429

5430+
AC_CHECK_DECL([MAXLOGNAME],
5431+
[AC_DEFINE([HAVE_MAXLOGNAME], [1],
5432+
[Define if you have the 'MAXLOGNAME' constant.])],
5433+
[],
5434+
[@%:@include <sys/params.h>])
5435+
5436+
AC_CHECK_DECLS([UT_NAMESIZE],
5437+
[AC_DEFINE([HAVE_UT_NAMESIZE], [1],
5438+
[Define if you have the 'HAVE_UT_NAMESIZE' constant.])],
5439+
[],
5440+
[@%:@include <utmp.h>])
5441+
54305442
# check for openpty, login_tty, and forkpty
54315443

54325444
AC_CHECK_FUNCS([openpty], [],

‎pyconfig.h.in

Copy file name to clipboardExpand all lines: pyconfig.h.in
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,6 +1633,12 @@
16331633
/* Define to 1 if the system has the type '__uint128_t'. */
16341634
#undef HAVE___UINT128_T
16351635

1636+
/* Define to 1 if you have the MAXLOGNAME constant. */
1637+
#undef HAVE_MAXLOGNAME
1638+
1639+
/* Define to 1 if you have the UT_NAMESIZE constant. */
1640+
#undef HAVE_UT_NAMESIZE
1641+
16361642
/* Define to 1 if 'major', 'minor', and 'makedev' are declared in <mkdev.h>.
16371643
*/
16381644
#undef MAJOR_IN_MKDEV

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.