Bug 6020

Summary: ls -l (long listing format) prints UID and GID instead of names
Product: Busybox Reporter: mytkalyk1990
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED WORKSFORME    
Severity: major CC: busybox-cvs
Priority: P5    
Version: 1.12.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description mytkalyk1990 2013-03-02 13:47:02 UTC
On Android, compiled by Stericson busybox 1.21.0 and 1.20.2

$ busybox ls -l 
gives the following output

drwxr-xr-x 3 0 0 0 Feb 28 18:16 acct

Notice the option -n was not specified.

The "$ toolbox ls -l" prints user names and group names properly.
Comment 1 Denys Vlasenko 2013-03-17 22:18:15 UTC
I need your help with debugging it further.

In ls.c, the usernames are printed by this code:

                        column += printf("%-8.8s %-8.8s ",
                                get_cached_username(dn->dn_uid),
                                get_cached_groupname(dn->dn_gid));

get_cached_username(uid), through several layers, calls getpwuid(uid).
Only if that fails (returns NULL) get_cached_username uses numeric uid.

If you have CONFIG_USE_BB_PWD_GRP=y, then it may be the reason, since IIRC android doesn't use standard /etc/passwd file, and BB_PWD_GRP code assumes they are in use. Turn CONFIG_USE_BB_PWD_GRP off.

If you _don_t_ have CONFIG_USE_BB_PWD_GRP=y, then please investigate with small test program why getpwuid(uid) fails. (Say, why getpwuid(0) doesn't return root's pw structure).