/*
- * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2010, 2011, 2013 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
#include "missing.h"
-#ifdef HAVE_GETGRSET
+#if defined(HAVE_GETGRSET)
/*
* BSD-compatible getgrouplist(3) using getgrset(3)
*/
return rval;
}
-#else /* HAVE_GETGRSET */
+#elif defined(HAVE__GETGROUPSBYMEMBER)
+
+/*
+ * BSD-compatible getgrouplist(3) using _getgroupsbymember(3)
+ */
+int
+getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp)
+{
+ int ngroups, grpsize = *ngroupsp;
+ int rval = -1;
+
+ if (grpsize > 0) {
+ /* We support BSD semantics where the first element is the base gid */
+ groups[0] = basegid;
+
+ /* The last arg is 1 because we already filled in the base gid. */
+ ngroups = _getgroupsbymember(name, groups, grpsize, 1);
+ if (ngroups != -1) {
+ rval = 0;
+ *ngroupsp = ngroups;
+ }
+ }
+ return rval;
+}
+
+#else /* !HAVE_GETGRSET && !HAVE__GETGROUPSBYMEMBER */
/*
* BSD-compatible getgrouplist(3) using getgrent(3)
return rval;
}
-#endif /* HAVE_GETGRSET */
+#endif /* !HAVE_GETGRSET && !HAVE__GETGROUPSBYMEMBER */
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
+/* Define to 1 if you have the `_getgroupsbymember' function. */
+#undef HAVE__GETGROUPSBYMEMBER
+
/* Define to 1 if you have the `_getpty' function. */
#undef HAVE__GETPTY
OS_INIT=os_init_solaris
SUDO_OBJS="${SUDO_OBJS} solaris.o"
+ # For implementing getgrouplist()
+ for ac_func in _getgroupsbymember
+do :
+ ac_fn_c_check_func "$LINENO" "_getgroupsbymember" "ac_cv_func__getgroupsbymember"
+if test "x$ac_cv_func__getgroupsbymember" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE__GETGROUPSBYMEMBER 1
+_ACEOF
+
+fi
+done
+
+
# To get the crypt(3) prototype (so we pass -Wall)
OSDEFS="${OSDEFS} -D__EXTENSIONS__"
# AFS support needs -lucb
OS_INIT=os_init_solaris
SUDO_OBJS="${SUDO_OBJS} solaris.o"
+ # For implementing getgrouplist()
+ AC_CHECK_FUNCS(_getgroupsbymember)
+
# To get the crypt(3) prototype (so we pass -Wall)
OSDEFS="${OSDEFS} -D__EXTENSIONS__"
# AFS support needs -lucb