aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-26 14:41:40 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-26 14:41:40 +0000
commit781e42d66c120183e4dea1058dc539bdc4c53651 (patch)
treeb139320b4b1275de767168b811ca45d1523f0573
parentb180e5a76678f697b2a368e2ef607d299d06a3ae (diff)
downloadbusybox-w32-781e42d66c120183e4dea1058dc539bdc4c53651.tar.gz
busybox-w32-781e42d66c120183e4dea1058dc539bdc4c53651.tar.bz2
busybox-w32-781e42d66c120183e4dea1058dc539bdc4c53651.zip
- introduce and use bb_path_wtmp_file for portability (saves 11 Bytes).
- fix last.c to also look at the double-underscore UT_ defines.
-rw-r--r--include/libbb.h10
-rw-r--r--libbb/messages.c14
-rw-r--r--loginutils/getty.c6
-rw-r--r--loginutils/login.c8
-rw-r--r--miscutils/last.c8
5 files changed, 33 insertions, 13 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 82d215bfe..64c91b170 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -11,6 +11,8 @@
11#ifndef __LIBBUSYBOX_H__ 11#ifndef __LIBBUSYBOX_H__
12#define __LIBBUSYBOX_H__ 1 12#define __LIBBUSYBOX_H__ 1
13 13
14#include "platform.h"
15
14#include <stdio.h> 16#include <stdio.h>
15#include <stdlib.h> 17#include <stdlib.h>
16#include <stdarg.h> 18#include <stdarg.h>
@@ -18,14 +20,10 @@
18#include <sys/stat.h> 20#include <sys/stat.h>
19#include <termios.h> 21#include <termios.h>
20#include <dirent.h> 22#include <dirent.h>
21#include <stdint.h>
22 23
23#include <netinet/in.h> 24#include <netinet/in.h>
24#include <netdb.h> 25#include <netdb.h>
25 26
26#include <features.h>
27
28#include "platform.h"
29#include "bb_config.h" 27#include "bb_config.h"
30#ifdef CONFIG_SELINUX 28#ifdef CONFIG_SELINUX
31#include <selinux/selinux.h> 29#include <selinux/selinux.h>
@@ -41,8 +39,11 @@
41#endif 39#endif
42 40
43/* Some useful definitions */ 41/* Some useful definitions */
42#undef FALSE
44#define FALSE ((int) 0) 43#define FALSE ((int) 0)
44#undef TRUE
45#define TRUE ((int) 1) 45#define TRUE ((int) 1)
46#undef SKIP
46#define SKIP ((int) 2) 47#define SKIP ((int) 2)
47 48
48/* for mtab.c */ 49/* for mtab.c */
@@ -348,6 +349,7 @@ extern const char * const bb_path_gshadow_file;
348extern const char * const bb_path_group_file; 349extern const char * const bb_path_group_file;
349extern const char * const bb_path_securetty_file; 350extern const char * const bb_path_securetty_file;
350extern const char * const bb_path_motd_file; 351extern const char * const bb_path_motd_file;
352extern const char * const bb_path_wtmp_file;
351extern const char * const bb_dev_null; 353extern const char * const bb_dev_null;
352 354
353#ifndef BUFSIZ 355#ifndef BUFSIZ
diff --git a/libbb/messages.c b/libbb/messages.c
index ab4c5d4b1..89ac94e13 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -93,6 +93,20 @@ const char * const bb_default_login_shell = LIBBB_DEFAULT_LOGIN_SHELL;
93const char * const bb_dev_null = "/dev/null"; 93const char * const bb_dev_null = "/dev/null";
94#endif 94#endif
95 95
96#ifdef L_bb_path_wtmp_file
97#include <utmp.h>
98/* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */
99const char * const bb_path_wtmp_file =
100#if defined _PATH_WTMP
101_PATH_WTMP;
102#elif defined WTMP_FILE
103WTMP_FILE;
104#else
105# error unknown path to wtmp file
106#endif
107#endif
108
109
96#ifdef L_bb_common_bufsiz1 110#ifdef L_bb_common_bufsiz1
97char bb_common_bufsiz1[BUFSIZ+1]; 111char bb_common_bufsiz1[BUFSIZ+1];
98#endif 112#endif
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 24d579f75..43a82df66 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -496,9 +496,9 @@ static void update_utmp(char *line)
496 endutent(); 496 endutent();
497 497
498#ifdef CONFIG_FEATURE_WTMP 498#ifdef CONFIG_FEATURE_WTMP
499 if (access(_PATH_WTMP, R_OK|W_OK) == -1) 499 if (access(bb_path_wtmp_file, R_OK|W_OK) == -1)
500 close(creat(_PATH_WTMP, 0664)); 500 close(creat(bb_path_wtmp_file, 0664));
501 updwtmp(_PATH_WTMP, &ut); 501 updwtmp(bb_path_wtmp_file, &ut);
502#endif 502#endif
503} 503}
504 504
diff --git a/loginutils/login.c b/loginutils/login.c
index 46766c551..b1367327b 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -463,7 +463,7 @@ static void checkutmp(int picky)
463static void setutmp(const char *name, const char *line ATTRIBUTE_UNUSED) 463static void setutmp(const char *name, const char *line ATTRIBUTE_UNUSED)
464{ 464{
465 time_t t_tmp = (time_t)utent.ut_time; 465 time_t t_tmp = (time_t)utent.ut_time;
466 466
467 utent.ut_type = USER_PROCESS; 467 utent.ut_type = USER_PROCESS;
468 strncpy(utent.ut_user, name, sizeof utent.ut_user); 468 strncpy(utent.ut_user, name, sizeof utent.ut_user);
469 time(&t_tmp); 469 time(&t_tmp);
@@ -472,10 +472,10 @@ static void setutmp(const char *name, const char *line ATTRIBUTE_UNUSED)
472 pututline(&utent); 472 pututline(&utent);
473 endutent(); 473 endutent();
474#ifdef CONFIG_FEATURE_WTMP 474#ifdef CONFIG_FEATURE_WTMP
475 if (access(_PATH_WTMP, R_OK|W_OK) == -1) { 475 if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) {
476 close(creat(_PATH_WTMP, 0664)); 476 close(creat(bb_path_wtmp_file, 0664));
477 } 477 }
478 updwtmp(_PATH_WTMP, &utent); 478 updwtmp(bb_path_wtmp_file, &utent);
479#endif 479#endif
480} 480}
481#endif /* CONFIG_FEATURE_UTMP */ 481#endif /* CONFIG_FEATURE_UTMP */
diff --git a/miscutils/last.c b/miscutils/last.c
index ac6c86c63..c10e1ea4f 100644
--- a/miscutils/last.c
+++ b/miscutils/last.c
@@ -26,7 +26,11 @@
26 * Do what we can while still keeping this reasonably small. 26 * Do what we can while still keeping this reasonably small.
27 * Note: We are assuming the ut_id[] size is fixed at 4. */ 27 * Note: We are assuming the ut_id[] size is fixed at 4. */
28 28
29#if (UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256) 29#if defined UT_LINESIZE \
30 && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256))
31#error struct utmp member char[] size(s) have changed!
32#elif defined __UT_LINESIZE \
33 && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 64) || (__UT_HOSTSIZE != 256))
30#error struct utmp member char[] size(s) have changed! 34#error struct utmp member char[] size(s) have changed!
31#endif 35#endif
32 36
@@ -39,7 +43,7 @@ int last_main(int argc, char **argv)
39 if (argc > 1) { 43 if (argc > 1) {
40 bb_show_usage(); 44 bb_show_usage();
41 } 45 }
42 file = bb_xopen(_PATH_WTMP, O_RDONLY); 46 file = bb_xopen(bb_path_wtmp_file, O_RDONLY);
43 47
44 printf("%-10s %-14s %-18s %-12.12s %s\n", "USER", "TTY", "HOST", "LOGIN", "TIME"); 48 printf("%-10s %-14s %-18s %-12.12s %s\n", "USER", "TTY", "HOST", "LOGIN", "TIME");
45 while ((n = safe_read(file, (void*)&ut, sizeof(struct utmp))) != 0) { 49 while ((n = safe_read(file, (void*)&ut, sizeof(struct utmp))) != 0) {