From ea3e27d968e5e664ad0f467617f7c7fd887a47a7 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 12 Dec 2025 22:19:16 +0100 Subject: [PATCH 1/2] configure.ac, lib/utmp.c: Assume ut_host is supported Every system we care about has ut_host. alx@devuan:~/src/musl/libc/master$ grepc -tt utmpx . \ | grep -e '^[.}]' -e ut_host ./include/utmpx.h:struct utmpx { char ut_host[256]; }; alx@devuan:~/src/musl/libc/master$ cd ../../../bsd/freebsd/main/ alx@devuan:~/src/bsd/freebsd/main$ grepc -tt utmpx . \ | grep -e '^[.}]' -e ut_host ./include/utmpx.h:struct utmpx { char ut_host[128]; /* Remote hostname. */ char __ut_host[128]; }; ./lib/libc/gen/getutxent.3:struct utmpx { char ut_host[]; /* Remote hostname. */ }; alx@devuan:~/src/bsd/freebsd/main$ cd ../../netbsd/trunk/ alx@devuan:~/src/bsd/netbsd/trunk$ grepc -tt utmpx . \ | grep -e '^[.}]' -e ut_host ./include/utmpx.h:struct utmpx { char ut_host[_UTX_HOSTSIZE]; /* host name */ }; ./lib/libc/gen/endutxent.3:struct utmpx { char ut_host[_UTX_HOSTSIZE]; /* host name */ }; alx@devuan:~/src/bsd/netbsd/trunk$ cd ../../openbsd/master/ alx@devuan:~/src/bsd/openbsd/master$ grepc -tt utmpx . \ | grep -e '^[.}]' -e ut_host alx@devuan:~/src/bsd/openbsd/master$ grepc -tt utmp . \ | grep -e '^[.}]' -e ut_host ./include/utmp.h:struct utmp { char ut_host[UT_HOSTSIZE]; }; ./share/man/man5/utmp.5:struct utmp { char ut_host[UT_HOSTSIZE]; }; alx@devuan:~/src/bsd/openbsd/master$ cd ../../../gnu/glibc/master/ alx@devuan:~/src/gnu/glibc/master$ grepc -tt utmpx . \ | grep -e '^[.}]' -e ut_host ./sysdeps/gnu/bits/utmpx.h:struct utmpx char ut_host[__UT_HOSTSIZE] }; ./sysdeps/unix/sysv/linux/s390/bits/utmpx.h:struct utmpx char ut_host[__UT_HOSTSIZE] }; Signed-off-by: Alejandro Colomar --- configure.ac | 1 - lib/utmp.c | 9 --------- 2 files changed, 10 deletions(-) diff --git a/configure.ac b/configure.ac index b3dd34d96d..3462dab30f 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,6 @@ AC_SYS_LARGEFILE dnl Checks for typedefs, structures, and compiler characteristics. AC_CHECK_MEMBERS([struct utmpx.ut_name, - struct utmpx.ut_host, struct utmpx.ut_syslen, struct utmpx.ut_addr, struct utmpx.ut_addr_v6, diff --git a/lib/utmp.c b/lib/utmp.c index 3c2a51aab5..779e3d5073 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -206,17 +206,12 @@ get_session_host(char **out, pid_t main_pid) ut = get_current_utmp(main_pid); -#if defined(HAVE_STRUCT_UTMPX_UT_HOST) if ((ut != NULL) && !strneq_a(ut->ut_host, "")) { *out = xstrndup_a(ut->ut_host); } else { *out = NULL; ret = -2; } -#else - *out = NULL; - ret = -2; -#endif free(ut); @@ -277,10 +272,8 @@ prepare_utmp(const char *name, const char *line, const char *host, if (NULL != host && !streq(host, "")) hostname = xstrdup(host); -#if defined(HAVE_STRUCT_UTMPX_UT_HOST) else if (NULL != ut && !strneq_a(ut->ut_host, "")) hostname = xstrndup_a(ut->ut_host); -#endif line = strprefix(line, "/dev/") ?: line; @@ -302,9 +295,7 @@ prepare_utmp(const char *name, const char *line, const char *host, strncpy_a(utent->ut_user, name); if (NULL != hostname) { struct addrinfo *info = NULL; -#if defined(HAVE_STRUCT_UTMPX_UT_HOST) strncpy_a(utent->ut_host, hostname); -#endif #if defined(HAVE_STRUCT_UTMPX_UT_SYSLEN) utent->ut_syslen = MIN(strlen(hostname), sizeof(utent->ut_host)); From 92eeb29fc41f4118338477c15676ba07030af9be Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 12 Dec 2025 22:31:26 +0100 Subject: [PATCH 2/2] configure.ac, lib/utmp.c: Assume ut_name is not supported ut_name and ut_user can't coexist. We already assume ut_user is supported. Signed-off-by: Alejandro Colomar --- configure.ac | 3 +-- lib/utmp.c | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 3462dab30f..79fed90b86 100644 --- a/configure.ac +++ b/configure.ac @@ -54,8 +54,7 @@ AC_SYS_LARGEFILE dnl Checks for typedefs, structures, and compiler characteristics. -AC_CHECK_MEMBERS([struct utmpx.ut_name, - struct utmpx.ut_syslen, +AC_CHECK_MEMBERS([struct utmpx.ut_syslen, struct utmpx.ut_addr, struct utmpx.ut_addr_v6, struct utmpx.ut_time, diff --git a/lib/utmp.c b/lib/utmp.c index 779e3d5073..ded2d5509b 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -289,9 +289,6 @@ prepare_utmp(const char *name, const char *line, const char *host, } else { strncpy_a(utent->ut_id, strnul(line) - MIN(strlen(line), countof(utent->ut_id))); } -#if defined(HAVE_STRUCT_UTMPX_UT_NAME) - strncpy_a(utent->ut_name, name); -#endif strncpy_a(utent->ut_user, name); if (NULL != hostname) { struct addrinfo *info = NULL;