Apply a patch from Evin Robertson -- new pivot_root applet.
[oweals/busybox.git] / logname.c
index 12ebfbde69c9eeffa83ffb4ff75ac49fa77b915f..d9056c69da364cf37deb593b0eadd2896eaf2483 100644 (file)
--- a/logname.c
+++ b/logname.c
  *
  */
 
-#include "internal.h"
+#include "busybox.h"
 #include <stdio.h>
-
-static const char logname_usage[] = "logname\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
-       "\nPrint the name of the current user.\n"
-#endif
-       ;
+#include <stdlib.h>
+#include <unistd.h>
 
 extern int logname_main(int argc, char **argv)
 {
-       char *user = xmalloc(9);
+       char user[9];
 
        if (argc > 1)
                usage(logname_usage);
 
        my_getpwuid(user, geteuid());
-       if (user) {
+       if (*user) {
                puts(user);
-               exit(TRUE);
+               return EXIT_SUCCESS;
        }
-       errorMsg("no login name\n");
-       return(FALSE);
+       error_msg_and_die("no login name");
 }