Method: Pawnee::Actions::User#read_from_system
- Defined in:
- lib/pawnee/pawnee/actions/user.rb
#read_from_system ⇒ Object
Pull in the current (starting) state of the attributes for the User model
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/pawnee/pawnee/actions/user.rb', line 97 def read_from_system @uid, stderr, exit_code, _ = exec("id -u #{login}", :with_codes => true, :log_stderr => false, :no_pty => true) @uid = @uid.strip if exit_code == 0 # The login exists, load in more data @gid = exec("id -g #{login}", :log_stderr => false, :no_pty => true).strip @groups = exec("groups #{login}", :no_pty => true).gsub(/^[^:]+[:]/, '').strip.split(/ /).sort @home = home_for_user(login) # TODO: Load in existing shell @shell = shell_for_user(login) self.new_record = false # Reject any ones we just changed, so its as if we did a find with these @changed_attributes = @changed_attributes.reject {|k,v| [:uid, :gid, :groups, :login].include?(k.to_sym) } @original_groups_value = @groups.dup else # No user @uid = nil @groups ||= [] @shell ||= '/bin/bash' self.shell_will_change! self.new_record = true end end |