Skip to content

Commit

Permalink
Fix potential crash if missing AccountsService permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
bluesabre committed Apr 5, 2014
1 parent 4ac8066 commit c814911
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
45 changes: 24 additions & 21 deletions mugshot/MugshotWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,27 +458,30 @@ def accounts_service_get_user_image(self):

def accounts_service_set_user_image(self, filename):
"""Set user profile image using AccountsService."""
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
result = bus.call_sync('org.freedesktop.Accounts',
'/org/freedesktop/Accounts',
'org.freedesktop.Accounts',
'FindUserByName',
GLib.Variant('(s)', (username,)),
GLib.VariantType.new('(o)'),
Gio.DBusCallFlags.NONE,
-1,
None)
(path,) = result.unpack()

bus.call_sync('org.freedesktop.Accounts',
path,
'org.freedesktop.Accounts.User',
'SetIconFile',
GLib.Variant('(s)', (filename,)),
GLib.VariantType.new('()'),
Gio.DBusCallFlags.NONE,
-1,
None)
try:
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
result = bus.call_sync('org.freedesktop.Accounts',
'/org/freedesktop/Accounts',
'org.freedesktop.Accounts',
'FindUserByName',
GLib.Variant('(s)', (username,)),
GLib.VariantType.new('(o)'),
Gio.DBusCallFlags.NONE,
-1,
None)
(path,) = result.unpack()

bus.call_sync('org.freedesktop.Accounts',
path,
'org.freedesktop.Accounts.User',
'SetIconFile',
GLib.Variant('(s)', (filename,)),
GLib.VariantType.new('()'),
Gio.DBusCallFlags.NONE,
-1,
None)
except GLib.GError:
pass

def set_pidgin_buddyicon(self, filename=None):
"""Sets the pidgin buddyicon to filename (usually ~/.face).
Expand Down
1 change: 0 additions & 1 deletion mugshot_lib/SudoDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def check_sudo():
return False
except:
child.close()
print("Sudoer")
return True


Expand Down
32 changes: 16 additions & 16 deletions po/mugshot.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -61,7 +61,7 @@ msgstr ""
msgid "Browse…"
msgstr ""

#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:571
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:573
msgid "Mugshot"
msgstr ""

Expand Down Expand Up @@ -131,65 +131,65 @@ msgid "Retry"
msgstr ""

#. Password was incorrect, complain.
#: ../mugshot/MugshotWindow.py:328
#: ../mugshot/MugshotWindow.py:327
msgid "Authentication Failed"
msgstr ""

#: ../mugshot/MugshotWindow.py:329
#: ../mugshot/MugshotWindow.py:328
msgid "User details were not updated."
msgstr ""

#: ../mugshot/MugshotWindow.py:493
#: ../mugshot/MugshotWindow.py:495
msgid "Update Pidgin buddy icon?"
msgstr ""

#: ../mugshot/MugshotWindow.py:494
#: ../mugshot/MugshotWindow.py:496
msgid "Would you also like to update your Pidgin buddy icon?"
msgstr ""

#: ../mugshot/MugshotWindow.py:572
#: ../mugshot/MugshotWindow.py:574
msgid "Enter your password to change user details."
msgstr ""

#: ../mugshot/MugshotWindow.py:574
#: ../mugshot/MugshotWindow.py:576
msgid ""
"This is a security measure to prevent unwanted updates\n"
"to your personal information."
msgstr ""

#: ../mugshot/MugshotWindow.py:725
#: ../mugshot/MugshotWindow.py:727
msgid "Update LibreOffice user details?"
msgstr ""

#: ../mugshot/MugshotWindow.py:726
#: ../mugshot/MugshotWindow.py:728
msgid "Would you also like to update your user details in LibreOffice?"
msgstr ""

#: ../mugshot_lib/SudoDialog.py:80
#: ../mugshot_lib/SudoDialog.py:79
msgid "Cancel"
msgstr ""

#: ../mugshot_lib/SudoDialog.py:81
#: ../mugshot_lib/SudoDialog.py:80
msgid "OK"
msgstr ""

#: ../mugshot_lib/SudoDialog.py:94
#: ../mugshot_lib/SudoDialog.py:93
msgid ""
"Enter your password to\n"
"perform administrative tasks."
msgstr ""

#: ../mugshot_lib/SudoDialog.py:96
#: ../mugshot_lib/SudoDialog.py:95
#, python-format
msgid ""
"The application '%s' lets you\n"
"modify essential parts of your system."
msgstr ""

#: ../mugshot_lib/SudoDialog.py:117
#: ../mugshot_lib/SudoDialog.py:116
msgid "Incorrect password... try again."
msgstr ""

#: ../mugshot_lib/SudoDialog.py:122
#: ../mugshot_lib/SudoDialog.py:121
msgid "Password:"
msgstr ""

0 comments on commit c814911

Please sign in to comment.