summaryrefslogtreecommitdiff
path: root/aports/busybox/0001-avoid-redefined-warnings-when-building-with-utmps.patch
blob: 083b8a8b8c95d9d0238c44f1ae6affb5a133a57a (plain)
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
From 770825e4730fadc0b7fc5a0f154eb368a37564a0 Mon Sep 17 00:00:00 2001
From: Laurent Bercot <ska-devel@skarnet.org>
Date: Wed, 20 Jul 2022 10:39:22 +0200
Subject: [PATCH] Avoid redefined warnings when buiding with utmps

Do not use _PATH_UTMP or _PATH_WTMP, and do not touch
the files directly.
---
 include/libbb.h         | 8 +++-----
 libbb/messages.c        | 4 ++--
 libbb/utmp.c            | 8 ++++----
 util-linux/last_fancy.c | 2 +-
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/include/libbb.h b/include/libbb.h
index abbc9ac59..9710e804c 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -107,14 +107,12 @@
 #  define _PATH_UTMPX _PATH_UTMP
 # else
 #  if !defined(__FreeBSD__)
-#   include <utmp.h>
+#   include <utmps/utmps.h>
+#   define _CORRECT_PATH_UTMPX "/run/utmps/utmp"
+#   define _CORRECT_PATH_WTMP "/var/log/wtmp"
 #  else
 #   define _PATH_UTMPX "/var/run/utx.active"
 #  endif
-#  include <utmpx.h>
-#  if defined _PATH_UTMP && !defined _PATH_UTMPX
-#   define _PATH_UTMPX _PATH_UTMP
-#  endif
 # endif
 #endif
 #if ENABLE_LOCALE_SUPPORT
diff --git a/libbb/messages.c b/libbb/messages.c
index 6914d5701..689dd0c6d 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -42,8 +42,8 @@ const int const_int_0 = 0;
 #if ENABLE_FEATURE_WTMP
 /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */
 const char bb_path_wtmp_file[] ALIGN1 =
-# if defined _PATH_WTMP
-	_PATH_WTMP;
+# if defined _CORRECT_PATH_WTMP
+	_CORRECT_PATH_WTMP;
 # elif defined WTMP_FILE
 	WTMP_FILE;
 # else
diff --git a/libbb/utmp.c b/libbb/utmp.c
index bd07670db..463ee1317 100644
--- a/libbb/utmp.c
+++ b/libbb/utmp.c
@@ -45,8 +45,8 @@ void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, con
 		tty_name += 3;
 	strncpy(id, tty_name, width);
 
-	touch(_PATH_UTMPX);
-	//utmpxname(_PATH_UTMPX);
+	//touch(_CORRECT_PATH_UTMPX);
+	//utmpxname(_CORRECT_PATH_UTMPX);
 	setutxent();
 	/* Append new one (hopefully, unless we collide on ut_id) */
 	pututxline(&utent);
@@ -67,8 +67,8 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const
 	struct utmpx utent;
 	struct utmpx *utp;
 
-	touch(_PATH_UTMPX);
-	//utmpxname(_PATH_UTMPX);
+	//touch(_CORRECT_PATH_UTMPX);
+	//utmpxname(_CORRECT_PATH_UTMPX);
 	setutxent();
 
 	/* Did init/getty/telnetd/sshd/... create an entry for us?
diff --git a/util-linux/last_fancy.c b/util-linux/last_fancy.c
index 648236229..aa7a62bbe 100644
--- a/util-linux/last_fancy.c
+++ b/util-linux/last_fancy.c
@@ -159,7 +159,7 @@ int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int last_main(int argc UNUSED_PARAM, char **argv)
 {
 	struct utmpx ut;
-	const char *filename = _PATH_WTMP;
+	const char *filename = _CORRECT_PATH_WTMP;
 	llist_t *zlist;
 	off_t pos;
 	time_t start_time;
-- 
2.37.1