mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user