Bug 8672 - gpgconf has incorrect paths when installing in host toolchain
Summary: gpgconf has incorrect paths when installing in host toolchain
Status: VERIFIED NOTABUG
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 2.1
Assignee: Jussi Kukkonen
QA Contact: Bogdan Alexandru Voiculescu
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-11-10 12:02 UTC by Gatis Paeglis
Modified: 2015-11-19 12:05 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
gnupg recipe bbappend (654 bytes, text/plain)
2015-11-12 13:55 UTC, Gatis Paeglis
no flags Details
gnupg library patch (1.37 KB, patch)
2015-11-12 13:57 UTC, Gatis Paeglis
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gatis Paeglis 2015-11-10 12:02:22 UTC
Steps to reproduce:

1) Add BBCLASSEXTEND = "native nativesdk" to the gnupg recipe.
2) Build toolchain for host.
3) Install the toolchain in custom prefix (MY_PREFIX).
4) Run ${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/gpgconf

Where on my setup it prints:

gpg:GPG for OpenPGP:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/gpg2
gpg-agent:GPG Agent:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/gpg-agent
scdaemon:Smartcard Daemon:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/gnupg/scdaemon
gpgsm:GPG for S/MIME:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/gpgsm
dirmngr:Directory Manager:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/dirmngr

But the expected output would be:

gpg:GPG for OpenPGP:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/gpg2
gpg-agent:GPG Agent:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/gpg-agent
scdaemon:Smartcard Daemon:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/lib/gnupg/scdaemon
gpgsm:GPG for S/MIME:${MY_PREFIX}sysroots/x86_64-pokysdk-linux/usr/bin/gpgsm
dirmngr:Directory Manager:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/dirmngr

Looking at the source code in gpgme library (gpgme/src/dirinfo.c::get_gpgconf_item) I see that it uses the gpgconf to find the gpg binary, but failing to find gpg in that path results in:
error: Unable to lookup key ID MY_KEY_ID: GPGME: Invalid crypto engine

Possibly recipe should add

/etc/gnupg/gpgconf.conf

as described in http://manpages.ubuntu.com/manpages/hardy/man1/gpgconf.1.html

Or run:

gpgconf --change-options when installing the toolchain.
Comment 1 Gatis Paeglis 2015-11-10 15:50:07 UTC
After looking some more at this I see that there is no way to change the prefix at runtime, it is defined at build time.

As I was told, other recipes have solved similar issues with patching the original library to add envvars and then use "create_wrapper pattern" from recipes.
Comment 2 Gatis Paeglis 2015-11-12 13:55:02 UTC
Created attachment 2849 [details]
gnupg recipe bbappend
Comment 3 Gatis Paeglis 2015-11-12 13:57:26 UTC
Created attachment 2850 [details]
gnupg library patch

This is not complete. There are few other places in gnupg src that uses GNUPG_ defines, but this patch covers my use cases.
Comment 4 Gatis Paeglis 2015-11-12 14:07:15 UTC
And here is the relevant discussion from gnupg-devel mailing list:
http://lists.gnupg.org/pipermail/gnupg-devel/2015-November/030547.html

It is not very useful, since I did not manage to convince them that there is an issue.
Comment 5 Ross Burton 2015-11-12 14:12:10 UTC
Can you submit the patches to the mailing list (openembedded-core@) for review?  We don't do patch review in bugzilla. Thanks!
Comment 6 Gatis Paeglis 2015-11-12 14:19:08 UTC
I don't do patches on mailing lists :) But if seriously, then the patch for gnupg library is not complete and probably should be handled in cleaner way and ideally would be done by upstream project (gnupg).

It works for me, so I attached it here for convenience if others experience the same issue or somebody wants to fix this properly. I do not have time for that unfortunately. Also I would like to see yocto project switching from ML to something more modern, like https://en.wikipedia.org/wiki/Gerrit_%28software%29
Comment 7 Gatis Paeglis 2015-11-13 12:26:55 UTC
Just a note: this patch was tested with gnupg_2.0.26 and wont work with gnupg_2.1.1 for example. Also in my patch I export this adjusted env only before calling gpgconf, but the same env is probably needed also for other gpg binaries.
Comment 8 Jussi Kukkonen 2015-11-13 14:26:04 UTC
I might be missing something... can you explain why gpgconf needs to be able to run in sysroot? gpgconf as I've understood it is a tool for modifying user configuration in place in ~/.gnupg: this doesn't sound like a toolchain tool to me.

Can you generate the configuration once and install that in a recipe (possibly with some sed-replacements in the recipe if needed)?
Comment 9 Gatis Paeglis 2015-11-13 14:41:39 UTC
> I might be missing something... can you explain why gpgconf needs to be able > to run in sysroot? gpgconf as I've understood it is a tool for modifying user > configuration in place in ~/.gnupg: this doesn't sound like a toolchain tool > to me.

My current situation is that I want to provide customers a binary executable of "something" that does not come as installable *.deb package on Ubuntu. It could be challenging for some to build this "something" natively on Ubuntu, so I want to provide it in my toolchain for convenience. This "something" depends on GNUPG (and gpgme) and that is the reason why I have been trying to make it work from a toolchain.

Looking at the source code in gpgme library (gpgme/src/dirinfo.c::get_gpgconf_item) I see that it uses the gpgconf to find the gpg binary, but failing to find gpg in that path results in:
error: Unable to lookup key ID MY_KEY_ID: GPGME: Invalid crypto engine

So this is what gpgconf seems to be used for in addition to other things.

I was thinking since GNUPG is a runtime dependency, maybe there is a way to force "something" from toolchain to uses the GNUGP from the system instead?
Comment 10 Gatis Paeglis 2015-11-17 10:27:17 UTC
Seems like nobody has ever tried this setup and also I droped GNUPG from my toolchain. This task can be closed as out-of-scope.
Comment 11 Jussi Kukkonen 2015-11-17 11:51:10 UTC
I agree that it's kind of out-of-scope, marking NOTABUG.

If you need advice on how to get a tool in sysroot to use host gnupg, you could try the mailing list: I'm guessing it's possible but can't think of suggestions right now.
Comment 12 Bogdan Alexandru Voiculescu 2015-11-19 12:05:21 UTC
out of scope.