Comment 3 for bug 1775371

Revision history for this message
Kurt Garloff (kgarloff) wrote : Re: [Bug 1775371] Re: cloud-init (18.2) fails on decoding proc1 env

Hi Scott,

Thanks for your quick response!
Thinking about it, I like your patch better than my own and definitely support it.
I'll try to find some time to come up with some unit tests - however please don't wait for it - I'm super-busy...

Thanks,
--
Kurt Garloff <email address hidden>, Cologne, Germany
(Sent from Mobile with K9.)

Am 6. Juni 2018 16:42:13 MESZ schrieb Scott Moser <email address hidden>:
>Kurt,
>
>Thanks for the good bug report and diagnosis.
>decode_binary doensn't seem like the right place for this.
>
>Heres a start of a patch to do that.
>
>We'd like to add some tests for this to tests/unittests/test_util.py
>I think the easiest way would be to just mock load_file .
>
>If you want to push this along, please put up a merge proposal with a
>unit test. If not, we'll get to it but not immediately.
>
>Thanks again.
>Scott
>
>
>** Patch added: "suggested fix"
>https://bugs.launchpad.net/cloud-init/+bug/1775371/+attachment/5149386/+files/suggested-1774371.patch
>
>** Changed in: cloud-init
> Status: New => Confirmed
>
>** Changed in: cloud-init
> Importance: Undecided => Medium
>
>--
>You received this bug notification because you are subscribed to the
>bug
>report.
>https://bugs.launchpad.net/bugs/1775371
>
>Title:
> cloud-init (18.2) fails on decoding proc1 env
>
>Status in cloud-init:
> Confirmed
>
>Bug description:
> cloud-init-18.2 on an openSUSE-15 (python 3.6) kiwi image fails with
> this:
>
> failed run of stage init-local
> ------------------------------------------------------------
> Traceback (most recent call last):
>File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line
>655, in status_wrapper
> ret = functor(name, args)
>File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line
>222, in main_init
> network=not args.local)]
>File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line
>156, in attempt_cmdline_url
> cmdline = util.get_cmdline()
>File "/usr/lib/python3.6/site-packages/cloudinit/util.py", line 1351,
>in get_cmdline
> if is_container():
>File "/usr/lib/python3.6/site-packages/cloudinit/util.py", line 2075,
>in is_container
> pid1env = get_proc_env(1)
>File "/usr/lib/python3.6/site-packages/cloudinit/util.py", line 2109,
>in get_proc_env
> contents = load_file(fn)
>File "/usr/lib/python3.6/site-packages/cloudinit/util.py", line 1338,
>in load_file
> return decode_binary(contents)
>File "/usr/lib/python3.6/site-packages/cloudinit/util.py", line 150, in
>decode_binary
> return blob.decode(encoding)
>UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position
>3432: invalid start byte
> ------------------------------------------------------------
>
> This is from reading /proc/1/environ
>
> hexdump around the relvant offset (3432 = 0x0d68) shows me:
>00000d50 32 61 32 32 37 37 30 34 66 00 42 4f 4f 54 41 42
>|2a227704f.BOOTAB|
>00000d60 4c 45 5f 46 4c 41 47 3d 80 00 69 6e 69 74 3d 2f
>|LE_FLAG=..init=/|
>
> So there we go: BOOTABLE_FLAG=\x80 does not decode to utf-8 ...
>
>To manage notifications about this bug go to:
>https://bugs.launchpad.net/cloud-init/+bug/1775371/+subscriptions