libs/libc/pwd and libs/libc/grp: Modify to giet user/group data from /etc/passwd and /etc/group if so configurated.

Squashed commit of the following:

    Last minute clean-up
    libs/libc/grp/lib_find_grpfile.c:  Fix some problems found in testing.
    libs/libc/pwd:  Finishes off implementation using /etc/passwd.
    libs/libc/grp:  Finishes off implementation using /etc/group.
    libs/libc/pwd/lib_find_pwdfile.c:  Add logic to look up user information in /etc/passwd file, if available.
    libs/libc/grp/lib_find_grpfile.c:  Add logic to look up group information in /etc/group file, if available.
This commit is contained in:
Gregory Nutt
2019-08-04 13:32:36 -06:00
parent 19b81899de
commit 89da9f2fea
23 changed files with 1245 additions and 135 deletions
+14
View File
@@ -72,6 +72,19 @@
int getgrgid_r(gid_t gid, FAR struct group *grp, FAR char *buf, size_t buflen,
FAR struct group **result)
{
#ifdef CONFIG_LIBC_GROUP_FILE
int ret;
ret = grp_findby_gid(gid, grp, buf, buflen);
if (ret != 1)
{
*result = NULL;
return ret < 0 ? -ret : 0;
}
*result = grp;
return 0;
#else
if (gid != ROOT_GID)
{
/* The only known group is 'root', which has a gid of 0. Thus, report
@@ -84,4 +97,5 @@ int getgrgid_r(gid_t gid, FAR struct group *grp, FAR char *buf, size_t buflen,
return getgrbuf_r(ROOT_GID, ROOT_NAME, ROOT_PASSWD, grp, buf, buflen,
result);
#endif
}