summaryrefslogtreecommitdiff
path: root/src/grp/getgrnam.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/grp/getgrnam.c')
-rw-r--r--src/grp/getgrnam.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/grp/getgrnam.c b/src/grp/getgrnam.c
index c3598866..493a6b5a 100644
--- a/src/grp/getgrnam.c
+++ b/src/grp/getgrnam.c
@@ -1,10 +1,21 @@
#include "sys/types.h"
#include <grp.h>
-#include "stddef.h"
+#include "_grp.h"
+#include "string.h"
struct group * getgrnam(const char * name)
{
- (void)name;
+ struct group *grp = NULL;
+ setgrent();
+
+ while ((grp = getgrent()) != NULL) {
+ if (strcmp(name, grp->gr_name) == 0) {
+ endgrent();
+ return grp;
+ }
+ }
+
+ endgrent();
return NULL;
}