Error in system information after logging in to your account

Bug #1780071 reported by Krzysztof Kolasa on 2018-07-04
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Landscape Client
Medium
Simon Poirier
landscape-client (Ubuntu)
Medium
Unassigned
Bionic
Medium
Unassigned
Cosmic
Medium
Unassigned
Disco
Medium
Unassigned
Eoan
Medium
Unassigned

Bug Description

[Impact]

 * An error message is included in when rendering landscape-sysinfo
   statistics through pam_motd if there are processes with a non-ascii
   command. This is due to the fact that environment is not passed
   by pam-motd.

 * As landscape-sysinfo is present on cloud-images, this bug affects
   all images since bionic.

 * This change sets locale variables in the landscape-sysinfo wrapper,
   so the python interpreter can know which locale to load.

[Test Case]

 * Make sure the system default locale is configured with a valid
   charset (e.g. /etc/default/locale contains "LANG=C.UTF-8").

 * Spawn a process with non-ascii parameters (which are part of the
   configured charset): sh -c 'sleep 60; echo holà mundo' & sudo login

 * Check the output of the motd

[Regression Potential]

 * Since this changes only alters the landscape-sysinfo wrapper script,
   its effects shouldn't alter other functionalities.

 * Although it is still possible to have a misconfigured locale file,
   and run commands, the effect would be limited to an error message
   similar to the one which is currently displayed.

[Original Description]

Exception after login:
---------------------
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-24-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage

  System information as of Wed Jul 4 10:41:09 CEST 2018

  System load: 0.0 Swap usage: 5%
  Usage of /home: unknown Users logged in: 0
  Memory usage: 16% IP address for enp3s0: 192.168.20.12

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

 * Meltdown, Spectre and Ubuntu: What are the attack vectors,
   how the fixes work, and everything else you need to know
   - https://ubu.one/u2Know

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 pakietów może zostać zaktualizowanych.
0 aktualizacji jest aktualizacjami zabezpieczeń.
--------------------

sysinfo.log:

2018-06-19 23:19:34,877 ERROR Processes plugin raised an exception.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/sysinfo.py", line 99, in run
    result = plugin.run()
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/processes.py", line 18, in run
    for process_info in info.get_all_process_info():
  File "/usr/lib/python3/dist-packages/landscape/lib/process.py", line 39, in get_all_process_info
    process_info = self.get_process_info(process_id)
  File "/usr/lib/python3/dist-packages/landscape/lib/process.py", line 61, in get_process_info
    cmd_line = file.readline()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 152: ordinal not in range(128)

-----------------
the problem concerned the decoding of utf8 forms, attached patch resolve my problem, after patch my login
screen looks normal:

-----------------
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-24-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage

  System information as of Wed Jul 4 11:10:20 CEST 2018

  System load: 0.2 Processes: 187
  Usage of /home: unknown Users logged in: 1
  Memory usage: 18% IP address for enp3s0: 192.168.20.12
  Swap usage: 5%

 * Meltdown, Spectre and Ubuntu: What are the attack vectors,
   how the fixes work, and everything else you need to know
   - https://ubu.one/u2Know

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 pakietów może zostać zaktualizowanych.
0 aktualizacji jest aktualizacjami zabezpieczeń.

Krzysztof Kolasa (kkolasa) wrote :
Simon Poirier (simpoir) on 2018-07-04
Changed in landscape-client:
status: New → Triaged
importance: Undecided → Medium
Simon Poirier (simpoir) wrote :

Thank you for reporting this bug. We believe it is an actual issue and will look into having it fixed.

For the record, I've been able to reproduce it easily on a pristine bionic container, by spawning a command and launching a login shell, which empties the environment and calls pam_motd:

simpoir@qs:~$ sh -c 'sleep 60; echo ಠ_ಠ' &
[1] 2514
simpoir@qs:~$ sudo login
qs login: simpoir
Password:
Last login: Wed Jul 4 12:31:15 UTC 2018 on pts/0
Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-15-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage
(None, None)

  System information as of Wed Jul 4 12:38:14 UTC 2018

  System load: 0.75 Memory usage: 0% Users logged in: 1
  Usage of /home: unknown Swap usage: 0% IP address for eth0: 10.4.50.157

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

Simon Poirier (simpoir) on 2018-07-04
Changed in landscape-client:
assignee: nobody → Simon Poirier (simpoir)
Simon Poirier (simpoir) wrote :
Changed in landscape-client:
status: Triaged → In Progress
Krzysztof Kolasa (kkolasa) wrote :

I tested and the patch #3 works correctly, thanks.

Simon Poirier (simpoir) on 2018-07-13
Changed in landscape-client:
status: In Progress → Fix Committed
Simon Poirier (simpoir) wrote :
Simon Poirier (simpoir) wrote :
Simon Poirier (simpoir) on 2018-07-16
description: updated
Changed in landscape-client (Ubuntu):
importance: Undecided → Medium
tags: added: patch
Simon Quigley (tsimonq2) wrote :

Uploaded to Bionic, Cosmic, Disco, Eoan. Unsubscribing sponsors.

Changed in landscape-client (Ubuntu Disco):
importance: Undecided → Medium
Changed in landscape-client (Ubuntu Bionic):
importance: Undecided → Medium
Changed in landscape-client (Ubuntu Cosmic):
importance: Undecided → Medium
Changed in landscape-client (Ubuntu Bionic):
status: New → In Progress
Changed in landscape-client (Ubuntu Cosmic):
status: New → In Progress
Changed in landscape-client (Ubuntu Disco):
status: New → In Progress
Changed in landscape-client (Ubuntu Eoan):
status: New → In Progress
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package landscape-client - 18.01-0ubuntu8

---------------
landscape-client (18.01-0ubuntu8) eoan; urgency=medium

  * Set LANG in sysinfo wrapper. (LP: #1780071)

 -- Simon Poirier <email address hidden> Mon, 16 Jul 2018 13:47:29 -0400

Changed in landscape-client (Ubuntu Eoan):
status: In Progress → Fix Released
Dimitri John Ledkov (xnox) wrote :

Garbage in, barbage out. I think opening things and reading as utf-8 is good. For added resilience, one has to also espace unicode encoding errors too, and replace them with anything readable. I.e. one may choose to read in binary, and then decode as utf-8 with any errors replaced, ie.:

b'somebinary string'.decode('utf-8', 'replace')

An upload of landscape-client to disco-proposed has been rejected from the upload queue for the following reason: "Wrong solution for the reported symptom. locale should be set globally in update-motd.".

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers