Public bug reported: When verifying bug 1532855 I realized that when add-apt-repository fails (at least due to a gpg key-add failure) it will leave the sources entry that it added still in place. It does not clean up as it should.
The issue is that after the failure, 'apt-get update' will fail as it wont have the key it needs but apt will grab the ppa sources. $ find /etc/apt/sources.list.d/ /etc/apt/sources.list.d/ $ sudo add-apt-repository -y ppa:smoser -k hkp://127.0.0.1/ gpg: keybox '/tmp/tmp03u3ibc9/pubring.gpg' created gpg: keyserver receive failed: No keyserver available Failed to add key. $ echo $? 1 $ find /etc/apt/sources.list.d/ /etc/apt/sources.list.d/ /etc/apt/sources.list.d/smoser-ubuntu-ppa-yakkety.list $ apt-get update -q Hit:1 http://us.archive.ubuntu.com/ubuntu yakkety InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates InRelease Get:3 http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease [17.5 kB] Err:3 http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0620BBCF03683F77 Reading package lists... W: GPG error: http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0620BBCF03683F77 E: The repository 'http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease' is not signed. $ echo $? 100 ProblemType: Bug DistroRelease: Ubuntu 16.10 Package: software-properties-common 0.96.24.7.1 ProcVersionSignature: Ubuntu 4.9.0-15.16-generic 4.9.5 Uname: Linux 4.9.0-15-generic x86_64 ApportVersion: 2.20.3-0ubuntu8.2 Architecture: amd64 Date: Thu Mar 9 16:54:42 2017 PackageArchitecture: all ProcEnviron: TERM=xterm-256color PATH=(custom, no user) LANG=C.UTF-8 SourcePackage: software-properties UpgradeStatus: No upgrade log present (probably fresh install) Related bugs: * bug 1532855 add-apt-repository exits with 0 even when adding key failed ** Affects: software-properties (Ubuntu) Importance: Medium Status: Confirmed ** Tags: amd64 apport-bug package-from-proposed uec-images yakkety ** Changed in: software-properties (Ubuntu) Status: New => Confirmed ** Changed in: software-properties (Ubuntu) Importance: Undecided => Medium ** Description changed: When verifying bug 1532855 I realized that when add-apt-repository fails (at least due to a gpg key-add failure) it will leave the sources entry that it added still in place. It does not clean up as it should. The issue is that after the failure, 'apt-get update' will fail as it wont have the key it needs but apt will grab the ppa sources. $ find /etc/apt/sources.list.d/ /etc/apt/sources.list.d/ $ sudo add-apt-repository -y ppa:smoser -k hkp://127.0.0.1/ gpg: keybox '/tmp/tmp03u3ibc9/pubring.gpg' created gpg: keyserver receive failed: No keyserver available Failed to add key. $ echo $? 1 $ find /etc/apt/sources.list.d/ /etc/apt/sources.list.d/ /etc/apt/sources.list.d/smoser-ubuntu-ppa-yakkety.list $ apt-get update -q Hit:1 http://us.archive.ubuntu.com/ubuntu yakkety InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates InRelease Get:3 http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease [17.5 kB] Err:3 http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease - The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0620BBCF03683F77 + The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0620BBCF03683F77 Reading package lists... W: GPG error: http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0620BBCF03683F77 E: The repository 'http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease' is not signed. $ echo $? 100 ProblemType: Bug DistroRelease: Ubuntu 16.10 Package: software-properties-common 0.96.24.7.1 ProcVersionSignature: Ubuntu 4.9.0-15.16-generic 4.9.5 Uname: Linux 4.9.0-15-generic x86_64 ApportVersion: 2.20.3-0ubuntu8.2 Architecture: amd64 Date: Thu Mar 9 16:54:42 2017 PackageArchitecture: all ProcEnviron: - TERM=xterm-256color - PATH=(custom, no user) - LANG=C.UTF-8 + TERM=xterm-256color + PATH=(custom, no user) + LANG=C.UTF-8 SourcePackage: software-properties UpgradeStatus: No upgrade log present (probably fresh install) + + Related bugs: + * bug 1532855 add-apt-repository exits with 0 even when adding key failed -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to software-properties in Ubuntu. https://bugs.launchpad.net/bugs/1671566 Title: when gpg key add fails, entry is still added to sources.list Status in software-properties package in Ubuntu: Confirmed Bug description: When verifying bug 1532855 I realized that when add-apt-repository fails (at least due to a gpg key-add failure) it will leave the sources entry that it added still in place. It does not clean up as it should. The issue is that after the failure, 'apt-get update' will fail as it wont have the key it needs but apt will grab the ppa sources. $ find /etc/apt/sources.list.d/ /etc/apt/sources.list.d/ $ sudo add-apt-repository -y ppa:smoser -k hkp://127.0.0.1/ gpg: keybox '/tmp/tmp03u3ibc9/pubring.gpg' created gpg: keyserver receive failed: No keyserver available Failed to add key. $ echo $? 1 $ find /etc/apt/sources.list.d/ /etc/apt/sources.list.d/ /etc/apt/sources.list.d/smoser-ubuntu-ppa-yakkety.list $ apt-get update -q Hit:1 http://us.archive.ubuntu.com/ubuntu yakkety InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates InRelease Get:3 http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease [17.5 kB] Err:3 http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0620BBCF03683F77 Reading package lists... W: GPG error: http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0620BBCF03683F77 E: The repository 'http://ppa.launchpad.net/smoser/ppa/ubuntu yakkety InRelease' is not signed. $ echo $? 100 ProblemType: Bug DistroRelease: Ubuntu 16.10 Package: software-properties-common 0.96.24.7.1 ProcVersionSignature: Ubuntu 4.9.0-15.16-generic 4.9.5 Uname: Linux 4.9.0-15-generic x86_64 ApportVersion: 2.20.3-0ubuntu8.2 Architecture: amd64 Date: Thu Mar 9 16:54:42 2017 PackageArchitecture: all ProcEnviron: TERM=xterm-256color PATH=(custom, no user) LANG=C.UTF-8 SourcePackage: software-properties UpgradeStatus: No upgrade log present (probably fresh install) Related bugs: * bug 1532855 add-apt-repository exits with 0 even when adding key failed To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/software-properties/+bug/1671566/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp