1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 11:37:45 +00:00

Add getgrent() family of functions.

This commit is contained in:
Andreas Kling 2018-11-06 22:27:51 +01:00
parent e5e0bffd76
commit 90bab5ea71
5 changed files with 149 additions and 1 deletions

View file

@ -1,6 +1,7 @@
#include <LibC/unistd.h>
#include <LibC/stdio.h>
#include <LibC/pwd.h>
#include <LibC/grp.h>
int main(int c, char** v)
{
@ -8,8 +9,9 @@ int main(int c, char** v)
gid_t gid = getgid();
struct passwd* pw = getpwuid(uid);
struct group* gr = getgrgid(gid);
printf("uid=%u(%s), gid=%u, pid=%u\n", uid, pw ? pw->pw_name : "n/a", gid, getpid());
printf("uid=%u(%s), gid=%u(%s)\n", uid, pw ? pw->pw_name : "n/a", gid, gr ? gr->gr_name : "n/a", getpid());
return 0;
}