diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-10 15:43:37 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-04-10 15:43:37 +0000 |
commit | 99912ca733dd960f5589227fd999c86e73c8e894 (patch) | |
tree | 9df947fc08884d498cf76a02204d74b121064134 /coreutils/logname.c | |
parent | ff131b980d524a33d8a43cefe65e14f64a43f2da (diff) | |
download | busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.gz busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.bz2 busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.zip |
audit small applets and mark some of them as NOFORK.
Put big scary warnings in relevant places.
Diffstat (limited to 'coreutils/logname.c')
-rw-r--r-- | coreutils/logname.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/coreutils/logname.c b/coreutils/logname.c index 743e2291c..aba6ce3c6 100644 --- a/coreutils/logname.c +++ b/coreutils/logname.c | |||
@@ -20,23 +20,23 @@ | |||
20 | * a diagnostic message and an error return. | 20 | * a diagnostic message and an error return. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <unistd.h> | ||
26 | #include "busybox.h" | 23 | #include "busybox.h" |
27 | 24 | ||
25 | /* This is a NOFORK applet. Be very careful! */ | ||
26 | |||
28 | int logname_main(int argc, char ATTRIBUTE_UNUSED **argv); | 27 | int logname_main(int argc, char ATTRIBUTE_UNUSED **argv); |
29 | int logname_main(int argc, char ATTRIBUTE_UNUSED **argv) | 28 | int logname_main(int argc, char ATTRIBUTE_UNUSED **argv) |
30 | { | 29 | { |
31 | const char *p; | 30 | char buf[128]; |
32 | 31 | ||
33 | if (argc > 1) { | 32 | if (argc > 1) { |
34 | bb_show_usage(); | 33 | bb_show_usage(); |
35 | } | 34 | } |
36 | 35 | ||
37 | if ((p = getlogin()) != NULL) { | 36 | /* Using _r function - avoid pulling in static buffer from libc */ |
38 | puts(p); | 37 | if (getlogin_r(buf, sizeof(buf)) == 0) { |
39 | fflush_stdout_and_exit(EXIT_SUCCESS); | 38 | puts(buf); |
39 | return fflush(stdout); | ||
40 | } | 40 | } |
41 | 41 | ||
42 | bb_perror_msg_and_die("getlogin"); | 42 | bb_perror_msg_and_die("getlogin"); |