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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
$NetBSD: patch-ao,v 1.11 2008/04/08 06:36:47 taca Exp $
One more replacing 0 with ROOTUID is handled by using SUBST framework
because patch can't handle it when hpn-patch option is enabled.
So, don't simply update this file with mkpatch command.
--- session.c.orig 2007-08-16 13:28:04.000000000 +0000
+++ session.c
@@ -954,7 +954,7 @@ read_etc_default_login(char ***env, u_in
if (tmpenv == NULL)
return;
- if (uid == 0)
+ if (uid == ROOTUID)
var = child_get_env(tmpenv, "SUPATH");
else
var = child_get_env(tmpenv, "PATH");
@@ -1063,7 +1063,7 @@ do_setup_env(Session *s, const char *she
# endif /* HAVE_ETC_DEFAULT_LOGIN */
if (path == NULL || *path == '\0') {
child_set_env(&env, &envsize, "PATH",
- s->pw->pw_uid == 0 ?
+ s->pw->pw_uid == ROOTUID ?
SUPERUSER_PATH : _PATH_STDPATH);
}
# endif /* HAVE_CYGWIN */
@@ -1177,6 +1177,18 @@ do_setup_env(Session *s, const char *she
strcmp(pw->pw_dir, "/") ? pw->pw_dir : "");
read_environment_file(&env, &envsize, buf);
}
+
+#ifdef HAVE_INTERIX
+ {
+ /* copy standard Windows environment, then apply changes */
+ env_t *winenv = env_login(pw);
+ env_putarray(winenv, env, ENV_OVERRIDE);
+
+ /* swap over to altered environment as a traditional array */
+ env = env_array(winenv);
+ }
+#endif
+
if (debug_flag) {
/* dump the environment */
fprintf(stderr, "Environment:\n");
@@ -1201,8 +1213,9 @@ do_rc_files(Session *s, const char *shel
do_xauth =
s->display != NULL && s->auth_proto != NULL && s->auth_data != NULL;
- /* ignore _PATH_SSH_USER_RC for subsystems */
- if (!s->is_subsystem && (stat(_PATH_SSH_USER_RC, &st) >= 0)) {
+ /* ignore _PATH_SSH_USER_RC for subsystems and admin forced commands */
+ if (!s->is_subsystem && options.adm_forced_command == NULL &&
+ (stat(_PATH_SSH_USER_RC, &st) >= 0)) {
snprintf(cmd, sizeof cmd, "%s -c '%s %s'",
shell, _PATH_BSHELL, _PATH_SSH_USER_RC);
if (debug_flag)
@@ -1287,9 +1300,9 @@ do_nologin(struct passwd *pw)
void
do_setusercontext(struct passwd *pw)
{
-#ifndef HAVE_CYGWIN
+#if !defined(HAVE_CYGWIN) && !defined(HAVE_INTERIX)
if (getuid() == 0 || geteuid() == 0)
-#endif /* HAVE_CYGWIN */
+#endif /* !HAVE_CYGWIN && !HAVE_INTERIX */
{
#ifdef HAVE_SETPCRED
@@ -1331,11 +1344,13 @@ do_setusercontext(struct passwd *pw)
perror("setgid");
exit(1);
}
+# if !defined(HAVE_INTERIX)
/* Initialize the group list. */
if (initgroups(pw->pw_name, pw->pw_gid) < 0) {
perror("initgroups");
exit(1);
}
+# endif /* !HAVE_INTERIX */
endgrent();
#ifdef GSSAPI
if (options.gss_authentication) {
@@ -2086,7 +2101,7 @@ session_pty_cleanup2(Session *s)
record_logout(s->pid, s->tty, s->pw->pw_name);
/* Release the pseudo-tty. */
- if (getuid() == 0)
+ if (getuid() == ROOTUID)
pty_release(s->tty);
/*
|