summaryrefslogtreecommitdiff
path: root/system/openssh/utmpx.patch
blob: d3f24aa761eb1dd4c60cb36975f72135849a1537 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--- openssh-9.9p2/configure.ac.old	2025-02-18 02:15:08.000000000 -0600
+++ openssh-9.9p2/configure.ac	2025-02-18 20:57:12.172701096 -0600
@@ -5449,7 +5449,9 @@
 AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
-#include <utmp.h>
+#ifdef HAVE_UTMP_H
+#  include <utmp.h>
+#endif
 #ifdef HAVE_LASTLOG_H
 #  include <lastlog.h>
 #endif
@@ -5466,7 +5468,9 @@
 		AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
 		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
-#include <utmp.h>
+#ifdef HAVE_UTMP_H
+#  include <utmp.h>
+#endif
 #ifdef HAVE_LASTLOG_H
 #  include <lastlog.h>
 #endif
@@ -5504,7 +5508,9 @@
 AC_MSG_CHECKING([if your system defines UTMP_FILE])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
-#include <utmp.h>
+#ifdef HAVE_UTMP_H
+#  include <utmp.h>
+#endif
 #ifdef HAVE_PATHS_H
 #  include <paths.h>
 #endif
@@ -5534,7 +5540,9 @@
 AC_MSG_CHECKING([if your system defines WTMP_FILE])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
-#include <utmp.h>
+#ifdef HAVE_UTMP_H
+#  include <utmp.h>
+#endif
 #ifdef HAVE_PATHS_H
 #  include <paths.h>
 #endif
@@ -5564,7 +5572,9 @@
 AC_MSG_CHECKING([if your system defines WTMPX_FILE])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
-#include <utmp.h>
+#ifdef HAVE_UTMP_H
+#  include <utmp.h>
+#endif
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #endif
--- openssh-9.9p2/loginrec.c.old	2025-02-18 02:15:08.000000000 -0600
+++ openssh-9.9p2/loginrec.c	2025-02-18 21:01:26.034757676 -0600
@@ -614,7 +614,7 @@
  ** into account.
  **/
 
-#if defined(USE_BTMP) || defined(USE_UTMP) || defined (USE_WTMP) || defined (USE_LOGIN)
+#if defined(USE_UTMP) || defined (USE_WTMP) || defined (USE_LOGIN)
 
 /* build the utmp structure */
 void
@@ -698,7 +698,7 @@
 	}
 # endif
 }
-#endif /* USE_BTMP || USE_UTMP || USE_WTMP || USE_LOGIN */
+#endif /* USE_UTMP || USE_WTMP || USE_LOGIN */
 
 /**
  ** utmpx utility functions
@@ -1644,7 +1644,13 @@
     const char *ttyn)
 {
 	int fd;
+#if defined(USE_UTMP)
 	struct utmp ut;
+#elif defined(USE_UTMPX)
+	struct utmpx ut;
+#else
+#  error either UTMP or UTMPX must be present to use BTMP
+#endif
 	struct logininfo li;
 	socklen_t fromlen = sizeof(li.hostaddr);
 	time_t t;
@@ -1681,7 +1687,11 @@
 		(void)getpeername(ssh_packet_get_connection_in(ssh),
 		    &li.hostaddr.sa, &fromlen);
 	}
+#if defined(USE_UTMP)
 	construct_utmp(&li, &ut);
+#elif defined(USE_UTMPX)
+	construct_utmpx(&li, &ut);
+#endif
 
 	if (atomicio(vwrite, fd, &ut, sizeof(ut)) != sizeof(ut)) {
 		error("Failed to write to %s: %s", _PATH_BTMP,