From 44a6f54fc420ac84987bbb12f2ccaa1efb3da8f2 Mon Sep 17 00:00:00 2001 From: quamrulmina Date: Mon, 12 Oct 2015 23:58:57 -0500 Subject: [PATCH] sshd updates USERDOMAIN env variable correctly USERDOMAIN environment variable was not being updated by sshd before s shell or subsystem was started, hence it was left pointing to local logged on user;'s domain. Now we set it correctly for the remote ssh user's domain or local account --- session.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/session.c b/session.c index afc3898..802354e 100644 --- a/session.c +++ b/session.c @@ -740,6 +740,11 @@ do_exec_no_pty(Session *s, const char *command) SetEnvironmentVariableW(L"HOME", s -> pw -> pw_dir); SetEnvironmentVariableW(L"USERPROFILE", s -> pw -> pw_dir); + // find the server name of the domain controller which created this token + GetDomainFromToken ( &hToken, buf, sizeof(buf)); + if (buf[0]) + SetEnvironmentVariable("USERDOMAIN", buf ); + /* * Set SSH_CLIENT variable. */