summaryrefslogtreecommitdiff
path: root/source3/lib/system.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-09-29 20:24:17 +0000
committerJeremy Allison <jra@samba.org>1998-09-29 20:24:17 +0000
commit9066025a8a4afe1f7f559c455d86fc023792ed17 (patch)
tree6ced773fa584a81c9a0fe957cac357c1f8a9aa2d /source3/lib/system.c
parent282eb4f3e8ea2f19c5609bc498d24a68a1ca48a5 (diff)
downloadsamba-9066025a8a4afe1f7f559c455d86fc023792ed17.tar.gz
samba-9066025a8a4afe1f7f559c455d86fc023792ed17.tar.bz2
samba-9066025a8a4afe1f7f559c455d86fc023792ed17.zip
Got very strict about the differences and uses of
uid_t, gid_t and vuid. Added sys_getgroups() to get around the int * return problem. Set correct datatypes for all uid, gid and vuid variables. Jeremy. (This used to be commit e570db46fc3a78e499523fd342e9a34cebb18998)
Diffstat (limited to 'source3/lib/system.c')
-rw-r--r--source3/lib/system.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index f474633dd1..cae688eb4c 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -464,7 +464,7 @@ char *dos_getwd(char *s)
/*******************************************************************
chown isn't used much but OS/2 doesn't have it
********************************************************************/
-int sys_chown(char *fname,int uid,int gid)
+int sys_chown(char *fname,uid_t uid,gid_t gid)
{
#ifndef HAVE_CHOWN
static int done;
@@ -634,3 +634,51 @@ void sys_srandom(unsigned int seed)
exit(1);
#endif
}
+
+/**************************************************************************
+ Wrapper for getgroups. Deals with broken (int) case.
+****************************************************************************/
+
+int sys_getgroups(int setlen, gid_t *gidset)
+{
+#if !defined(HAVE_BROKEN_GETGROUPS)
+ return getgroups(setlen, gidset);
+#else
+
+ GID_T gid;
+ GID_T *group_list;
+ int i, ngroups;
+
+ if(setlen == 0) {
+ return getgroups(setlen, &gid);
+ }
+
+ /*
+ * Broken case. We need to allocate a
+ * GID_T array of size setlen.
+ */
+
+ if(setlen < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if((group_list = (GID_T *)malloc(setlen * sizoef(GID_T))) == NULL) {
+ DEBUG(0,("sys_getgroups: Malloc fail.\n"));
+ return -1;
+ }
+
+ if((ngroups = getgroups(setlen, group_list)) < 0) {
+ int saved_errno = errno;
+ free((char *)group_list);
+ errno = saved_errno;
+ return -1;
+ }
+
+ for(i = 0; i < ngroups; i++)
+ gidset[i] = (gid_t)group_list[i];
+
+ free((char *)group_list);
+ return ngroups;
+#endif /* HAVE_BROKEN_GETGROUPS */
+}