1303 files changed, 32187 insertions, 57138 deletions
diff --git a/miscutils/last.c b/miscutils/last.c index 24f6e1c..67c1343 100644 --- a/miscutils/last.c +++ b/miscutils/last.c @@ -6,6 +6,28 @@ * * Licensed under GPLv2, see file LICENSE in this source tree. */ +//config:config LAST +//config: bool "last" +//config: default y +//config: depends on FEATURE_WTMP +//config: help +//config: 'last' displays a list of the last users that logged into the system. +//config: +//config:config FEATURE_LAST_FANCY +//config: bool "Turn on output of extra information" +//config: default y +//config: depends on LAST +//config: help +//config: 'last' displays detailed information about the last users that +//config: logged into the system (mimics sysvinit last). +900 bytes. + +//applet:IF_LAST(APPLET(last, BB_DIR_USR_BIN, BB_SUID_DROP)) + +//kbuild:ifeq ($(CONFIG_FEATURE_LAST_FANCY),y) +//kbuild:lib-$(CONFIG_FEATURE_LAST_FANCY) += last_fancy.o +//kbuild:else +//kbuild:lib-$(CONFIG_LAST) += last.o +//kbuild:endif //usage:#define last_trivial_usage //usage: ""IF_FEATURE_LAST_FANCY("[-HW] [-f FILE]") @@ -32,21 +54,22 @@ #if defined UT_LINESIZE \ && ((UT_LINESIZE != 32) || (UT_NAMESIZE != 32) || (UT_HOSTSIZE != 256)) -#error struct utmp member char[] size(s) have changed! +#error struct utmpx 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! + && ((__UT_LINESIZE != 32) || (__UT_NAMESIZE != 32) || (__UT_HOSTSIZE != 256)) +/* __UT_NAMESIZE was checked with 64 above, but glibc-2.11 definitely uses 32! */ +#error struct utmpx member char[] size(s) have changed! #endif #if EMPTY != 0 || RUN_LVL != 1 || BOOT_TIME != 2 || NEW_TIME != 3 || \ OLD_TIME != 4 -#error Values for the ut_type field of struct utmp changed +#error Values for the ut_type field of struct utmpx changed #endif int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) { - struct utmp ut; + struct utmpx ut; int n, file = STDIN_FILENO; time_t t_tmp; off_t pos; @@ -87,11 +110,11 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) if (++n > 0) ut.ut_type = n != 3 ? n : SHUTDOWN_TIME; #else - if (strncmp(ut.ut_user, "shutdown", 8) == 0) + if (is_prefixed_with(ut.ut_user, "shutdown")) ut.ut_type = SHUTDOWN_TIME; - else if (strncmp(ut.ut_user, "reboot", 6) == 0) + else if (is_prefixed_with(ut.ut_user, "reboot")) ut.ut_type = BOOT_TIME; - else if (strncmp(ut.ut_user, "runlevel", 8) == 0) + else if (is_prefixed_with(ut.ut_user, "runlevel")) ut.ut_type = RUN_LVL; #endif } else { |