On Sun, 26 Oct 2025 08:18:26 +0200
Nir Lichtman <[email protected]> wrote:

> Problem: Currently the usage of `id` shows two unsupported options.
> 
> Solution: Remove unsupported options from usage.
> 
> Also, simplify a related if condition.
> 
> Signed-off-by: Nir Lichtman <[email protected]>
> ---
>  coreutils/id.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/coreutils/id.c b/coreutils/id.c
> index a4f178b..2f8f755 100644
> --- a/coreutils/id.c
> +++ b/coreutils/id.c
> @@ -33,7 +33,7 @@
>  /* BB_AUDIT SUSv3 compliant. */
>  
>  //usage:#define id_trivial_usage
> -//usage:       "[-ugGnr"IF_SELINUX("Z")"] [USER]"
> +//usage:       "[-ugG"IF_SELINUX("Z")"] [USER]"
Hi,
the -n option works:

./busybox id -un tito
tito
 ./busybox id -u tito
1000

For checking the -r option you can use the examples in
the test script in busybox/coreutils/  named id_test.sh:

#./busybox adduser -s /bin/true -g "" -H -D "provaprova" 
Adding group `provaprova' (GID 1002) ...
Done.
# chown provaprova:provaprova busybox
# ls -la busybox
-rwxr-xr-x 1 provaprova provaprova 1037904 Oct 26 09:24 busybox
# chmod u+s ./busybox
# ls -la busybox
-rwsr-xr-x 1 provaprova provaprova 1037904 Oct 26 09:24 busybox
# ./busybox id -u
1002
# ./busybox id -un
provaprova
# ./busybox id -unr
root
 
>  //usage:#define id_full_usage "\n\n"
>  //usage:       "Print information about USER or the current user\n"
>  //usage:     IF_SELINUX(
> @@ -42,8 +42,6 @@
>  //usage:     "\n     -u      User ID"
>  //usage:     "\n     -g      Group ID"
>  //usage:     "\n     -G      Supplementary group IDs"
> -//usage:     "\n     -n      Print names instead of numbers"
> -//usage:     "\n     -r      Print real ID instead of effective ID"
>  //usage:
>  //usage:#define id_example_usage
>  //usage:       "$ id\n"
> @@ -159,7 +157,7 @@ int id_main(int argc UNUSED_PARAM, char **argv)
>       security_context_t scontext = NULL;
>  #endif

I think that way  this code is compiled in even if the groups applet is 
not selected in config.

> -     if (ENABLE_GROUPS && (!ENABLE_ID || applet_name[0] == 'g')) {
> +     if (applet_name[0] == 'g') {
>               /* TODO: coreutils groups prepend "USER : " prefix,
>                * and accept many usernames. Example:
>                * # groups root root


Ciao,
Tito

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to