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
=== modified file 'service/authentication.cpp'
--- service/authentication.cpp 2016-04-25 20:57:22 +0000
+++ service/authentication.cpp 2016-08-22 19:42:57 +0000
@@ -21,6 +21,7 @@
2121
22#include <glib/gi18n.h>22#include <glib/gi18n.h>
23#include <iostream>23#include <iostream>
24#include <regex>
2425
25/* Make it so all our GObjects are easier to work with */26/* Make it so all our GObjects are easier to work with */
26template <typename T>27template <typename T>
@@ -367,6 +368,9 @@
367 g_menu_insert_item(menus.get(), location, item.get());368 g_menu_insert_item(menus.get(), location, item.get());
368}369}
369370
371/** A regex to see if the incoming request is for a password */
372static const std::regex passwordDetector{"\\s*[Pp]assword:?\\s*"};
373
370/** Add a request for information from the user. This is a menu item in374/** Add a request for information from the user. This is a menu item in
371 the menu model. If there isn't an item, it is created here, else it375 the menu model. If there isn't an item, it is created here, else it
372 is updated to include this request. */376 is updated to include this request. */
@@ -382,9 +386,10 @@
382 int index = findMenuItem(menus, "x-canonical-type", "com.canonical.snapdecision.textfield");386 int index = findMenuItem(menus, "x-canonical-type", "com.canonical.snapdecision.textfield");
383387
384 std::string label;388 std::string label;
385 if (request == "password:" || request == "Password:")389 if (std::regex_match(request, passwordDetector))
386 {390 {
387 label = _("Password"); // TODO: Add Username (Password for Joe)391 label = _("Password"); // TODO: Add Username (Password for Joe)
392 password = true; /* Force to password even if PAM doesn't think so */
388 }393 }
389 else394 else
390 {395 {
@@ -397,6 +402,8 @@
397 auto item = shared_gobject<GMenuItem>(g_menu_item_new(label.c_str(), "pk.response"));402 auto item = shared_gobject<GMenuItem>(g_menu_item_new(label.c_str(), "pk.response"));
398 g_menu_item_set_attribute_value(item.get(), "x-canonical-type",403 g_menu_item_set_attribute_value(item.get(), "x-canonical-type",
399 g_variant_new_string("com.canonical.snapdecision.textfield"));404 g_variant_new_string("com.canonical.snapdecision.textfield"));
405 g_menu_item_set_attribute_value(item.get(), "x-echo-mode-password",
406 g_variant_new_boolean(password ? TRUE : FALSE));
400 g_menu_append_item(menus.get(), item.get());407 g_menu_append_item(menus.get(), item.get());
401 }408 }
402 else409 else
@@ -404,6 +411,8 @@
404 /* Update it */411 /* Update it */
405 auto item = shared_gobject<GMenuItem>(g_menu_item_new_from_model(G_MENU_MODEL(menus.get()), index));412 auto item = shared_gobject<GMenuItem>(g_menu_item_new_from_model(G_MENU_MODEL(menus.get()), index));
406 g_menu_item_set_label(item.get(), label.c_str());413 g_menu_item_set_label(item.get(), label.c_str());
414 g_menu_item_set_attribute_value(item.get(), "x-echo-mode-password",
415 g_variant_new_boolean(password ? TRUE : FALSE));
407 g_menu_remove(menus.get(), index);416 g_menu_remove(menus.get(), index);
408 g_menu_insert_item(menus.get(), index, item.get());417 g_menu_insert_item(menus.get(), index, item.get());
409 }418 }
410419
=== modified file 'service/session-iface.cpp'
--- service/session-iface.cpp 2016-04-25 20:57:22 +0000
+++ service/session-iface.cpp 2016-08-22 19:42:57 +0000
@@ -109,7 +109,7 @@
109 /** Static callback for the complete signal. Passed up to the109 /** Static callback for the complete signal. Passed up to the
110 complete C++ signal. Also sets the session complete flag110 complete C++ signal. Also sets the session complete flag
111 which ensures we don't cancel on destruction. */111 which ensures we don't cancel on destruction. */
112 static void completeCb(PolkitAgentSession *session, bool success, gpointer user_data)112 static void completeCb(PolkitAgentSession *session, gboolean success, gpointer user_data)
113 {113 {
114 g_debug("PK Session Complete: %s", success ? "success" : "fail");114 g_debug("PK Session Complete: %s", success ? "success" : "fail");
115 auto obj = reinterpret_cast<Impl *>(user_data);115 auto obj = reinterpret_cast<Impl *>(user_data);

Subscribers

People subscribed via source and target branches

to all changes: