svn commit: trunk/busybox: include libbb loginutils miscutils

aldot at busybox.net aldot at busybox.net
Fri May 26 14:41:44 UTC 2006


Author: aldot
Date: 2006-05-26 07:41:40 -0700 (Fri, 26 May 2006)
New Revision: 15193

Log:
- introduce and use bb_path_wtmp_file for portability (saves 11 Bytes).
- fix last.c to also look at the double-underscore UT_ defines.


Modified:
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/messages.c
   trunk/busybox/loginutils/getty.c
   trunk/busybox/loginutils/login.c
   trunk/busybox/miscutils/last.c


Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2006-05-26 14:24:56 UTC (rev 15192)
+++ trunk/busybox/include/libbb.h	2006-05-26 14:41:40 UTC (rev 15193)
@@ -11,6 +11,8 @@
 #ifndef	__LIBBUSYBOX_H__
 #define	__LIBBUSYBOX_H__    1
 
+#include "platform.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -18,14 +20,10 @@
 #include <sys/stat.h>
 #include <termios.h>
 #include <dirent.h>
-#include <stdint.h>
 
 #include <netinet/in.h>
 #include <netdb.h>
 
-#include <features.h>
-
-#include "platform.h"
 #include "bb_config.h"
 #ifdef CONFIG_SELINUX
 #include <selinux/selinux.h>
@@ -41,8 +39,11 @@
 #endif
 
 /* Some useful definitions */
+#undef FALSE
 #define FALSE   ((int) 0)
+#undef TRUE
 #define TRUE    ((int) 1)
+#undef SKIP
 #define SKIP	((int) 2)
 
 /* for mtab.c */
@@ -348,6 +349,7 @@
 extern const char * const bb_path_group_file;
 extern const char * const bb_path_securetty_file;
 extern const char * const bb_path_motd_file;
+extern const char * const bb_path_wtmp_file;
 extern const char * const bb_dev_null;
 
 #ifndef BUFSIZ

Modified: trunk/busybox/libbb/messages.c
===================================================================
--- trunk/busybox/libbb/messages.c	2006-05-26 14:24:56 UTC (rev 15192)
+++ trunk/busybox/libbb/messages.c	2006-05-26 14:41:40 UTC (rev 15193)
@@ -93,6 +93,20 @@
 const char * const bb_dev_null = "/dev/null";
 #endif
 
+#ifdef L_bb_path_wtmp_file
+#include <utmp.h>
+/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */
+const char * const bb_path_wtmp_file =
+#if defined _PATH_WTMP
+_PATH_WTMP;
+#elif defined WTMP_FILE
+WTMP_FILE;
+#else
+# error unknown path to wtmp file
+#endif
+#endif
+
+
 #ifdef L_bb_common_bufsiz1
 char bb_common_bufsiz1[BUFSIZ+1];
 #endif

Modified: trunk/busybox/loginutils/getty.c
===================================================================
--- trunk/busybox/loginutils/getty.c	2006-05-26 14:24:56 UTC (rev 15192)
+++ trunk/busybox/loginutils/getty.c	2006-05-26 14:41:40 UTC (rev 15193)
@@ -496,9 +496,9 @@
 	endutent();
 
 #ifdef CONFIG_FEATURE_WTMP
-	if (access(_PATH_WTMP, R_OK|W_OK) == -1)
-		close(creat(_PATH_WTMP, 0664));
-	updwtmp(_PATH_WTMP, &ut);
+	if (access(bb_path_wtmp_file, R_OK|W_OK) == -1)
+		close(creat(bb_path_wtmp_file, 0664));
+	updwtmp(bb_path_wtmp_file, &ut);
 #endif
 }
 

Modified: trunk/busybox/loginutils/login.c
===================================================================
--- trunk/busybox/loginutils/login.c	2006-05-26 14:24:56 UTC (rev 15192)
+++ trunk/busybox/loginutils/login.c	2006-05-26 14:41:40 UTC (rev 15193)
@@ -463,7 +463,7 @@
 static void setutmp(const char *name, const char *line ATTRIBUTE_UNUSED)
 {
 	time_t t_tmp = (time_t)utent.ut_time;
-	
+
 	utent.ut_type = USER_PROCESS;
 	strncpy(utent.ut_user, name, sizeof utent.ut_user);
 	time(&t_tmp);
@@ -472,10 +472,10 @@
 	pututline(&utent);
 	endutent();
 #ifdef CONFIG_FEATURE_WTMP
-	if (access(_PATH_WTMP, R_OK|W_OK) == -1) {
-		close(creat(_PATH_WTMP, 0664));
+	if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) {
+		close(creat(bb_path_wtmp_file, 0664));
 	}
-	updwtmp(_PATH_WTMP, &utent);
+	updwtmp(bb_path_wtmp_file, &utent);
 #endif
 }
 #endif /* CONFIG_FEATURE_UTMP */

Modified: trunk/busybox/miscutils/last.c
===================================================================
--- trunk/busybox/miscutils/last.c	2006-05-26 14:24:56 UTC (rev 15192)
+++ trunk/busybox/miscutils/last.c	2006-05-26 14:41:40 UTC (rev 15193)
@@ -26,8 +26,12 @@
  * Do what we can while still keeping this reasonably small.
  * Note: We are assuming the ut_id[] size is fixed at 4. */
 
-#if (UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)
+#if defined UT_LINESIZE \
+	&& ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256))
 #error struct utmp member char[] size(s) have changed!
+#elif defined __UT_LINESIZE \
+	&& ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 64) || (__UT_HOSTSIZE != 256))
+#error struct utmp member char[] size(s) have changed!
 #endif
 
 int last_main(int argc, char **argv)
@@ -39,7 +43,7 @@
 	if (argc > 1) {
 		bb_show_usage();
 	}
-	file = bb_xopen(_PATH_WTMP, O_RDONLY);
+	file = bb_xopen(bb_path_wtmp_file, O_RDONLY);
 
 	printf("%-10s %-14s %-18s %-12.12s %s\n", "USER", "TTY", "HOST", "LOGIN", "TIME");
 	while ((n = safe_read(file, (void*)&ut, sizeof(struct utmp))) != 0) {




More information about the busybox-cvs mailing list