Bug 12521 - [2.2.3 rc2] setUpClass - gpg fail to build skey array skipping testcases (auto)
Summary: [2.2.3 rc2] setUpClass - gpg fail to build skey array skipping testcases (auto)
Status: CLOSED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.2.3
Hardware: x86 x86_64
: Medium normal
Target Milestone: 2.2.4
Assignee: Alexander Kanavin
QA Contact:
URL:
Whiteboard:
: 12533 12610 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-02-01 06:30 UTC by Aaron Chan
Modified: 2018-10-12 16:37 UTC (History)
10 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: Regression (Found by QA test)
Verified:
Documentation change: Don't know


Attachments
setUpClass signing module oeqa.selftest.signing.Signing (13.43 KB, application/octet-stream)
2018-02-01 06:30 UTC, Aaron Chan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Chan 2018-02-01 06:30:26 UTC
Created attachment 4193 [details]
setUpClass signing module oeqa.selftest.signing.Signing

Description:

Found (2) testcases were not run and status of testcases are not updated in Testopia due to signing class failed skipping the entire tests.
Error indicate a timeout while trying to build skey array.

1. Testcases 1362: Signing packages in the package feeds
2. Testcases 1382: Signing sstate archive

both of these testcases are mapped to AB testcases:

1. oeqa.selftest.signing.Signing.test_signing_packages
2. oeqa.selftest.signing.Signing.test_signing_sstate_archive

======================================================================
ERROR [0.000s]: setUpClass (oeqa.selftest.signing.Signing)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ab/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta/lib/oeqa/selftest/signing.py", line 29, in setUpClass
    runCmd('gpg --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path))
  File "/home/ab/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta/lib/oeqa/utils/commands.py", line 114, in runCmd
    raise AssertionError("Command '%s' returned non-zero exit status %d:\n%s" % (command, result.status, result.output))
AssertionError: Command 'gpg --homedir /tmp/oeqa-signing-07tqth1g --import /home/ab/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta-selftest/files/signing/key.pub /home/ab/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta-selftest/files/signing/key.secret' returned non-zero exit status 2:
gpg: keybox '/tmp/oeqa-signing-07tqth1g/pubring.kbx' created
gpg: /tmp/oeqa-signing-07tqth1g/trustdb.gpg: trustdb created
gpg: key 7B31316B5D64AD52: public key "testuser (nocomment) <testuser@testemail.com>" imported
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52/7B31316B5D64AD52: error sending to agent: Timeout
gpg: error building skey array: Timeout
gpg: Total number processed: 2
gpg:               imported: 1
gpg:              unchanged: 1
gpg:       secret keys read: 1
Comment 1 Alexander Kanavin 2018-02-06 14:51:23 UTC
To me this looks like a host distribution issue. In YP 2.2 we still use host gpg to sign packages, and so rely on gpg provided by distribution, and that it works properly. Here it seems like it does not:

gpg --homedir /tmp/oeqa-signing-07tqth1g --import /home/ab/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta-selftest/files/signing/key.pub /home/ab/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta-selftest/files/signing/key.secret

eventually prints:

gpg: key 7B31316B5D64AD52/7B31316B5D64AD52: error sending to agent: Timeout


Can you run the same command manually? Create the directory that is used for the --homedir argument first.

If you have access to a computer with another distribution, you can also try and see if the same selftest works there.
Comment 2 Alexander Kanavin 2018-02-08 16:56:55 UTC
*** Bug 12533 has been marked as a duplicate of this bug. ***
Comment 3 Alexander Kanavin 2018-02-15 16:02:49 UTC
Were you able to do what I requested?
Comment 4 Aaron Chan 2018-02-21 02:49:42 UTC
Hi Alexander Kanavin,

Sorry i was away for long vacation for Chinese New Year celebration.

So here are some quick updates on the gpg verification on the host distribution we had on our autobuilder workers. Instead of using the YP 2.2 poky, we were able to replicate the same issue on YP 2.4 poky (rocko)
on Debian 9 Distro and not reproduce on Fedora 27 Distro. 

Also, i've manage to list down all the default gpg package installation on various host distribution for your reference. 
It appears to me that the issue can be found on gpg version 2.1.18, with reference to the Release Notes on GnuPG - https://lists.gnupg.org/pipermail/gnupg-announce/2017q1/000401.html

Distributions	gpg (GnuPG) version	libcrypt version
-------------   -----------             --------
Fedora 26	1.4.22	                No comments
Fedora 27	1.5.22	                No comments
Debian 8	1.4.18	                No comments
Debian 9	2.1.18	                1.7.6-beta
CentOS7	        2.0.22	                1.5.3
Ubuntu1704	2.1.15	                1.7.6-beta
Ubuntu1710	2.1.15	                1.7.8
OpenSuse42.2	2.0.24	                1.6.1
OpenSuse42.3	2.0.24	                1.6.1

Debian 9 (stretch) Distribuion
------------------------------

~/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build$ git log -n 5 --oneline
50189fdf62 (HEAD -> master) build-appliance-image: Update to rocko head revision
a9588646fc poky.conf: Bump version for 2.4.2 rocko release
90c1d0d127 documentation: Updated Manual Revision Table for 2.4.2 Release Date
583b5a8445 yocto-project-qs: Fixed spelling error in Welcome section
0fa8ccad9a dev-manual: Fixed variable link to DEFAULTTUNE variable

$ gpg --version
gpg (GnuPG) 2.1.18
libgcrypt 1.7.6-beta
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ mkdir -p /tmp/oeqa-signing-07tqth1g
$ gpg --homedir /tmp/oeqa-signing-07tqth1g --import ~/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta-selftest/files/signing/key.pub ~/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta-selftest/files/signing/key.secret
gpg: WARNING: unsafe permissions on homedir '/tmp/oeqa-signing-07tqth1g'
gpg: keybox '/tmp/oeqa-signing-07tqth1g/pubring.kbx' created
gpg: /tmp/oeqa-signing-07tqth1g/trustdb.gpg: trustdb created
gpg: key 7B31316B5D64AD52: public key "testuser (nocomment) <testuser@testemail.com>" imported
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52/7B31316B5D64AD52: error sending to agent: Timeout
gpg: error building skey array: Timeout
gpg: Total number processed: 2
gpg:               imported: 1
gpg:              unchanged: 1
gpg:       secret keys read: 1

$ ls -al /tmp/oeqa-signing-07tqth1g/
total 76
drwxr-xr-x  3 ab   ab    4096 Feb 21 04:30 .
drwxrwxrwt 23 root root 53248 Feb 21 04:31 ..
drwx------  2 ab   ab    4096 Feb 21 04:29 private-keys-v1.d
-rw-r--r--  1 ab   ab    1374 Feb 21 04:29 pubring.kbx
-rw-------  1 ab   ab      32 Feb 21 04:29 pubring.kbx~
-rw-------  1 ab   ab    1200 Feb 21 04:29 trustdb.gpg

Fedora 27 Distribution
----------------------
[user@fedora27 build]$ git log -n 5 --oneline
50189fdf62 (HEAD -> master) build-appliance-image: Update to rocko head revision
a9588646fc poky.conf: Bump version for 2.4.2 rocko release
90c1d0d127 documentation: Updated Manual Revision Table for 2.4.2 Release Date
583b5a8445 yocto-project-qs: Fixed spelling error in Welcome section
0fa8ccad9a dev-manual: Fixed variable link to DEFAULTTUNE variable

[user@fedora27 build]$ gpg --version
gpg (GnuPG) 1.4.22
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[ab@fedora27 build]$ mkdir -p /tmp/oeqa-signing-07tqth1g

[user@fedora27 build]$ gpg --homedir /tmp/oeqa-signing-07tqth1g --import ~/autobuilder/yocto-worker/nightly-oe-selftest-fedora27/build/meta-selftest/files/signing/key.pub ~/autobuilder/yocto-worker/nightly-oe-selftest-fedora27/build/meta-selftest/files/signing/key.secret
gpg: WARNING: unsafe permissions on homedir `/tmp/oeqa-signing-07tqth1g'
gpg: /tmp/oeqa-signing-07tqth1g/trustdb.gpg: trustdb created
gpg: key 5D64AD52: public key "testuser (nocomment) <testuser@testemail.com>" imported
gpg: key 5D64AD52: secret key imported
gpg: key 5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: Total number processed: 2
gpg:               imported: 1  (RSA: 1)
gpg:              unchanged: 1
gpg:       secret keys read: 1
gpg:   secret keys imported: 1

[user@fedora27 build]$ ls -al /tmp/oeqa-signing-07tqth1g/
total 12
drwxrwxr-x.  2 ab   ab    120 Feb  21 04:38 .
drwxrwxrwt. 36 root root 8880 Feb  21 04:39 ..
-rw-------.  1 ab   ab   1204 Feb  21 04:38 pubring.gpg
-rw-------.  1 ab   ab      0 Feb  21 04:38 pubring.gpg~
-rw-------.  1 ab   ab   2582 Feb  21 04:38 secring.gpg
-rw-------.  1 ab   ab   1200 Feb  21 04:38 trustdb.gpg

CentOS7 Distribution
--------------------
[user@centos7 build]$ git log -n 5 --oneline
50189fd build-appliance-image: Update to rocko head revision
a958864 poky.conf: Bump version for 2.4.2 rocko release
90c1d0d documentation: Updated Manual Revision Table for 2.4.2 Release Date
583b5a8 yocto-project-qs: Fixed spelling error in Welcome section
0fa8cca dev-manual: Fixed variable link to DEFAULTTUNE variable

[user@centos7 ~]$ gpg --version
gpg (GnuPG) 2.0.22
libgcrypt 1.5.3
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, ?, ?, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

[user@centos7 build]$ mkdir -p /tmp/oeqa-signing-07tqth1g

[user@centos7 build]$ gpg --homedir /tmp/oeqa-signing-07tqth1g --import ~/autobuilder/yocto-worker/nightly-oe-selftest-centos7/build/meta-selftest/files/signing/key.pub ~/autobuilder/yocto-worker/nightly-oe-selftest-centos7/build/meta-selftest/files/signing/key.secret
gpg: WARNING: unsafe permissions on homedir `/tmp/oeqa-signing-07tqth1g'
gpg: keyring `/tmp/oeqa-signing-07tqth1g/secring.gpg' created
gpg: keyring `/tmp/oeqa-signing-07tqth1g/pubring.gpg' created
gpg: /tmp/oeqa-signing-07tqth1g/trustdb.gpg: trustdb created
gpg: key 5D64AD52: public key "testuser (nocomment) <testuser@testemail.com>" imported
gpg: key 5D64AD52: secret key imported
gpg: key 5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: Total number processed: 2
gpg:               imported: 1  (RSA: 1)
gpg:              unchanged: 1
gpg:       secret keys read: 1
gpg:   secret keys imported: 1

[user@centos7 build]$ echo $?
0

[user@centos7 build]$ ls -al /tmp/oeqa-signing-07tqth1g/
total 60
drwxrwxr-x.  2 ab   ab    4096 Feb  21 17:48 .
drwxrwxrwt. 46 root root 40960 Feb  21 17:48 ..
-rw-------.  1 ab   ab    1204 Feb  21 17:48 pubring.gpg
-rw-------.  1 ab   ab       0 Feb  21 17:48 pubring.gpg~
-rw-------.  1 ab   ab    2582 Feb  21 17:48 secring.gpg
-rw-------.  1 ab   ab    1200 Feb  21 17:48 trustdb.gpg
Comment 5 Alexander Kanavin 2018-02-27 13:02:12 UTC
Do you have another Debian 9 machine available? Can you check if the issue also happens in that machine? It's possible your specific setup somehow got broken.

(you can also do a fresh install of Debian 9 in a virtual machine).

Here are the open bugs for gnupg in deb9, and I don't immediately see anything that resembles this issue:
https://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=gnupg;dist=stable
Comment 6 Aaron Chan 2018-03-02 01:55:42 UTC
On another new distribution setup on Debian 9 (stretch) KVM.
Copy over the key.pub and key.secret into the another KVM machine under ~/Downloads

Here are  the steps taken:

$ mkdir -p /tmp/oeqa-signing-07tqth1g/
$ gpg --homedir /tmp/oeqa-signing-07tqth1g --import ~/Downloads/key.pub ~/Downloads/key.secret

hence results in passphrase prompt shown below, 

┌────────────────────────────────────────────────────────────────┐
│ Please enter the passphrase to import the OpenPGP secret key:  │
│ "testuser (nocomment) <testuser@testemail.com>"                │
│ 2048-bit RSA key, ID 7B31316B5D64AD52,                         │
│ created 2015-10-14.                                            │
│                                                                │
│                                                                │
│ Bad Passphrase (try 2 of 3)                                    │
│                                                                │
│ Passphrase: __________________________________________________ │
│                                                                │
│         <OK>                                    <Cancel>       │
└────────────────────────────────────────────────────────────────┘

 Do you know what is the passphrase which is needed to be parse to the prompt ?
Comment 7 Alexander Kanavin 2018-03-02 08:47:34 UTC
(In reply to comment #6)
>
>  Do you know what is the passphrase which is needed to be parse to the
> prompt ?

You need to use --batch option so that gpg doesn't ask anything (same option as the signing selftest is using).
Comment 8 Aaron Chan 2018-03-03 15:50:38 UTC
Attach options --batch to the gpg resulted in timeout. Is this some needed to send the public key to testuser@testmail.com?

$:~/Downloads$ rm -rf /tmp/oeqa-signing-07tqth1g/*
$:~/Downloads$ gpg --homedir /tmp/oeqa-signing-07tqth1g --batch --import ~/Downloads/key.pub ~/Downloads/key.secret
gpg: WARNING: unsafe permissions on homedir '/tmp/oeqa-signing-07tqth1g'
gpg: keybox '/tmp/oeqa-signing-07tqth1g/pubring.kbx' created
gpg: /tmp/oeqa-signing-07tqth1g/trustdb.gpg: trustdb created
gpg: key 7B31316B5D64AD52: public key "testuser (nocomment) <testuser@testemail.com>" imported
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52/7B31316B5D64AD52: error sending to agent: No such file or directory
gpg: error building skey array: No such file or directory
gpg: Total number processed: 2
gpg:               imported: 1
gpg:              unchanged: 1
gpg:       secret keys read: 1
$:~/Downloads$ echo $?
2

It appears the prompt passphrase somehow was skipped and resulted in the previous failed symptom

$:~/Downloads$ rm -rf /tmp/oeqa-signing-07tqth1g/*
$:~/Downloads$ gpg --homedir /tmp/oeqa-signing-07tqth1g --import ~/Downloads/key.pub ~/Downloads/key.secret
gpg: WARNING: unsafe permissions on homedir '/tmp/oeqa-signing-07tqth1g'
gpg: keybox '/tmp/oeqa-signing-07tqth1g/pubring.kbx' created
gpg: /tmp/oeqa-signing-07tqth1g/trustdb.gpg: trustdb created
gpg: key 7B31316B5D64AD52: public key "testuser (nocomment) <testuser@testemail.com>" imported
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52/7B31316B5D64AD52: error sending to agent: Timeout
gpg: error building skey array: Timeout
gpg: Total number processed: 2
gpg:               imported: 1
gpg:              unchanged: 1
gpg:       secret keys read: 1
$:~/Downloads$ echo $?
2
Comment 9 Alexander Kanavin 2018-03-05 02:31:09 UTC
Adding the '--batch' should work, as that is what newer releases of Yocto do, and they don't seem to fail, including Debian 9 as the host distro. 

Can you try again, with an empty, newly created --homedir?

Also, if you can provide ssh access I can try to experiment.

Otherwise, I would say it's not a particularly significant issue, as long as it appears only with YP 2.2 and Debian 9. I'd be fine if it gets documented in release notes and remains unresolved.
Comment 10 Aaron Chan 2018-03-05 17:45:27 UTC
Hi Alex,

Using the same set of sign keys stored in `/Downloads. 
I've cleanup the previous homedir and recreate a new one. Seems like its working now and this has been repeated twice.

# MACHINE-1 (New) - Add batch options
=================
$:~/Downloads$ gpg --homedir /tmp/gpg-signing-debian9-stretch/ --batch --import ~/Downloads/key.pub ~/Downloads/key.secret
gpg: WARNING: unsafe permissions on homedir '/tmp/gpg-signing-debian9-stretch/'
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52: secret key imported
gpg: Total number processed: 2
gpg:              unchanged: 2
gpg:       secret keys read: 1
gpg:  secret keys unchanged: 1
$:~/Downloads$ echo $?
0

# MACHINE-1 (New) - Remove batch options
=================
$:~$ gpg --homedir /tmp/gpg-sign-debian9/ --import ~/Downloads/key.pub ~/Downloads/key.secret
gpg: WARNING: unsafe permissions on homedir '/tmp/gpg-sign-debian9/'
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52/7B31316B5D64AD52: error sending to agent: No passphrase given
gpg: error building skey array: No passphrase given
gpg: Total number processed: 2
gpg:              unchanged: 2
gpg:       secret keys read: 1
$:~/Downloads$ echo $?
2
... resulted in passphrase prompt

# MACHINE-2 (Old) - Add batch options
=================
$:~/Downloads$ gpg --homedir /tmp/oeqa-sign-debian9-stretch/ --import ~/Downloads/key.pub ~/Downloads/key.secret
gpg: WARNING: unsafe permissions on homedir '/tmp/oeqa-sign-debian9-stretch/'
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52: secret key imported
gpg: Total number processed: 2
gpg:              unchanged: 2
gpg:       secret keys read: 1
gpg:  secret keys unchanged: 1
ab@debian9:~/Downloads$ echo $?
0

# MACHINE-2 (Old) - Remove batch options
=================
ab@debian9:~/Downloads$ gpg --homedir /tmp/oeqa-signing-debian9/ --import ~/Downloads/key.pub ~/Downloads/key.secret
gpg: WARNING: unsafe permissions on homedir '/tmp/oeqa-signing-debian9/'
gpg: keybox '/tmp/oeqa-signing-debian9//pubring.kbx' created
gpg: /tmp/oeqa-signing-debian9//trustdb.gpg: trustdb created
gpg: key 7B31316B5D64AD52: public key "testuser (nocomment) <testuser@testemail.com>" imported
gpg: key 7B31316B5D64AD52: "testuser (nocomment) <testuser@testemail.com>" not changed
gpg: key 7B31316B5D64AD52/7B31316B5D64AD52: error sending to agent: Timeout
gpg: error building skey array: Timeout
gpg: Total number processed: 2
gpg:               imported: 1
gpg:              unchanged: 1
gpg:       secret keys read: 1
ab@debian9:~/Downloads$ echo $?
2

Summary:
To confirm my analysis, both exiting old and new Debian 9 stretch VM are exhibiting the same symptom when adding/remove --batch options.
Although that would fix the issue, however this option (--batch) is no where to be found under the help menu. 

$ gpg -h

gpg (GnuPG) 2.1.18
libgcrypt 1.8.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /home/ab/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

Syntax: gpg [options] [files]
Sign, check, encrypt or decrypt
Default operation depends on the input data

Commands:

 -s, --sign                  make a signature
     --clear-sign            make a clear text signature
 -b, --detach-sign           make a detached signature
 -e, --encrypt               encrypt data
 -c, --symmetric             encryption only with symmetric cipher
 -d, --decrypt               decrypt data (default)
     --verify                verify a signature
 -k, --list-keys             list keys
     --list-signatures       list keys and signatures
     --check-signatures      list and check key signatures
     --fingerprint           list keys and fingerprints
 -K, --list-secret-keys      list secret keys
     --generate-key          generate a new key pair
     --quick-generate-key    quickly generate a new key pair
     --quick-add-uid         quickly add a new user-id
     --quick-revoke-uid      quickly revoke a user-id
     --quick-set-expire      quickly set a new expiration date
     --full-generate-key     full featured key pair generation
     --generate-revocation   generate a revocation certificate
     --delete-keys           remove keys from the public keyring
     --delete-secret-keys    remove keys from the secret keyring
     --quick-sign-key        quickly sign a key
     --quick-lsign-key       quickly sign a key locally
     --sign-key              sign a key
     --lsign-key             sign a key locally
     --edit-key              sign or edit a key
     --change-passphrase     change a passphrase
     --export                export keys
     --send-keys             export keys to a keyserver
     --receive-keys          import keys from a keyserver
     --search-keys           search for keys on a keyserver
     --refresh-keys          update all keys from a keyserver
     --import                import/merge keys
     --card-status           print the card status
     --edit-card             change data on a card
     --change-pin            change a card's PIN
     --update-trustdb        update the trust database
     --print-md              print message digests
     --server                run in server mode
     --tofu-policy VALUE     set the TOFU policy for a key

Options:

 -a, --armor                 create ascii armored output
 -r, --recipient USER-ID     encrypt for USER-ID
 -u, --local-user USER-ID    use USER-ID to sign or decrypt
 -z N                        set compress level to N (0 disables)
     --textmode              use canonical text mode
 -o, --output FILE           write output to FILE
 -v, --verbose               verbose
 -n, --dry-run               do not make any changes
 -i, --interactive           prompt before overwriting
     --openpgp               use strict OpenPGP behavior

(See the man page for a complete listing of all commands and options)

Examples:

 -se -r Bob [file]          sign and encrypt for user Bob
 --clear-sign [file]        make a clear text signature
 --detach-sign [file]       make a detached signature
 --list-keys [names]        show keys
 --fingerprint [names]      show fingerprints

Please report bugs to <https://bugs.gnupg.org>.
Comment 11 Alexander Kanavin 2018-03-05 21:34:36 UTC
You can see the --batch option in 'man gpg'. It's not undocumented :)

So seems like the signing selftest needs to have this option in setUpClass() - can you add and see if the tests pass? 

Change

runCmd('gpg --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path))

to

runCmd('gpg --batch --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path))
Comment 12 Aaron Chan 2018-03-06 20:49:40 UTC
Hi Alex,

On OE-Core: rocko branch - http://centaurus01.png.intel.com:8010/builders/nightly-oe-selftest-debian9/builds/18
The option --batch is added into the signing.py selftest. Not sure what your asking me to do and we can't alter the code in oeqa
during runtime using autobuilder. Let me know if you have any ideas.


2.4.2 (rocko) branch
====================
$:~/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta/lib/oeqa/selftest/cases$ git log -n 5 --oneline
342fbd6a3e (HEAD -> rocko, rocko) linux-yocto: update genericx86* SRCREVs for v4.12
2b5d5d7ecd meta-yocto-bsp: bump to the latest linux stable kernel for the non-x86 BSPs
d75a48f791 linux-yocto: update genericx86* SRCREVs for v4.9
0a3bdfe36d linux-yocto: update genericx86* SRCREVs for v4.4
771144419d linux-yocto: update genericx86* SRCREVs for v4.12

$:~/autobuilder/yocto-worker/nightly-oe-selftest-debian9/build/meta/lib/oeqa/selftest/cases$ git grep -n "gpg" signing.py
signing.py:30:        runCmd('gpg --batch --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path))

2.2.3 (morty) branch
====================
$:/data/aaronchu/workspace/poky/meta/lib/oeqa/selftest$ git log -n 5 --oneline
4f6027c p11-kit: take source code from official git
c323026 ruby: update to 2.4.3
3c735b0 insane: consider INSANE_SKIP without package-specifier too
e9b9b59 portmaper: checkuri fails.
267f2f4 gnu-efi: Fix build with gcc7

$:/data/aaronchu/workspace/poky/meta/lib/oeqa/selftest$ git grep -n "gpg" signing.py
signing.py:29:        runCmd('gpg --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path))


If 2.4.2 rc2 (rocko) is passing the SetUpClass on oeqa.selftest.signing.Signing then 2.2.3 rc3 (morty) should be passing when this
change is upstream to the HEAD (morty). After the patch is merged into the morty branch, our autobuilder can pickup your change
and test out your changes work in the autobuilder.
Comment 13 Alexander Kanavin 2018-03-07 03:33:41 UTC
(In reply to comment #12)

> If 2.4.2 rc2 (rocko) is passing the SetUpClass on
> oeqa.selftest.signing.Signing then 2.2.3 rc3 (morty) should be passing when
> this
> change is upstream to the HEAD (morty). After the patch is merged into the
> morty branch, our autobuilder can pickup your change
> and test out your changes work in the autobuilder.

I'd like to be sure that adding '--batch' is enough to make tests pass. I wouldn't want to send the patch, get it accepted, only to find out that something else further in the test is failing, and further fixing is needed.

So if you can:

- modify meta/lib/oeqa/selftest/signing.py in a morty checkout, so that it has '--batch' where the keys are imported

- run 'oe-selftest -r signing' to check that signings tests pass with that change

... then it would be great! If it's for some reason difficult to do, I can send the patch directly to oe-core list, but I would want the change to be tested and confirmed first.
Comment 14 Aaron Chan 2018-03-21 19:43:28 UTC
With reference to the changes, here is a trial run and --batch option is added into the oeqa signing.py scripts

http://centaurus01.png.intel.com:8010/builders/nightly-oe-selftest-debian9/builds/27/steps/Running%20oe-selftest/logs/stdio

2018-03-21 13:12:47 -   test_locked_signatures (oeqa.selftest.signing.LockedSignatures) ... OK (34.884s)
2018-03-21 13:13:23 -   test_signing_packages (oeqa.selftest.signing.Signing) ... OK (43.045s)
2018-03-21 13:14:06 -   test_signing_sstate_archive (oeqa.selftest.signing.Signing) ... FAIL (5.322s)
2018-03-21 13:14:12 -   test_cleansstate_task_distro_nonspecific (oeqa.selftest.sstatetests.SStateTests) ... OK (29.597s)
2018-03-21 13:14:41 -   test_cleansstate_task_distro_specific (oeqa.selftest.sstatetests.SStateTests) ... OK (28.296s)

You may proceed to upstream the patch and Resolve this ticket so that the autobuilder can pick up the change.
We do recommend you to submit the patch on the poky contrib branch and allow autobuilder to pick up the change and test your patch before you merge into master.
Comment 15 Aaron Chan 2018-03-22 01:51:34 UTC
Assign back to Alexander Kanavin since issue has been resolved.
Comment 16 Alexander Kanavin 2018-03-22 06:02:28 UTC
Do not close the bug, reassign to me instead :)
Comment 18 Alexander Kanavin 2018-03-23 03:19:40 UTC
*** Bug 12610 has been marked as a duplicate of this bug. ***
Comment 20 Armin Kuster 2018-04-05 08:17:09 UTC
done