*
*/
-#include "internal.h"
+#include "busybox.h"
#include <stdio.h>
-
-static const char logname_usage[] = "logname\n\n"
-
- "Print the name of the current user.\n";
+#include <stdlib.h>
+#include <unistd.h>
extern int logname_main(int argc, char **argv)
{
- char *cp;
+ char user[9];
if (argc > 1)
- usage(logname_usage);
+ show_usage();
- cp = getlogin();
- if (cp) {
- puts(cp);
- exit(TRUE);
+ my_getpwuid(user, geteuid());
+ if (*user) {
+ puts(user);
+ return EXIT_SUCCESS;
}
- fprintf(stderr, "%s: no login name\n", argv[0]);
- exit(FALSE);
+ error_msg_and_die("no login name");
}