* @error: return location for a #GError, or %NULL
*
* Triggers a system suspend.
- *
+ *
* Return value: #TRUE if suspend initiated.
**/
gboolean
GVariant *result;
gboolean suspended;
- result = login1_call_function ("Suspend", g_variant_new("(b)", FALSE), error);
+ result = login1_call_function ("Suspend", g_variant_new("(b)", FALSE),
+ error);
if (!result)
{
- if (error)
- g_debug ("Can't suspend using logind; falling back to UPower: %s",
- (*error)->message);
- g_clear_error (error);
- result = upower_call_function ("Suspend", error);
+ if (error)
+ g_debug ("Can't suspend using logind; falling back to UPower: %s",
+ (*error)->message);
+ g_clear_error (error);
+ result = upower_call_function ("Suspend", error);
}
suspended = result != NULL;
* @error: return location for a #GError, or %NULL
*
* Triggers a system hibernate.
- *
+ *
* Return value: #TRUE if hibernate initiated.
**/
gboolean
GVariant *result;
gboolean hibernated;
- result = login1_call_function ("Hibernate", g_variant_new("(b)", FALSE), error);
+ result = login1_call_function ("Hibernate", g_variant_new("(b)", FALSE),
+ error);
if (!result)
{
- if (error)
- g_debug ("Can't hibernate using logind; falling back to UPower: %s",
- (*error)->message);
- g_clear_error (error);
- result = upower_call_function ("Hibernate", error);
+ if (error)
+ g_debug ("Can't hibernate using logind; falling back to UPower: %s",
+ (*error)->message);
+ g_clear_error (error);
+ result = upower_call_function ("Hibernate", error);
}
hibernated = result != NULL;
if (result)
- g_variant_unref (result);
+ g_variant_unref (result);
return hibernated;
}
{
gboolean can_shutdown = FALSE;
GVariant *r;
-
+
r = login1_call_function ("CanPowerOff", NULL, NULL);
if (r)
{
/*
* 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
gboolean authentication_complete;
int authentication_result;
gchar *authentication_result_string;
-
+
/* File to log to */
gchar *log_filename;
-
+
/* Seat class */
gchar *class;
/* tty this session is running on */
gchar *tty;
-
+
/* X display connected to */
gchar *xdisplay;
XAuthority *xauthority;
g_warning ("Invalid string length %d from child", length);
return NULL;
}
-
+
value = g_malloc (sizeof (char) * (length + 1));
read_from_child (session, value, length);
- value[length] = '\0';
+ value[length] = '\0';
return value;
}
Session *session = data;
session->priv->pid = 0;
-
+
if (WIFEXITED (status))
g_debug ("Session %d exited with return value %d", pid, WEXITSTATUS (status));
else if (WIFSIGNALED (status))
session->priv->authentication_result = PAM_CONV_ERR;
g_free (session->priv->authentication_result_string);
session->priv->authentication_result_string = g_strdup ("Authentication stopped before completion");
- g_signal_emit (G_OBJECT (session), signals[AUTHENTICATION_COMPLETE], 0);
+ g_signal_emit (G_OBJECT (session), signals[AUTHENTICATION_COMPLETE], 0);
}
g_signal_emit (G_OBJECT (session), signals[STOPPED], 0);
for (i = 0; i < session->priv->messages_length; i++)
{
struct pam_message *m = &session->priv->messages[i];
- read_from_child (session, &m->msg_style, sizeof (m->msg_style));
+ read_from_child (session, &m->msg_style, sizeof (m->msg_style));
m->msg = read_string_from_child (session);
}
g_debug ("Session %d got %d message(s) from PAM", session->priv->pid, session->priv->messages_length);
g_signal_emit (G_OBJECT (session), signals[GOT_MESSAGES], 0);
- }
+ }
return TRUE;
}
/* Close the ends of the pipes we don't need */
close (to_child_output);
close (from_child_input);
-
+
/* Indicate what version of the protocol we are using */
version = 0;
write_data (session, &version, sizeof (version));
write_data (session, xauth_get_authorization_data (session->priv->xauthority), length);
}
else
- write_string (session, NULL);
+ write_string (session, NULL);
g_debug ("Started session %d with service '%s', username '%s'", session->priv->pid, service, username);
g_return_if_fail (session != NULL);
g_return_if_fail (error != PAM_SUCCESS);
- write_data (session, &error, sizeof (error));
+ write_data (session, &error, sizeof (error));
}
int
{
gchar *run_dir, *dir;
- run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory");
+ run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory");
dir = g_build_filename (run_dir, session->priv->username, NULL);
g_free (run_dir);
void
session_lock (Session *session)
-{
+{
g_return_if_fail (session != NULL);
if (getuid () == 0)
{
void
session_unlock (Session *session)
-{
+{
g_return_if_fail (session != NULL);
if (getuid () == 0)
{
session_stop (Session *session)
{
g_return_if_fail (session != NULL);
-
+
if (session->priv->pid > 0)
{
g_debug ("Session %d: Sending SIGTERM", session->priv->pid);
{
Process *process;
gchar *status_text;
-
+
if (getenv ("DEBUG"))
{
if (WIFEXITED (status))
static Process *
watch_process (pid_t pid)
{
- Process *process;
+ Process *process;
process = g_malloc0 (sizeof (Process));
process->pid = pid;
else if (strcmp (name, "SWITCH-TO-USER") == 0)
{
gchar *status_text, *username;
-
+
username = g_hash_table_lookup (params, "USERNAME");
g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
"org.freedesktop.DisplayManager",
StatusClient *client = link->data;
int length;
GError *error = NULL;
-
+
length = strlen (command);
g_socket_send (client->socket, (gchar *) &length, sizeof (length), NULL, &error);
g_socket_send (client->socket, command, strlen (command), NULL, &error);
if (error)
g_printerr ("Failed to write to client socket: %s\n", error->message);
g_clear_error (&error);
- }
+ }
}
else
{
g_printerr ("Unknown command '%s'\n", name);
quit (EXIT_FAILURE);
}
-
+
g_free (name);
g_hash_table_unref (params);
}
if (stop)
return;
-
+
statuses = g_list_append (statuses, g_strdup (status));
-
+
if (getenv ("DEBUG"))
g_print ("%s\n", status);
result = g_regex_match_simple (full_pattern, status, 0, 0);
g_free (full_pattern);
}
-
+
if (!result)
{
fail (NULL, pattern);
upower_info = g_dbus_node_info_new_for_xml (upower_interface, &error);
if (error)
- g_warning ("Failed to parse D-Bus interface: %s", error->message);
+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
g_clear_error (&error);
if (!upower_info)
return;
}
-// Shared between CK and Login1 - identical signatures
+/* Shared between CK and Login1 - identical signatures */
static void
handle_session_call (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
if (strcmp (method_name, "Lock") == 0)
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
ck_info = g_dbus_node_info_new_for_xml (ck_interface, &error);
if (error)
- g_warning ("Failed to parse D-Bus interface: %s", error->message);
+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
g_clear_error (&error);
if (!ck_info)
return;
ck_session_info = g_dbus_node_info_new_for_xml (ck_session_interface, &error);
if (error)
- g_warning ("Failed to parse D-Bus interface: %s", error->message);
+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
g_clear_error (&error);
if (!ck_session_info)
return;
static Login1Session *
open_login1_session (GDBusConnection *connection,
- GVariant *params)
+ GVariant *params)
{
Login1Session *session;
GError *error = NULL;
"</node>";
static const GDBusInterfaceVTable login1_session_vtable =
{
- handle_session_call,
+ handle_session_call,
};
session = g_malloc0 (sizeof (Login1Session));
login1_sessions = g_list_append (login1_sessions, session);
session->path = g_strdup_printf("/org/freedesktop/login1/Session/c%d",
- login1_session_index++);
+ login1_session_index++);
login1_session_info = g_dbus_node_info_new_for_xml (login1_session_interface,
- &error);
+ &error);
if (error)
g_warning ("Failed to parse login1 session D-Bus interface: %s",
- error->message);
+ error->message);
g_clear_error (&error);
if (!login1_session_info)
return;
g_dbus_connection_register_object (connection,
- session->path,
- login1_session_info->interfaces[0],
- &login1_session_vtable,
- session,
- NULL,
- &error);
+ session->path,
+ login1_session_info->interfaces[0],
+ &login1_session_vtable,
+ session,
+ NULL,
+ &error);
if (error)
g_warning ("Failed to register login1 session: %s", error->message);
g_clear_error (&error);
if (strcmp (method_name, "GetSessionByPID") == 0)
{
- //Look for a session with our PID, and create one if we don't have one
- //already.
- GList *link;
- guint pid;
- Login1Session *ret = NULL;
-
- g_variant_get (parameters, "(u)", &pid);
-
- for (link = login1_sessions; link; link = link->next)
- {
- Login1Session *session;
- session = link->data;
- if (session->pid == pid)
- {
- ret = session;
- break;
- }
- }
- // Not found
- if (!ret)
- ret = open_login1_session (connection, parameters);
-
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new("(o)", ret->path));
-
+ /* Look for a session with our PID, and create one if we don't have one
+ already. */
+ GList *link;
+ guint pid;
+ Login1Session *ret = NULL;
+
+ g_variant_get (parameters, "(u)", &pid);
+
+ for (link = login1_sessions; link; link = link->next)
+ {
+ Login1Session *session;
+ session = link->data;
+ if (session->pid == pid)
+ {
+ ret = session;
+ break;
+ }
+ }
+ // Not found
+ if (!ret)
+ ret = open_login1_session (connection, parameters);
+
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new("(o)", ret->path));
+
}
else if (strcmp (method_name, "CanReboot") == 0)
{
g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
- load_passwd_file ();
+ load_passwd_file ();
for (link = accounts_users; link; link = link->next)
{
AccountsUser *user = link->data;
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such user: %s", user_name);
}
else
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "No such method: %s", method_name);
}
static void
accounts_info = g_dbus_node_info_new_for_xml (accounts_interface, &error);
if (error)
- g_warning ("Failed to parse D-Bus interface: %s", error->message);
+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
g_clear_error (&error);
if (!accounts_info)
return;
user_info = g_dbus_node_info_new_for_xml (user_interface, &error);
if (error)
- g_warning ("Failed to parse D-Bus interface: %s", error->message);
+ g_warning ("Failed to parse D-Bus interface: %s", error->message);
g_clear_error (&error);
if (!user_info)
return;
g_critical ("Error getting current directory: %s", strerror (errno));
quit (EXIT_FAILURE);
}
-
+
/* Don't contact our X server */
g_unsetenv ("DISPLAY");
g_free (path);
/* Use locally built libraries */
- path1 = g_build_filename (BUILDDIR, "liblightdm-gobject", ".libs", NULL);
+ path1 = g_build_filename (BUILDDIR, "liblightdm-gobject", ".libs", NULL);
path2 = g_build_filename (BUILDDIR, "liblightdm-qt", ".libs", NULL);
ld_library_path = g_strdup_printf ("%s:%s", path1, path2);
g_free (path1);
/* Always copy the script */
if (system (g_strdup_printf ("cp %s %s/script", config_path, temp_dir)))
- perror ("Failed to copy configuration");
+ perror ("Failed to copy configuration");
/* Copy over the greeter files */
if (system (g_strdup_printf ("cp -r %s/xsessions %s/usr/share", DATADIR, temp_dir)))
/* This account has a set of keyboard layouts */
{"have-layouts", "", TRUE, "Layouts User", NULL, "ru", "fr\toss;ru;", NULL, 1010},
/* This account has a language set */
- {"have-language", "", TRUE, "Language User", NULL, NULL, NULL, "en_AU.utf8", 1011},
+ {"have-language", "", TRUE, "Language User", NULL, NULL, NULL, "en_AU.utf8", 1011},
/* This account has a preconfigured session */
{"have-session", "", TRUE, "Session User", "alternative", NULL, NULL, NULL, 1012},
/* This account has the home directory mounted on login */
{
g_key_file_set_string (dmrc_file, "X-Accounts", "Layouts", users[i].dbus_layouts);
save_dmrc = TRUE;
+
}
if (users[i].language)
{
data = g_key_file_to_data (dmrc_file, NULL, NULL);
g_file_set_contents (path, data, -1, NULL);
g_free (data);
- g_free (path);
+ g_free (path);
}
g_key_file_free (dmrc_file);