#include <sys/ioctl.h>
#include <fcntl.h>
+/* Hopefully, grp.h declares initgroups(). If we run into a platform
+ where it doesn't, we could consider declaring it here as well. */
+#include <grp.h>
+
/* This define is needed for Berkeley db v2 and above to
* make the header file expose the 'historical' ndbm APIs.
* We define it unconditionally because this is simple and
chdir ("/");
umask (0077);
+ if (geteuid() == 0) {
+ if (setgid (pw->pw_gid) != 0) {
+ adios ("setgid", "unable to set group to %ld", (long) pw->pw_gid);
+ }
+ initgroups (pw->pw_name, pw->pw_gid);
+ if (setuid (pw->pw_uid) != 0) {
+ adios ("setuid", "unable to set user to %ld", (long) pw->pw_uid);
+ }
+ }
+
if (info == NULL)
info = "";