Skip to content

Commit

Permalink
Fall back to regular login when autologin fails
Browse files Browse the repository at this point in the history
Fixes #316
  • Loading branch information
jleclanche committed Nov 5, 2015
1 parent e646bd3 commit cb76889
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
42 changes: 25 additions & 17 deletions src/daemon/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,29 @@ namespace SDDM {
m_displayServer->start();
}

bool Display::attemptAutologin() {
Session::Type sessionType = Session::X11Session;

// determine session type
const QString &autologinSession = mainConfig.Autologin.Session.get();
if (findSessionEntry(mainConfig.XDisplay.SessionDir.get(), autologinSession)) {
sessionType = Session::X11Session;
} else if (findSessionEntry(mainConfig.WaylandDisplay.SessionDir.get(), autologinSession)) {
sessionType = Session::WaylandSession;
} else {
qCritical() << "Unable to find autologin session entry" << autologinSession;
return false;
}

Session session;
session.setTo(sessionType, autologinSession);

m_auth->setAutologin(true);
startAuth(mainConfig.Autologin.User.get(), QString(), session);

return true;
}

void Display::displayServerStarted() {
// check flag
if (m_started)
Expand All @@ -122,25 +145,10 @@ namespace SDDM {
// set flags
m_started = true;

// determine session type
const QString &autologinSession = mainConfig.Autologin.Session.get();
Session session;
if (findSessionEntry(mainConfig.XDisplay.SessionDir.get(), autologinSession)) {
session.setTo(Session::X11Session, autologinSession);
} else if (findSessionEntry(mainConfig.WaylandDisplay.SessionDir.get(), autologinSession)) {
session.setTo(Session::WaylandSession, autologinSession);
} else {
qCritical() << "Unable to find autologin session entry" << autologinSession;
emit loginFailed(m_socket);
bool success = attemptAutologin();
if (success) {
return;
}

// start session
m_auth->setAutologin(true);
startAuth(mainConfig.Autologin.User.get(), QString(), session);

// return
return;
}

// start socket server
Expand Down
1 change: 1 addition & 0 deletions src/daemon/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace SDDM {
void login(QLocalSocket *socket,
const QString &user, const QString &password,
const Session &session);
bool attemptAutologin();
void displayServerStarted();

signals:
Expand Down

0 comments on commit cb76889

Please sign in to comment.