liblightdm_gobject_0_la_SOURCES= \
greeter.c \
- greeter-protocol.h \
language.c \
layout.c \
session.c \
+++ /dev/null
-/*
- * Copyright (C) 2010-2011 Robert Ancell.
- * Author: Robert Ancell <robert.ancell@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#ifndef _GREETER_PROTOCOL_H_
-#define _GREETER_PROTOCOL_H_
-
-typedef enum
-{
- /* Messages from the greeter to the server */
- GREETER_MESSAGE_CONNECT = 1,
- GREETER_MESSAGE_LOGIN = 2,
- GREETER_MESSAGE_LOGIN_AS_GUEST = 3,
- GREETER_MESSAGE_CONTINUE_AUTHENTICATION = 4,
- GREETER_MESSAGE_START_SESSION = 5,
- GREETER_MESSAGE_CANCEL_AUTHENTICATION = 6,
-
- /* Messages from the server to the greeter */
- GREETER_MESSAGE_CONNECTED = 101,
- GREETER_MESSAGE_QUIT = 102,
- GREETER_MESSAGE_PROMPT_AUTHENTICATION = 103,
- GREETER_MESSAGE_END_AUTHENTICATION = 104,
- GREETER_MESSAGE_SESSION_FAILED = 105
-} GreeterMessage;
-
-#endif /* _GREETER_PROTOCOL_H_ */
* license.
*/
+#include <config.h>
+
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "lightdm/greeter.h"
#include "user-private.h"
-#include "greeter-protocol.h"
enum {
PROP_0,
#define PASSWD_FILE "/etc/passwd"
#define USER_CONFIG_FILE "/etc/lightdm/users.conf"
+/* Messages from the greeter to the server */
+typedef enum
+{
+ GREETER_MESSAGE_CONNECT = 0,
+ GREETER_MESSAGE_LOGIN,
+ GREETER_MESSAGE_LOGIN_AS_GUEST,
+ GREETER_MESSAGE_CONTINUE_AUTHENTICATION,
+ GREETER_MESSAGE_START_SESSION,
+ GREETER_MESSAGE_CANCEL_AUTHENTICATION
+} GreeterMessage;
+
+/* Messages from the server to the greeter */
+typedef enum
+{
+ SERVER_MESSAGE_CONNECTED = 0,
+ SERVER_MESSAGE_QUIT,
+ SERVER_MESSAGE_PROMPT_AUTHENTICATION,
+ SERVER_MESSAGE_END_AUTHENTICATION,
+ SERVER_MESSAGE_SESSION_FAILED,
+} ServerMessage;
+
/**
* ldm_greeter_new:
*
read_int (greeter, &offset);
switch (id)
{
- case GREETER_MESSAGE_CONNECTED:
+ case SERVER_MESSAGE_CONNECTED:
handle_connected (greeter, &offset);
break;
- case GREETER_MESSAGE_PROMPT_AUTHENTICATION:
+ case SERVER_MESSAGE_PROMPT_AUTHENTICATION:
handle_prompt_authentication (greeter, &offset);
break;
- case GREETER_MESSAGE_END_AUTHENTICATION:
+ case SERVER_MESSAGE_END_AUTHENTICATION:
handle_end_authentication (greeter, &offset);
break;
- case GREETER_MESSAGE_SESSION_FAILED:
+ case SERVER_MESSAGE_SESSION_FAILED:
handle_session_failed (greeter, &offset);
break;
- case GREETER_MESSAGE_QUIT:
+ case SERVER_MESSAGE_QUIT:
handle_quit (greeter, &offset);
break;
default:
g_io_add_watch (greeter->priv->from_server_channel, G_IO_IN, from_server_cb, greeter);
g_debug ("Connecting to display manager...");
- write_header (message, MAX_MESSAGE_LENGTH, GREETER_MESSAGE_CONNECT, 0, &offset);
+ write_header (message, MAX_MESSAGE_LENGTH, GREETER_MESSAGE_CONNECT, string_length (VERSION), &offset);
+ write_string (message, MAX_MESSAGE_LENGTH, VERSION, &offset);
write_message (greeter, message, offset);
return TRUE;
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
+/* Messages from the greeter to the server */
typedef enum
{
- /* Messages from the greeter to the server */
- GREETER_MESSAGE_CONNECT = 1,
- GREETER_MESSAGE_LOGIN = 2,
- GREETER_MESSAGE_LOGIN_AS_GUEST = 3,
- GREETER_MESSAGE_CONTINUE_AUTHENTICATION = 4,
- GREETER_MESSAGE_START_SESSION = 5,
- GREETER_MESSAGE_CANCEL_AUTHENTICATION = 6,
-
- /* Messages from the server to the greeter */
- GREETER_MESSAGE_CONNECTED = 101,
- GREETER_MESSAGE_QUIT = 102,
- GREETER_MESSAGE_PROMPT_AUTHENTICATION = 103,
- GREETER_MESSAGE_END_AUTHENTICATION = 104,
- GREETER_MESSAGE_SESSION_FAILED = 105
+ GREETER_MESSAGE_CONNECT = 0,
+ GREETER_MESSAGE_LOGIN,
+ GREETER_MESSAGE_LOGIN_AS_GUEST,
+ GREETER_MESSAGE_CONTINUE_AUTHENTICATION,
+ GREETER_MESSAGE_START_SESSION,
+ GREETER_MESSAGE_CANCEL_AUTHENTICATION
} GreeterMessage;
+/* Messages from the server to the greeter */
+typedef enum
+{
+ SERVER_MESSAGE_CONNECTED = 0,
+ SERVER_MESSAGE_QUIT,
+ SERVER_MESSAGE_PROMPT_AUTHENTICATION,
+ SERVER_MESSAGE_END_AUTHENTICATION,
+ SERVER_MESSAGE_SESSION_FAILED,
+} ServerMessage;
+
#define HEADER_SIZE 8
using namespace QLightDM;
connect(d->n, SIGNAL(activated(int)), this, SLOT(onRead(int)));
qDebug() << "Connecting to display manager...";
- writeHeader(GREETER_MESSAGE_CONNECT, 0);
+ writeHeader(GREETER_MESSAGE_CONNECT, stringLength(VERSION));
+ writeString(VERSION);
flush();
}
QString version, username;
switch(id)
{
- case GREETER_MESSAGE_CONNECTED:
+ case SERVER_MESSAGE_CONNECTED:
version = readString(&offset);
d->defaultSession = readString(&offset);
d->timedUser = readString(&offset);
}
emit connected();
break;
- case GREETER_MESSAGE_QUIT:
+ case SERVER_MESSAGE_QUIT:
qDebug() << "Got quit request from server";
emit quit();
break;
- case GREETER_MESSAGE_PROMPT_AUTHENTICATION:
+ case SERVER_MESSAGE_PROMPT_AUTHENTICATION:
sequenceNumber = readInt(&offset);
if (sequenceNumber == d->authenticateSequenceNumber &&
}
}
break;
- case GREETER_MESSAGE_END_AUTHENTICATION:
+ case SERVER_MESSAGE_END_AUTHENTICATION:
sequenceNumber = readInt(&offset);
returnCode = readInt(&offset);
else
qDebug () << "Ignoring end authentication with invalid sequence number " << sequenceNumber;
break;
- case GREETER_MESSAGE_SESSION_FAILED:
+ case SERVER_MESSAGE_SESSION_FAILED:
qDebug() << "Session failed to start";
emit sessionFailed();
break;
dmrc.h \
greeter.c \
greeter.h \
- greeter-protocol.h \
guest-account.c \
guest-account.h \
lightdm.c \
+++ /dev/null
-/*
- * Copyright (C) 2010-2011 Robert Ancell.
- * Author: Robert Ancell <robert.ancell@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
- * license.
- */
-
-#ifndef _GREETER_PROTOCOL_H_
-#define _GREETER_PROTOCOL_H_
-
-typedef enum
-{
- /* Messages from the greeter to the server */
- GREETER_MESSAGE_CONNECT = 1,
- GREETER_MESSAGE_LOGIN = 2,
- GREETER_MESSAGE_LOGIN_AS_GUEST = 3,
- GREETER_MESSAGE_CONTINUE_AUTHENTICATION = 4,
- GREETER_MESSAGE_START_SESSION = 5,
- GREETER_MESSAGE_CANCEL_AUTHENTICATION = 6,
-
- /* Messages from the server to the greeter */
- GREETER_MESSAGE_CONNECTED = 101,
- GREETER_MESSAGE_QUIT = 102,
- GREETER_MESSAGE_PROMPT_AUTHENTICATION = 103,
- GREETER_MESSAGE_END_AUTHENTICATION = 104,
- GREETER_MESSAGE_SESSION_FAILED = 105
-} GreeterMessage;
-
-#endif /* _GREETER_PROTOCOL_H_ */
#include "greeter.h"
#include "ldm-marshal.h"
-#include "greeter-protocol.h"
#include "guest-account.h"
enum {
/* Session running on */
Session *session;
- /* TRUE if the greeter has connected to the daemon pipe */
- gboolean connected;
-
/* Buffer for data read from greeter */
guint8 *read_buffer;
gsize n_read;
G_DEFINE_TYPE (Greeter, greeter, G_TYPE_OBJECT);
+/* Messages from the greeter to the server */
+typedef enum
+{
+ GREETER_MESSAGE_CONNECT = 0,
+ GREETER_MESSAGE_LOGIN,
+ GREETER_MESSAGE_LOGIN_AS_GUEST,
+ GREETER_MESSAGE_CONTINUE_AUTHENTICATION,
+ GREETER_MESSAGE_START_SESSION,
+ GREETER_MESSAGE_CANCEL_AUTHENTICATION
+} GreeterMessage;
+
+/* Messages from the server to the greeter */
+typedef enum
+{
+ SERVER_MESSAGE_CONNECTED = 0,
+ SERVER_MESSAGE_QUIT,
+ SERVER_MESSAGE_PROMPT_AUTHENTICATION,
+ SERVER_MESSAGE_END_AUTHENTICATION,
+ SERVER_MESSAGE_SESSION_FAILED,
+} ServerMessage;
+
Greeter *
greeter_new (Session *session)
{
}
static void
-handle_connect (Greeter *greeter)
+handle_connect (Greeter *greeter, const gchar *version)
{
guint8 message[MAX_MESSAGE_LENGTH];
gsize offset = 0;
- if (!greeter->priv->connected)
- {
- greeter->priv->connected = TRUE;
- g_debug ("Greeter connected");
- }
+ g_debug ("Greeter connected version=%s", version);
- write_header (message, MAX_MESSAGE_LENGTH, GREETER_MESSAGE_CONNECTED, string_length (VERSION) + string_length (greeter->priv->default_session) + string_length (greeter->priv->selected_user) + int_length () + int_length (), &offset);
+ write_header (message, MAX_MESSAGE_LENGTH, SERVER_MESSAGE_CONNECTED, string_length (VERSION) + string_length (greeter->priv->default_session) + string_length (greeter->priv->selected_user) + int_length () + int_length (), &offset);
write_string (message, MAX_MESSAGE_LENGTH, VERSION, &offset);
write_string (message, MAX_MESSAGE_LENGTH, greeter->priv->default_session, &offset);
write_string (message, MAX_MESSAGE_LENGTH, greeter->priv->selected_user, &offset);
size = int_length () + int_length ();
for (i = 0; i < num_msg; i++)
size += int_length () + string_length (msg[i]->msg);
- write_header (message, MAX_MESSAGE_LENGTH, GREETER_MESSAGE_PROMPT_AUTHENTICATION, size, &offset);
+ write_header (message, MAX_MESSAGE_LENGTH, SERVER_MESSAGE_PROMPT_AUTHENTICATION, size, &offset);
write_int (message, MAX_MESSAGE_LENGTH, greeter->priv->authentication_sequence_number, &offset);
write_int (message, MAX_MESSAGE_LENGTH, num_msg, &offset);
for (i = 0; i < num_msg; i++)
guint8 message[MAX_MESSAGE_LENGTH];
gsize offset = 0;
- write_header (message, MAX_MESSAGE_LENGTH, GREETER_MESSAGE_END_AUTHENTICATION, int_length () + int_length (), &offset);
+ write_header (message, MAX_MESSAGE_LENGTH, SERVER_MESSAGE_END_AUTHENTICATION, int_length () + int_length (), &offset);
write_int (message, MAX_MESSAGE_LENGTH, sequence_number, &offset);
write_int (message, MAX_MESSAGE_LENGTH, result, &offset);
write_message (greeter, message, offset);
struct pam_response *response;
int i, j, n_secrets = 0;
- /* Not connected */
- if (!greeter->priv->connected)
- return;
-
/* Not in authorization */
if (greeter->priv->pam_session == NULL)
return;
static void
handle_cancel_authentication (Greeter *greeter)
{
- /* Not connected */
- if (!greeter->priv->connected)
- return;
-
/* Not in authorization */
if (greeter->priv->pam_session == NULL)
return;
g_return_if_fail (greeter != NULL);
- write_header (message, MAX_MESSAGE_LENGTH, GREETER_MESSAGE_QUIT, 0, &offset);
+ write_header (message, MAX_MESSAGE_LENGTH, SERVER_MESSAGE_QUIT, 0, &offset);
write_message (greeter, message, offset);
}
guint8 message[MAX_MESSAGE_LENGTH];
gsize offset = 0;
- write_header (message, MAX_MESSAGE_LENGTH, GREETER_MESSAGE_SESSION_FAILED, 0, &offset);
+ write_header (message, MAX_MESSAGE_LENGTH, SERVER_MESSAGE_SESSION_FAILED, 0, &offset);
write_message (greeter, message, offset);
}
}
GIOStatus status;
int id, n_secrets, i;
guint32 sequence_number;
- gchar *username, *session_name;
+ gchar *version, *username, *session_name;
gchar **secrets;
GError *error = NULL;
switch (id)
{
case GREETER_MESSAGE_CONNECT:
- handle_connect (greeter);
+ version = read_string (greeter, &offset);
+ handle_connect (greeter, version);
+ g_free (version);
break;
case GREETER_MESSAGE_LOGIN:
sequence_number = read_int (greeter, &offset);