[SRU] Mugshot fails to start for some users

Bug #1353530 reported by Owen Dunn
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mugshot
Fix Released
High
Unassigned
mugshot (Ubuntu)
Fix Released
Undecided
Unassigned
Trusty
New
Undecided
Unassigned

Bug Description

[Impact]
Because of incomplete logic for collecting user details, Mugshot < 0.2.5 may
fail to start for some users. As of version 0.2.5, user details are pulled
from several sources including LibreOffice, passwd, and GLib. In this way,
the following critical errors are avoided.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mugshot/MugshotWindow.py", line 252, in init_user_details
    first_name, last_name = name.split(' ', 1)
UnboundLocalError: local variable 'name' referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/mugshot", line 35, in <module>
    mugshot.main()
  File "/usr/lib/python3/dist-packages/mugshot/__init__.py", line 45, in main
    window = MugshotWindow.MugshotWindow()
  File "/usr/lib/python3/dist-packages/mugshot_lib/Window.py", line 50, in __new__
    new_object.finish_initializing(builder)
  File "/usr/lib/python3/dist-packages/mugshot/MugshotWindow.py", line 217, in finish_initializing
    self.init_user_details()
  File "/usr/lib/python3/dist-packages/mugshot/MugshotWindow.py", line 254, in init_user_details
    first_name = name
UnboundLocalError: local variable 'name' referenced before assignment

[Test Case]
If you have an LDAP-configured account...
1. Start Mugshot.

Otherwise...
1. Set your account name to "A".
2. Start Mugshot.

[Expected Results]
Mugshot should start successfully.

[Regression Potential]
None. This new release adds several safeguards to prevent future similar issues.

Revision history for this message
François Seguin (francois-seguin) wrote :

Hello Owen,

I experienced the same issue with LDAP users. But it works with local users.
Reading the lines above 252 in MugshotWindow.py, it can be seen that the program only looks in the passwd file to get user info, and doesn't expect the user to be outside of it. That's why it crashes.

The program should use "getent passwd username" or an equivalent for Python to get user information.
It should inform the user, too, it can't handle distant users.

As a dirty patch, you could add those two lines after the instruction "break" at line 248:
        else:
                name, office, office_phone, home_phone = 'User Unknown', '', '', ''
It displays the right dialog, though you can't validate any changes.

Xubuntu 14.04 amd64, mugshot 0.2.3-1, python3 3.4.0-0ubuntu2

Sean Davis (bluesabre)
Changed in mugshot:
status: New → Fix Committed
milestone: none → 0.2.5
importance: Undecided → High
Sean Davis (bluesabre)
Changed in mugshot (Ubuntu):
status: New → Fix Released
Changed in mugshot:
status: Fix Committed → Fix Released
Sean Davis (bluesabre)
summary: - mugshot produces python errors
+ [SRU] Mugshot fails to start for some users
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.