<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 7, 2014 at 10:25 AM, Rob Landley <span dir="ltr"><<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Haven't checked this in yet because it needs more testing, but patch is<br>
attached:<br>
<br>
GROUP is always toys.optargs[toys.optc-1] so let's move the getgrnam()<br>
before the two if/else cases so it's not duplicated. (Speaking of which,<br>
in the original code getgrnam() with the corresponding error message<br>
gets called twice in a row?)<br>
<br>
First question: are we ok hardwiring in the colon-separated /etc/groups<br>
file? (Because I thought android had some magic database instead?) I'm<br>
going to assume that's ok for now...<br>
<br>
I got confused by the man page for getgrnam pointing me to man 5 group,<br>
the second of which said that gr_mem is a comma separated list. But in<br>
the first it's a char *array[] which I _assume_ has a null terminator at<br>
the end, but it never SAYS so. (That's what the man page in Ubuntu 12.04<br></blockquote><div><br></div><div>The second one explain about the format of the /etc/group file, where gr_mem si a comma</div><div>separated list. The first one is the structure representation of the same, as a *array[]. </div>
<div>The null termination is not mentioned but is observed to be there.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
says, anyway. Maybe it's stale?) That tangent got me to write a<br>
comma_find() function that should at least be useful elsewhere. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The found == -1 part is using xprintf() instead of error_exit() because<br>
it wants to exit with status 0? And to print to stdout instead of<br>
stderr? And while we're at it, removing a user from a group that has no<br>
users in it doesn't produce this message either?<br>
<br>
Why do we call getpwnam() at all? Just to confirm it's an actual user?<br>
(Not being there is an error, can it be there and _not_ be a valid user?)<br></blockquote><div><br></div><div>when a user is added to the group, it is validated for its existence, On deletion</div><div>of a user from system it is removed from all the groups it belongs to, may be due</div>
<div>to this __it__ not being there in case of removal from group is treated as error.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ooh, _subtle_: due to xexec() not necessarily doing an actual exec()<br>
each time, we should call setpwent() before our first getpwent() because<br>
it's yet more process state that doesn't necessarily get reset between<br>
calls. (Possibly endpwent() should be part of the toy_init() stuff?) Or<br>
maybe endpwent() is better?<br>
<br>_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
<br></blockquote></div><br></div></div>