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

Port to libsecret, #239 #351

Merged
merged 6 commits into from
Oct 20, 2020
Merged

Conversation

NP-Hardass
Copy link
Contributor

Adds libsecret support. I'll leave it up to you guys to decide at a future time about dropping libgnome-keyring support. This should close out Issue #239.

I wasn't able to runtime test the code in-situ, but copied it to a standalone file and it locked the databased as expected.

@NP-Hardass
Copy link
Contributor Author

@raveit65 Would you also like a commit removing old, deprecated libgnome-keyring? Or do you want to keep it for the time being?

@raveit65
Copy link
Member

raveit65 commented Aug 4, 2020

@NP-Hardass
Still wondering why there isn't an effort in fedora to drop libgnome-keyring.
But fedora ship libsecret since a long time.
Did you check the situation in other linux/bsd distros?

@sc0w
Copy link
Member

sc0w commented Aug 4, 2020

@NP-Hardass I think you can remove --without-keyring in build.yml

I mean

- scan-build $CHECKERS ./configure --enable-compile-warnings=maximum

instead

  - if [ ${DISTRO_NAME} == "debian" -o ${DISTRO_NAME} == "ubuntu" ];then
  -     scan-build $CHECKERS ./configure --without-keyring --enable-compile-warnings=maximum
  - else
  -     scan-build $CHECKERS ./configure --enable-compile-warnings=maximum
  - fi

@sc0w
Copy link
Member

sc0w commented Aug 4, 2020

we need deprecated libgnome-keyring with this change? it can be removed?

@NP-Hardass
Copy link
Contributor Author

@NP-Hardass
Still wondering why there isn't an effort in fedora to drop libgnome-keyring.
But fedora ship libsecret since a long time.
Did you check the situation in other linux/bsd distros?

Of every pkg listed at v1.24.x on repology, every distro has libsecret support except Linux Mint.

we need deprecated libgnome-keyring with this change? it can be removed?

As is, libgnome-keyring is available if someone enables it, but off by default.

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just build and installed a rebase of this against today's master, with the very old libgnome-keyring 1.12 finally removed from my system. Note that that package is NOT offered in Debian Unstable at this time. Didn't realize a rebuild without libgnome-keyring would have removed support for/dependency on it and let the package function.

Anyway, this build runs normally and suspending works fine.

Got these runtime warnings, unsure if they have anything to do with this PR, one appears to relate to systemd and the other to key mappings:

(mate-power-manager:218930): PowerManager-WARNING **: 01:58:35.670: Failed to get session for pid 218930: The name org.freedesktop.ConsoleKit was not provided by any .service files

(mate-power-manager:218930): PowerManager-WARNING **: 01:58:35.682: could not map keysym 1008ffa8 to keycode

@sc0w
Copy link
Member

sc0w commented Aug 7, 2020

@NP-Hardass

Of every pkg listed at v1.24.x on repology, every distro has libsecret support except Linux Mint.

Linux Mint is based on ubuntu and debian, so, I suppose it has libsecret

@lukefromdc
Copy link
Member

Libsecret I have, it's the old deprecated libgnome-keyring that is no longer in Sid. This is one of the reasons we need this PR

@raveit65
Copy link
Member

raveit65 commented Sep 3, 2020

@NP-Hardass
Can you please rebase with master and update PR for meson?
#338 is merged now

@raveit65 raveit65 requested a review from a team September 3, 2020 11:34
@NP-Hardass
Copy link
Contributor Author

NP-Hardass commented Sep 3, 2020 via email

@NP-Hardass
Copy link
Contributor Author

If someone could verify it works properly, as I don't have meson configured atm...

Copy link
Member

@lukefromdc lukefromdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autotools build worked fine on desktop, though note that desktops support only limited features on mate-power-manager.

Meson build with

meson build/ --prefix /usr
ninja -C build

completed fine.
Installation with
sudo ninja -C build install
stalled temporarily twice but eventually restarted and appeared to finish and return.
This meson build once installed did not run, generated these warnings

** (mate-power-manager:8937): WARNING **: 18:20:10.435: Failed to get session for pid 8937: The name org.freedesktop.ConsoleKit was not provided by any .service files

** (mate-power-manager:8937): WARNING **: 18:20:11.252: could not map keysym 1008ffa8 to keycode

** (mate-power-manager:8937): ERROR **: 18:20:11.259: failed to get value: Failed to execute child process “/usr/sbin/mate-power-backlight-helper” (No such file or directory)
Trace/breakpoint trap
luke@ubuntu:~/Desktop/Development/MATE_Development_Work/mate-power-manager_test-9-4-2020$ 

The third warning is the one causing the crash and is happened only in the meson build and not the autotools build.
Looks like /usr/sbin/mate-power-backlight-helper either was not installed or was installed to the wrong place and not found

On Uninstall:
install finished.

Deleted: 571
Failed: 0

Remember that files created by custom scripts have not been removed.

@raveit65
Copy link
Member

raveit65 commented Sep 5, 2020

If someone could verify it works properly, as I don't have meson configured atm...

That's easy:

meson build -Dprefix=/usr (w/h -Dprefix it's /usr/local/)
ninja -C build
sudo ninja -C build install

dist:
meson dist -C build

@raveit65
Copy link
Member

raveit65 commented Sep 5, 2020

There is a conflict with master. You should do a git rebase master.

@raveit65
Copy link
Member

raveit65 commented Sep 5, 2020

@NP-Hardass @lukefromdc
The segfault is caused by meson PR. Installing master branch with meson give me same error.

[rave@mother ~]$ /usr/bin/mate-power-manager 

** (mate-power-manager:6737): WARNING **: 09:59:52.272: Failed to get session for pid 6737: The name is not activatable

** (mate-power-manager:6737): WARNING **: 09:59:52.277: could not map keysym 1008ffa8 to keycode

** (mate-power-manager:6737): ERROR **: 09:59:52.282: failed to get value: Failed to execute child process ?/usr/sbin/mate-power-backlight-helper? (No such file or directory)
Trace/breakpoint trap (core dumped)

The other warnings we get with using autotools too. They are not new.

@lukefromdc
Copy link
Member

lukefromdc commented Sep 5, 2020

Just posted my results to #338 (comment) and yes, I agree we should revert the Meson PR, merge this, fix the Meson stuff, then merge it again.

I agree that master should not be allowed to remain broken at any time

@raveit65
Copy link
Member

raveit65 commented Sep 10, 2020

@NP-Hardass
Meson PR is reverted. Can you please remove meson commit from your PR.
Then this can be tested.

@NP-Hardass
Copy link
Contributor Author

@NP-Hardass
Meson PR is reverted. Can you please remove meson commit from your PR.
Then this can be tested.

Done

src/gpm-control.c Outdated Show resolved Hide resolved
src/gpm-control.c Outdated Show resolved Hide resolved
src/gpm-control.c Outdated Show resolved Hide resolved
src/gpm-control.c Outdated Show resolved Hide resolved
src/gpm-control.c Outdated Show resolved Hide resolved
src/gpm-control.c Outdated Show resolved Hide resolved
@raveit65
Copy link
Member

@NP-Hardass
Normally our code style is not to use tabs i newly written code, but whole gpm-control.c file use tab=4 size, so you should do the same.

@raveit65
Copy link
Member

raveit65 commented Oct 3, 2020

@NP-Hardass
Code-formatting-style needs to be fixed.

@raveit65
Copy link
Member

raveit65 commented Oct 13, 2020

Don't think i like to use tabs in code but they are used all over this file, so we should respect it.
https://www.dropbox.com/s/bxnwf3k38pr6uoa/0001-gpm-control.c-Add-libsecret-implementation-to-gpm_co.patch?dl=0

From 86b1025e9708ad0913084f33a8421bdfb93ff682 Mon Sep 17 00:00:00 2001
From: NP-Hardass <[email protected]>
Date: Mon, 3 Aug 2020 01:49:47 -0400
Subject: [PATCH 1/5] gpm-control.c: Add libsecret implementation to
 gpm_control_suspend()

---
 src/gpm-control.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/src/gpm-control.c b/src/gpm-control.c
index 4834a05..ef0b385 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -39,6 +39,9 @@
 #include <gio/gio.h>
 #include <glib/gi18n.h>
 
+#ifdef WITH_LIBSECRET
+#include <libsecret/secret.h>
+#endif /* WITH_LIBSECRET */
 #ifdef WITH_KEYRING
 #include <gnome-keyring.h>
 #endif /* WITH_KEYRING */
@@ -210,6 +213,13 @@ gpm_control_suspend (GpmControl *control, GError **error)
 	EggConsoleKit *console;
 	GpmScreensaver *screensaver;
 	guint32 throttle_cookie = 0;
+#ifdef WITH_LIBSECRET
+	gboolean lock_libsecret;
+	GCancellable *libsecret_cancellable = NULL;
+	SecretService *secretservice_proxy = NULL;
+	gint num_secrets_locked;
+	GList *libsecret_collections = NULL;
+#endif /* WITH_LIBSECRET */
 #ifdef WITH_KEYRING
 	gboolean lock_gnome_keyring;
 	GnomeKeyringResult keyres;
@@ -233,6 +243,36 @@ gpm_control_suspend (GpmControl *control, GError **error)
 		}
 	}
 
+#ifdef WITH_LIBSECRET
+	/* we should perhaps lock keyrings when sleeping #375681 */
+	lock_libsecret = g_settings_get_boolean (control->priv->settings,
+						 GPM_SETTINGS_LOCK_KEYRING_SUSPEND);
+	if (lock_libsecret) {
+		libsecret_cancellable = g_cancellable_new ();
+		secretservice_proxy = secret_service_get_sync (SECRET_SERVICE_LOAD_COLLECTIONS,
+							       libsecret_cancellable,
+							       error);
+		if (secretservice_proxy == NULL) {
+			g_warning ("failed to connect to secret service");
+		} else {
+			libsecret_collections = secret_service_get_collections (secretservice_proxy);
+			if ( libsecret_collections == NULL) {
+				g_warning ("failed to get secret collections");
+			} else {
+				num_secrets_locked = secret_service_lock_sync (secretservice_proxy,
+									       libsecret_collections,
+									       libsecret_cancellable,
+									       NULL,
+									       error);
+				if (num_secrets_locked <= 0)
+					g_warning ("could not lock keyring");
+				g_list_free (libsecret_collections);
+			}
+	 		g_object_unref (secretservice_proxy);
+		}
+		g_object_unref (libsecret_cancellable);
+	}
+#endif /* WITH_LIBSECRET */
 #ifdef WITH_KEYRING
 	/* we should perhaps lock keyrings when sleeping #375681 */
 	lock_gnome_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_SUSPEND);
-- 
2.26.2

https://www.dropbox.com/s/y7wdu5h9f5k5qil/0002-gpm-control.c-Add-libsecret-implementation-to-gpm_co.patch?dl=0

From ffa759299652683bb95dcc939546060360a5a0d7 Mon Sep 17 00:00:00 2001
From: NP-Hardass <[email protected]>
Date: Mon, 3 Aug 2020 01:55:43 -0400
Subject: [PATCH 2/5] gpm-control.c: Add libsecret implementation to
 gpm_control_hibernate()

---
 src/gpm-control.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/gpm-control.c b/src/gpm-control.c
index ef0b385..c1109db 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -368,6 +368,13 @@ gpm_control_hibernate (GpmControl *control, GError **error)
 	EggConsoleKit *console;
 	GpmScreensaver *screensaver;
 	guint32 throttle_cookie = 0;
+#ifdef WITH_LIBSECRET
+	gboolean lock_libsecret;
+	GCancellable *libsecret_cancellable = NULL;
+	SecretService *secretservice_proxy = NULL;
+	gint num_secrets_locked;
+	GList *libsecret_collections = NULL;
+#endif /* WITH_LIBSECRET */
 #ifdef WITH_KEYRING
 	gboolean lock_gnome_keyring;
 	GnomeKeyringResult keyres;
@@ -391,6 +398,36 @@ gpm_control_hibernate (GpmControl *control, GError **error)
 		}
 	}
 
+#ifdef WITH_LIBSECRET
+	/* we should perhaps lock keyrings when sleeping #375681 */
+	lock_libsecret = g_settings_get_boolean (control->priv->settings,
+						 GPM_SETTINGS_LOCK_KEYRING_SUSPEND);
+	if (lock_libsecret) {
+		libsecret_cancellable = g_cancellable_new ();
+		secretservice_proxy = secret_service_get_sync (SECRET_SERVICE_LOAD_COLLECTIONS,
+							       libsecret_cancellable,
+							       error);
+		if (secretservice_proxy == NULL) {
+			g_warning ("failed to connect to secret service");
+		} else {
+			libsecret_collections = secret_service_get_collections (secretservice_proxy);
+			if (libsecret_collections == NULL) {
+				g_warning ("failed to get secret collections");
+			} else {
+				num_secrets_locked = secret_service_lock_sync (secretservice_proxy,
+									       libsecret_collections,
+									       libsecret_cancellable,
+									       NULL,
+									       error);
+				if (num_secrets_locked <= 0)
+					g_warning ("could not lock keyring");
+				g_list_free (libsecret_collections);
+			}
+			g_object_unref (secretservice_proxy);
+		}
+		g_object_unref (libsecret_cancellable);
+	}
+#endif /* WITH_LIBSECRET */
 #ifdef WITH_KEYRING
 	/* we should perhaps lock keyrings when sleeping #375681 */
 	lock_gnome_keyring = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_KEYRING_HIBERNATE);
-- 
2.26.2
  • Lines are shorter as in other parts of this file.
  • Commits use correct indents level
  • A space is added before opening brackets

Does this looks better, or not?

@NP-Hardass
Copy link
Contributor Author

NP-Hardass commented Oct 13, 2020

Don't think i like to use tabs in code but they are used all over this file, so we should respect it.

  • Lines are shorter as in other parts of this file.
  • Commits use correct indents level
  • A space is added before opening brackets

Does this looks better, or not?

+#ifdef WITH_LIBSECRET
+	/* we should perhaps lock keyrings when sleeping #375681 */
+	lock_libsecret = g_settings_get_boolean (control->priv->settings,
+						 GPM_SETTINGS_LOCK_KEYRING_SUSPEND);

Updated accordingly. The only change you made that stuck out to me was the above quoted, because it changes a line that existed for KEYRING to wrap. I have no feelings one way or the other though.

src/gpm-control.c Outdated Show resolved Hide resolved
Copy link
Member

@raveit65 raveit65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,
thanks.

@raveit65
Copy link
Member

@mate-desktop/core-team
Any other reviewer who like to review this PR?

@raveit65 raveit65 requested a review from a team October 13, 2020 21:20
@raveit65 raveit65 merged commit 42ccd70 into mate-desktop:master Oct 20, 2020
@lukefromdc
Copy link
Member

Builds and runs fine on my desktop with libsecret support enabled, same warnings I've always gotten on starting from terminal

(mate-power-manager:506313): PowerManager-WARNING **: 16:16:23.995: Failed to get session for pid 506313: The name org.freedesktop.ConsoleKit was not provided by any .service files

(mate-power-manager:506313): PowerManager-WARNING **: 16:16:24.001: could not map keysym 1008ffa8 to keycode

(mate-power-manager:506313): Gdk-CRITICAL **: 16:16:24.088: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed

(mate-power-preferences:506350): PowerManager-WARNING **: 16:16:29.373: Failed to get session for pid 506350: The name org.freedesktop.ConsoleKit was not provided by any .service files

Nothing in the warnings seems to come from this change.

@rbuj rbuj linked an issue Apr 29, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch from libgnome-keyring to libsecret
4 participants