Fix potential crash if missing AccountsService permissions

This commit is contained in:
Sean Davis 2014-04-04 21:21:19 -04:00
parent 4ac8066158
commit c814911d96
3 changed files with 39 additions and 37 deletions

View File

@ -458,27 +458,30 @@ class MugshotWindow(Window):
def accounts_service_set_user_image(self, filename): def accounts_service_set_user_image(self, filename):
"""Set user profile image using AccountsService.""" """Set user profile image using AccountsService."""
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) try:
result = bus.call_sync('org.freedesktop.Accounts', bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
'/org/freedesktop/Accounts', result = bus.call_sync('org.freedesktop.Accounts',
'org.freedesktop.Accounts', '/org/freedesktop/Accounts',
'FindUserByName', 'org.freedesktop.Accounts',
GLib.Variant('(s)', (username,)), 'FindUserByName',
GLib.VariantType.new('(o)'), GLib.Variant('(s)', (username,)),
Gio.DBusCallFlags.NONE, GLib.VariantType.new('(o)'),
-1, Gio.DBusCallFlags.NONE,
None) -1,
(path,) = result.unpack() None)
(path,) = result.unpack()
bus.call_sync('org.freedesktop.Accounts', bus.call_sync('org.freedesktop.Accounts',
path, path,
'org.freedesktop.Accounts.User', 'org.freedesktop.Accounts.User',
'SetIconFile', 'SetIconFile',
GLib.Variant('(s)', (filename,)), GLib.Variant('(s)', (filename,)),
GLib.VariantType.new('()'), GLib.VariantType.new('()'),
Gio.DBusCallFlags.NONE, Gio.DBusCallFlags.NONE,
-1, -1,
None) None)
except GLib.GError:
pass
def set_pidgin_buddyicon(self, filename=None): def set_pidgin_buddyicon(self, filename=None):
"""Sets the pidgin buddyicon to filename (usually ~/.face). """Sets the pidgin buddyicon to filename (usually ~/.face).

View File

@ -34,7 +34,6 @@ def check_sudo():
return False return False
except: except:
child.close() child.close()
print("Sudoer")
return True return True

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-01 23:14-0400\n" "POT-Creation-Date: 2014-04-04 21:20-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -61,7 +61,7 @@ msgstr ""
msgid "Browse…" msgid "Browse…"
msgstr "" msgstr ""
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:571 #: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:573
msgid "Mugshot" msgid "Mugshot"
msgstr "" msgstr ""
@ -131,65 +131,65 @@ msgid "Retry"
msgstr "" msgstr ""
#. Password was incorrect, complain. #. Password was incorrect, complain.
#: ../mugshot/MugshotWindow.py:328 #: ../mugshot/MugshotWindow.py:327
msgid "Authentication Failed" msgid "Authentication Failed"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:329 #: ../mugshot/MugshotWindow.py:328
msgid "User details were not updated." msgid "User details were not updated."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:493 #: ../mugshot/MugshotWindow.py:495
msgid "Update Pidgin buddy icon?" msgid "Update Pidgin buddy icon?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:494 #: ../mugshot/MugshotWindow.py:496
msgid "Would you also like to update your Pidgin buddy icon?" msgid "Would you also like to update your Pidgin buddy icon?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:572 #: ../mugshot/MugshotWindow.py:574
msgid "Enter your password to change user details." msgid "Enter your password to change user details."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:574 #: ../mugshot/MugshotWindow.py:576
msgid "" msgid ""
"This is a security measure to prevent unwanted updates\n" "This is a security measure to prevent unwanted updates\n"
"to your personal information." "to your personal information."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:725 #: ../mugshot/MugshotWindow.py:727
msgid "Update LibreOffice user details?" msgid "Update LibreOffice user details?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:726 #: ../mugshot/MugshotWindow.py:728
msgid "Would you also like to update your user details in LibreOffice?" msgid "Would you also like to update your user details in LibreOffice?"
msgstr "" msgstr ""
#: ../mugshot_lib/SudoDialog.py:80 #: ../mugshot_lib/SudoDialog.py:79
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: ../mugshot_lib/SudoDialog.py:81 #: ../mugshot_lib/SudoDialog.py:80
msgid "OK" msgid "OK"
msgstr "" msgstr ""
#: ../mugshot_lib/SudoDialog.py:94 #: ../mugshot_lib/SudoDialog.py:93
msgid "" msgid ""
"Enter your password to\n" "Enter your password to\n"
"perform administrative tasks." "perform administrative tasks."
msgstr "" msgstr ""
#: ../mugshot_lib/SudoDialog.py:96 #: ../mugshot_lib/SudoDialog.py:95
#, python-format #, python-format
msgid "" msgid ""
"The application '%s' lets you\n" "The application '%s' lets you\n"
"modify essential parts of your system." "modify essential parts of your system."
msgstr "" msgstr ""
#: ../mugshot_lib/SudoDialog.py:117 #: ../mugshot_lib/SudoDialog.py:116
msgid "Incorrect password... try again." msgid "Incorrect password... try again."
msgstr "" msgstr ""
#: ../mugshot_lib/SudoDialog.py:122 #: ../mugshot_lib/SudoDialog.py:121
msgid "Password:" msgid "Password:"
msgstr "" msgstr ""