r-lib / keyring

:closed_lock_with_key: Access the system credential store from R

Home Page:https://keyring.r-lib.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()

aoles opened this issue · comments

Hi,
first of all thank you for providing a cross-platform solution to secret management in R. I find it very handy for storing e.g. API keys.

When I try calling functions from the package I get the following error under Linux . Any thoughts on this? Thanks a lot for your help!

Andrzej

library(keyring)
kb <- backend_secret_service$new()
kb$is_available()

## (process:5857): GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()

## (process:5857): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
sessionInfo()

## R Under development (unstable) (2017-12-07 r73866)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Fedora 18 (Spherical Cow)
## 
## Matrix products: default
## BLAS: /home/oles/R/R-devel/lib/libRblas.so
## LAPACK: /home/oles/R/R-devel/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] keyring_1.0.0
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.16     getPass_0.2-2    digest_0.6.15    rprojroot_1.3-2 
##  [5] assertthat_0.2.0 R6_2.2.2         backports_1.1.2  magrittr_1.5    
##  [9] evaluate_0.10.1  stringi_1.1.7    rmarkdown_1.9    tools_3.5.0     
## [13] stringr_1.3.0    yaml_2.1.18      compiler_3.5.0   htmltools_0.3.6 
## [17] openssl_1.0.1    knitr_1.20

Hi, what is the return value of kb$is_available() ?

Thanks Gábor for getting back to me. I don't get to see the result of kb$is_available(), as the R session hangs after printing the errors. Here is the whole output I get in the console.

> library(keyring)
> kb <- backend_secret_service$new()
> kb$is_available()

(process:8877): GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()

(process:8877): GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()

(process:8877): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed

(process:8877): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed

(process:8877): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:8877): GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()

(process:8877): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
                                                                                                 
(process:8877): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed              
                                                                                                 
(process:8877): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed                                                                
                                                                                                 
(process:8877): GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()         
                                                                                                 
(process:8877): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed                                                              
                                                                                                 
(process:8877): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed              
                                                                                                 
(process:8877): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed

(process:8877): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed

(process:8877): GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init()

Oh, I see. What's your linux distrib and version?

Linux Fedora 18. libsecret-devel is at version 0.12-1.

I am sorry, that is really old, long unsupported. Do any other libsecret clients work on this machine?

I know it's an old one, but everything has been working so far.. I use kwallet for managing passwords but this doesn't seem to depend on libsecret.

I've just tried on CentOS Linux 7. I don't get any errors, but the service seems to be unavailable. Any advice?

> library(keyring)
> kb <- backend_secret_service$new()
> kb$is_available()
[1] FALSE

In my experience libsecret and dbus support in general was not the best in older CentOS versions, even in newer ones, actually. I don't have first hand experience with older Fedora versions, but I would assume the same.

Please try to see if another client works, e.g. I think there is a command line client, maybe this one: https://www.mankier.com/1/secret-tool ?

As for CentOS 7, was the package compiled with libsecret support at all? Does it link to libsecret? If yes, do you have some libsecret daemon running?

Thanks Gábor! I installed from sources on CentOS 7 and had to first install libsecret-devel to get it compile. There seem to be a problem with libsecret, as the following example from secret-tool man page results in an error.

$ secret-tool store --label='My password' key1 value1 key2 value2

(secret-tool:22493): GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
secret-tool: Failed to execute child process "dbus-launch" (No such file or directory)

Do you log in to this machine via a gui?

Nope.. this is a remote server I use in console mode.

libsecret and keyring definitely works on centos 7, I remember that I tried it. But the secret service provider is typically not running if you don't log in from a gui.

You can start it from the command line, but AFAIR centos has some buggy old dbus, and it is a pain to get rid of the dbus background processes.

AFAIR dbus-launch can be used to start it up.

Here are some notes of mine:

OK, I managed to get it work.
I don't know how stable this is, though. Anyway, here is how

  1. ssh -X <host>
  2. dbus-run-session bash
  3. gnome-keyring-daemon -r
  4. R (edited)

Then

> library(keyring)
> keyring_list()
  keyring num_secrets locked
1                   0  FALSE
2   Login           4   TRUE
> keyring_unlock()
Activating service name='org.gnome.keyring.SystemPrompter'
Activating service name='org.a11y.Bus'
Activating service name='org.gtk.vfs.Daemon'
Successfully activated service 'org.gtk.vfs.Daemon'
Successfully activated service 'org.a11y.Bus'
Successfully activated service 'org.gnome.keyring.SystemPrompter'
> keyring_list()
  keyring num_secrets locked
1                   0  FALSE
2   Login           4  FALSE

The default keyring is locked by default, so you need to unlock it, and AFAIK this is only possible by getting a GUI window, hence the need for -X in the ssh.

Oh, man

> key_list()

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: .Call("keyring_secret_service_list", keyring, service)
 2: b_ss_list(self, private, service, keyring)
 3: default_backend()$list(service, keyring = keyring)
 4: key_list()

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 3

One glitch is that after quitting the dbus daemon is still running.
Also, there is gnome-keyring-daemon --unlock, maybe that can avoid the window.

Unfortunately libsecret without a GUI is not a nice experience.....

Thanks a lot for your helpful notes! For the record, once dbus-x11 and gnome-keyring were installed on CentOS 7, I was able to run the following.

  1. ssh -X <host>
  2. dbus-launch --sh-syntax
  3. gnome-keyring-daemon -r
  4. run R

Closing, please reopen if you still have problems with this.