Merge lp:~ted/policykit-unity8/lp1580236-hide-password into lp:policykit-unity8

Proposed by Ted Gould
Status: Merged
Approved by: Ted Gould
Approved revision: 11
Merged at revision: 9
Proposed branch: lp:~ted/policykit-unity8/lp1580236-hide-password
Merge into: lp:policykit-unity8
Diff against target: 64 lines (+11/-2)
2 files modified
service/authentication.cpp (+10/-1)
service/session-iface.cpp (+1/-1)
To merge this branch: bzr merge lp:~ted/policykit-unity8/lp1580236-hide-password
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
unity-api-1-bot continuous-integration Needs Fixing
Review via email: mp+303467@code.launchpad.net

Commit message

Setting the password echo mode on passwords

Description of the change

Simpler than expected

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) :
review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'service/authentication.cpp'
2--- service/authentication.cpp 2016-04-25 20:57:22 +0000
3+++ service/authentication.cpp 2016-08-22 19:42:57 +0000
4@@ -21,6 +21,7 @@
5
6 #include <glib/gi18n.h>
7 #include <iostream>
8+#include <regex>
9
10 /* Make it so all our GObjects are easier to work with */
11 template <typename T>
12@@ -367,6 +368,9 @@
13 g_menu_insert_item(menus.get(), location, item.get());
14 }
15
16+/** A regex to see if the incoming request is for a password */
17+static const std::regex passwordDetector{"\\s*[Pp]assword:?\\s*"};
18+
19 /** Add a request for information from the user. This is a menu item in
20 the menu model. If there isn't an item, it is created here, else it
21 is updated to include this request. */
22@@ -382,9 +386,10 @@
23 int index = findMenuItem(menus, "x-canonical-type", "com.canonical.snapdecision.textfield");
24
25 std::string label;
26- if (request == "password:" || request == "Password:")
27+ if (std::regex_match(request, passwordDetector))
28 {
29 label = _("Password"); // TODO: Add Username (Password for Joe)
30+ password = true; /* Force to password even if PAM doesn't think so */
31 }
32 else
33 {
34@@ -397,6 +402,8 @@
35 auto item = shared_gobject<GMenuItem>(g_menu_item_new(label.c_str(), "pk.response"));
36 g_menu_item_set_attribute_value(item.get(), "x-canonical-type",
37 g_variant_new_string("com.canonical.snapdecision.textfield"));
38+ g_menu_item_set_attribute_value(item.get(), "x-echo-mode-password",
39+ g_variant_new_boolean(password ? TRUE : FALSE));
40 g_menu_append_item(menus.get(), item.get());
41 }
42 else
43@@ -404,6 +411,8 @@
44 /* Update it */
45 auto item = shared_gobject<GMenuItem>(g_menu_item_new_from_model(G_MENU_MODEL(menus.get()), index));
46 g_menu_item_set_label(item.get(), label.c_str());
47+ g_menu_item_set_attribute_value(item.get(), "x-echo-mode-password",
48+ g_variant_new_boolean(password ? TRUE : FALSE));
49 g_menu_remove(menus.get(), index);
50 g_menu_insert_item(menus.get(), index, item.get());
51 }
52
53=== modified file 'service/session-iface.cpp'
54--- service/session-iface.cpp 2016-04-25 20:57:22 +0000
55+++ service/session-iface.cpp 2016-08-22 19:42:57 +0000
56@@ -109,7 +109,7 @@
57 /** Static callback for the complete signal. Passed up to the
58 complete C++ signal. Also sets the session complete flag
59 which ensures we don't cancel on destruction. */
60- static void completeCb(PolkitAgentSession *session, bool success, gpointer user_data)
61+ static void completeCb(PolkitAgentSession *session, gboolean success, gpointer user_data)
62 {
63 g_debug("PK Session Complete: %s", success ? "success" : "fail");
64 auto obj = reinterpret_cast<Impl *>(user_data);

Subscribers

People subscribed via source and target branches

to all changes: