$NetBSD: patch-ad,v 1.3 2008/03/08 01:06:52 tnn Exp $ --- src/su.c.orig 2007-11-25 14:23:31.000000000 +0100 +++ src/su.c @@ -118,6 +118,12 @@ /* The user to become if none is specified. */ #define DEFAULT_USER "root" +#ifdef __INTERIX +# include +# undef DEFAULT_USER +# define DEFAULT_USER (strdup(getpwuid(197108)->pw_name)) +#endif + char *crypt (); char *getusershell (); void endusershell (); @@ -244,9 +250,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 @@ -296,6 +306,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) @@ -306,6 +319,7 @@ change_identity (const struct passwd *pw error (EXIT_FAILURE, errno, _("cannot set group id")); if (setuid (pw->pw_uid)) error (EXIT_FAILURE, errno, _("cannot set user id")); +#endif } /* Run SHELL, or DEFAULT_SHELL if SHELL is empty.