summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKapil Chouhan <kapil.chouhan@msystechnologies.com>2020-11-03 11:46:30 +0000
committerKapil Chouhan <kapil.chouhan@msystechnologies.com>2020-11-03 11:46:30 +0000
commite2250072a2dd5bab1c0fab3bd29f85e28eef6b43 (patch)
tree12f73abf4794f1b5256bc314591abe43ae5306e8
parent68709d3edd76ced2403c01185b1db7b3f3230dc7 (diff)
downloadmixlib-shellout-e2250072a2dd5bab1c0fab3bd29f85e28eef6b43.tar.gz
Load a user's profile, before retrieves the environment variables
Signed-off-by: Kapil Chouhan <kapil.chouhan@msystechnologies.com>
-rw-r--r--lib/mixlib/shellout/windows/core_ext.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/mixlib/shellout/windows/core_ext.rb b/lib/mixlib/shellout/windows/core_ext.rb
index b651df0..2cd0893 100644
--- a/lib/mixlib/shellout/windows/core_ext.rb
+++ b/lib/mixlib/shellout/windows/core_ext.rb
@@ -186,6 +186,14 @@ module Process
logon, passwd, domain = format_creds_from_hash(hash)
logon_type = hash["elevated"] ? LOGON32_LOGON_BATCH : LOGON32_LOGON_INTERACTIVE
token = logon_user(logon, domain, passwd, logon_type)
+ logon_ptr = FFI::MemoryPointer.from_string(logon)
+ profile = PROFILEINFO.new.tap do |dat|
+ dat[:dwSize] = dat.size
+ dat[:dwFlags] = 1
+ dat[:lpUserName] = logon_ptr
+ end
+
+ load_user_profile(token, profile.pointer)
env_list = retrieve_environment_variables(token)
end