Bug 118387 - Troubles with keys with multiple ids from keyserver
Summary: Troubles with keys with multiple ids from keyserver
Status: RESOLVED FIXED
Alias: None
Product: kgpg
Classification: Applications
Component: general (show other bugs)
Version: 1.2.1
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Rolf Eike Beer
URL:
Keywords:
: 118864 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-12-15 16:18 UTC by Bernd Paysan
Modified: 2007-08-20 09:27 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Paysan 2005-12-15 16:18:52 UTC
Version:           1.2.1 (using KDE KDE 3.4.2)
Installed from:    SuSE RPMs
OS:                Linux

There's obviously a parsing problem with multiple-ID keys from the keyserver (keyserver dialog). E.g. try to load my key, and search for "Bernd Paysan". You'll get three "keys" where only the last one actually has a key ID in it. The output of gpg --search-keys is

(1)     Bernd Paysan <bernd.paysan@gmx.de>
        Bernd Paysan <bernd.paysan@arcor.de>
        Bernd Paysan (business) <bpaysan@zetex.com>
        Bernd Paysan (Gesch\xe4\x66tlich) <bernd.paysan@mikron.de>
        Bernd Paysan (Forth Gesellschaft e.V.) <bp@forth-ev.de>
          1024 bit DSA key 67007C30, created: 1998-12-12

So it's really *one* key that has the number listed in the last line.

It's worst when you have two IDs (or any other even number), because then the actual key line is dropped completely, and you can't import anything.

The output of gpg is obviously organized that way:

First line of a key starts with a (<number>) tag, followed by a tab, and the primary ID for that key (this ID should be displayed in any case). Next lines may start with a tab, followed by a further ID (displayed when unfolding). The last line starts with a tab and two spaces, and contains the actual key number, type and creation date. That's the one you are supposed to import when clicking on the key.
Comment 1 Rolf Eike Beer 2007-08-08 14:30:48 UTC
*** Bug 118864 has been marked as a duplicate of this bug. ***
Comment 2 Rolf Eike Beer 2007-08-20 08:07:14 UTC
I'm working on this.
Comment 3 Rolf Eike Beer 2007-08-20 09:27:25 UTC
SVN commit 702193 by dakon:

Fix and improve searching on keyserver

BUGS:142069,118387


 M  +35 -23    keyservers.cpp  
 M  +2 -1      keyservers.h  


--- trunk/KDE/kdeutils/kgpg/keyservers.cpp #702192:702193
@@ -406,13 +406,13 @@
     connect(m_listpop, SIGNAL(destroyed()), this, SLOT(slotAbortSearch()));
 
     m_count = 0;
-    m_cycle = false;
+    m_keyid = QString();
     m_readmessage.clear();
 
     QString keyserv = page->kCBimportks->currentText();
     QStringList *args = new QStringList();
 
-    *args << "--command-fd=0" << "--search-keys" << page->kLEimportid->text().simplified().toLocal8Bit();
+    *args << "--command-fd=0" << "--with-colons"<< "--search-keys"  << page->kLEimportid->text().simplified().toLocal8Bit();
 
     m_searchproc = createGPGProc(args);
 
@@ -459,25 +459,21 @@
         {
             m_count++;
             required.clear();
-        }
+        } else if (required.startsWith("pub")) {
+            if (m_keyid.length() > 0)
+              CreateUidEntry();
+            m_keyid = required;
+            m_kitem = NULL;
+        } else if (required.startsWith("uid")) {
+            QString kid = required.section(':', 1, 1);
 
-        if ((m_cycle) && (!required.isEmpty()))
-        {
-            QString kid = required.simplified();
-            (void) new Q3ListViewItem(m_kitem, kid);
-            kid = kid.section("key", 1, 1);
-            kid = kid.simplified();
-            kid = kid.left(8);
-            required.clear();
-        }
-
-        m_cycle = false;
-
-        if (required.contains('(') && !required.isEmpty())
-        {
-            m_cycle = true;
-            m_kitem = new Q3ListViewItem(m_listpop->kLVsearch, required.remove(0, required.indexOf(')') + 1).simplified());
-            m_keynumbers++;
+            if (m_kitem != NULL) {
+              Q3ListViewItem *k = new Q3ListViewItem(m_kitem, kid);
+              k->setSelectable(false);
+            } else {
+              m_kitem = new Q3ListViewItem(m_listpop->kLVsearch, kid);
+              m_keynumbers++;
+            }
             m_count = 0;
             required.clear();
         }
@@ -486,6 +482,10 @@
 
 void KeyServer::slotSearchResult(K3Process *)
 {
+    // add last key id
+    if (m_kitem != NULL)
+      CreateUidEntry();
+
     QString nb;
     m_dialogserver->enableButtonOk(true);
     QApplication::restoreOverrideCursor();
@@ -548,13 +548,13 @@
             else
                 kid = searchList.at(i)->text(0).simplified();
 
-            kid = kid.section("key", 1, 1);
+            kid = kid.section(i18n("Key") + ' ', 1, 1);
             kid = kid.simplified().section(",", 0, 0);
             keysToSearch << kid.right(16);
         }
     }
 
-    kDebug(2100) << keysToSearch;
+//     kDebug(2100) << keysToSearch;
     m_listpop->kLEID->setText(keysToSearch.join(" "));
 }
 
@@ -566,7 +566,6 @@
         KMessageBox::sorry(this, i18n("You must choose a key."));
         return;
     }
-
     page->kLEimportid->setText(m_listpop->kLEID->text());
     m_dialogserver->close();
     slotImport();
@@ -645,4 +644,17 @@
 	page->kCBimportks->setCurrentIndex(page->kCBimportks->findText(server));
 }
 
+void KeyServer::CreateUidEntry(void)
+{
+	Q_ASSERT(m_keyid.section(':', 1, 1).length() > 0);
+	QString id = m_keyid.section(':', 1, 1);
+
+	Q3ListViewItem *k = new Q3ListViewItem(m_kitem, i18n("Key") + ' ' + id);
+	k->setSelectable(false);
+// TODO: add more information (Key type, key size, creation date)
+	if (m_keyid.section(':', 6, 6) == "r") {
+		m_kitem->setText(0, m_kitem->text(0) + ' ' + i18n("revoked"));
+	}
+}
+
 #include "keyservers.moc"
--- trunk/KDE/kdeutils/kgpg/keyservers.h #702192:702193
@@ -108,10 +108,11 @@
 
     int m_count;
     uint m_keynumbers;
-    bool m_cycle;
     bool m_autoclosewindow;
+    QString m_keyid;
     QString expattr;
 
+    void CreateUidEntry(void);
     K3ProcIO *createGPGProc(QStringList *keys);
 };