Merge lp:~mterry/ubuntu-system-settings/same-pass-switch into lp:ubuntu-system-settings

Proposed by Michael Terry
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 1005
Merged at revision: 1016
Proposed branch: lp:~mterry/ubuntu-system-settings/same-pass-switch
Merge into: lp:ubuntu-system-settings
Diff against target: 125 lines (+40/-11)
3 files modified
plugins/security-privacy/securityprivacy.cpp (+24/-6)
src/accountsservice.cpp (+9/-1)
wizard/qml/main.qml (+7/-4)
To merge this branch: bzr merge lp:~mterry/ubuntu-system-settings/same-pass-switch
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+233790@code.launchpad.net

Commit message

Allow switch from PIN code to passphrase and back using the same password. (LP: #1357043)

The reason this bug exists in the first place is that passwd doesn't let you switch to the same password. So while we could change the AccountsService password display hint just fine, we'd see an error from passwd and bail out. So IF the user gave us the correct password, we can ignore any errors from passwd if the new password is the same.

I also added some more verbose output in some error cases while I was there. It'll be helpful when debugging in the future (and I didn't want to separate it out into its own branch because conflicts).

Description of the change

Allow switch from PIN code to passphrase and back using the same password. (LP: #1357043)

The reason this bug exists in the first place is that passwd doesn't let you switch to the same password. So while we could change the AccountsService password display hint just fine, we'd see an error from passwd and bail out. So IF the user gave us the correct password, we can ignore any errors from passwd if the new password is the same.

I also added some more verbose output in some error cases while I was there. It'll be helpful when debugging in the future (and I didn't want to separate it out into its own branch because conflicts).

== Checklist ==

 * Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
 Yes

 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
 Yes

 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
 Yes

 * Has your component "TestPlan” been executed successfully on emulator, N4?
 Yes

 * Has a 5 minute exploratory testing run been executed on N4?
 Yes

 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
 NA

 * If you changed the UI, did you subscribe the design-reviewers to this MP?
 NA

 * What components might get impacted by your changes?
 Security/Privacy

 * Have you requested review by the teams of these owning components?
 Is that me these days?

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

seems ok to me, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/security-privacy/securityprivacy.cpp'
2--- plugins/security-privacy/securityprivacy.cpp 2014-08-29 05:19:03 +0000
3+++ plugins/security-privacy/securityprivacy.cpp 2014-09-08 19:37:19 +0000
4@@ -18,6 +18,7 @@
5 */
6
7 #include "securityprivacy.h"
8+#include <QtCore/QDebug>
9 #include <QtCore/QProcess>
10 #include <QtDBus/QDBusConnection>
11 #include <QtDBus/QDBusConnectionInterface>
12@@ -220,7 +221,12 @@
13 QDBusConnection::systemBus());
14
15 QDBusReply<void> success = iface.call("SetPasswordMode", newMode);
16- return success.isValid();
17+ if (success.isValid()) {
18+ return true;
19+ } else {
20+ qWarning() << "Could not set password mode:" << success.error().message();
21+ return false;
22+ }
23 }
24
25 bool SecurityPrivacy::setPasswordModeWithPolicykit(SecurityType type, QString password)
26@@ -242,6 +248,8 @@
27 // But first, see if we have cached authentication
28 if (setPasswordMode(type))
29 return true;
30+ else if (password.isEmpty())
31+ return false;
32
33 QProcess polkitHelper;
34 polkitHelper.setProgram(HELPER_EXEC);
35@@ -283,7 +291,7 @@
36 QString output = QString::fromUtf8(pamHelper.readLine());
37 if (output.isEmpty()) {
38 return "Internal error: could not run passwd";
39- } else {
40+ } else {
41 // Grab everything on first line after the last colon. This is because
42 // passwd will bunch it up like so:
43 // "(current) UNIX password: Enter new UNIX password: Retype new UNIX password: You must choose a longer password"
44@@ -363,12 +371,22 @@
45 } else {
46 QString errorText = setPassword(oldValue, value);
47 if (!errorText.isEmpty()) {
48- setDisplayHint(oldType);
49- // Special case this common message because the one PAM gives is so awful
50- if (errorText == dgettext("Linux-PAM", "Authentication token manipulation error"))
51+ if (errorText == dgettext("Linux-PAM", "Authentication token manipulation error")) {
52+ // Special case this common message because the one PAM gives is so awful
53+ setDisplayHint(oldType);
54 return badPasswordMessage(oldType);
55- else
56+ } else if (oldValue != value) {
57+ // Only treat this as an error case if the passwords aren't
58+ // the same. (If they are the same, and we're just switching
59+ // display hints, then passwd will give us an error message
60+ // like "Password unchanged" but we don't want to rely on
61+ // parsing that output. Instead, if we got past the "bad old
62+ // password" part above and oldValue == value, we don't care
63+ // about any errors from passwd.)
64+ setDisplayHint(oldType);
65 return errorText;
66+ }
67+ // else fall through to below
68 }
69 if (!setPasswordModeWithPolicykit(type, value)) {
70 setDisplayHint(oldType);
71
72=== modified file 'src/accountsservice.cpp'
73--- src/accountsservice.cpp 2014-07-28 09:08:45 +0000
74+++ src/accountsservice.cpp 2014-09-08 19:37:19 +0000
75@@ -21,6 +21,7 @@
76 #include "accountsservice.h"
77
78 #include <QDBusReply>
79+#include <QDebug>
80
81 #include <unistd.h>
82 #include <sys/types.h>
83@@ -134,6 +135,9 @@
84 interface,
85 property,
86 QVariant::fromValue(QDBusVariant(value)));
87+ if (msg.type() == QDBusMessage::ErrorMessage) {
88+ qWarning() << "Could not set AccountsService property" << property << "on interface" << interface << "for object" << m_objectPath << "to" << value << ":" << msg.errorMessage();
89+ }
90 return msg.type() == QDBusMessage::ReplyMessage;
91 }
92
93@@ -146,5 +150,9 @@
94 m_systemBusConnection,
95 this);
96
97- return iface.call(method, value).type() == QDBusMessage::ReplyMessage;
98+ QDBusMessage msg = iface.call(method, value);
99+ if (msg.type() == QDBusMessage::ErrorMessage) {
100+ qWarning() << "Could not call AccountsService method" << method << "for object" << m_objectPath << "with argument" << value << ":" << msg.errorMessage();
101+ }
102+ return msg.type() == QDBusMessage::ReplyMessage;
103 }
104
105=== modified file 'wizard/qml/main.qml'
106--- wizard/qml/main.qml 2014-09-04 00:57:21 +0000
107+++ wizard/qml/main.qml 2014-09-08 19:37:19 +0000
108@@ -46,10 +46,13 @@
109 // Immediately go to black to give quick feedback
110 blackCover.visible = true
111
112- // Ignore any errors, since we're past where the user set the
113- // method. Worst case, we just leave the user with a swipe
114- // security method and they fix it in the system settings.
115- securityPrivacy.setSecurity("", password, passwordMethod)
116+ var errorMsg = securityPrivacy.setSecurity("", password, passwordMethod)
117+ if (errorMsg !== "") {
118+ // Ignore (but log) any errors, since we're past where the user set
119+ // the method. Worst case, we just leave the user with a swipe
120+ // security method and they fix it in the system settings.
121+ console.log("Error setting security method:", errorMsg)
122+ }
123
124 Qt.quit()
125 }

Subscribers

People subscribed via source and target branches