class Serverkit::Resources::User
Public Instance Methods
apply()
click to toggle source
@note Override
# File lib/serverkit/resources/user.rb, line 16 def apply if has_correct_user? update_user_encrypted_password unless has_correct_password? update_user_gid unless has_correct_gid? update_user_home_directory unless has_correct_home_directory? update_user_login_shell unless has_correct_login_shell? update_user_uid unless has_correct_uid? else add_user end end
check()
click to toggle source
@note Override
# File lib/serverkit/resources/user.rb, line 29 def check if !has_correct_user? false elsif !has_correct_gid? false elsif !has_correct_home_directory? false elsif !has_correct_password? false elsif !has_correct_login_shell? false elsif !has_correct_uid? false else true end end
Private Instance Methods
add_user()
click to toggle source
# File lib/serverkit/resources/user.rb, line 49 def add_user run_command_from_identifier( :add_user, name, gid: gid, home_directory: home, password: encrypted_password, shell: shell, system_user: system, uid: uid, ) end
encrypted_password()
click to toggle source
@return [String, nil]
# File lib/serverkit/resources/user.rb, line 63 def encrypted_password unless password.nil? @encrypted_password ||= UnixCrypt::SHA512.build(password) end end
get_remote_encrypted_password()
click to toggle source
# File lib/serverkit/resources/user.rb, line 69 def get_remote_encrypted_password run_command_from_identifier(:get_user_encrypted_password, name).stdout end
has_correct_gid?()
click to toggle source
# File lib/serverkit/resources/user.rb, line 73 def has_correct_gid? gid.nil? || check_command_from_identifier(:check_user_belongs_to_group, name, gid) end
has_correct_home_directory?()
click to toggle source
# File lib/serverkit/resources/user.rb, line 77 def has_correct_home_directory? home.nil? || check_command_from_identifier(:check_user_has_home_directory, name, home) end
has_correct_login_shell?()
click to toggle source
# File lib/serverkit/resources/user.rb, line 81 def has_correct_login_shell? shell.nil? || check_command_from_identifier(:check_user_has_login_shell, name, shell) end
has_correct_password?()
click to toggle source
# File lib/serverkit/resources/user.rb, line 85 def has_correct_password? password.nil? || ::UnixCrypt.valid?(password, get_remote_encrypted_password) end
has_correct_uid?()
click to toggle source
# File lib/serverkit/resources/user.rb, line 89 def has_correct_uid? uid.nil? || check_command_from_identifier(:check_user_has_uid, name, uid) end
has_correct_user?()
click to toggle source
# File lib/serverkit/resources/user.rb, line 93 def has_correct_user? check_command_from_identifier(:check_user_exists, name) end
update_user_encrypted_password()
click to toggle source
# File lib/serverkit/resources/user.rb, line 97 def update_user_encrypted_password run_command_from_identifier(:update_user_encrypted_password, name, encrypted_password) end
update_user_gid()
click to toggle source
# File lib/serverkit/resources/user.rb, line 101 def update_user_gid run_command_from_identifier(:update_user_gid, name, gid) end
update_user_home_directory()
click to toggle source
# File lib/serverkit/resources/user.rb, line 105 def update_user_home_directory run_command_from_identifier(:update_user_home_directory, name, home) end
update_user_login_shell()
click to toggle source
# File lib/serverkit/resources/user.rb, line 109 def update_user_login_shell run_command_from_identifier(:update_user_login_shell, name, shell) end
update_user_uid()
click to toggle source
# File lib/serverkit/resources/user.rb, line 113 def update_user_uid run_command_from_identifier(:update_user_uid, name, uid) end