• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

rpmkeyring.c

Go to the documentation of this file.
00001 #include "system.h"
00002 const char *__progname;
00003 
00004 #define _AUTOHELP
00005 
00006 #include <rpm/rpmcli.h>
00007 #include <rpm/rpmlib.h>                 /* RPMSIGTAG, rpmReadPackageFile .. */
00008 #include <rpm/rpmlog.h>
00009 #include <rpm/rpmts.h>
00010 #include "cliutils.h"
00011 
00012 #include "debug.h"
00013 
00014 enum modes {
00015     MODE_CHECKSIG       = (1 <<  6),
00016     MODE_RESIGN         = (1 <<  7),
00017 #define MODES_K  (MODE_CHECKSIG | MODE_RESIGN)
00018 
00019     MODE_UNKNOWN        = 0
00020 };
00021 
00022 static int quiet;
00023 
00024 static struct poptOption keyPoptTable[] = {
00025  { "import", '\0', 0, NULL, 'I',
00026     N_("import an armored public key"), NULL },
00027 
00028  POPT_TABLEEND
00029 };
00030 
00031 /* the structure describing the options we take and the defaults */
00032 static struct poptOption optionsTable[] = {
00033 
00034  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, keyPoptTable, 0,
00035         N_("Keyring options:"),
00036         NULL },
00037  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmSignPoptTable, 0,
00038         N_("Signature options:"),
00039         NULL },
00040 
00041  { "quiet", '\0', POPT_ARGFLAG_DOC_HIDDEN, &quiet, 0, NULL, NULL},
00042 
00043  { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
00044         N_("Common options for all rpm modes and executables:"),
00045         NULL },
00046 
00047    POPT_AUTOALIAS
00048    POPT_AUTOHELP
00049    POPT_TABLEEND
00050 };
00051 
00052 int main(int argc, char *argv[])
00053 {
00054     rpmts ts = NULL;
00055     enum modes bigMode = MODE_UNKNOWN;
00056     QVA_t ka = &rpmQVKArgs;
00057 
00058     poptContext optCon;
00059     int ec = 0;
00060 
00061     optCon = rpmcliInit(argc, argv, optionsTable);
00062 
00063 #if 0
00064     switch (ka->qva_mode) {
00065     case RPMSIGN_IMPORT_PUBKEY:
00066         case RPMSIGN_NONE:
00067             ka->sign = 0;
00068             break;
00069         case RPMSIGN_IMPORT_PUBKEY:
00070         case RPMSIGN_CHK_SIGNATURE:
00071             bigMode = MODE_CHECKSIG;
00072             ka->sign = 0;
00073             break;
00074         case RPMSIGN_ADD_SIGNATURE:
00075         case RPMSIGN_NEW_SIGNATURE:
00076         case RPMSIGN_DEL_SIGNATURE:
00077             bigMode = MODE_RESIGN;
00078             ka->sign = (ka->qva_mode != RPMSIGN_DEL_SIGNATURE);
00079             break;
00080         }
00081     }
00082 #endif
00083 
00084     if (rpmcliRootDir && rpmcliRootDir[0] != '/') {
00085         argerror(_("arguments to --root (-r) must begin with a /"));
00086     }
00087 
00088     if (quiet)
00089         rpmSetVerbosity(RPMLOG_WARNING);
00090 
00091     if (rpmcliPipeOutput && initPipe())
00092         exit(EXIT_FAILURE);
00093         
00094     ts = rpmtsCreate();
00095     (void) rpmtsSetRootDir(ts, rpmcliRootDir);
00096 
00097     /* XXX kill this stupid interface */
00098     ec = rpmcliSign(ts, ka, (ARGV_const_t) poptGetArgs(optCon));
00099 
00100     ts = rpmtsFree(ts);
00101 
00102 exit:
00103     finishPipe();
00104     rpmcliFini(optCon);
00105 
00106     return RETVAL(ec);
00107 }

Generated on Mon Aug 23 2010 for rpm by  doxygen 1.7.1