summaryrefslogtreecommitdiff
path: root/sysutils/coreutils/patches/patch-ad
blob: d4d811ef193484345f0a08640520c803ce10e73f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$NetBSD: patch-ad,v 1.1 2005/03/21 14:44:08 tv Exp $

--- src/su.c.orig	Wed Jan 21 17:27:02 2004
+++ src/su.c
@@ -141,6 +141,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 *getpass ();
 char *getusershell ();
@@ -291,9 +297,13 @@ correct_password (const struct passwd *p
       error (0, 0, _("getpass: cannot open /dev/tty"));
       return 0;
     }
+#ifdef __INTERIX
+  return setuser (pw->pw_name, unencrypted, SU_CHECK) == 0;
+#else
   encrypted = crypt (unencrypted, correct);
   memset (unencrypted, 0, strlen (unencrypted));
   return strcmp (encrypted, correct) == 0;
+#endif
 }
 
 /* Update `environ' for the new shell based on PW, with SHELL being
@@ -343,6 +353,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)
@@ -353,6 +366,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.