From cc9766bd0a98b733eef3e9d40f3eac85a25f7e93 Mon Sep 17 00:00:00 2001 From: nimisha Date: Mon, 18 Dec 2017 17:44:15 +0530 Subject: Brought back Chef::Win32::Security functional test for running as a non admin user Signed-off-by: nimisha --- lib/chef/win32/security.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/chef/win32/security.rb') 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) -- cgit v1.2.1