[PATCH] Re: Question about adduser in Busybox

Denys Vlasenko vda.linux at googlemail.com
Sat Jan 9 21:01:11 UTC 2010


On Saturday 09 January 2010 21:53, Tito wrote:
> shouldn't we also do:
> 
> -- loginutils/adduser_orig.c	2010-01-09 21:39:03.000000000 +0100
> +++ loginutils/adduser.c	2010-01-09 21:51:38.000000000 +0100
> @@ -69,8 +69,11 @@
>  {
>  	char *cmd;
>  
> -	cmd = xasprintf("addgroup '%s' '%s'",
> -			p->pw_name, group_name);
> +	if (group_name) /* Add user to existing group */
> +		cmd = xasprintf("addgroup '%s' '%s'", p->pw_name, group_name);
> +	else	/* Add user to his own group with the first free gid found in passwd_study */
> +		cmd = xasprintf("addgroup -g %u '%s'", (unsigned)p->pw_gid, p->pw_name);
> +	/* Warning: to be compatible with external addgroup programs we should use --gid instead */
>  	system(cmd);
>  	free(cmd);
>  }
> @@ -191,8 +194,7 @@
>  	/* add to group */
>  	/* addgroup should be responsible for dealing w/ gshadow */
>  	/* if using a pre-existing group, don't create one */
> -    	if (usegroup)
> -		addgroup_wrapper(&pw, usegroup);
> +	addgroup_wrapper(&pw, usegroup);
>  
>  	/* clear the umask for this process so it doesn't
>  	 * screw up the permissions on the mkdir and chown. */
> 
> 
> Just compile tested. 

I don't know whether it would do the right thing, please run-test it.
--
vda


More information about the busybox mailing list