From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: prj@po.cwru.edu (Paul Jarc) Newsgroups: gmane.lisp.guile.devel Subject: Re: setgroups Date: Thu, 17 Apr 2003 19:20:12 -0400 Organization: What did you have in mind? A short, blunt, human pyramid? Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <87brz4dagq.fsf@raven.i.defaultvalue.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1050621893 903 80.91.224.249 (17 Apr 2003 23:24:53 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 17 Apr 2003 23:24:53 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Apr 18 01:24:51 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 196Ijt-0000DQ-00 for ; Fri, 18 Apr 2003 01:24:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 196Ij7-0005KC-05 for guile-devel@m.gmane.org; Thu, 17 Apr 2003 19:23:33 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 196Ii7-0004A9-00 for guile-devel@gnu.org; Thu, 17 Apr 2003 19:22:31 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 196Ihp-0003to-00 for guile-devel@gnu.org; Thu, 17 Apr 2003 19:22:14 -0400 Original-Received: from multivac.student.cwru.edu ([129.22.114.26] helo=multivac.cwru.edu) by monty-python.gnu.org with smtp (Exim 4.10.13) id 196Ift-0003RU-00 for guile-devel@gnu.org; Thu, 17 Apr 2003 19:20:13 -0400 Original-Received: (qmail 15306 invoked by uid 500); 17 Apr 2003 23:20:35 -0000 Original-To: guile-devel@gnu.org Mail-Followup-To: guile-devel@gnu.org In-Reply-To: <87brz4dagq.fsf@raven.i.defaultvalue.org> (Rob Browning's message of "Thu, 17 Apr 2003 17:29:25 -0500") Original-Lines: 67 User-Agent: Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2180 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2180 Ok, here's a patch for setgroups. It's my first time writing Guile C code, so someone should check it carefully. I used a vector argument just because that's what getgroups returns. Index: configure.in =================================================================== RCS file: /cvsroot/guile/guile/guile-core/configure.in,v retrieving revision 1.213 diff -u -r1.213 configure.in --- configure.in 7 Apr 2003 17:31:02 -0000 1.213 +++ configure.in 17 Apr 2003 23:11:05 -0000 @@ -583,7 +583,7 @@ [Define if the system supports Unix-domain (file-domain) sockets.]) fi -AC_CHECK_FUNCS(socketpair getgroups setpwent pause tzset) +AC_CHECK_FUNCS(socketpair getgroups setgroups setpwent pause tzset) AC_CHECK_FUNCS(sethostent gethostent endhostent dnl setnetent getnetent endnetent dnl Index: libguile/posix.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/posix.c,v retrieving revision 1.112 diff -u -r1.112 posix.c --- libguile/posix.c 5 Apr 2003 19:10:22 -0000 1.112 +++ libguile/posix.c 17 Apr 2003 23:11:05 -0000 @@ -228,6 +228,36 @@ #undef FUNC_NAME #endif +#ifdef HAVE_SETGROUPS +SCM_DEFINE (scm_setgroups, "setgroups", 1, 0, 0, + (SCM group_vec), + "Set the supplementary group IDs to those found in the vector\n" + "argument.") +#define FUNC_NAME s_scm_setgroups +{ + size_t ngroups; + size_t size; + size_t i; + int result; + GETGROUPS_T *groups; + + SCM_VALIDATE_VECTOR (1, group_vec); + + ngroups = SCM_VECTOR_LENGTH (group_vec); + size = ngroups * sizeof (GETGROUPS_T); + groups = scm_malloc (size); + for(i = ngroups; i >= 0; i--) + groups [i] = SCM_INUM (SCM_VECTOR_REF (group_vec, i)); + + result = setgroups (ngroups, groups); + free (groups); + if (result < 0) + SCM_SYSERROR; + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME +#endif + #ifdef HAVE_GETPWENT SCM_DEFINE (scm_getpwuid, "getpw", 0, 1, 0, (SCM user), paul _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel