From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2068 Path: news.gmane.org!not-for-mail From: Isaac Dunham Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] fgetgrent Date: Tue, 9 Oct 2012 22:42:15 -0700 Message-ID: <20121009224215.114783b2.idunham@lavabit.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Tue__9_Oct_2012_22_42_15_-0700_E5F21p8_FF7cZafR" X-Trace: ger.gmane.org 1349847763 28194 80.91.229.3 (10 Oct 2012 05:42:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Oct 2012 05:42:43 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2069-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 10 07:42:50 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TLp4A-00020s-6f for gllmg-musl@plane.gmane.org; Wed, 10 Oct 2012 07:42:46 +0200 Original-Received: (qmail 11450 invoked by uid 550); 10 Oct 2012 05:42:39 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 11442 invoked from network); 10 Oct 2012 05:42:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=MxIm2XOllqZNq5pXzfTEH61rvqE9AHtjvRKLXCwrwVNacymS9CIhplWYQ8azLGh/ua7ryh25EJE6LjYF92/AfxAWNwpnINY1g/UChps+1lPmo0a+uXlOAYVfPId0sIBbg8PlrUJ3g/etv0jlRgn59A2jT2yymkqhsxXsT+bByeQ=; h=Date:From:To:Subject:Message-Id:X-Mailer:Mime-Version:Content-Type; X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Xref: news.gmane.org gmane.linux.lib.musl.general:2068 Archived-At: This is a multi-part message in MIME format. --Multipart=_Tue__9_Oct_2012_22_42_15_-0700_E5F21p8_FF7cZafR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit The attached patch adds support for fgetgrent; which is basically a version of getgrent that expects you to open the right file yourself. The main use is software for administering multiple systems; I added it to compile heirloom-pkgtools, which provide that functionality. One could redefine getgrent to call __fgetgrent, but I was more eager to get the software at the time. -- Isaac Dunham --Multipart=_Tue__9_Oct_2012_22_42_15_-0700_E5F21p8_FF7cZafR Content-Type: text/x-diff; name="fgetgrent.diff" Content-Disposition: attachment; filename="fgetgrent.diff" Content-Transfer-Encoding: 7bit diff --git a/include/grp.h b/include/grp.h index 030d7f8..cb40e07 100644 --- a/include/grp.h +++ b/include/grp.h @@ -30,6 +30,10 @@ struct group *getgrent(void); void endgrent(void); void setgrent(void); +#ifdef _GNU_SOURCE +struct group *fgetgrent(FILE *stream); +#endif + #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) int getgrouplist(const char *, gid_t, gid_t *, int *); int setgroups(size_t, const gid_t *); diff --git a/src/passwd/getgrent.c b/src/passwd/getgrent.c index 429a3e5..d59bcb6 100644 --- a/src/passwd/getgrent.c +++ b/src/passwd/getgrent.c @@ -10,6 +10,17 @@ void setgrent() weak_alias(setgrent, endgrent); +struct group *__fgetgrent(FILE *f) +{ + static char *line, **mem; + static struct group gr; + size_t size=0, nmem=0; + if (!f) return 0; + return __getgrent_a(f, &gr, &line, &size, &mem, &nmem); +} + +weak_alias(__fgetgrent,fgetgrent); + struct group *getgrent() { static char *line, **mem; --Multipart=_Tue__9_Oct_2012_22_42_15_-0700_E5F21p8_FF7cZafR--