$NetBSD: patch-ad,v 1.2 2007/07/18 11:25:20 tnn Exp $

--- src/su.c.orig	2007-03-18 22:36:43.000000000 +0100
+++ src/su.c
@@ -119,6 +119,12 @@
 /* The user to become if none is specified.  */
 #define DEFAULT_USER "root"
 
+#ifdef __INTERIX
+# include <interix/security.h>
+# undef DEFAULT_USER
+# define DEFAULT_USER (strdup(getpwuid(197108)->pw_name))
+#endif
+
 char *crypt ();
 char *getusershell ();
 void endusershell ();
@@ -245,9 +251,13 @@ correct_password (const struct passwd *p
       error (0, 0, _("getpass: cannot open /dev/tty"));
       return false;
     }
+#ifdef __INTERIX
+  return setuser (pw->pw_name, unencrypted, SU_CHECK) == 0;
+#else
   encrypted = crypt (unencrypted, correct);
   memset (unencrypted, 0, strlen (unencrypted));
   return STREQ (encrypted, correct);
+#endif
 }
 
 /* Update `environ' for the new shell based on PW, with SHELL being
@@ -297,6 +307,9 @@ modify_environment (const struct passwd 
 static void
 change_identity (const struct passwd *pw)
 {
+#ifdef __INTERIX
+  setuser (pw->pw_name, NULL, SU_COMPLETE);
+#else
 #ifdef HAVE_INITGROUPS
   errno = 0;
   if (initgroups (pw->pw_name, pw->pw_gid) == -1)
@@ -307,6 +320,7 @@ change_identity (const struct passwd *pw
     error (EXIT_FAIL, errno, _("cannot set group id"));
   if (setuid (pw->pw_uid))
     error (EXIT_FAIL, errno, _("cannot set user id"));
+#endif
 }
 
 /* Run SHELL, or DEFAULT_SHELL if SHELL is empty.
