pmaports/unity8/accountsservice-ubuntu/0002-0007-add-lightdm-support.patch.patch
Luca Weiss 8c2a95dbe2
unity8: initial packaging (!27)
* Mir starts up and is able to display system settings
* x86_64 only for now, because at least ubuntu-app-test did not build
  on aarch64

Based on PureTryOut's work. Getting it to this stage was a huge effort
(as it shows in the package count: 111(!)). See the merge request for
details.

[skip ci]: this won't finish in CI; ollieparanoid made sure that
           everything builds for x86_64.
2019-02-13 21:47:29 +01:00

190 lines
6.7 KiB
Diff

From 5f8f807b2a9a22d203d948127b24e5790b6b64b9 Mon Sep 17 00:00:00 2001
From: Luca Weiss <luca@z3ntu.xyz>
Date: Thu, 27 Sep 2018 23:31:06 +0200
Subject: [PATCH 2/4] 0007-add-lightdm-support.patch
---
src/daemon.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 132 insertions(+), 11 deletions(-)
diff --git a/src/daemon.c b/src/daemon.c
index 312394a..ae59e50 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -1413,10 +1413,10 @@ daemon_local_check_auth (Daemon *daemon,
}
gboolean
-load_autologin (Daemon *daemon,
- gchar **name,
- gboolean *enabled,
- GError **error)
+load_autologin_gdm (Daemon *daemon,
+ gchar **name,
+ gboolean *enabled,
+ GError **error)
{
GKeyFile *keyfile;
GError *local_error;
@@ -1459,23 +1459,89 @@ load_autologin (Daemon *daemon,
return TRUE;
}
-static gboolean
-save_autologin (Daemon *daemon,
- const gchar *name,
- gboolean enabled,
+gboolean
+load_autologin_lightdm (Daemon *daemon,
+ gchar **name,
+ gboolean *enabled,
+ GError **error)
+{
+ GKeyFile *keyfile;
+ const gchar *filename;
+
+ filename = "/etc/lightdm/lightdm.conf";
+
+ keyfile = g_key_file_new ();
+ if (!g_key_file_load_from_file (keyfile,
+ filename,
+ G_KEY_FILE_KEEP_COMMENTS,
+ error)) {
+ g_key_file_free (keyfile);
+ return FALSE;
+ }
+
+ *name = g_key_file_get_string (keyfile, "SeatDefaults", "autologin-user", error);
+ *enabled = (*error == NULL && (*name) && (*name)[0] != 0);
+
+ g_key_file_free (keyfile);
+
+ return (*error == NULL);
+}
+
+gboolean
+load_autologin (Daemon *daemon,
+ gchar **name,
+ gboolean *enabled,
GError **error)
+{
+ GDBusProxy *proxy;
+
+ /* First, determine whether we should load GDM or LightDM values by
+ checking if GDM is running. */
+ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES|
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS|
+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+ NULL,
+ "org.gnome.DisplayManager",
+ "/org/gnome/DisplayManager/Manager",
+ "org.gnome.DisplayManager.Manager",
+ NULL, /* GCancellable */
+ NULL); /* GError */
+
+ if (proxy != NULL) {
+ g_object_unref (proxy);
+ return load_autologin_gdm (daemon, name, enabled, error);
+ } else {
+ return load_autologin_lightdm (daemon, name, enabled, error);
+ }
+}
+
+static gboolean
+save_autologin_gdm (Daemon *daemon,
+ const gchar *name,
+ gboolean enabled,
+ GError **error)
{
GKeyFile *keyfile;
gchar *data;
gboolean result;
+ GError *local_error = NULL;
+
+ if (!g_file_test ("/etc/gdm3", G_FILE_TEST_EXISTS))
+ return TRUE; /* not an error, just not installed */
keyfile = g_key_file_new ();
if (!g_key_file_load_from_file (keyfile,
PATH_GDM_CUSTOM,
G_KEY_FILE_KEEP_COMMENTS,
- error)) {
- g_key_file_free (keyfile);
- return FALSE;
+ &local_error)) {
+ /* It's OK for custom.conf to not exist, we will make it */
+ if (!g_error_matches (local_error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
+ g_propagate_error (error, local_error);
+ g_key_file_free (keyfile);
+ return FALSE;
+ }
+ g_error_free (local_error);
}
g_key_file_set_string (keyfile, "daemon", "AutomaticLoginEnable", enabled ? "True" : "False");
@@ -1490,6 +1556,61 @@ save_autologin (Daemon *daemon,
return result;
}
+static gboolean
+save_autologin_lightdm (Daemon *daemon,
+ const gchar *name,
+ gboolean enabled,
+ GError **error)
+{
+ GKeyFile *keyfile;
+ const gchar *filename;
+ gchar *data;
+ gboolean result;
+ GError *local_error = NULL;
+
+ if (!g_file_test ("/etc/lightdm", G_FILE_TEST_EXISTS))
+ return TRUE; /* not an error, just not installed */
+
+ filename = "/etc/lightdm/lightdm.conf";
+
+ keyfile = g_key_file_new ();
+ if (!g_key_file_load_from_file (keyfile,
+ filename,
+ G_KEY_FILE_KEEP_COMMENTS,
+ &local_error)) {
+ /* It's OK for custom.conf to not exist, we will make it */
+ if (!g_error_matches (local_error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
+ g_propagate_error (error, local_error);
+ g_key_file_free (keyfile);
+ return FALSE;
+ }
+ g_error_free (local_error);
+ }
+
+ g_key_file_set_string (keyfile, "SeatDefaults", "autologin-user", enabled ? name : "");
+
+ data = g_key_file_to_data (keyfile, NULL, NULL);
+ result = g_file_set_contents (filename, data, -1, error);
+
+ g_key_file_free (keyfile);
+ g_free (data);
+
+ return result;
+}
+
+static gboolean
+save_autologin (Daemon *daemon,
+ const gchar *name,
+ gboolean enabled,
+ GError **error)
+{
+ if (!save_autologin_gdm (daemon, name, enabled, error))
+ return FALSE;
+ if (!save_autologin_lightdm (daemon, name, enabled, error))
+ return FALSE;
+ return TRUE;
+}
+
gboolean
daemon_local_set_automatic_login (Daemon *daemon,
User *user,
--
2.20.1