Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1385003621-10289-3-git-send-email-mforney@mforney.org>
Date: Wed, 20 Nov 2013 19:13:41 -0800
From: Michael Forney <mforney@...rney.org>
To: musl@...ts.openwall.com
Subject: [PATCH 2/2] shadow: Implement fgetspent

---
 src/passwd/fgetspent.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/passwd/fgetspent.c b/src/passwd/fgetspent.c
index 3dda784..47473bd 100644
--- a/src/passwd/fgetspent.c
+++ b/src/passwd/fgetspent.c
@@ -1,6 +1,15 @@
 #include "pwf.h"
+#include <pthread.h>
 
 struct spwd *fgetspent(FILE *f)
 {
-	return 0;
+	static char *line;
+	static struct spwd sp;
+	size_t size = 0;
+	struct spwd *res = 0;
+	int cs;
+	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+	if (getline(&line, &size, f) >= 0 && __parsespent(line, &sp) >= 0) res = &sp;
+	pthread_setcancelstate(cs, 0);
+	return res;
 }
-- 
1.8.4.2

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.