GNOME Bugzilla – Bug 633958
Allow None where NULL is allowed in C API for method gnomekeyring.unlock_sync()
Last modified: 2014-08-02 13:02:26 UTC
Seems as if the gnomekeyring.unlock_sync()-method was missing when fixing Bug 460518 ( https://bugzilla.gnome.org/show_bug.cgi?id=460518 ): Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import gnomekeyring >>> gnomekeyring.lock_sync('login') >>> gnomekeyring.unlock_sync('login') Traceback (most recent call last):
+ Trace 224478
>>> gnomekeyring.unlock_sync('login', None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unlock_sync() argument 2 must be string, not None
Sorry for the confusion, but the GNOME-version is 2.32 and the gnomekeyring-version is 2.30. I hope I've set it right now for this (first bugzilla) report. :-)
My diff'ing patching skills are pretty lame but I've fixed this bug locally and reported it to Ubuntu (who seem to be just sitting on it). The fix is: diff ./gnomekeyring/gnomekeyring.defs ./gnomekeyring/gnomekeyring.defs.orig 272c272 < '("const-char*" "password" (null-ok)) --- > '("const-char*" "password") The Ubuntu bug report which details stuff in much more detail is here: https://bugs.launchpad.net/ubuntu/+source/gnome-python-desktop/+bug/432882 Should take all of 2 minutes to fix this bug.
Created attachment 202025 [details] [review] Patch to fix the bug My first ever Gnome patch. Yay!
Could you provide a small test program, so I can easily check before/after behavior?
@ Stef Walter: You can take the commandline-tests in my original bug-description or type in this one-liner in your commandline: python -c "import gnomekeyring; defaultKeyring = gnomekeyring.get_default_keyring_sync(); gnomekeyring.unlock_sync(defaultKeyring, None)" Before behavior was and is this Python-Traceback: Traceback (most recent call last):
+ Trace 229120
Expected behavior is unlock your (previously locked if unlocked ;-) ) default-keyring. Would be great if you can confirm and merge this patch that it hopefully soon can be shiped. Thank you very much for approaching! @ Bryan Hunt: Yay! :-D Thank you so much!!! Cheers, Patrick
Thanks Bryan. Congratulations on your first contribution. Could you format the git commit message (use 'git commit --amend') to be similar to the other messages in the log. In particular could you include a full email address, and change the commit message to look something like: gnomekeyring: A short one line description of fix Optional paragraph describing detail https://bugzilla.gnome.org/ Bugzilla URL But, more importantly for some reason this doesn't seem to fix the problem for me: $ git log commit 9c8df4d5faabf6b8ea8f7d01a7f4d5bf1026dc53 Author: bryan <bryan@catah.(none)> Date: Wed Nov 23 20:37:31 2011 +0000 Created a fix for gnome buzilla issue #633958.Allow null password, this will trigger the safer system password prompt - rathe ... $ ls -l /data/build/gnome/lib64/python2.7/site-packages/gtk-2.0/gnomekeyring.so -rwxr-xr-x 1 stef stef 114047 Nov 24 15:54 /data/build/gnome/lib64/python2.7/site-packages/gtk-2.0/gnomekeyring.so $ python Python 2.7.2 (default, Oct 27 2011, 01:40:22) [GCC 4.6.1 20111003 (Red Hat 4.6.1-10)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import gnomekeyring >>> print gnomekeyring.__file__ /data/build/gnome/lib64/python2.7/site-packages/gtk-2.0/gnomekeyring.so >>> defaultKeyring = gnomekeyring.get_default_keyring_sync(); gnomekeyring.unlock_sync(defaultKeyring, None) Traceback (most recent call last):
+ Trace 229122
>>> Any ideas on how to get it to work. It seems that the fix is being built in, and the rebuilt module being loaded by python, but for some reason I still see the same problem.
Hi. Stef, can you please also check this patch by "dtk": http://bugzilla-attachments.gnome.org/attachment.cgi?id=199841 found here: https://bugzilla.gnome.org/show_bug.cgi?id=460518#c9 I'm not into git, so I can't check. :-( Sorry. Patrick
Created attachment 202067 [details] [review] Patch to fix the bug v2 (better description/username)
> But, more importantly for some reason this doesn't seem to fix the problem for > me: > > $ git log > commit 9c8df4d5faabf6b8ea8f7d01a7f4d5bf1026dc53 > Author: bryan <bryan@catah.(none)> > Date: Wed Nov 23 20:37:31 2011 +0000 > > Created a fix for gnome buzilla issue #633958.Allow null password, this > will trigger the safer system password prompt - rathe > ... > > $ ls -l /data/build/gnome/lib64/python2.7/site-packages/gtk-2.0/gnomekeyring.so > -rwxr-xr-x 1 stef stef 114047 Nov 24 15:54 > /data/build/gnome/lib64/python2.7/site-packages/gtk-2.0/gnomekeyring.so > $ python > Python 2.7.2 (default, Oct 27 2011, 01:40:22) > [GCC 4.6.1 20111003 (Red Hat 4.6.1-10)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import gnomekeyring > >>> print gnomekeyring.__file__ > /data/build/gnome/lib64/python2.7/site-packages/gtk-2.0/gnomekeyring.so > >>> defaultKeyring = gnomekeyring.get_default_keyring_sync(); gnomekeyring.unlock_sync(defaultKeyring, None) > Traceback (most recent call last): > Steps I took to check it locally: sudo apt-get install libtool libtoolize --force aclocal autoheader touch ./ChangeLog automake --force-missing --add-missing autoconf sudo apt-get install python-gtk2-dev python-gtk2 ./configure make cd gnomekeyring make gnomekeyring.c The above produced for me the following content in the (generated) gnomekeyring.c file. static PyObject * _wrap_gnome_keyring_unlock_sync(PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "keyring", "password", NULL }; char *keyring, *password; GnomeKeyringResult ret; if (!PyArg_ParseTupleAndKeywords(args, kwargs,"zs:unlock_sync", kwlist, &keyring, &password)) return NULL; pyg_begin_allow_threads; ret = gnome_keyring_unlock_sync(keyring, password); pyg_end_allow_threads; if (pygnomekeyring_result_check(ret)) return NULL; Py_INCREF(Py_None); return Py_None; } const PyMethodDef pygnomekeyring_functions[] = { { "is_available", (PyCFunction)_wrap_gnome_keyring_is_available, METH_NOARGS, NULL }, { "set_default_keyring_sync", (PyCFunction)_wrap_gnome_keyring_set_default_keyring_sync, METH_VARARGS|METH_KEYWORDS, NULL }, { "get_default_keyring_sync", (PyCFunction)_wrap_gnome_keyring_get_default_keyring_sync, METH_NOARGS, NULL }, { "list_keyring_names_sync", (PyCFunction)_wrap_gnome_keyring_list_keyring_names_sync, METH_NOARGS, NULL }, { "lock_all_sync", (PyCFunction)_wrap_gnome_keyring_lock_all_sync, METH_NOARGS, NULL }, { "create_sync", (PyCFunction)_wrap_gnome_keyring_create_sync, METH_VARARGS|METH_KEYWORDS, NULL }, { "unlock_sync", (PyCFunction)_wrap_gnome_keyring_unlock_sync, METH_VARARGS|METH_KEYWORDS,
(In reply to comment #9) > if (!PyArg_ParseTupleAndKeywords(args, kwargs,"zs:unlock_sync", kwlist, > &keyring, &password)) So shouldn't this line end up saying "zz:unlock_sync" instead?
Created attachment 204156 [details] [review] Fix suppressed password prompt by allowing a null password
Looks like the patch was missing the code to update unlock_sync. And it turns out I can't push to gnome-python-desktop at all: remote: A valid gnome-python-desktop.doap file is required. See http://live.gnome.org/MaintainersCorner#maintainers To ssh://git.gnome.org/git/gnome-python-desktop ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'ssh://git.gnome.org/git/gnome-python-desktop' Grumble. Seems like it really is utterly unmaintained, and I don't want to take over maintainership of the whole thing. Posted the updated patch here.
*** Bug 686672 has been marked as a duplicate of this bug. ***
Although it seems this will never be fixed in this version, it is fixed in the new Python3 gobject introspection version. To start you off: from gi.repository import GnomeKeyring keyring=None # Keyring name GnomeKeyring.unlock_sync(keyring, None) # Works! I'm not affiliated with any development team, just a hobbyist.
The last gnome-python-desktop code changes took place in January 2011: https://git.gnome.org/browse/archive/gnome-python-desktop/log/ This project is not under active development anymore. This project got recently archived in GNOME Git. It is currently unlikely that there will be any further active development. Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Please feel free to reopen this bug report in the future if anyone takes the responsibility for active development again. If you are interested in maintainership, inform https://mail.gnome.org/mailman/listinfo/desktop-devel-list gnome-python-desktop wrapped application API in GNOME 2. For Python in GNOME 3, see https://wiki.gnome.org/Projects/PyGObject and its gobject-introspection approach.