diff options
Diffstat (limited to 'lib/chef/provider/user')
-rw-r--r-- | lib/chef/provider/user/dscl.rb | 26 | ||||
-rw-r--r-- | lib/chef/provider/user/pw.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider/user/solaris.rb | 10 | ||||
-rw-r--r-- | lib/chef/provider/user/useradd.rb | 12 | ||||
-rw-r--r-- | lib/chef/provider/user/windows.rb | 16 |
5 files changed, 38 insertions, 38 deletions
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 78769ae758..563d56dce7 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'mixlib/shellout' -require 'chef/provider/user' -require 'openssl' -require 'plist' -require 'chef/util/path_helper' +require "mixlib/shellout" +require "chef/provider/user" +require "openssl" +require "plist" +require "chef/util/path_helper" class Chef class Provider @@ -136,14 +136,14 @@ user password using shadow hash.") if shadow_hash["SALTED-SHA512"] # Convert the shadow value from Base64 encoding to hex before consuming them @password_shadow_conversion_algorithm = "SALTED-SHA512" - current_resource.password(shadow_hash["SALTED-SHA512"].string.unpack('H*').first) + current_resource.password(shadow_hash["SALTED-SHA512"].string.unpack("H*").first) elsif shadow_hash["SALTED-SHA512-PBKDF2"] @password_shadow_conversion_algorithm = "SALTED-SHA512-PBKDF2" # Convert the entropy from Base64 encoding to hex before consuming them - current_resource.password(shadow_hash["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack('H*').first) + current_resource.password(shadow_hash["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack("H*").first) current_resource.iterations(shadow_hash["SALTED-SHA512-PBKDF2"]["iterations"]) # Convert the salt from Base64 encoding to hex before consuming them - current_resource.salt(shadow_hash["SALTED-SHA512-PBKDF2"]["salt"].string.unpack('H*').first) + current_resource.salt(shadow_hash["SALTED-SHA512-PBKDF2"]["salt"].string.unpack("H*").first) else raise(Chef::Exceptions::User,"Unknown shadow_hash format: #{shadow_hash.keys.join(' ')}") end @@ -213,7 +213,7 @@ user password using shadow hash.") # def dscl_set_uid # XXX: mutates the new resource - new_resource.uid(get_free_uid) if (new_resource.uid.nil? || new_resource.uid == '') + new_resource.uid(get_free_uid) if (new_resource.uid.nil? || new_resource.uid == "") if uid_used?(new_resource.uid) raise(Chef::Exceptions::RequestedUIDUnavailable, "uid #{new_resource.uid} is already in use") @@ -396,7 +396,7 @@ user password using shadow hash.") # Create a random 4 byte salt salt = OpenSSL::Random.random_bytes(4) encoded_password = OpenSSL::Digest::SHA512.hexdigest(salt + new_resource.password) - hash_value = salt.unpack('H*').first + encoded_password + hash_value = salt.unpack("H*").first + encoded_password end shadow_info["SALTED-SHA512"] = StringIO.new @@ -664,7 +664,7 @@ user password using shadow hash.") result = shell_out("plutil -#{args.join(' ')}") raise(Chef::Exceptions::PlistUtilCommandFailed,"plutil error: #{result.inspect}") unless result.exitstatus == 0 if result.stdout.encoding == Encoding::ASCII_8BIT - result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => '?') + result.stdout.encode("utf-8", "binary", :undef => :replace, :invalid => :replace, :replace => "?") else result.stdout end @@ -675,7 +675,7 @@ user password using shadow hash.") end def convert_to_binary(string) - string.unpack('a2'*(string.size/2)).collect { |i| i.hex.chr }.join + string.unpack("a2"*(string.size/2)).collect { |i| i.hex.chr }.join end def salted_sha512?(string) @@ -702,7 +702,7 @@ user password using shadow hash.") current_resource.iterations, 128, OpenSSL::Digest::SHA512.new, - ).unpack('H*').first == current_resource.password + ).unpack("H*").first == current_resource.password end end diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb index e53d647f37..37890bdc1e 100644 --- a/lib/chef/provider/user/pw.rb +++ b/lib/chef/provider/user/pw.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/provider/user' +require "chef/provider/user" class Chef class Provider @@ -71,11 +71,11 @@ class Chef opts = " #{@new_resource.username}" field_list = { - 'comment' => "-c", - 'home' => "-d", - 'gid' => "-g", - 'uid' => "-u", - 'shell' => "-s", + "comment" => "-c", + "home" => "-d", + "gid" => "-g", + "uid" => "-u", + "shell" => "-s", } field_list.sort{ |a,b| a[0] <=> b[0] }.each do |field, option| field_symbol = field.to_sym diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb index c16db22ad4..d9108d4ca4 100644 --- a/lib/chef/provider/user/solaris.rb +++ b/lib/chef/provider/user/solaris.rb @@ -18,7 +18,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'chef/provider/user/useradd' +require "chef/provider/user/useradd" class Chef class Provider @@ -45,14 +45,14 @@ class Chef end def check_lock - shadow_line = shell_out!('getent', 'shadow', new_resource.username).stdout.strip rescue nil + shadow_line = shell_out!("getent", "shadow", new_resource.username).stdout.strip rescue nil # if the command fails we return nil, this can happen if the user # in question doesn't exist return nil if shadow_line.nil? # convert "dave:NP:16507::::::\n" to "NP" - fields = shadow_line.split(':') + fields = shadow_line.split(":") # '*LK*...' and 'LK' are both considered locked, # so look for LK at the beginning of the shadow entry @@ -63,11 +63,11 @@ class Chef end def lock_user - shell_out!('passwd', '-l', new_resource.username) + shell_out!("passwd", "-l", new_resource.username) end def unlock_user - shell_out!('passwd', '-u', new_resource.username) + shell_out!("passwd", "-u", new_resource.username) end private diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb index a1b5b3459c..da6606bc14 100644 --- a/lib/chef/provider/user/useradd.rb +++ b/lib/chef/provider/user/useradd.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'pathname' -require 'chef/provider/user' +require "pathname" +require "chef/provider/user" class Chef class Provider @@ -63,7 +63,7 @@ class Chef raise Chef::Exceptions::User, "Cannot determine if #{@new_resource} is locked!" if passwd_s.stdout.empty? - status_line = passwd_s.stdout.split(' ') + status_line = passwd_s.stdout.split(" ") case status_line[1] when /^P/ @locked = false @@ -75,11 +75,11 @@ class Chef unless passwd_s.exitstatus == 0 raise_lock_error = false - if ['redhat', 'centos'].include?(node[:platform]) - passwd_version_check = shell_out!('rpm -q passwd') + if ["redhat", "centos"].include?(node[:platform]) + passwd_version_check = shell_out!("rpm -q passwd") passwd_version = passwd_version_check.stdout.chomp - unless passwd_version == 'passwd-0.73-1' + unless passwd_version == "passwd-0.73-1" raise_lock_error = true end else diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb index b0b2d7e956..0851c2272a 100644 --- a/lib/chef/provider/user/windows.rb +++ b/lib/chef/provider/user/windows.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'chef/provider/user' -require 'chef/exceptions' +require "chef/provider/user" +require "chef/exceptions" if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - require 'chef/util/windows/net_user' + require "chef/util/windows/net_user" end class Chef @@ -101,11 +101,11 @@ class Chef opts = {:name => @new_resource.username} field_list = { - 'comment' => 'full_name', - 'home' => 'home_dir', - 'uid' => 'user_id', - 'shell' => 'script_path', - 'password' => 'password', + "comment" => "full_name", + "home" => "home_dir", + "uid" => "user_id", + "shell" => "script_path", + "password" => "password", } field_list.sort{ |a,b| a[0] <=> b[0] }.each do |field, option| |