[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setgroups
From: |
Paul Jarc |
Subject: |
Re: setgroups |
Date: |
Fri, 18 Apr 2003 13:38:46 -0400 |
User-agent: |
Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3 (gnu/linux) |
Off-by-one bug in that last version.
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 18 Apr 2003 17:37:56 -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 18 Apr 2003 17:37:57 -0000
@@ -228,6 +228,41 @@
#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 (0, group_vec);
+
+ ngroups = SCM_VECTOR_LENGTH (group_vec);
+ size = ngroups * sizeof (GETGROUPS_T);
+ /* XXX - if (ngroups / sizeof (GETGROUPS_T) != size) out-of-range */
+ groups = scm_malloc (size);
+ for(i = ngroups - 1; i >= 0; i--)
+ {
+ SCM gid = SCM_VECTOR_REF (group_vec, i);
+ SCM_VALIDATE_INUM (0, gid);
+ groups [i] = SCM_INUM (gid);
+ }
+
+ 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