[mate-session-manager] 02/03: debian/patches: Add 2000_revert_updating_environment_for_dbus_and_systemd_user_session.patch.

Mike Gabriel sunweaver at debian.org
Tue Jul 25 14:19:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository mate-session-manager.

commit ea849f39be7f665cc4220763637dce5090ee3717
Author: Martin Wimpress <martin.wimpress at ubuntu.com>
Date:   Tue Jul 25 15:05:05 2017 +0100

    debian/patches: Add 2000_revert_updating_environment_for_dbus_and_systemd_user_session.patch.
---
 ...ronment_for_dbus_and_systemd_user_session.patch | 331 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 332 insertions(+)

diff --git a/debian/patches/2000_revert_updating_environment_for_dbus_and_systemd_user_session.patch b/debian/patches/2000_revert_updating_environment_for_dbus_and_systemd_user_session.patch
new file mode 100644
index 0000000..c864702
--- /dev/null
+++ b/debian/patches/2000_revert_updating_environment_for_dbus_and_systemd_user_session.patch
@@ -0,0 +1,331 @@
+diff -rupN mate-session-manager/mate-session/gsm-util.c mate-session-manager-revert/mate-session/gsm-util.c
+--- mate-session-manager/mate-session/gsm-util.c	2017-07-21 21:38:40.405080458 +0100
++++ mate-session-manager-revert/mate-session/gsm-util.c	2017-07-21 21:47:26.628455051 +0100
+@@ -435,256 +435,72 @@ gsm_util_update_activation_environment (
+                                         const char  *value,
+                                         GError     **error)
+ {
+-        GDBusConnection *connection;
++        DBusGConnection *dbus_connection;
++        DBusGProxy      *bus_proxy;
++        GHashTable      *environment;
+         gboolean         environment_updated;
+-        GVariantBuilder  builder;
+-        GVariant        *reply;
+-        GError          *bus_error = NULL;
+ 
+         environment_updated = FALSE;
+-        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
++        bus_proxy = NULL;
++        environment = NULL;
+ 
+-        if (connection == NULL) {
+-                return FALSE;
+-        }
+-
+-        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
+-        g_variant_builder_add (&builder, "{ss}", variable, value);
+-
+-        reply = g_dbus_connection_call_sync (connection,
+-                                             "org.freedesktop.DBus",
+-                                             "/org/freedesktop/DBus",
+-                                             "org.freedesktop.DBus",
+-                                             "UpdateActivationEnvironment",
+-                                             g_variant_new ("(@a{ss})",
+-                                                            g_variant_builder_end (&builder)),
+-                                             NULL,
+-                                             G_DBUS_CALL_FLAGS_NONE,
+-                                             -1, NULL, &bus_error);
+-
+-        if (bus_error != NULL) {
+-                g_propagate_error (error, bus_error);
+-        } else {
+-                environment_updated = TRUE;
+-                g_variant_unref (reply);
+-        }
+-
+-        g_clear_object (&connection);
+-
+-        return environment_updated;
+-}
+-
+-gboolean
+-gsm_util_export_activation_environment (GError     **error)
+-{
+-        GDBusConnection *connection;
+-        gboolean         environment_updated = FALSE;
+-        char           **entry_names;
+-        int              i = 0;
+-        GVariantBuilder  builder;
+-        GRegex          *name_regex, *value_regex;
+-        GVariant        *reply;
+-        GError          *bus_error = NULL;
+-
+-        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+-
+-        if (connection == NULL) {
+-                return FALSE;
+-        }
++        dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, error);
+ 
+-        name_regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*$", G_REGEX_OPTIMIZE, 0, error);
+-
+-        if (name_regex == NULL) {
++        if (dbus_connection == NULL) {
+                 return FALSE;
+         }
+ 
+-        value_regex = g_regex_new ("^([[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
++        bus_proxy = dbus_g_proxy_new_for_name_owner (dbus_connection,
++                                                     DBUS_SERVICE_DBUS,
++                                                     DBUS_PATH_DBUS,
++                                                     DBUS_INTERFACE_DBUS,
++                                                     error);
+ 
+-        if (value_regex == NULL) {
+-                return FALSE;
++        if (bus_proxy == NULL) {
++                goto out;
+         }
+ 
+-        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
+-        for (entry_names = g_listenv (); entry_names[i] != NULL; i++) {
+-                const char *entry_name = entry_names[i];
+-                const char *entry_value = g_getenv (entry_name);
++        environment = g_hash_table_new (g_str_hash, g_str_equal);
+ 
+-                if (!g_utf8_validate (entry_name, -1, NULL))
+-                    continue;
++        g_hash_table_insert (environment, (void *) variable, (void *) value);
+ 
+-                if (!g_regex_match (name_regex, entry_name, 0, NULL))
+-                    continue;
++        if (!dbus_g_proxy_call (bus_proxy,
++                                "UpdateActivationEnvironment", error,
++                                DBUS_TYPE_G_STRING_STRING_HASHTABLE,
++                                environment, G_TYPE_INVALID,
++                                G_TYPE_INVALID))
++                goto out;
+ 
+-                if (!g_utf8_validate (entry_value, -1, NULL))
+-                    continue;
++        environment_updated = TRUE;
+ 
+-                if (!g_regex_match (value_regex, entry_value, 0, NULL))
+-                    continue;
++ out:
+ 
+-                g_variant_builder_add (&builder, "{ss}", entry_name, entry_value);
++        if (bus_proxy != NULL) {
++                g_object_unref (bus_proxy);
+         }
+-        g_regex_unref (name_regex);
+-        g_regex_unref (value_regex);
+ 
+-        g_strfreev (entry_names);
+-
+-        reply = g_dbus_connection_call_sync (connection,
+-                                             "org.freedesktop.DBus",
+-                                             "/org/freedesktop/DBus",
+-                                             "org.freedesktop.DBus",
+-                                             "UpdateActivationEnvironment",
+-                                             g_variant_new ("(@a{ss})",
+-                                                            g_variant_builder_end (&builder)),
+-                                             NULL,
+-                                             G_DBUS_CALL_FLAGS_NONE,
+-                                             -1, NULL, &bus_error);
+-
+-        if (bus_error != NULL) {
+-                g_propagate_error (error, bus_error);
+-        } else {
+-                environment_updated = TRUE;
+-                g_variant_unref (reply);
++        if (environment != NULL) {
++                g_hash_table_destroy (environment);
+         }
+ 
+-        g_clear_object (&connection);
+-
+         return environment_updated;
+ }
+ 
+-#ifdef HAVE_SYSTEMD
+-gboolean
+-gsm_util_export_user_environment (GError     **error)
+-{
+-        GDBusConnection *connection;
+-        gboolean         environment_updated = FALSE;
+-        char           **entries;
+-        int              i = 0;
+-        GVariantBuilder  builder;
+-        GRegex          *regex;
+-        GVariant        *reply;
+-        GError          *bus_error = NULL;
+-
+-        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+-
+-        if (connection == NULL) {
+-                return FALSE;
+-        }
+-
+-        regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*=([[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
+-
+-        if (regex == NULL) {
+-                return FALSE;
+-        }
+-
+-        g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+-        for (entries = g_get_environ (); entries[i] != NULL; i++) {
+-                const char *entry = entries[i];
+-
+-                if (!g_utf8_validate (entry, -1, NULL))
+-                    continue;
+-
+-                if (!g_regex_match (regex, entry, 0, NULL))
+-                    continue;
+-
+-                g_variant_builder_add (&builder, "s", entry);
+-        }
+-        g_regex_unref (regex);
+-
+-        g_strfreev (entries);
+-
+-        reply = g_dbus_connection_call_sync (connection,
+-                                             "org.freedesktop.systemd1",
+-                                             "/org/freedesktop/systemd1",
+-                                             "org.freedesktop.systemd1.Manager",
+-                                             "SetEnvironment",
+-                                             g_variant_new ("(@as)",
+-                                                            g_variant_builder_end (&builder)),
+-                                             NULL,
+-                                             G_DBUS_CALL_FLAGS_NONE,
+-                                             -1, NULL, &bus_error);
+-
+-        if (bus_error != NULL) {
+-                g_propagate_error (error, bus_error);
+-        } else {
+-                environment_updated = TRUE;
+-                g_variant_unref (reply);
+-        }
+-
+-        g_clear_object (&connection);
+-
+-        return environment_updated;
+-}
+-
+-static gboolean
+-gsm_util_update_user_environment (const char  *variable,
+-                                  const char  *value,
+-                                  GError     **error)
+-{
+-        GDBusConnection *connection;
+-        gboolean         environment_updated;
+-        char            *entry;
+-        GVariantBuilder  builder;
+-        GVariant        *reply;
+-        GError          *bus_error = NULL;
+-
+-        environment_updated = FALSE;
+-        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+-
+-        if (connection == NULL) {
+-                return FALSE;
+-        }
+-
+-        g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+-        entry = g_strdup_printf ("%s=%s", variable, value);
+-        g_variant_builder_add (&builder, "s", entry);
+-        g_free (entry);
+-
+-        reply = g_dbus_connection_call_sync (connection,
+-                                             "org.freedesktop.systemd1",
+-                                             "/org/freedesktop/systemd1",
+-                                             "org.freedesktop.systemd1.Manager",
+-                                             "SetEnvironment",
+-                                             g_variant_new ("(@as)",
+-                                                            g_variant_builder_end (&builder)),
+-                                             NULL,
+-                                             G_DBUS_CALL_FLAGS_NONE,
+-                                             -1, NULL, &bus_error);
+-
+-        if (bus_error != NULL) {
+-                g_propagate_error (error, bus_error);
+-        } else {
+-                environment_updated = TRUE;
+-                g_variant_unref (reply);
+-        }
+-
+-        g_clear_object (&connection);
+-
+-        return environment_updated;
+-}
+-#endif
+-
+ void
+ gsm_util_setenv (const char *variable,
+                  const char *value)
+ {
+-        GError *error = NULL;
++        GError *bus_error;
+ 
+         g_setenv (variable, value, TRUE);
+ 
++        bus_error = NULL;
++
+         /* If this fails it isn't fatal, it means some things like session
+          * management and keyring won't work in activated clients.
+          */
+-        if (!gsm_util_update_activation_environment (variable, value, &error)) {
+-                g_warning ("Could not make bus activated clients aware of %s=%s environment variable: %s", variable, value, error->message);
+-                g_clear_error (&error);
+-        }
+-
+-#ifdef HAVE_SYSTEMD
+-        /* If this fails, the system user session won't get the updated environment
+-         */
+-        if (!gsm_util_update_user_environment (variable, value, &error)) {
+-                g_debug ("Could not make systemd aware of %s=%s environment variable: %s", variable, value, error->message);
+-                g_clear_error (&error);
++        if (!gsm_util_update_activation_environment (variable, value, &bus_error)) {
++                g_warning ("Could not make bus activated clients aware of %s=%s environment variable: %s", variable, value, bus_error->message);
++                g_error_free (bus_error);
+         }
+-#endif
+ }
+diff -rupN mate-session-manager/mate-session/gsm-util.h mate-session-manager-revert/mate-session/gsm-util.h
+--- mate-session-manager/mate-session/gsm-util.h	2017-07-21 21:38:40.405080458 +0100
++++ mate-session-manager-revert/mate-session/gsm-util.h	2017-07-21 21:47:26.628455051 +0100
+@@ -48,12 +48,6 @@ void        gsm_util_init_error
+ 
+ char *      gsm_util_generate_startup_id            (void);
+ 
+-gboolean    gsm_util_export_activation_environment  (GError     **error);
+-
+-#ifdef HAVE_SYSTEMD
+-gboolean    gsm_util_export_user_environment        (GError     **error);
+-#endif
+-
+ void        gsm_util_setenv                         (const char *variable,
+                                                      const char *value);
+ 
+diff -rupN mate-session-manager/mate-session/main.c mate-session-manager-revert/mate-session/main.c
+--- mate-session-manager/mate-session/main.c	2017-07-21 21:38:40.409080513 +0100
++++ mate-session-manager-revert/mate-session/main.c	2017-07-21 21:47:26.628455051 +0100
+@@ -620,12 +620,6 @@ int main(int argc, char** argv)
+ 		exit(1);
+ 	}
+ 
+-        gsm_util_export_activation_environment (NULL);
+-
+-#ifdef HAVE_SYSTEMD
+-        gsm_util_export_user_environment (NULL);
+-#endif
+-
+ 	mdm_log_init();
+ 
+ 	/* Allows to enable/disable debug from GSettings only if it is not set from argument */
+@@ -733,4 +727,3 @@ int main(int argc, char** argv)
+ 
+ 	return 0;
+ }
+-
diff --git a/debian/patches/series b/debian/patches/series
index 9cf4102..099c45f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0005_lock-session-before-user-switch.patch
+2000_revert_updating_environment_for_dbus_and_systemd_user_session.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mate/mate-session-manager.git



More information about the pkg-mate-commits mailing list