Skip to content

invalid byte sequence in UTF-8 #49

@anarcat

Description

@anarcat

When switching to this module from my dumb sysctl one, I get this error when running my manifest:

Error: Failed to apply catalog: invalid byte sequence in UTF-8

To reproduce:

Add this to a reproducer.pp file:

  sysctl::value { 'kernel.unprivileged_userns_clone':
    value  => '1',
    target => '/etc/sysctl.d/userns.conf',
  }

Download the 0.0.12 module to test-modules/sysctl, and run this:

puppet apply --modulepath="$PWD/test-modules" repro.pp 

I get this error:

$ puppet apply --modulepath="$PWD/test-modules" repro.pp 
Notice: Compiled catalog for angela.anarc.at in environment production in 0.04 seconds
Error: Failed to apply catalog: invalid byte sequence in UTF-8

This can also be reproduced in the git head. I can't find any corrupt UTF-8 output in the module's source code, so that can't be it.

My guess is that the output of sysctl -a makes Puppet unhappy: it might trying to decode it as unicode at some point and failing. And indeed, here, the sysctl -a output isn't UTF-8 clean:

$ sudo sysctl -a | iconv -f utf8 -t latin1 > /dev/null
iconv: illegal input sequence at position 66297

It specifically stumbles upon sunrpc.transports, which less shows as:

sunrpc.transports = <C0><E3><A3><C1>m^?

And indeed, this is happy:

anarcat@angela:puppet(master)$ sudo sysctl -a | grep -v sunrpc.transports | iconv -f utf8 -t latin1 > /dev/null
anarcat@angela:puppet(master)$ 

I would recommend not making any assertions on the encoding of values in the kernel's sysctl output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions