[PATCH] implement groups applet

Tito farmatito at tiscali.it
Sat Jun 18 19:33:26 UTC 2011



On Saturday 18 June 2011 18:10:13 Tanguy Pruvot wrote:
> 
> This applet is used by WinSCP on SCP login to know user groups
> Code only implements the "groups" standalone syntax
> 
> 
> GROUPS(1)                                                           User Commands                                                           GROUPS(1)
> 
> NAME
>        groups - print the groups a user is in
> 
> SYNOPSIS
>        groups [OPTION]... [USERNAME]...
> 
> DESCRIPTION
>        Print  group  memberships  for each USERNAME or, if no USERNAME is specified, for the current process (which may differ if the groups database
>        has changed).
> 
>        --help display this help and exit
> 
>        --version
>               output version information and exit
> 
> AUTHOR
>        Written by David MacKenzie and James Youngman.
> 
> REPORTING BUGS
>        Report groups bugs to bug-coreutils at gnu.org
>        GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
>        General help using GNU software: <http://www.gnu.org/gethelp/>
>        Report groups translation bugs to <http://translationproject.org/team/>
> 
> COPYRIGHT
>        Copyright © 2010 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
>        This is free software: you are free to change and redistribute it.  There is NO WARRANTY, to the extent permitted by law.
> 
> SEE ALSO
>        The full documentation for groups is maintained as a Texinfo manual.  If the info and groups programs are properly installed at your site, the
>        command
> 
>               info coreutils 'groups invocation'
> 
>        should give you access to the complete manual.
> 
> GNU coreutils 8.5                                                     April 2010                                                            GROUPS(1)


Hi,
couldn't this be achieved with a simple script: 

----------------------------------------------------------------------
#!/bin/sh
id -Gn
----------------------------------------------------------------------




BTW:
coreutils/groups.c: In function ‘groups_main’:
coreutils/groups.c:27: warning: ISO C90 forbids mixed declarations and code

BTW2: seems to work without memory allocation:

	char *id_argv[3];
	
	if (argv[1])
		bb_show_usage();


	id_argv[0] = (char *)"id";
	id_argv[1] = (char *)"-Gn";
	id_argv[2] = 0;

	return id_main(3, id_argv);


Ciao,
Tito






More information about the busybox mailing list