From 84b29174e6a8da103e8afbffa48dc10958cc2e62 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 12 May 2008 10:44:07 +0300 Subject: [PATCH] Rip old, bit-rotten librpmio test programs --- rpmio/Makefile.am | 47 --------------- rpmio/tax.c | 68 --------------------- rpmio/tdir.c | 78 ------------------------ rpmio/tfts.c | 173 ------------------------------------------------------ rpmio/tget.c | 90 ---------------------------- rpmio/tglob.c | 93 ----------------------------- rpmio/thkp.c | 127 --------------------------------------- rpmio/tkey.c | 143 -------------------------------------------- rpmio/tput.c | 139 ------------------------------------------- rpmio/tring.c | 62 ------------------- rpmio/trpmio.c | 44 -------------- rpmio/tsw.c | 25 -------- rpmio/tufdio.c | 126 --------------------------------------- 13 files changed, 1215 deletions(-) delete mode 100644 rpmio/tax.c delete mode 100644 rpmio/tdir.c delete mode 100644 rpmio/tfts.c delete mode 100644 rpmio/tget.c delete mode 100644 rpmio/tglob.c delete mode 100644 rpmio/thkp.c delete mode 100644 rpmio/tkey.c delete mode 100644 rpmio/tput.c delete mode 100644 rpmio/tring.c delete mode 100644 rpmio/trpmio.c delete mode 100644 rpmio/tsw.c delete mode 100644 rpmio/tufdio.c diff --git a/rpmio/Makefile.am b/rpmio/Makefile.am index a5b2146..810da02 100644 --- a/rpmio/Makefile.am +++ b/rpmio/Makefile.am @@ -33,50 +33,3 @@ librpmio_la_LIBADD = \ check_PROGRAMS = -check_PROGRAMS += tax -tax_SOURCES = tax.c -tax_LDADD = librpmio.la - -check_PROGRAMS += tdir -tdir_SOURCES = tdir.c rpmio_internal.h -tdir_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += tfts -tfts_SOURCES = tfts.c rpmio_internal.h -tfts_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += tget -tget_SOURCES = tget.c rpmio_internal.h -tget_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += thkp -thkp_SOURCES = thkp.c rpmio_internal.h -thkp_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += tglob -tglob_SOURCES = tglob.c rpmio_internal.h -tglob_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += tkey -tkey_SOURCES = tkey.c rpmio_internal.h -tkey_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += tring -tring_SOURCES = tring.c rpmio_internal.h -tring_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += trpmio -trpmio_SOURCES = trpmio.c -trpmio_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += tsw -tsw_SOURCES = tsw.c -tsw_LDADD = librpmio.la - -check_PROGRAMS += tput -tput_SOURCES = tput.c -tput_LDADD = librpmio.la @WITH_POPT_LIB@ - -check_PROGRAMS += tufdio -tufdio_SOURCES = tufdio.c -tufdio_LDADD = librpmio.la diff --git a/rpmio/tax.c b/rpmio/tax.c deleted file mode 100644 index aeac175..0000000 --- a/rpmio/tax.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "system.h" - -#include - -#include -#include "rpmio/base64.h" - -#include "debug.h" - -const char * applechallenge = "09KF45soMYmvj6dpsUGiIg=="; - -#if 1 -const char * rsaaeskey = "\ -5QYIqmdZGTONY5SHjEJrqAhaa0W9wzDC5i6q221mdGZJ5ubO6Kg\ -yhC6U83wpY87TFdPRdfPQl2kVC7+Uefmx1bXdIUo07ZcJsqMbgtje4w2JQw0b\ -Uw2BlzNPmVGQOxfdpGc3LXZzNE0jI1D4conUEiW6rrzikXBhk7Y/i2naw13ayy\ -xaSwtkiJ0ltBQGYGErbV2tx43QSNj7O0JIG9GrF2GZZ6/UHo4VH+ZXgQ4NZvP/\ -QXPCsLutZsvusFDzIEq7TN1fveINOiwrzlN+bckEixvhXlvoQTWE2tjbmQYhMvO\ -FIly5gNbZiXi0l5AdolX4jDC2vndFHqWDks/3sPikNg==\ -"; -#else -const char * rsaaeskey = "5QYIqmdZGTONY5SHjEJrqAhaa0W9wzDC5i6q221mdGZJ5ubO6KgyhC6U83wpY87TFdPRdfPQl2kVC7+Uefmx1bXdIUo07ZcJsqMbgtje4w2JQw0bUw2BlzNPmVGQOxfdpGc3LXZzNE0jI1D4conUEiW6rrzikXBhk7Y/i2naw13ayyxaSwtkiJ0ltBQGYGErbV2tx43QSNj7O0JIG9GrF2GZZ6/UHo4VH+ZXgQ4NZvP/QXPCsLutZsvusFDzIEq7TN1fveINOiwrzlN+bckEixvhXlvoQTWE2tjbmQYhMvOFIly5gNbZiXi0l5AdolX4jDC2vndFHqWDks/3sPikNg=="; -#endif - -const char * aesiv = "zcZmAZtqh7uGcEwPXk0QeA=="; - -const char * appleresponse = "\ -u+msU8Cc7KBrVPjI/Ir8fOL8+C5D3Jsw1+acaW3MNTndrTQAeb/a\ -5m10UVBX6wb/DYQGY+b28ksSwBjN0nFOk4Y2cODEf83FAh7B\ -mkLpmpkpplp7zVXQ+Z9DcB6gC60ZsS3t98aoR7tSzVLKZNgi2X2sC+vGsz\ -utQxX03HK008VjcdngHv3g1p2knoETd07T6eVfZCmPqp6Ga7Dj8VIIj/GEP3\ -AjjDx3lJnQBXUDmxM484YXLXZjWFXCiY8GJt6whjf7/2c3rIoT3Z7PQpEvPmM\ -1MXU9cv4NL59Y/q0OAVQ38foOz7eGAhfvjOsCnHU25aik7/7ToIYt1tyVtap/kA==\ -"; - -static int doit(const char * msg, const char * sig) -{ - unsigned char * dec; - size_t declen; - int rc; - - if ((rc = b64decode(sig, (void **)&dec, &declen)) != 0) { - fprintf(stderr, "*** b64decode returns %d\n", rc); - return rc; - } - - fprintf(stderr, "*** %p[%zd] %s\n", dec, declen, msg); - if (declen == 256) { - fprintf(stderr, "%s\n", pgpHexStr(dec, declen/2)); - fprintf(stderr, "%s\n", pgpHexStr(dec+declen/2, declen/2)); - } else { - fprintf(stderr, "%s\n", pgpHexStr(dec, declen)); - } - - return 0; - -} - -int -main (int argc, char *argv[]) -{ - - doit("applechallenge", applechallenge); - doit("rsaaeskey", rsaaeskey); - doit("aesiv", aesiv); - doit("appleresponse", appleresponse); - return 0; -} diff --git a/rpmio/tdir.c b/rpmio/tdir.c deleted file mode 100644 index 742225b..0000000 --- a/rpmio/tdir.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "system.h" - -#include - -#include -#include - -#include "rpmio/rpmio_internal.h" -#include "debug.h" - -static int _debug = 0; - -#define HTTPPATH "https://wellfleet.jbj.org/rawhide/test/" -#define FTPPATH "ftp://wellfleet.jbj.org/pub/rawhide/packages/test/" -#define DIRPATH "/var/ftp/pub/rawhide/packages/test" -static char * httppath = HTTPPATH; -static char * ftppath = FTPPATH; -static char * dirpath = DIRPATH; - -static void printDir(const char * path) -{ - struct dirent * dp; - DIR * dir; - int xx; - int i; - -fprintf(stderr, "===== %s\n", path); - dir = opendir(path); - i = 0; - while ((dp = readdir(dir)) != NULL) { -fprintf(stderr, "%5d (%x,%x) %x %x %s\n", i++, -(unsigned) dp->d_ino, -(unsigned) dp->d_off, -(unsigned) dp->d_reclen, -(unsigned) dp->d_type, -dp->d_name); - } - xx = closedir(dir); -} - -static struct poptOption optionsTable[] = { - { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL }, - { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, - N_("debug rpmio I/O"), NULL}, - { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, - N_("debug URL cache handling"), NULL}, - { "verbose", 'v', 0, 0, 'v', NULL, NULL }, - POPT_AUTOHELP - POPT_TABLEEND -}; - -int -main(int argc, char *argv[]) -{ - poptContext optCon = poptGetContext(argv[0], argc, (const char**) argv, optionsTable, 0); - int rc; - - while ((rc = poptGetNextOpt(optCon)) > 0) { - switch (rc) { - case 'v': - rpmIncreaseVerbosity(); - break; - default: - break; - } - } - - if (_debug) { - rpmIncreaseVerbosity(); - rpmIncreaseVerbosity(); - } - - printDir(dirpath); - printDir(ftppath); - printDir(httppath); - - return 0; -} diff --git a/rpmio/tfts.c b/rpmio/tfts.c deleted file mode 100644 index 80c746c..0000000 --- a/rpmio/tfts.c +++ /dev/null @@ -1,173 +0,0 @@ -#include "system.h" - -#include - -#include -#include - -#include "rpmio/fts.h" -#include "rpmio/rpmio_internal.h" -#include "debug.h" - -static int _fts_debug = 0; - -#if 0 -#define HTTPSPATH "https://localhost/rawhide/test/" -#define HTTPPATH "http://localhost/rawhide/test/" -#else -#define HTTPSPATH "https://localhost/rawhide/" -#define HTTPPATH "http://localhost/rawhide/" -#endif -#define FTPPATH "ftp://localhost/pub/rawhide/packages/test" -#define DIRPATH "/var/ftp/pub/rawhide/packages/test" -static char * httpspath = HTTPSPATH; -static char * httppath = HTTPPATH; -static char * ftppath = FTPPATH; -static char * dirpath = DIRPATH; - -static int ndirs = 0; -static int nfiles = 0; - -static int indent = 2; - -static const char * ftsInfoStrings[] = { - "UNKNOWN", - "D", - "DC", - "DEFAULT", - "DNR", - "DOT", - "DP", - "ERR", - "F", - "INIT", - "NS", - "NSOK", - "SL", - "SLNONE", - "W", -}; - -static const char * ftsInfoStr(int fts_info) { - if (!(fts_info >= 1 && fts_info <= 14)) - fts_info = 0; - return ftsInfoStrings[ fts_info ]; -} - -static int ftsPrint(FTS * ftsp, FTSENT * fts) -{ - - if (_fts_debug) - fprintf(stderr, "FTS_%s\t%*s %s\n", ftsInfoStr(fts->fts_info), - indent * (fts->fts_level < 0 ? 0 : fts->fts_level), "", - fts->fts_name); - - switch (fts->fts_info) { - case FTS_D: /* preorder directory */ - ndirs++; - break; - case FTS_DP: /* postorder directory */ - break; - case FTS_F: /* regular file */ - nfiles++; - break; - case FTS_NS: /* stat(2) failed */ - case FTS_DNR: /* unreadable directory */ - case FTS_ERR: /* error; errno is set */ - break; - case FTS_DC: /* directory that causes cycles */ - case FTS_DEFAULT: /* none of the above */ - case FTS_DOT: /* dot or dot-dot */ - case FTS_INIT: /* initialized only */ - case FTS_NSOK: /* no stat(2) requested */ - case FTS_SL: /* symbolic link */ - case FTS_SLNONE: /* symbolic link without target */ - case FTS_W: /* whiteout object */ - default: - break; - } - - return 0; -} - -static int ftsOpts = 0; - -static void ftsWalk(const char * path) -{ - const char * ftsSet[2]; - FTS * ftsp; - FTSENT * fts; - int xx; - - - ftsSet[0] = path; - ftsSet[1] = NULL; - - ndirs = nfiles = 0; - ftsp = Fts_open((char *const *)ftsSet, ftsOpts, NULL); - while((fts = Fts_read(ftsp)) != NULL) - xx = ftsPrint(ftsp, fts); - xx = Fts_close(ftsp); -fprintf(stderr, "===== (%d/%d) dirs/files in %s\n", ndirs, nfiles, path); - -} - -static struct poptOption optionsTable[] = { - { "ftsdebug", 'd', POPT_ARG_VAL, &_fts_debug, -1, NULL, NULL }, - - { "comfollow", '\0', POPT_BIT_SET, &ftsOpts, FTS_COMFOLLOW, - N_("follow command line symlinks"), NULL }, - { "logical", '\0', POPT_BIT_SET, &ftsOpts, FTS_LOGICAL, - N_("logical walk"), NULL }, - { "nochdir", '\0', POPT_BIT_SET, &ftsOpts, FTS_NOCHDIR, - N_("don't change directories"), NULL }, - { "nostat", '\0', POPT_BIT_SET, &ftsOpts, FTS_NOSTAT, - N_("don't get stat info"), NULL }, - { "physical", '\0', POPT_BIT_SET, &ftsOpts, FTS_PHYSICAL, - N_("physical walk"), NULL }, - { "seedot", '\0', POPT_BIT_SET, &ftsOpts, FTS_SEEDOT, - N_("return dot and dot-dot"), NULL }, - { "xdev", '\0', POPT_BIT_SET, &ftsOpts, FTS_XDEV, - N_("don't cross devices"), NULL }, - { "whiteout", '\0', POPT_BIT_SET, &ftsOpts, FTS_WHITEOUT, - N_("return whiteout information"), NULL }, - - { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, - N_("debug rpmio I/O"), NULL}, - { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, - N_("debug URL cache handling"), NULL}, - { "verbose", 'v', 0, 0, 'v', NULL, NULL }, - POPT_AUTOHELP - POPT_TABLEEND -}; - -int -main(int argc, char *argv[]) -{ - poptContext optCon = poptGetContext(argv[0], argc, (const char **) argv, optionsTable, 0); - int rc; - - while ((rc = poptGetNextOpt(optCon)) > 0) { - switch (rc) { - case 'v': - rpmIncreaseVerbosity(); - break; - default: - break; - } - } - - if (ftsOpts == 0) - ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT); - -#if 0 - ftsWalk(dirpath); - ftsWalk(ftppath); -#endif - ftsWalk(httppath); -#if 0 - ftsWalk(httpspath); -#endif - - return 0; -} diff --git a/rpmio/tget.c b/rpmio/tget.c deleted file mode 100644 index 3462bab..0000000 --- a/rpmio/tget.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "system.h" - -#include -#include -#include -#include "rpmio/rpmio_internal.h" - -#include "debug.h" - -static int _debug = 0; - -#define HTTPSPATH "https://localhost/test.txt" -#define HTTPPATH "http://localhost/test.txt" -#define FTPPATH "ftp://localhost/test.txt" -#define DIRPATH "/var/ftp/test.txt" -static char * httpspath = HTTPSPATH; -static char * httppath = HTTPPATH; -static char * ftppath = FTPPATH; -static char * dirpath = DIRPATH; - -static void readFile(const char * path) -{ - FD_t fd; - int xx; - -fprintf(stderr, "===== %s\n", path); - fd = Fopen(path, "r.ufdio"); - if (fd != NULL) { - char buf[BUFSIZ]; - size_t len = Fread(buf, 1, sizeof(buf), fd); - xx = Fclose(fd); - - if (len > 0) - fwrite(buf, 1, len, stderr); - } -} - -static struct poptOption optionsTable[] = { - { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL }, - { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, - N_("debug rpmio I/O"), NULL}, - { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, - N_("debug URL cache handling"), NULL}, - { "verbose", 'v', 0, 0, 'v', NULL, NULL }, - POPT_AUTOHELP - POPT_TABLEEND -}; - -int -main(int argc, char *argv[]) -{ - poptContext optCon = poptGetContext(argv[0], argc, (const char **) argv, optionsTable, 0); - int rc; - - while ((rc = poptGetNextOpt(optCon)) > 0) { - switch (rc) { - case 'v': - rpmIncreaseVerbosity(); - break; - default: - break; - } - } - - if (_debug) { - rpmIncreaseVerbosity(); - rpmIncreaseVerbosity(); - } - -#if 1 - readFile(dirpath); -#endif -#if 1 - readFile(ftppath); - readFile(ftppath); - readFile(ftppath); -#endif -#if 1 - readFile(httppath); - readFile(httppath); - readFile(httppath); -#endif -#if 1 - readFile(httpspath); - readFile(httpspath); - readFile(httpspath); -#endif - - return 0; -} diff --git a/rpmio/tglob.c b/rpmio/tglob.c deleted file mode 100644 index 94350d5..0000000 --- a/rpmio/tglob.c +++ /dev/null @@ -1,93 +0,0 @@ -#include "system.h" - -#include -#include -#include -#include "rpmio/rpmio_internal.h" - -#include "debug.h" - -static int _debug = 0; - -#define HTTPSPATH "https://localhost/rawhide/test/*.rpm" -#if 0 -#define HTTPPATH "http://localhost/rawhide/test/*.rpm" -#else -#define HTTPPATH "http://localhost/rawhide/*.rpm" -#endif -#define FTPPATH "ftp://localhost/pub/rawhide/packages/test/*.rpm" -#define DIRPATH "/var/ftp/pub/rawhide/packages/test/*.rpm" -static char * dirpath = DIRPATH; -static char * ftppath = FTPPATH; -static char * httppath = HTTPPATH; -static char * httpspath = HTTPSPATH; - -#if 0 -static int Glob_error(const char *epath, int eerrno) -{ -fprintf(stderr, "*** glob_error(%p,%d) path %s\n", epath, eerrno, epath); - return 1; -} -#endif - -static void printGlob(const char * path) -{ - glob_t gl; - int rc; - int i; - -fprintf(stderr, "===== %s\n", path); - gl.gl_pathc = 0; - gl.gl_pathv = NULL; - gl.gl_offs = 0; - rc = glob(path, 0, NULL, &gl); -fprintf(stderr, "*** Glob rc %d\n", rc); - if (rc == 0) - for (i = 0; i < gl.gl_pathc; i++) - fprintf(stderr, "%5d %s\n", i, gl.gl_pathv[i]); - globfree(&gl); -} - -static struct poptOption optionsTable[] = { - { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL }, - { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, - N_("debug rpmio I/O"), NULL}, - { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, - N_("debug URL cache handling"), NULL}, - { "verbose", 'v', 0, 0, 'v', NULL, NULL }, - POPT_AUTOHELP - POPT_TABLEEND -}; - -int -main(int argc, char *argv[]) -{ - poptContext optCon = poptGetContext(argv[0], argc, (const char **) argv, optionsTable, 0); - int rc; - - while ((rc = poptGetNextOpt(optCon)) > 0) { - switch (rc) { - case 'v': - rpmIncreaseVerbosity(); - break; - default: - break; - } - } - - if (_debug) { - rpmIncreaseVerbosity(); - rpmIncreaseVerbosity(); - } - -#if 0 - printGlob(dirpath); - printGlob(ftppath); -#endif - printGlob(httppath); -#if 0 - printGlob(httpspath); -#endif - - return 0; -} diff --git a/rpmio/thkp.c b/rpmio/thkp.c deleted file mode 100644 index 62a365d..0000000 --- a/rpmio/thkp.c +++ /dev/null @@ -1,127 +0,0 @@ -#include "system.h" - -#include -#include -#include -#include "rpmio/rpmio_internal.h" - -#include "debug.h" - -static int _debug = 0; -static int _printing = 0; - -#if 0 -#define HKPPATH "hkp://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF5C75256" -#else -#if 0 -#define HKPPATH "hkp://pgp.mit.edu" -#else -#define HKPPATH "hkp://sks.keyserver.penguin.de" -#endif -#endif -static char * hkppath = HKPPATH; - -static unsigned int keyids[] = { -#if 0 - 0xc2b079fc, 0xf5c75256, - 0x94cd5742, 0xe418e3aa, - 0xb44269d0, 0x4f2a6fd2, - 0xda84cbd4, 0x30c9ecf8, - 0x29d5ba24, 0x8df56d05, - 0xa520e8f1, 0xcba29bf9, - 0x219180cd, 0xdb42a60e, - 0xfd372689, 0x897da07a, - 0xe1385d4e, 0x1cddbca9, - 0xb873641b, 0x2039b291, -#endif - 0x58e727c4, 0xc621be0f, - 0 -}; - -static int readKeys(const char * uri) -{ - unsigned int * kip; - const uint8_t * pkt; - size_t pktlen; - uint8_t keyid[8]; - char *fn = NULL; - pgpDig dig; - int rc; - int ec = 0; - - rpmInitCrypto(); - dig = pgpNewDig(); - for (kip = keyids; *kip; kip += 2) { - pgpArmor pa; - - rasprintf(&fn, "%s/pks/lookup?op=get&search=0x%08x%08x", uri, kip[0], kip[1]); -fprintf(stderr, "======================= %s\n", fn); - pkt = NULL; - pktlen = 0; - pa = pgpReadPkts(fn, &pkt, &pktlen); - free(fn); - if (pa == PGPARMOR_ERROR || pa == PGPARMOR_NONE - || pkt == NULL || pktlen <= 0) - { - ec++; - continue; - } - - rc = pgpPrtPkts(pkt, pktlen, dig, _printing); - if (rc) - ec++; -#if 0 -fprintf(stderr, "%s\n", pgpHexStr(pkt, pktlen)); -#endif - if (!pgpPubkeyFingerprint(pkt, pktlen, keyid)) -fprintf(stderr, "KEYID: %08x %08x\n", pgpGrab(keyid, 4), pgpGrab(keyid+4, 4)); - - - pgpCleanDig(dig); - - free((void *)pkt); - pkt = NULL; - } - dig = pgpFreeDig(dig); - - return ec; -} - -static struct poptOption optionsTable[] = { - { "print", 'p', POPT_ARG_VAL, &_printing, 1, NULL, NULL }, - { "noprint", 'n', POPT_ARG_VAL, &_printing, 0, NULL, NULL }, - { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL }, - { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, - N_("debug rpmio I/O"), NULL}, - { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, - N_("debug URL cache handling"), NULL}, - { "verbose", 'v', 0, 0, 'v', NULL, NULL }, - POPT_AUTOHELP - POPT_TABLEEND -}; - -int -main(int argc, char *argv[]) -{ - poptContext optCon = poptGetContext(argv[0], argc, (const char **) argv, optionsTable, 0); - int rc; - - while ((rc = poptGetNextOpt(optCon)) > 0) { - switch (rc) { - case 'v': - rpmIncreaseVerbosity(); - break; - default: - break; - } - } - - if (_debug) { - rpmIncreaseVerbosity(); - rpmIncreaseVerbosity(); - } - - readKeys(hkppath); - - return 0; -} diff --git a/rpmio/tkey.c b/rpmio/tkey.c deleted file mode 100644 index b6f01c0..0000000 --- a/rpmio/tkey.c +++ /dev/null @@ -1,143 +0,0 @@ -/** \ingroup rpmio signature - * \file rpmio/tkey.c - * Routines to handle RFC-2440 detached signatures. - */ - -static int _debug = 0; - -#include "system.h" -#include "rpmio/digest.h" -#include "debug.h" - -static int doit(const char *sig, pgpDig dig, int printing) -{ - const char *s, *t; - unsigned char * dec; - size_t declen; - char * enc; - int rc; - int i; - -if (_debug) -fprintf(stderr, "*** sig is\n%s\n", sig); - - if ((rc = b64decode(sig, (void **)&dec, &declen)) != 0) { - fprintf(stderr, "*** b64decode returns %d\n", rc); - return rc; - } - rc = pgpPrtPkts(dec, declen, dig, printing); - if (rc < 0) { - fprintf(stderr, "*** pgpPrtPkts returns %d\n", rc); - return rc; - } - - if ((enc = b64encode(dec, declen, -1)) == NULL) { - fprintf(stderr, "*** b64encode failed\n"); - return rc; - } - -if (_debug) -fprintf(stderr, "*** enc is\n%s\n", enc); - -rc = 0; -for (i = 0, s = sig, t = enc; *s & *t; i++, s++, t++) { - if (*s == '\n') s++; - if (*t == '\n') t++; - if (*s == *t) continue; -fprintf(stderr, "??? %5d %02x != %02x '%c' != '%c'\n", i, (*s & 0xff), (*t & 0xff), *s, *t); - rc = 5; -} - - return rc; -} - -/* Secret key */ -static const char * jbjSecretDSA = -"lQFvBDu6XHwRAwCTIHRgKeIlOFUIEZeJVYSrXn0eUrM5S8OF471tTc+IV7AwiXBR" -"zCFCan4lO1ipmoAipyN2A6ZX0HWOcWdYlWz2adxA7l8JNiZTzkemA562xwex2wLy" -"AQWVTtRN6jv0LccAoN4UWZkIvkT6tV918sEvDEggGARxAv9190RhrDq/GMqd+AHm" -"qWrRkrBRHDUBBL2fYEuU3gFekYrW5CDIN6s3Mcq/yUsvwHl7bwmoqbf2qabbyfnv" -"Y66ETOPKLcw67ggcptHXHcwlvpfJmHKpjK+ByzgauPXXbRAC+gKDjzXL0kAQxjmT" -"2D+16O4vI8Emlx2JVcGLlq/aWhspvQWIzN6PytA3iKZ6uzesrM7yXmqzgodZUsJh" -"1wwl/0K5OIJn/oD41UayU8RXNER8SzDYvDYsJymFRwE1s58lL/8DAwJUAllw1pdZ" -"WmBIoAvRiv7kE6hWfeCvZzdBVgrHYrp8ceUa3OdulGfYw/0sIzpEU0FfZmFjdG9y" -"OgAA30gJ4JMFKVfthnDCHHL+O8lNxykKBmrgVPLClue0KUplZmYgSm9obnNvbiAo" -"QVJTIE4zTlBRKSA8amJqQHJlZGhhdC5jb20+iFcEExECABcFAju6XHwFCwcKAwQD" -"FQMCAxYCAQIXgAAKCRCB0qVW2I6DmQU6AJ490bVWZuM4yCOh8MWj6qApCr1/gwCf" -"f3+QgXFXAeTyPtMmReyWxThABtE=" -; - -/* Public key */ -static const char * jbjPublicDSA = -"mQFCBDu6XHwRAwCTIHRgKeIlOFUIEZeJVYSrXn0eUrM5S8OF471tTc+IV7AwiXBR" -"zCFCan4lO1ipmoAipyN2A6ZX0HWOcWdYlWz2adxA7l8JNiZTzkemA562xwex2wLy" -"AQWVTtRN6jv0LccAoN4UWZkIvkT6tV918sEvDEggGARxAv9190RhrDq/GMqd+AHm" -"qWrRkrBRHDUBBL2fYEuU3gFekYrW5CDIN6s3Mcq/yUsvwHl7bwmoqbf2qabbyfnv" -"Y66ETOPKLcw67ggcptHXHcwlvpfJmHKpjK+ByzgauPXXbRAC+gKDjzXL0kAQxjmT" -"2D+16O4vI8Emlx2JVcGLlq/aWhspvQWIzN6PytA3iKZ6uzesrM7yXmqzgodZUsJh" -"1wwl/0K5OIJn/oD41UayU8RXNER8SzDYvDYsJymFRwE1s58lL7QpSmVmZiBKb2hu" -"c29uIChBUlMgTjNOUFEpIDxqYmpAcmVkaGF0LmNvbT6IVwQTEQIAFwUCO7pcfAUL" -"BwoDBAMVAwIDFgIBAheAAAoJEIHSpVbYjoOZBToAn3TXaAI+bhg51EeyaiFip/6W" -"OVwBAJ44rTtNsgZBQxXISjB64CWxl4VaWQ==" -; - -/* Signature */ -static const char * abcSignatureDSA = -"iD8DBQA7vII+gdKlVtiOg5kRAvg4AJ0fV3gDBADobAnK2HOkV88bfmFMEgCeNysO" -"nP3dWWJnp0Pnbor7pIob4Dk=" -; - -int -main (int argc, char *argv[]) -{ - pgpDig dig; - int printing = 1; - int rc; - - rpmInitCrypto(); - dig = pgpNewDig(); - -fprintf(stderr, "=============================== GPG Secret Key\n"); - if ((rc = doit(jbjSecretDSA, dig, printing)) != 0) - fprintf(stderr, "==> FAILED: rc %d\n", rc); - -fprintf(stderr, "=============================== GPG Public Key\n"); - if ((rc = doit(jbjPublicDSA, dig, printing)) != 0) - fprintf(stderr, "==> FAILED: rc %d\n", rc); - -fprintf(stderr, "=============================== GPG Signature of \"abc\"\n"); - if ((rc = doit(abcSignatureDSA, dig, printing)) != 0) - fprintf(stderr, "==> FAILED: rc %d\n", rc); - - { DIGEST_CTX ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE); - struct pgpDigParams_s * dsig = &dig->signature; - void *digest = NULL; - size_t digestlen = 0; - const char * txt = "abc"; - SECItem digitem; - - rpmDigestUpdate(ctx, txt, strlen(txt)); - rpmDigestUpdate(ctx, dsig->hash, dsig->hashlen); - rpmDigestFinal(ctx, &digest, &digestlen, 0); - -fprintf(stderr, "\n hm = [ 160]: %s\n\n", pgpHexStr(digest, digestlen)); - digitem.type = siBuffer; - digitem.data = digest; - digitem.len = digestlen; - - rc = VFY_VerifyDigest(&digitem, dig->dsa, dig->dsasig, SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST, NULL); - - if (digest) { - free(digest); - digest = NULL; - } - } - - -fprintf(stderr, "=============================== DSA verify: rc %d\n", rc); - - dig = pgpFreeDig(dig); - - return rc; -} - diff --git a/rpmio/tput.c b/rpmio/tput.c deleted file mode 100644 index 61ca42c..0000000 --- a/rpmio/tput.c +++ /dev/null @@ -1,139 +0,0 @@ -#include "system.h" - -#include -#include -#include -#include "rpmio/rpmio_internal.h" - -#include "debug.h" - -static int _debug = 0; - -#define HTTPSPATH "https://localhost/rawhide/toad/tput.txt" -#define HTTPPATH "http://localhost/rawhide/toad/tput.txt" -#define FTPPATH "ftp://localhost/home/test/tput.txt" -#define DIRPATH "file://localhost/var/ftp/tput.txt" -static char * httpspath = HTTPSPATH; -static char * httppath = HTTPPATH; -static char * ftppath = FTPPATH; -static char * dirpath = DIRPATH; - -static size_t readFile(const char * path) -{ - char buf[BUFSIZ]; - size_t len = 0; - FD_t fd; - int xx; - - buf[0] = '\0'; -fprintf(stderr, "===== Fread %s\n", path); - fd = Fopen(path, "r.ufdio"); - if (fd != NULL) { - - len = Fread(buf, 1, sizeof(buf), fd); - xx = Fclose(fd); - } - - if (len > 0) - fwrite(buf, 1, strlen(buf), stderr); - - return len; -} - -static size_t writeFile(const char * path) -{ - char buf[BUFSIZ]; - size_t len = 0; - FD_t fd; - int xx; - - strcpy(buf, "Hello World!\n"); -fprintf(stderr, "===== Fwrite %s\n", path); - fd = Fopen(path, "w.ufdio"); - if (fd != NULL) { - len = Fwrite(buf, 1, strlen(buf), fd); - xx = Fclose(fd); -if (xx) -fprintf(stderr, "===> Fclose rc %d\n", xx); - } - - if (len > 0) - fwrite(buf, 1, strlen(buf), stderr); - - return len; -} - -static int unlinkFile(const char * path) -{ -fprintf(stderr, "===== Unlink %s\n", path); - return unlink(path); -} - -static void doFile(const char * path) -{ - int xx; - -fprintf(stderr, "===== %s\n", path); -#if 0 - xx = unlink("/home/toad/tput.txt"); - xx = unlink("/var/ftp/tput.txt"); - xx = unlink("/var/www/html/tput.txt"); -#endif - -#if 0 - xx = unlinkFile(path); -#endif - xx = writeFile(path); -#if 0 - xx = readFile(path); - xx = unlink(path); - - xx = unlink("/home/toad/tput.txt"); - xx = unlink("/var/ftp/tput.txt"); - xx = unlink("/var/www/html/tput.txt"); -#endif -} - -static struct poptOption optionsTable[] = { - { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL }, - { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, - N_("debug rpmio I/O"), NULL}, - { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, - N_("debug URL cache handling"), NULL}, - { "verbose", 'v', 0, 0, 'v', NULL, NULL }, - POPT_AUTOHELP - POPT_TABLEEND -}; - -int -main(int argc, char *argv[]) -{ - poptContext optCon = poptGetContext(argv[0], argc, (const char **) argv, optionsTable, 0); - int rc; - - while ((rc = poptGetNextOpt(optCon)) > 0) { - switch (rc) { - case 'v': - rpmIncreaseVerbosity(); - break; - default: - break; - } - } - - if (_debug) { - rpmIncreaseVerbosity(); - rpmIncreaseVerbosity(); - } - -#if 0 - doFile(dirpath); - doFile(ftppath); -#endif - doFile(httppath); -#if 0 - doFile(httpspath); -#endif - - return 0; -} diff --git a/rpmio/tring.c b/rpmio/tring.c deleted file mode 100644 index 46f19e1..0000000 --- a/rpmio/tring.c +++ /dev/null @@ -1,62 +0,0 @@ -#include "system.h" -#include -#include "rpmio/digest.h" -#include "rpmio/rpmio_internal.h" /* XX _*debug */ -#include "debug.h" - -static int printing = 1; -static int _debug = 0; -int noNeon; - -static struct poptOption optionsTable[] = { - { "print", 'p', POPT_ARG_VAL, &printing, 1, NULL, NULL }, - { "noprint", 'n', POPT_ARG_VAL, &printing, 0, NULL, NULL }, - { "debug", 'd', POPT_ARG_VAL, &_debug, -1, NULL, NULL }, - { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1, - N_("debug rpmio I/O"), NULL}, - { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1, - N_("debug URL cache handling"), NULL}, - { "verbose", 'v', 0, 0, 'v', NULL, NULL }, - POPT_AUTOHELP - POPT_TABLEEND -}; - -int -main (int argc, const char *argv[]) -{ - poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0); - pgpDig dig; - const uint8_t * pkt = NULL; - size_t pktlen; - const char ** args; - const char * fn; - int rc, ec = 0; - - rpmInitCrypto(); - - while ((rc = poptGetNextOpt(optCon)) > 0); - - if ((args = poptGetArgs(optCon)) != NULL) - while ((fn = *args++) != NULL) { - pgpArmor pa; - - pa = pgpReadPkts(fn, &pkt, &pktlen); - if (pa == PGPARMOR_ERROR - || pa == PGPARMOR_NONE - || pkt == NULL || pktlen <= 0) - { - ec++; - continue; - } - -fprintf(stderr, "===================== %s\n", fn); - dig = xcalloc(1, sizeof(*dig)); - (void) pgpPrtPkts(pkt, pktlen, dig, printing); - free((void *)pkt); - pkt = NULL; - free((void *)dig); - dig = NULL; - } - - return ec; -} diff --git a/rpmio/trpmio.c b/rpmio/trpmio.c deleted file mode 100644 index 3438bee..0000000 --- a/rpmio/trpmio.c +++ /dev/null @@ -1,44 +0,0 @@ -/** \ingroup rpmio - * \file rpmio/trpmio.c - */ - -#include -#include -#include "debug.h" - -int main (void) -{ - FD_t f1, f2, f3, f4, f5; - - printf ("open http://www.gnome.org/\n"); - f1 = Fopen ("http://www.gnome.org/", "r.fdio"); - - printf ("open http://people.redhat.com/\n"); - f2 = Fopen ("http://people.redhat.com/", "r.ufdio"); - - printf ("close http://www.gnome.org/\n"); - Fclose (f1); - - printf ("open http://www.redhat.com/\n"); - f3 = Fopen ("http://www.redhat.com/", "r.ufdio"); - - printf ("close http://people.redhat.com/\n"); - Fclose (f2); - - printf ("open http://www.slashdot.org/\n"); - f4 = Fopen ("http://www.slashdot.org/", "r.ufdio"); - - printf ("close http://people.redhat.com/\n"); - Fclose (f3); - - printf ("open http://people.redhat.com/\n"); - f5 = Fopen ("http://people.redhat.com/", "r.ufdio"); - - printf ("close http://www.slashdot.org/\n"); - Fclose (f4); - - printf ("close http://people.redhat.com/\n"); - Fclose (f5); - - return 0; -} diff --git a/rpmio/tsw.c b/rpmio/tsw.c deleted file mode 100644 index e68f36b..0000000 --- a/rpmio/tsw.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "system.h" -#include -#include "debug.h" - -int -main(int argc, char *argv[]) -{ - struct rpmsw_s begin, end; - rpmtime_t diff; - int scale = 1000 * 1000; - int nsecs = 5; - - diff = rpmswInit(); - -fprintf(stderr, "*** Sleeping for %d secs ... ", nsecs); - (void) rpmswNow(&begin); - sleep(nsecs); - (void) rpmswNow(&end); - - diff = rpmswDiff(&end, &begin); -fprintf(stderr, "measured %u.%06u secs\n", (unsigned)diff/scale, (unsigned)diff%scale); - - return 0; - -} diff --git a/rpmio/tufdio.c b/rpmio/tufdio.c deleted file mode 100644 index 034d19a..0000000 --- a/rpmio/tufdio.c +++ /dev/null @@ -1,126 +0,0 @@ -/** \ingroup rpmio - * \file rpmio/tufdio.c - */ - -#include "system.h" - -#include -#include - -#include -#include - -#include "debug.h" - -extern int _url_debug; -extern int _rpmio_debug; - -const char *tmpdir = "/tmp"; -const char *dio_xxxxxx = "/dio.XXXXXX"; -#define DIO_XXXXXX strdup(dio_xxxxxx) -const char *fio_xxxxxx = "/fio.XXXXXX"; -#define FIO_XXXXXX strdup(fio_xxxxxx) - -static const char * xstrconcat(const char * arg, ...) -{ - const char *s; - char *t, *te; - size_t nt = 0; - va_list ap; - - if (arg == NULL) return xstrdup(""); - - va_start(ap, arg); - for (s = arg; s != NULL; s = va_arg(ap, const char *)) - nt += strlen(s); - va_end(ap); - - te = t = xmalloc(nt+1); - - va_start(ap, arg); - for (s = arg; s != NULL; s = va_arg(ap, const char *)) - te = stpcpy(te, s); - va_end(ap); - *te = '\0'; - return t; -} - -static int doFIO(const char *ofn, const char *rfmode, const char *wfmode) -{ - FD_t fd; - int rc = 0; - char buf[8192]; - - if ((fd = Fopen(ofn, wfmode)) == NULL) - warn("Fopen: write %s (%s) %s\n", wfmode, rfmode, ofn); - else if ((rc = Fwrite(ofn, sizeof(ofn[0]), strlen(ofn), fd)) != strlen(ofn)) - warn("Fwrite: write %s (%s) %s\n", wfmode, rfmode, ofn); - else if ((rc = Fclose(fd)) != 0) - warn("Fclose: write %s (%s) %s\n", wfmode, rfmode, ofn); - else if ((fd = Fopen(ofn, rfmode)) == NULL) - warn("Fopen: read %s (%s) %s\n", rfmode, wfmode, ofn); - else if ((rc = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) != strlen(ofn)) - warn("Fread: read %s (%s) %s\n", rfmode, wfmode, ofn); - else if ((rc = Fclose(fd)) != 0) - warn("Fclose: read %s (%s) %s\n", rfmode, wfmode, ofn); - else if (strcmp(ofn, buf)) - warn("Compare: write(%s) \"%s\" != read(%s) \"%s\" for %s\n", wfmode, ofn, rfmode, buf, ofn); - else - rc = 0; - if (unlink(ofn) != 0) - warn("Unlink: write(%s) read(%s) for %s\n", wfmode, rfmode, ofn); - return rc; -} - -static int doFile(const char * url, const char * odn, const char * ndn) -{ - const char * ofn = xstrconcat(odn, mktemp(FIO_XXXXXX), NULL); - const char * nfn = xstrconcat(ndn, mktemp(FIO_XXXXXX), NULL); - FD_t fd; - int rc; - - if ((fd = Fopen(ofn, "r.ufdio")) != NULL) - err(1, "Fopen: r !exists %s fail\n", ofn); - - rc = doFIO(ofn, "r.ufdio", "w.ufdio"); - rc = doFIO(nfn, "r.ufdio", "w.ufdio"); - - return rc; -} - -static int doDir(const char *url) -{ - const char * odn = xstrconcat(url, tmpdir, mktemp(DIO_XXXXXX), NULL); - const char * ndn = xstrconcat(url, tmpdir, mktemp(DIO_XXXXXX), NULL); - - doFile(url, odn, ndn); - - return 0; -} - -static int doUrl(const char *url) -{ - int rc; - - rc = doDir(url); - - return rc; - -} - -int main (int argc, char * argv[]) -{ - int rc; - - _url_debug = -1; - _rpmio_debug = -1; - - if (argc != 2) { - fprintf(stderr, "%s: url ...\n", argv[0]); - exit(1); - } - - rc = doUrl(argv[1]); - - return 0; -} -- 2.7.4