Skip to content

Commit c814911

Browse files
committed
Fix potential crash if missing AccountsService permissions
1 parent 4ac8066 commit c814911

File tree

3 files changed

+40
-38
lines changed

3 files changed

+40
-38
lines changed

mugshot/MugshotWindow.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -458,27 +458,30 @@ def accounts_service_get_user_image(self):
458458

459459
def accounts_service_set_user_image(self, filename):
460460
"""Set user profile image using AccountsService."""
461-
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
462-
result = bus.call_sync('org.freedesktop.Accounts',
463-
'/org/freedesktop/Accounts',
464-
'org.freedesktop.Accounts',
465-
'FindUserByName',
466-
GLib.Variant('(s)', (username,)),
467-
GLib.VariantType.new('(o)'),
468-
Gio.DBusCallFlags.NONE,
469-
-1,
470-
None)
471-
(path,) = result.unpack()
472-
473-
bus.call_sync('org.freedesktop.Accounts',
474-
path,
475-
'org.freedesktop.Accounts.User',
476-
'SetIconFile',
477-
GLib.Variant('(s)', (filename,)),
478-
GLib.VariantType.new('()'),
479-
Gio.DBusCallFlags.NONE,
480-
-1,
481-
None)
461+
try:
462+
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
463+
result = bus.call_sync('org.freedesktop.Accounts',
464+
'/org/freedesktop/Accounts',
465+
'org.freedesktop.Accounts',
466+
'FindUserByName',
467+
GLib.Variant('(s)', (username,)),
468+
GLib.VariantType.new('(o)'),
469+
Gio.DBusCallFlags.NONE,
470+
-1,
471+
None)
472+
(path,) = result.unpack()
473+
474+
bus.call_sync('org.freedesktop.Accounts',
475+
path,
476+
'org.freedesktop.Accounts.User',
477+
'SetIconFile',
478+
GLib.Variant('(s)', (filename,)),
479+
GLib.VariantType.new('()'),
480+
Gio.DBusCallFlags.NONE,
481+
-1,
482+
None)
483+
except GLib.GError:
484+
pass
482485

483486
def set_pidgin_buddyicon(self, filename=None):
484487
"""Sets the pidgin buddyicon to filename (usually ~/.face).

mugshot_lib/SudoDialog.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def check_sudo():
3434
return False
3535
except:
3636
child.close()
37-
print("Sudoer")
3837
return True
3938

4039

po/mugshot.pot

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2014-04-01 23:14-0400\n"
11+
"POT-Creation-Date: 2014-04-04 21:20-0400\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -61,7 +61,7 @@ msgstr ""
6161
msgid "Browse…"
6262
msgstr ""
6363

64-
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:571
64+
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:573
6565
msgid "Mugshot"
6666
msgstr ""
6767

@@ -131,65 +131,65 @@ msgid "Retry"
131131
msgstr ""
132132

133133
#. Password was incorrect, complain.
134-
#: ../mugshot/MugshotWindow.py:328
134+
#: ../mugshot/MugshotWindow.py:327
135135
msgid "Authentication Failed"
136136
msgstr ""
137137

138-
#: ../mugshot/MugshotWindow.py:329
138+
#: ../mugshot/MugshotWindow.py:328
139139
msgid "User details were not updated."
140140
msgstr ""
141141

142-
#: ../mugshot/MugshotWindow.py:493
142+
#: ../mugshot/MugshotWindow.py:495
143143
msgid "Update Pidgin buddy icon?"
144144
msgstr ""
145145

146-
#: ../mugshot/MugshotWindow.py:494
146+
#: ../mugshot/MugshotWindow.py:496
147147
msgid "Would you also like to update your Pidgin buddy icon?"
148148
msgstr ""
149149

150-
#: ../mugshot/MugshotWindow.py:572
150+
#: ../mugshot/MugshotWindow.py:574
151151
msgid "Enter your password to change user details."
152152
msgstr ""
153153

154-
#: ../mugshot/MugshotWindow.py:574
154+
#: ../mugshot/MugshotWindow.py:576
155155
msgid ""
156156
"This is a security measure to prevent unwanted updates\n"
157157
"to your personal information."
158158
msgstr ""
159159

160-
#: ../mugshot/MugshotWindow.py:725
160+
#: ../mugshot/MugshotWindow.py:727
161161
msgid "Update LibreOffice user details?"
162162
msgstr ""
163163

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

168-
#: ../mugshot_lib/SudoDialog.py:80
168+
#: ../mugshot_lib/SudoDialog.py:79
169169
msgid "Cancel"
170170
msgstr ""
171171

172-
#: ../mugshot_lib/SudoDialog.py:81
172+
#: ../mugshot_lib/SudoDialog.py:80
173173
msgid "OK"
174174
msgstr ""
175175

176-
#: ../mugshot_lib/SudoDialog.py:94
176+
#: ../mugshot_lib/SudoDialog.py:93
177177
msgid ""
178178
"Enter your password to\n"
179179
"perform administrative tasks."
180180
msgstr ""
181181

182-
#: ../mugshot_lib/SudoDialog.py:96
182+
#: ../mugshot_lib/SudoDialog.py:95
183183
#, python-format
184184
msgid ""
185185
"The application '%s' lets you\n"
186186
"modify essential parts of your system."
187187
msgstr ""
188188

189-
#: ../mugshot_lib/SudoDialog.py:117
189+
#: ../mugshot_lib/SudoDialog.py:116
190190
msgid "Incorrect password... try again."
191191
msgstr ""
192192

193-
#: ../mugshot_lib/SudoDialog.py:122
193+
#: ../mugshot_lib/SudoDialog.py:121
194194
msgid "Password:"
195195
msgstr ""

0 commit comments

Comments
 (0)