KeyError: 'USERNAME'

Bug #715507 reported by Levi Larsen
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cGmail
New
Undecided
Francesco Marella

Bug Description

Version 0.6.2

Traceback (most recent call last):
  File "/usr/share/cgmail/cgmailservice.py", line 20, in <module>
    from cGmail.service.mainloop import MainLoop
  File "/usr/share/cgmail/cGmail/service/mainloop.py", line 33, in <module>
    if os.environ["USERNAME"] == "root":
  File "/usr/lib/python2.6/UserDict.py", line 22, in __getitem__
    raise KeyError(key)
KeyError: 'USERNAME'

The problem is that there is no "USERNAME" environmental variable set on my system (Debian Sid). This also just a bad way to check if the script is running as root, anyway. I would suggest replacing

    if os.environ["USERNAME"] == "root":

with

    if os.geteuid() == 0:

Related branches

Changed in cgmail:
milestone: none → 0.6.3
assignee: nobody → Francesco Marella (francesco-marella)
Revision history for this message
Lucas Saliés Brum (sistematico) wrote :

Thank you Levi!!!

Revision history for this message
Lucas Saliés Brum (sistematico) wrote :

And thank you Francesco!!

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.