summaryrefslogtreecommitdiff
path: root/lib/chef/win32
diff options
context:
space:
mode:
authorAnton Kvashenkin <ak@gfoil.ru>2018-09-24 21:57:12 +0300
committerAnton Kvashenkin <ak@gfoil.ru>2018-10-16 22:46:27 +0300
commitb2f02d134ce96599416f1c3a5ab045cb261cc883 (patch)
tree2a692fa9ef10c771d71f2c98918648012c504a14 /lib/chef/win32
parent1a793e91ed42e8e36f748c16ceda3874205f9968 (diff)
downloadchef-b2f02d134ce96599416f1c3a5ab045cb261cc883.tar.gz
Add support for localized system account to windows_task resource
Signed-off-by: Anton Kvashenkin <anton.jugatsu@gmail.com>
Diffstat (limited to 'lib/chef/win32')
-rw-r--r--lib/chef/win32/security/sid.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index b551cbd2e3..43efc6e3fe 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -246,6 +246,45 @@ class Chef
SID.from_account("#{::ENV['USERDOMAIN']}\\#{::ENV['USERNAME']}")
end
+ SERVICE_ACCOUNT_USERS = [self.LocalSystem,
+ self.NtLocal,
+ self.NtNetwork].flat_map do |user_type|
+ [user_type.account_simple_name.upcase,
+ user_type.account_name.upcase]
+ end.freeze
+
+ BUILT_IN_GROUPS = [self.BuiltinAdministrators,
+ self.BuiltinUsers, self.Guests].flat_map do |user_type|
+ [user_type.account_simple_name.upcase,
+ user_type.account_name.upcase]
+ end.freeze
+
+ SYSTEM_USER = SERVICE_ACCOUNT_USERS + BUILT_IN_GROUPS
+
+ # Сheck if the user belongs to service accounts category
+ #
+ # @return [Boolean] True or False
+ #
+ def self.service_account_user?(user)
+ SERVICE_ACCOUNT_USERS.include?(user.to_s.upcase)
+ end
+
+ # Сheck if the user is in builtin system group
+ #
+ # @return [Boolean] True or False
+ #
+ def self.group_user?(user)
+ BUILT_IN_GROUPS.include?(user.to_s.upcase)
+ end
+
+ # Сheck if the user belongs to system users category
+ #
+ # @return [Boolean] True or False
+ #
+ def self.system_user?(user)
+ SYSTEM_USER.include?(user.to_s.upcase)
+ end
+
# See https://technet.microsoft.com/en-us/library/cc961992.aspx
# In practice, this is SID.Administrators if the current_user is an admin (even if not
# running elevated), and is current_user otherwise.