aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-08-26 22:36:02 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-08-26 22:36:02 +0000
commitca445ce9a882189413e0307bebf2a48e97fb4dca (patch)
tree5ae3cd745cea2f6358bf09c440383a1af66ee892
parentea5497b73d6c2d239a17e691f9efe88270d0df07 (diff)
downloadbusybox-w32-ca445ce9a882189413e0307bebf2a48e97fb4dca.tar.gz
busybox-w32-ca445ce9a882189413e0307bebf2a48e97fb4dca.tar.bz2
busybox-w32-ca445ce9a882189413e0307bebf2a48e97fb4dca.zip
Tito writes:
Hi, I've fixed also the issue of whoami cutting down usernames. This time I cannot send a diff because i don't know if my previous patches will be applied or not, so I send in the whole file. The changes I've made don't affect size but ensure that usernames of whatever lenght are correctly displayed. root@localhost:/dev/pts/3:/root/Desktop/busybox/coreutils# size whoami_orig.o text data bss dec hex filename 102 0 0 102 66 whoami_orig.o root@localhost:/dev/pts/3:/root/Desktop/busybox/coreutils# size whoami.o text data bss dec hex filename 93 0 0 93 5d whoami.o This should be applied even if the other patches aren't as this matches the behaviour of the GNU whoami. Thanks in advance, Ciao, Tito git-svn-id: svn://busybox.net/trunk/busybox@9168 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--coreutils/whoami.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/coreutils/whoami.c b/coreutils/whoami.c
index e2a03b1e9..c979b0dd9 100644
--- a/coreutils/whoami.c
+++ b/coreutils/whoami.c
@@ -26,18 +26,20 @@
26#include <stdlib.h> 26#include <stdlib.h>
27#include <unistd.h> 27#include <unistd.h>
28#include "busybox.h" 28#include "busybox.h"
29#include "pwd_.h"
30#include "grp_.h"
29 31
30extern int whoami_main(int argc, char **argv) 32extern int whoami_main(int argc, char **argv)
31{ 33{
32 char user[9]; 34 struct passwd *p;
33 uid_t uid; 35 uid_t uid;
34 36
35 if (argc > 1) 37 if (argc > 1)
36 bb_show_usage(); 38 bb_show_usage();
37 39
38 uid = geteuid(); 40 uid = geteuid();
39 if (my_getpwuid(user, uid, sizeof(user))) { 41 if((p = getpwuid(uid))!=NULL) {
40 puts(user); 42 puts(p->pw_name);
41 bb_fflush_stdout_and_exit(EXIT_SUCCESS); 43 bb_fflush_stdout_and_exit(EXIT_SUCCESS);
42 } 44 }
43 bb_error_msg_and_die("cannot find username for UID %u", (unsigned) uid); 45 bb_error_msg_and_die("cannot find username for UID %u", (unsigned) uid);