[BusyBox] Fwd: BBUnstable adduser.c patch

tito farmatito at tiscali.it
Thu Jul 4 06:27:05 UTC 2002


On Thursday 04 July 2002 11:01, you wrote:
> Tito,
>
> > ----------  Forwarded Message  ----------
> >
> > Subject: BBUnstable adduser.c patch
> > Date: Wed, 3 Jul 2002 22:02:53 +0200
> > From: tito <farmatito at tiscali.it>
> > To: <andersen at codepoet.org>
> >
> > Hi Erik
> > this little patch for adduser.c that i humbly submit to your attention
> > contains my previous fixes for the commandline parsing (which you should
> > check and optimize 'cause they looks too rustic to me ),
> > on the same time i standardized the behavior of the
> >
> >  addgroup_wrapper and passwd_wrapper functions
> >
> > making them both able to use busybox builtins and external progs
> > and improving the error handling
> > (these part of the patch looks good to me).
> > Let me know if you like it.......
>
> "Much simpler and easier to unerstand and be sure it is correct" (c) Erik.
> I like not strange patch:
> http://www.busybox.net/lists/busybox/2002-February/010972.html
>
> But, Why without fork() and "Exiting"?

I'm just learning so I used functions I Know well.
About the Exiting I just followed the previous code
because it seemed to me that the writing of the entry in /etc/groups
was mandatory and so on failure the whole action have to be aborted.
At the contrary in passwd_wrapper()  the error_msg gives an advice
to do things manaully and so I tought that the prog could go on.

> Now it is possible to simplify still:
>
> static void addgroup_wrapper(const char *login, gid_t gid)
> {
> 	char *cmd = xmalloc(strlen(login)+32);
>
> 	sprintf(cmd, "addgroup %s -g %d", login, gid);
> 	system(cmd);
> 	free(cmd);
> }

Looks good maybe it can be extended to passwd_wrapper() function?

Just a last question:
wouldn't it be a good thing to intercept the return value af the system()
function because in case of failure you won't know anything ( e.g. a missing 
link or external executable or a binary with an other name (on my Mandrake 
8.2 only groupadd exist) ...) so at least you may have a hint for trying to 
solve the problem.....
(my C Programming Manual hammers a lot about error handling ;-)   ) 

Ciao 

TITO
>
>
>
> --w
> vodz
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/mailman/listinfo/busybox



More information about the busybox mailing list