Jira (PUP-11137) Puppet cannot query non-ASCII users

2 views
Skip to first unread message

Dorin Pleava (Jira)

unread,
Jun 30, 2021, 9:06:02 AM6/30/21
to puppe...@googlegroups.com
Dorin Pleava created an issue
 
Puppet / Bug PUP-11137
Puppet cannot query non-ASCII users
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/06/30 6:05 AM
Priority: Normal Normal
Reporter: Dorin Pleava

On Debian 10(might be also other platforms affected) when querying a user that contains non-ASCII characters in its name, puppet errors out as seen below:

 
root@fell-scattergun:~# puppet --version
6.23.0
 
root@fell-scattergun:~# cat manifest.pp
user { 'Gérard':
 ensure => present,
 password => 'pass',
}
 
root@fell-scattergun:~# puppet apply manifest.pp
Notice: Compiled catalog for fell-scattergun.delivery.puppetlabs.net in environment production in 0.01 seconds
Notice: /Stage[main]/Main/User[Gérard]/ensure: created
Notice: Applied catalog in 0.09 seconds
 
root@fell-scattergun:~# puppet resource user Gérard --trace
Error: Could not run: incompatible character encodings: ASCII-8BIT and UTF-8
/opt/puppetlabs/puppet/lib/ruby/vendor_gems/gems/fast_gettext-1.1.2/lib/fast_gettext/vendor/string.rb:70:in `%'
/opt/puppetlabs/puppet/lib/ruby/vendor_gems/gems/fast_gettext-1.1.2/lib/fast_gettext/vendor/string.rb:70:in `%'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:489:in `to_manifest'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:152:in `block (2 levels) in main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:151:in `map'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:151:in `block in main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:62:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:314:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:138:in `main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:390:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:382:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:735:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:382:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:143:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:77:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'

Checking variables from puppet/resource.rb shows:

[1] pry(#<Puppet::Resource>)> self.type.to_s.downcase
=> "user"
[2] pry(#<Puppet::Resource>)> escaped
=> "G\xC3\xA9rard"
[3] pry(#<Puppet::Resource>)> attributes
=> "  ensure             => 'present',\n  gid                => 1020,\n  home               => '/home/G\u00E9rard',\n  password           => 'pass',\n  password_max_age   => 99999,\n  password_min_age   => 0,\n  password_warn_days => 7,\n  provider           => 'useradd',\n  shell              => '/bin/sh',\n  uid                => 1020,\n"
[4] pry(#<Puppet::Resource>)>
[5] pry(#<Puppet::Resource>)> attributes.encoding
=> #<Encoding:UTF-8>
[6] pry(#<Puppet::Resource>)> escaped.encoding
=> #<Encoding:ASCII-8BIT>

This error seems to come from core Ruby which cannot handle concatenating differently encoded strings that contain special characters:

# irb
2.7.3 :028 > a = "Gérard"
 => "Gérard"
2.7.3 :029 > b = "Gérard".force_encoding("ASCII-8BIT")
 => "G\xC3\xA9rard"
2.7.3 :030 > a + b
Traceback (most recent call last):
        5: from /Users/dorinpleava/.rvm/rubies/ruby-2.7.3/bin/irb:23:in `<main>'
        4: from /Users/dorinpleava/.rvm/rubies/ruby-2.7.3/bin/irb:23:in `load'
        3: from /Users/dorinpleava/.rvm/rubies/ruby-2.7.3/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        2: from (irb):30
        1: from (irb):30:in `+'
Encoding::CompatibilityError (incompatible character encodings: UTF-8 and ASCII-8BIT)

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages