$NetBSD: patch-ao,v 1.8 2006/02/12 00:13:55 salo Exp $ --- session.c.orig 2005-12-23 21:59:12.000000000 -0600 +++ session.c 2006-02-08 21:07:01.000000000 -0600 @@ -322,7 +322,7 @@ break; } debug("Received TCP/IP port forwarding request."); - channel_input_port_forward_request(s->pw->pw_uid == 0, options.gateway_ports); + channel_input_port_forward_request(s->pw->pw_uid == ROOTUID, options.gateway_ports); success = 1; break; @@ -921,7 +921,7 @@ if (tmpenv == NULL) return; - if (uid == 0) + if (uid == ROOTUID) var = child_get_env(tmpenv, "SUPATH"); else var = child_get_env(tmpenv, "PATH"); @@ -1027,7 +1027,7 @@ # 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 */ @@ -1141,6 +1141,18 @@ 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"); @@ -1251,9 +1263,9 @@ 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 @@ -1295,11 +1307,13 @@ 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) { @@ -2045,7 +2059,7 @@ record_logout(s->pid, s->tty, s->pw->pw_name); /* Release the pseudo-tty. */ - if (getuid() == 0) + if (getuid() == ROOTUID) pty_release(s->tty); /*