Bug 6020 - ls -l (long listing format) prints UID and GID instead of names
Summary: ls -l (long listing format) prints UID and GID instead of names
Status: RESOLVED WORKSFORME
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.12.x
Hardware: Other Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-02 13:47 UTC by mytkalyk1990
Modified: 2017-07-21 17:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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).