X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Flogname.c;h=3400c30d957bf5192ca6e2e48b340314347d541d;hb=5b492ee87614632e7bf5cd68fe0ce87dad30002a;hp=e2a74f932bb612908e3a800fa6e974def4b9d10b;hpb=20f40000864609866b51624351581d067b18469c;p=oweals%2Fbusybox.git diff --git a/coreutils/logname.c b/coreutils/logname.c index e2a74f932..3400c30d9 100644 --- a/coreutils/logname.c +++ b/coreutils/logname.c @@ -20,22 +20,23 @@ * a diagnostic message and an error return. */ -#include -#include -#include -#include "busybox.h" +#include "libbb.h" -extern int logname_main(int argc, char ATTRIBUTE_UNUSED **argv) +/* This is a NOFORK applet. Be very careful! */ + +int logname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; +int logname_main(int argc, char **argv UNUSED_PARAM) { - const char *p; + char buf[128]; if (argc > 1) { bb_show_usage(); } - if ((p = getlogin()) != NULL) { - puts(p); - bb_fflush_stdout_and_exit(EXIT_SUCCESS); + /* Using _r function - avoid pulling in static buffer from libc */ + if (getlogin_r(buf, sizeof(buf)) == 0) { + puts(buf); + return fflush(stdout); } bb_perror_msg_and_die("getlogin");