diff options
author | Tobias Schmidt <ts@soundcloud.com> | 2013-12-03 12:49:56 +0700 |
---|---|---|
committer | Tobias Schmidt <ts@soundcloud.com> | 2013-12-04 01:41:34 +0700 |
commit | bff171e7a00f951231efdb45e51c0ae1d97ba05d (patch) | |
tree | bbb49f706fc9cf66d2e16831005413042d139f2c /lib/chef/provider/user.rb | |
parent | 41ca23434f820885dd6d78ca49403b24d7400949 (diff) | |
download | chef-bff171e7a00f951231efdb45e51c0ae1d97ba05d.tar.gz |
[CHEF-4842] Fix comparison of user resources with non-ASCII comments
In case a comment of a user resource includes non-ASCII characters, the
comparison whether the resource was changed will always fail. Therefore,
such user resources will get modified during every chef-client run.
Example:
user "marci" do
comment "Márton Salomváry"
# ...
end
So far, this resulted in a comparision of "M\xC3\xA1rton
Salomv\xC3\xA1ry" with "Márton Salomváry" which fails, unless the
encoding gets changed prior to the comparision.
Diffstat (limited to 'lib/chef/provider/user.rb')
-rw-r--r-- | lib/chef/provider/user.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index 738f7660f8..2ab7b0fb98 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -63,11 +63,15 @@ class Chef if user_info @current_resource.uid(user_info.uid) @current_resource.gid(user_info.gid) - @current_resource.comment(user_info.gecos) @current_resource.home(user_info.dir) @current_resource.shell(user_info.shell) @current_resource.password(user_info.passwd) + if @new_resource.comment && user_info.gecos.respond_to?(:force_encoding) + user_info.gecos.force_encoding(@new_resource.comment.encoding) + end + @current_resource.comment(user_info.gecos) + if @new_resource.password && @current_resource.password == 'x' begin require 'shadow' |