Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never try to login as the user SDDM #279

Merged
merged 1 commit into from
Oct 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/auth/Auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace SDDM {
QString sessionPath { };
QString user { };
bool autologin { false };
bool greeter { false };
QProcessEnvironment environment { };
qint64 id { 0 };
static qint64 lastId;
Expand Down Expand Up @@ -237,6 +238,11 @@ namespace SDDM {
return d->autologin;
}

bool Auth::isGreeter() const
{
return d->greeter;
}

const QString &Auth::session() const {
return d->sessionPath;
}
Expand Down Expand Up @@ -275,6 +281,14 @@ namespace SDDM {
}
}

void Auth::setGreeter(bool on)
{
if (on != d->greeter) {
d->greeter = on;
Q_EMIT greeterChanged();
}
}

void Auth::setSession(const QString& path) {
if (path != d->sessionPath) {
d->sessionPath = path;
Expand Down Expand Up @@ -302,6 +316,8 @@ namespace SDDM {
args << "--user" << d->user;
if (d->autologin)
args << "--autologin";
if (d->greeter)
args << "--greeter";
d->child->start(QString("%1/sddm-helper").arg(LIBEXEC_INSTALL_DIR), args);
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/auth/Auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace SDDM {
Q_OBJECT
// not setting NOTIFY for the properties - they should be set only once before calling start
Q_PROPERTY(bool autologin READ autologin WRITE setAutologin NOTIFY autologinChanged)
Q_PROPERTY(bool greeter READ isGreeter WRITE setGreeter NOTIFY greeterChanged)
Q_PROPERTY(bool verbose READ verbose WRITE setVerbose NOTIFY verboseChanged)
Q_PROPERTY(QString user READ user WRITE setUser NOTIFY userChanged)
Q_PROPERTY(QString session READ session WRITE setSession NOTIFY sessionChanged)
Expand Down Expand Up @@ -86,6 +87,7 @@ namespace SDDM {
static void registerTypes();

bool autologin() const;
bool isGreeter() const;
bool verbose() const;
const QString &user() const;
const QString &session() const;
Expand Down Expand Up @@ -113,6 +115,12 @@ namespace SDDM {
*/
void setAutologin(bool on = true);

/**
* Set mode to greeter
* This will bypass authentication checks
*/
void setGreeter(bool on = true);

/**
* Forwards the output of the underlying authenticator to the current process
* @param on true if should forward the output
Expand All @@ -139,6 +147,7 @@ namespace SDDM {

Q_SIGNALS:
void autologinChanged();
void greeterChanged();
void verboseChanged();
void userChanged();
void sessionChanged();
Expand Down
7 changes: 7 additions & 0 deletions src/daemon/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ namespace SDDM {

void Display::login(QLocalSocket *socket, const QString &user, const QString &password, const QString &session) {
m_socket = socket;

//the SDDM user has special priveledges that skip password checking so that we can load the greeter
//block ever trying to log in as the SDDM user
if (user == "sddm") {
return;
}

startAuth(user, password, session);
}

Expand Down
1 change: 1 addition & 0 deletions src/daemon/Greeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ namespace SDDM {

// start greeter
m_auth->setUser("sddm");
m_auth->setGreeter(true);
m_auth->setSession(args.join(" "));
m_auth->start();
}
Expand Down
4 changes: 4 additions & 0 deletions src/helper/Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace SDDM {
m_autologin = on;
}

void Backend::setGreeter(bool on) {
m_greeter = on;
}

bool Backend::openSession() {
struct passwd *pw;
pw = getpwnam(qPrintable(qobject_cast<HelperApp*>(parent())->user()));
Expand Down
2 changes: 2 additions & 0 deletions src/helper/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace SDDM {
static Backend *get(HelperApp *parent);

void setAutologin(bool on = true);
void setGreeter(bool on = true);

public slots:
virtual bool start(const QString &user = QString()) = 0;
Expand All @@ -48,6 +49,7 @@ namespace SDDM {
Backend(HelperApp *parent);
HelperApp *m_app;
bool m_autologin { false };
bool m_greeter { false };
};
}

Expand Down
4 changes: 4 additions & 0 deletions src/helper/HelperApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ namespace SDDM {
m_backend->setAutologin(true);
}

if ((pos == args.indexOf("--greeter")) >= 0) {
m_backend->setGreeter(true);
}

if (server.isEmpty() || m_id <= 0) {
qCritical() << "This application is not supposed to be executed manually";
exit(Auth::HELPER_OTHER_ERROR);
Expand Down
2 changes: 1 addition & 1 deletion src/helper/backend/PamBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace SDDM {

QString service = "sddm";

if (user == "sddm")
if (m_greeter)
service = "sddm-greeter";
else if (m_app->session()->path().isEmpty())
service = "sddm-check";
Expand Down