summaryrefslogtreecommitdiff
path: root/liblightdm-qt
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2011-07-12 16:58:54 +1000
committerRobert Ancell <robert.ancell@canonical.com>2011-07-12 16:58:54 +1000
commit0a12a677baddf5075f26193e5a3208d5ce63100b (patch)
tree2aadee90358bb054bf92948b959ffc53ec9f432c /liblightdm-qt
parent040cac72cd6eb051e04b288ef672efad25df7494 (diff)
downloadlightdm-git-0a12a677baddf5075f26193e5a3208d5ce63100b.tar.gz
Fix error where an authentication failure from a previous session could be interpreted as a failure in the current session
Diffstat (limited to 'liblightdm-qt')
-rw-r--r--liblightdm-qt/QLightDM/greeter.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/liblightdm-qt/QLightDM/greeter.cpp b/liblightdm-qt/QLightDM/greeter.cpp
index 6dbe6503..344c08fb 100644
--- a/liblightdm-qt/QLightDM/greeter.cpp
+++ b/liblightdm-qt/QLightDM/greeter.cpp
@@ -77,6 +77,7 @@ public:
bool inAuthentication;
bool isAuthenticated;
QString authenticationUser;
+ int authenticateSequenceNumber;
};
@@ -88,6 +89,7 @@ Greeter::Greeter(QObject *parent) :
d->nRead = 0;
d->config = 0;
d->sessionsModel = new SessionsModel(this);
+ d->authenticateSequenceNumber = 0;
}
Greeter::~Greeter()
@@ -220,18 +222,22 @@ void Greeter::login(const QString &username)
d->isAuthenticated = false;
d->authenticationUser = username;
qDebug() << "Starting authentication for user " << username << "...";
- writeHeader(GREETER_MESSAGE_LOGIN, stringLength(username));
+ writeHeader(GREETER_MESSAGE_LOGIN, intLength() + stringLength(username));
+ d->authenticateSequenceNumber++;
+ writeInt(d->authenticateSequenceNumber);
writeString(username);
flush();
}
void Greeter::loginAsGuest()
{
+ d->authenticateSequenceNumber++;
d->inAuthentication = true;
d->isAuthenticated = false;
d->authenticationUser = "";
qDebug() << "Starting authentication for guest account";
- writeHeader(GREETER_MESSAGE_LOGIN_AS_GUEST, 0);
+ writeHeader(GREETER_MESSAGE_LOGIN_AS_GUEST, intLength());
+ writeInt(d->authenticateSequenceNumber);
flush();
}
@@ -316,7 +322,7 @@ void Greeter::onRead(int fd)
int offset = 0;
int id = readInt(&offset);
readInt(&offset);
- int nMessages, returnCode;
+ int nMessages, sequenceNumber, returnCode;
switch(id)
{
case GREETER_MESSAGE_CONNECTED:
@@ -365,14 +371,21 @@ void Greeter::onRead(int fd)
}
break;
case GREETER_MESSAGE_END_AUTHENTICATION:
+ sequenceNumber = readInt(&offset);
returnCode = readInt(&offset);
- qDebug() << "Authentication complete with return code " << returnCode;
- d->isAuthenticated = (returnCode == 0);
- if(!d->isAuthenticated) {
- d->authenticationUser = "";
+
+ if (sequenceNumber == d->authenticateSequenceNumber)
+ {
+ qDebug() << "Authentication complete with return code " << returnCode;
+ d->isAuthenticated = (returnCode == 0);
+ if(!d->isAuthenticated) {
+ d->authenticationUser = "";
+ }
+ emit authenticationComplete(d->isAuthenticated);
+ d->inAuthentication = false;
}
- emit authenticationComplete(d->isAuthenticated);
- d->inAuthentication = false;
+ else
+ qDebug () << "Ignoring end authentication with invalid sequence number " << sequenceNumber;
break;
default:
qDebug() << "Unknown message from server: " << id;