Kristian Fiskerstrand avatar Kristian Fiskerstrand committed 880a6a2

Original import

Comments (0)

Files changed (3)

-#!/usr/bin/env python
+#!/usr/bin/env python2
 # -*- coding: iso-8859-1 -*-
 
 # pks2wot, create .wot file from pks server.
 def debug(string):
     global __debugstr
     __debugstr += string + "\n"
-    print string
+    print(string)
     sys.stdout.flush()
 
 benchmarktimes, tmpbenchmarktimes = {}, {}
             # terminal. Call setsid() to become group/session leader
             # and get rid of the controlling tty.
             os.setsid()
-            cmd = "%s %s get %s b%s %s%s %s" % \
-                  (pksclient, db, keyid, pksflags, a, keyfile, v)
+			
+
+            cmd = "%s %s %s" % \
+                  (pksclient, keyid, keyfile)
             if verbose:
-                print cmd
+                print(cmd)
             ret = os.system(cmd)
             if ret>=256: ret //= 256
             os._exit(ret) # _exit() won't call cleanup handlers.
+			
+            ret = os.system(cmd)
         try:
             ret = os.wait()[1]
         except KeyboardInterrupt:
-            print "Keyboard interrupt. Waiting for pksclient to finish."
+            print("Keyboard interrupt. Waiting for pksclient to finish.")
             os.wait()
-            print "OK, pksclient has finished. Exiting."
+            print("OK, pksclient has finished. Exiting.")
             sys.exit(1)
         if ret>=256: ret //= 256
         benchmark("stop", "pksclient: Key ", "%sfound." % (ret and "not " or ""))
         name=keyid=None
         for x in reply.xreadlines():
             y = splitcolons(x)
+            if y[0] == "uid":
+                name = y[9].strip()
+                break
             if y[0] == "pub":
-                name = y[9].strip()
                 # Make sure we always use GPGs idea of keyid.
                 keyid = "0x" + y[4]
-                if y[1] != "":
-                    benchmark("stop",  "gpg: get name")
-                    return None, None
-                break
         benchmark("stop",  "gpg: get name")
         if not isvalidkeyid(keyid):
             print >>sys.stderr, "Something seems to be wrong in the output when running:"
                     sys.stdout.flush()
                     lastok = len(namedict)
                 if len(namedict) >= nexttoprint:
-                    print ""
+                    print("")
                     debug("Keys fetched/OK/seen/in queue: %5d/%5d/%5d/%5d. Now fetching: %s"\
                           % (totalcount, len(namedict), len(seenkeys),
                              len(keystocheck), key))
                     keystocheck.append(x)
             seenkeys.update(sigdict[key])
     finally:
-        # Remove the temporary GPG home directory.
+		#Remove the temporary GPG home directory.
         for f in tmpdir+"/trustdb.gpg", tmpdir+"/key":
             try: os.remove(f)
             except OSError: pass
         try: os.rmdir(tmpdir)
-        except OSError, (errno, strerror):
-            print >>sys.stderr, \
-                  'Unable to remove temporary GPG directory "%s": %s' % (tmpdir, strerror)
+        except(OSError) as e:
+            print('Unable to remove temporary GPG directory "%s"') % (tmpdir)
     return (sigdict, namedict)
 
 def reversesigs(sigdict):
 
 def clearlockfiles(pksdb):
     cmd = "rm -f %s/{__*,log*}" % pksdb
-    print "Clearing stale db lock files: %s" % cmd
+    print("Clearing stale db lock files: %s") % cmd
     os.system(cmd)
 
 def main(argv):
     import getopt
     benchmark("start", "TOTAL")
     def usage():
-        print version
-        print "Usage: %s [OPTIONS] local_server_name pks_database_dir output.wot" \
+        print(version)
+        print("Usage: %s [OPTIONS] local_server_name pks_database_dir output.wot") \
               % sys.argv[0]
-        print
-        print " local_server_name should be something to identify this server,"
-        print "    e.g. \"Foo server (http://keyserver.foo.org:11371/)\""
-        print
-        print " -n        disable signature verification. Faster, but less safe."
-        print " -c        clear stale lock files in db. Use with caution!"
-        print " -v        turn on (very) verbose output."
-        print " -w FILE   dump intermediate state to file."
-        print " -r FILE   read intermediate state from file, skipping the"
-        print "           slow pksclient/gpg parts. Useful for debugging."
-        print
-        print " --pksclient=/path/to/pksclient"
-        print " --gnupg=/path/to/gpg"
-        print "           Explicitly set path to pksclient or gpg. Default is to"
-        print "           let a shell find them in $PATH."
-        print " --nopkslogging"
-        print "           Pass the `t' flag to pksclient, making it run without"
-        print "           logging and transactions. This is faster, but less safe."
-        print "           Use only if noone else is accessing the database."
-        print " --eightdigits"
-        print "           Feed pksclient with eight instead of sixteen digit KeyIDs."
-        print "           Needed for older versions of pks. Newer versions ignore"
-        print "           higher bits anyway."
-        print " --startkeys=0x0123456789ABCDEF,0XFEDCBA9876543210"
-        print "           A comma-separated list of 16-digit KeyIDs in the largest"
-        print "           strongly connected set to start from. Defaults to four"
-        print "           keys known to be in the set."
-        print " --feedback=nnn"
-        print "           Delay between feedbacks when fetching signatures."
-        print "           Defaults to 100."
-        print " --cachesize=N"
-        print "           Cache N MiB of keys in memory during extraction. Most of"
-        print "           the time goes to key extraction from pks, and each key is"
-        print "           fetched several times, so a large cache will improve spead"
-        print "           greatly."
-        print "           Defaults to 50."
-        print " --sigcache=FILE"
-        print "           Use FILE as a signature and name cache file. Unchanged"
-        print "           (SHA1-sum of) keys are not processed by gnupg again."
-        print "           FILE does not need to exist. It is overwritten or created"
-        print "           with new data on exit."
+        print()
+        print(" local_server_name should be something to identify this server,")
+        print("    e.g. \"Foo server (http://keyserver.foo.org:11371/)\"")
+        print()
+        print(" -n        disable signature verification. Faster, but less safe.")
+        print(" -c        clear stale lock files in db. Use with caution!")
+        print(" -v        turn on (very) verbose output.")
+        print(" -w FILE   dump intermediate state to file.")
+        print(" -r FILE   read intermediate state from file, skipping the")
+        print("           slow pksclient/gpg parts. Useful for debugging.")
+        print()
+        print(" --pksclient=/path/to/pksclient")
+        print(" --gnupg=/path/to/gpg")
+        print("           Explicitly set path to pksclient or gpg. Default is to")
+        print("           let a shell find them in $PATH.")
+        print(" --nopkslogging")
+        print("           Pass the `t' flag to pksclient, making it run without")
+        print("           logging and transactions. This is faster, but less safe.")
+        print("           Use only if noone else is accessing the database.")
+        print(" --eightdigits")
+        print("           Feed pksclient with eight instead of sixteen digit KeyIDs.")
+        print("           Needed for older versions of pks. Newer versions ignore")
+        print("           higher bits anyway.")
+        print(" --startkeys=0x0123456789ABCDEF,0XFEDCBA9876543210")
+        print("           A comma-separated list of 16-digit KeyIDs in the largest")
+        print("           strongly connected set to start from. Defaults to four")
+        print("           keys known to be in the set.")
+        print(" --feedback=nnn")
+        print("           Delay between feedbacks when fetching signatures.")
+        print("           Defaults to 100.")
+        print(" --cachesize=N")
+        print("           Cache N MiB of keys in memory during extraction. Most of")
+        print("           the time goes to key extraction from pks, and each key is")
+        print("           fetched several times, so a large cache will improve spead")
+        print("           greatly.")
+        print("           Defaults to 50.")
+        print(" --sigcache=FILE")
+        print("           Use FILE as a signature and name cache file. Unchanged")
+        print("           (SHA1-sum of) keys are not processed by gnupg again.")
+        print("           FILE does not need to exist. It is overwritten or created")
+        print("           with new data on exit.")
         sys.exit(1)
 
     try:
             startkeys = a.split(',')
             for key in startkeys:
                 if not isvalidkeyid(key):
-                    print "Invalid KeyID:", key
-                    print
+                    print("Invalid KeyID:"), key
+                    print()
                     usage()
         elif o == '--feedback':
             printevery = int(a)
         cPickle.dump(newsigcache, open(sigcachefile, 'w'), cPickle.HIGHEST_PROTOCOL)
 
     endtime = time.time()
-    print ""
+    print("")
     debug("Done fetching signatures.")
     debug("Now is %s local time." % time.ctime(endtime))
     debug("Number of keys in backwards reachable set: %d" % len(sigdict))
     benchmark("stop", "TOTAL")
     debug(benchmark("report"))
 
-    print "Writing to file %s:" % savefile,
+    print("Writing to file %s:") % savefile,
     sys.stdout.flush()
     writetofile(savefile, siglist, namelist, keylist,
                 begintime, endtime, servername, __debugstr, verify)
-    print "Done."
+    print("Done.")
 
 if __name__ == "__main__":
     main(sys.argv)

pksclient-wrapper

+#!/bin/bash
+cd /etc/sks
+/home/kristianf/sks-keyserver/sksclient ${1} | gpg --dearmor >> ${2}
+#!/bin/bash
+/home/kristianf/pks2wot/pks2wot -v \
+   --pksclient=/home/kristianf/pks2wot/pksclient-wrapper \
+   --startkeys=0x16E0CF8D6B0B9508 \
+   keys2 KDB output.wot
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.