Bug#804703: gnome-keyring: The race with SessionManager initialization

2017-09-16 Thread Luca Boccassi
On Mon, 13 Jun 2016 08:55:23 +0200 Andreas Henriksson  wrote:
> Control: tags -1 = confirmed upstream
> 
> Hello!
> 
> On Mon, Jun 13, 2016 at 02:46:33PM +0900, OGAWA Hirofumi wrote:
> > Jeremy Bicha  writes:
> > 
> > > Control: tags -1 moreinfo
> > >
> > > Please update to gnome-keyring 3.20.0-1 and report back whether
this
> > > fixes your bug.
> 
> I was struck by this issue pretty consistently while using 3.20.0-1
(but
> did not run into it in earlier versions, classical race issue it
seems).
> 
> The problems went away for me when applying the patch in this bug
> report.
> 
> > >
> > > gnome-keyring 3.20 fixed https://bugzilla.gnome.org/738205
> > > (Despite the bug title, it wasn't limited to just Wayland
sessions).
> > 
> > At least for now, this bug is not reproduced. So it would be better
to
> > close the bug.  If reproduced, I will re-open.
> 
> I've been trying to get a hold off stefw to discuss your patch but
> haven't succeded reaching him. This issue (and the patch) should
> be forwarded to the upstream bugzilla.
> 
> Regards,
> Andreas Henriksson

Hi,

I am occasionally seeing the same problem since I upgraded to Stretch a
few months ago. I am using Gnome (gnome-keyring 3.20.0-3) with Xorg.

$ echo $SSH_AUTH_SOCK
/tmp/ssh-3ymBpl68cNYk/agent.2019

$ dbus-send --session --dest=org.gnome.keyring --print-reply 
/org/gnome/keyring/daemon org.gnome.keyring.Daemon.GetEnvironment
method return time=1505550164.345498 sender=:1.25 -> destination=:1.636 
serial=10249 reply_serial=2
   array [
  dict entry(
 string "SSH_AUTH_SOCK"
 string "/run/user/1000/keyring/ssh"
  )
   ]

$ ps aux | grep gnome-keyring
luca  2000  0.3  0.0 299844 21224 ?SLl  08:37   0:09 
/usr/bin/gnome-keyring-daemon --daemonize --login

$ ssh-add -L
The agent has no identities.

$ SSH_AUTH_SOCK=/run/user/1000/keyring/ssh ssh-add -L
ssh-rsa B3 

Kind regards,
Luca Boccassi

signature.asc
Description: This is a digitally signed message part


Bug#804703: gnome-keyring: The race with SessionManager initialization

2016-06-12 Thread Andreas Henriksson
Control: tags -1 = confirmed upstream

Hello!

On Mon, Jun 13, 2016 at 02:46:33PM +0900, OGAWA Hirofumi wrote:
> Jeremy Bicha  writes:
> 
> > Control: tags -1 moreinfo
> >
> > Please update to gnome-keyring 3.20.0-1 and report back whether this
> > fixes your bug.

I was struck by this issue pretty consistently while using 3.20.0-1 (but
did not run into it in earlier versions, classical race issue it seems).

The problems went away for me when applying the patch in this bug
report.

> >
> > gnome-keyring 3.20 fixed https://bugzilla.gnome.org/738205
> > (Despite the bug title, it wasn't limited to just Wayland sessions).
> 
> At least for now, this bug is not reproduced. So it would be better to
> close the bug.  If reproduced, I will re-open.

I've been trying to get a hold off stefw to discuss your patch but
haven't succeded reaching him. This issue (and the patch) should
be forwarded to the upstream bugzilla.

Regards,
Andreas Henriksson



Bug#804703: gnome-keyring: The race with SessionManager initialization

2016-06-12 Thread OGAWA Hirofumi
Jeremy Bicha  writes:

> Control: tags -1 moreinfo
>
> Please update to gnome-keyring 3.20.0-1 and report back whether this
> fixes your bug.
>
> gnome-keyring 3.20 fixed https://bugzilla.gnome.org/738205
> (Despite the bug title, it wasn't limited to just Wayland sessions).

At least for now, this bug is not reproduced. So it would be better to
close the bug.  If reproduced, I will re-open.

Thanks.
-- 
OGAWA Hirofumi 



Bug#804703: gnome-keyring: The race with SessionManager initialization

2016-06-12 Thread Jeremy Bicha
Control: tags -1 moreinfo

Please update to gnome-keyring 3.20.0-1 and report back whether this
fixes your bug.

gnome-keyring 3.20 fixed https://bugzilla.gnome.org/738205
(Despite the bug title, it wasn't limited to just Wayland sessions).


Thanks,
Jeremy Bicha



Bug#804703: gnome-keyring: The race with SessionManager initialization

2015-11-10 Thread OGAWA Hirofumi
Package: gnome-keyring
Version: 3.18.2-1
Severity: normal

Hi,

When I start gnome-session (not sure if startx is important to
reproduce) by

$ startx

Current gnome-keyring has the race with org.gnome.SessionManager
initialization of gnome-session. Because dbus doesn't seem to make the
name available to others immediately.

The sequence of the race is:

 gnome-session   gnome-keyring
  .SessionManager init
  run autostart apps
 start by autostart
 call .SessionManager.Setenv
 call .SessionManager.ClientPrivate
  .SessionManager available
  
This race becomes the cause of random Setenv failure for SSH_AUTH_SOCK
for example like following.

** Message: couldn't register in session: 
GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name 
org.gnome.SessionManager was not provided by any .service files

To fix this, the attached patch starts to watch .NameOwnerChanged before
calling .SessionManager. With this, if .SessionManager is not available
yet, callings are done via .NameOwnerChanged notification.

Then, after makes sure calling of .SessionManager was done, this
removes watch of .NameOwnerChanged.

-- System Information:
Debian Release: stretch/sid
  APT prefers testing-proposed-updates
  APT policy: (500, 'testing-proposed-updates'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.18.24 (SMP w/8 CPU cores)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: sysvinit (via /sbin/init)

Versions of packages gnome-keyring depends on:
ii  dbus-x11 1.10.2-1
ii  dconf-gsettings-backend [gsettings-backend]  0.24.0-2
ii  gcr  3.18.0-1
ii  libc62.19-22
ii  libcap-ng0   0.7.7-1
ii  libcap2-bin  1:2.24-12
ii  libgck-1-0   3.18.0-1
ii  libgcr-base-3-1  3.18.0-1
ii  libgcrypt20  1.6.4-3
ii  libglib2.0-0 2.46.1-2
ii  p11-kit  0.23.1-3
ii  pinentry-gnome3  0.9.6-4

Versions of packages gnome-keyring recommends:
ii  libpam-gnome-keyring  3.18.2-1

gnome-keyring suggests no packages.

-- no debconf information

-- 
OGAWA Hirofumi 



Current gnome-keyring has the race with org.gnome.SessionManager
initialization of gnome-session. Because dbus doesn't make the name
available to others immediately.

The sequence of the race is:

 gnome-session   gnome-keyring
  .SessionManager init
  run autostart apps
 start by autostart
			 call .SessionManager.Setenv
			 call .SessionManager.ClientPrivate
  .SessionManager available
  
This race becomes the cause of random Setenv failure for SSH_AUTH_SOCK
for example like following.

	** Message: couldn't register in session: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files

To fix this, this starts to watch .NameOwnerChanged before calling
.SessionManager. With this, if .SessionManager is not available yet,
callings are done via .NameOwnerChanged notification.

Then, after makes sure calling of .SessionManager was done, this
removes watch of .NameOwnerChanged.

---

 daemon/dbus/gkd-dbus-environment.c |9 ++-
 daemon/dbus/gkd-dbus-session.c |   89 ++--
 daemon/dbus/gkd-dbus.c |1 
 3 files changed, 92 insertions(+), 7 deletions(-)

diff -puN daemon/dbus/gkd-dbus-environment.c~session-race-fix daemon/dbus/gkd-dbus-environment.c
--- gnome-keyring-3.18.2/daemon/dbus/gkd-dbus-environment.c~session-race-fix	2015-10-29 20:37:32.812933216 +0900
+++ gnome-keyring-3.18.2-hirofumi/daemon/dbus/gkd-dbus-environment.c	2015-10-29 20:38:12.196871701 +0900
@@ -103,6 +103,7 @@ on_watch_environment (gpointer data, gpo
 void
 gkd_dbus_environment_init (GDBusConnection *conn)
 {
+	static gboolean watch_installed = FALSE;
 	const gchar **envp;
 
 	/*
@@ -114,6 +115,10 @@ gkd_dbus_environment_init (GDBusConnecti
 	for (; *envp; ++envp)
 		setenv_request (conn, *envp);
 
-	gkd_util_watch_environment (on_watch_environment, g_object_ref (conn),
-(GDestroyNotify) g_object_unref);
+	if (!watch_installed) {
+		watch_installed = TRUE;
+		gkd_util_watch_environment (on_watch_environment,
+	g_object_ref (conn),
+	(GDestroyNotify) g_object_unref);
+	}
 }
diff -puN daemon/dbus/gkd-dbus-session.c~session-race-fix daemon/dbus/gkd-dbus-session.c
--- gnome-keyring-3.18.2/daemon/dbus/gkd-dbus-session.c~session-race-fix	2015-10-29 20:37:32.816933209 +0900