[BusyBox] Fwd: BBUnstable adduser.c patch
Vladimir N. Oleynik
dzo at simtreas.ru
Thu Jul 4 07:08:03 UTC 2002
Tito,
> > "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.
The impossibility of work with a /etc/groups is not a critical and fatal
error.
> 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.
passwd_wrapper() is called by last and consequently probably to not come back
in the main function.
> > 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?
It seems to me, this passwd_wrapper should not be changed.
> 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 ;-) )
system() calling /bin/sh.
It also will tell about all problems.
--w
vodz
More information about the busybox
mailing list