diff options
author | nimisha <nimisha.sharad@msystechnologies.com> | 2017-12-18 17:44:15 +0530 |
---|---|---|
committer | nimisha <nimisha.sharad@msystechnologies.com> | 2018-01-24 15:00:37 +0530 |
commit | cc9766bd0a98b733eef3e9d40f3eac85a25f7e93 (patch) | |
tree | 5430925a36cbf05ed7949439a1e5686beeb1ea01 /lib/chef/win32 | |
parent | 9382e77576921af4dd22de00bf5537e55ed60ac1 (diff) | |
download | chef-cc9766bd0a98b733eef3e9d40f3eac85a25f7e93.tar.gz |
Brought back Chef::Win32::Security functional test for running as a non admin user
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
Diffstat (limited to 'lib/chef/win32')
-rw-r--r-- | lib/chef/win32/security.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb index b8fdf1716f..2cb19ad520 100644 --- a/lib/chef/win32/security.rb +++ b/lib/chef/win32/security.rb @@ -647,7 +647,14 @@ class Chef true else - process_token = open_current_process_token(TOKEN_READ) + # a regular user doesn't have privileges to call Chef::ReservedNames::Win32::Security.OpenProcessToken + # hence we return false if the open_current_process_token fails with `Access is denied.` error message. + begin + process_token = open_current_process_token(TOKEN_READ) + rescue Exception => run_error + return false if run_error.message.match(/Access is denied/) + Chef::ReservedNames::Win32::Error.raise! + end # display token elevation details token_elevation_type = get_token_information_elevation_type(process_token) |