Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2002 22:00:28 +0000
From:      Mark Murray <mark@grondar.za>
To:        audit@freebsd.org
Subject:   Fixes for gid_t usage in libc
Message-ID:  <200201172200.g0HM0St19717@grimreaper.grondar.org>

next in thread | raw e-mail | index | archive | help
Hi

Reviews please?

This fixes some places where groups are handled in integers
rather than gid_t's.

I've been running it for more than a month.

M

Index: include/grp.h
===================================================================
RCS file: /home/ncvs/src/include/grp.h,v
retrieving revision 1.3
diff -u -d -r1.3 grp.h
--- include/grp.h	7 May 1997 19:59:59 -0000	1.3
+++ include/grp.h	7 Dec 2001 20:48:47 -0000
@@ -48,7 +48,7 @@
 struct group {
 	char	*gr_name;		/* group name */
 	char	*gr_passwd;		/* group password */
-	int	gr_gid;			/* group id */
+	gid_t	gr_gid;			/* group id */
 	char	**gr_mem;		/* group members */
 };
 
Index: include/unistd.h
===================================================================
RCS file: /home/ncvs/src/include/unistd.h,v
retrieving revision 1.46
diff -u -d -r1.46 unistd.h
--- include/unistd.h	22 Dec 2001 05:18:37 -0000	1.46
+++ include/unistd.h	22 Dec 2001 14:23:04 -0000
@@ -140,7 +140,7 @@
 #endif
 int	 getdomainname __P((char *, int));
 int	 getdtablesize __P((void));
-int	 getgrouplist __P((const char *, int, int *, int *));
+int	 getgrouplist __P((const char *, gid_t, gid_t *, int *));
 long	 gethostid __P((void));
 int	 gethostname __P((char *, int));
 int	 getlogin_r __P((char *, int));
@@ -154,7 +154,7 @@
 int	 getsid __P((pid_t _pid));
 char	*getusershell __P((void));
 char	*getwd __P((char *));			/* obsoleted by getcwd() */
-int	 initgroups __P((const char *, int));
+int	 initgroups __P((const char *, gid_t));
 int	 iruserok __P((unsigned long, int, const char *, const char *));
 int	 iruserok_sa __P((const void *, int, int, const char *, const char *));
 int	 issetugid __P((void));
Index: lib/libc/gen/getgrent.3
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/getgrent.3,v
retrieving revision 1.17
diff -u -d -r1.17 getgrent.3
--- lib/libc/gen/getgrent.3	14 Jan 2002 16:59:00 -0000	1.17
+++ lib/libc/gen/getgrent.3	15 Jan 2002 18:55:26 -0000
@@ -78,7 +78,7 @@
 struct group {
 	char	*gr_name;	/* group name */
 	char	*gr_passwd;	/* group password */
-	int	gr_gid;		/* group id */
+	gid_t	gr_gid;		/* group id */
 	char	**gr_mem;	/* group members */
 };
 .Ed
Index: lib/libc/gen/getgrouplist.3
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/getgrouplist.3,v
retrieving revision 1.7
diff -u -d -r1.7 getgrouplist.3
--- lib/libc/gen/getgrouplist.3	1 Oct 2001 16:08:51 -0000	1.7
+++ lib/libc/gen/getgrouplist.3	14 Dec 2001 15:21:22 -0000
@@ -43,7 +43,7 @@
 .Sh SYNOPSIS
 .In unistd.h
 .Ft int
-.Fn getgrouplist "const char *name" "int basegid" "int *groups" "int *ngroups"
+.Fn getgrouplist "const char *name" "gid_t basegid" "gid_t *groups" "int *ngroups"
 .Sh DESCRIPTION
 The
 .Fn getgrouplist
@@ -56,7 +56,7 @@
 Typically this value is given as
 the group number from the password file.
 .Pp
-The resulting group list is returned in the integer array pointed to by
+The resulting group list is returned in the array pointed to by
 .Fa groups .
 The caller specifies the size of the
 .Fa groups
Index: lib/libc/gen/getgrouplist.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/getgrouplist.c,v
retrieving revision 1.7
diff -u -d -r1.7 getgrouplist.c
--- lib/libc/gen/getgrouplist.c	12 Mar 1997 14:54:22 -0000	1.7
+++ lib/libc/gen/getgrouplist.c	14 Dec 2001 15:29:19 -0000
@@ -31,9 +31,12 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)getgrouplist.c	8.2 (Berkeley) 12/8/94";
-#endif /* LIBC_SCCS and not lint */
+#endif
 
 /*
  * get credential
@@ -45,12 +48,12 @@
 int
 getgrouplist(uname, agroup, groups, grpcnt)
 	const char *uname;
-	int agroup;
-	register int *groups;
+	gid_t agroup;
+	gid_t *groups;
 	int *grpcnt;
 {
-	register struct group *grp;
-	register int i, ngroups;
+	struct group *grp;
+	int i, ngroups;
 	int ret, maxgroups;
 
 	ret = 0;
Index: lib/libc/gen/initgroups.3
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/initgroups.3,v
retrieving revision 1.11
diff -u -d -r1.11 initgroups.3
--- lib/libc/gen/initgroups.3	28 Nov 2001 10:55:02 -0000	1.11
+++ lib/libc/gen/initgroups.3	14 Dec 2001 15:18:14 -0000
@@ -43,7 +43,7 @@
 .Sh SYNOPSIS
 .In unistd.h
 .Ft int
-.Fn initgroups "const char *name" "int basegid"
+.Fn initgroups "const char *name" "gid_t basegid"
 .Sh DESCRIPTION
 The
 .Fn initgroups
Index: lib/libc/gen/initgroups.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/initgroups.c,v
retrieving revision 1.5
diff -u -d -r1.5 initgroups.c
--- lib/libc/gen/initgroups.c	28 Nov 2001 10:55:02 -0000	1.5
+++ lib/libc/gen/initgroups.c	14 Dec 2001 15:30:10 -0000
@@ -31,14 +31,12 @@
  * SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 #if defined(LIBC_SCCS) && !defined(lint)
-#if 0
 static char sccsid[] = "@(#)initgroups.c	8.1 (Berkeley) 6/4/93";
-#else
-static const char rcsid[] =
-  "$FreeBSD: src/lib/libc/gen/initgroups.c,v 1.5 2001/11/28 10:55:02 tobez Exp $";
 #endif
-#endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 
@@ -51,7 +49,7 @@
 int
 initgroups(uname, agroup)
 	const char *uname;
-	int agroup;
+	gid_t agroup;
 {
 	int groups[NGROUPS], ngroups;
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201172200.g0HM0St19717>