summaryrefslogtreecommitdiff
path: root/lib/poptK.c
blob: ed532f8dd6c91eecc913e3ef07cf5301e2cb0327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/** \ingroup rpmcli
 * \file lib/poptK.c
 *  Popt tables for signature modes.
 */

#include "system.h"

#include <rpmcli.h>

#include "debug.h"

struct rpmSignArguments_s rpmKArgs =
	{ RESIGN_NONE, CHECKSIG_ALL, 0, NULL };

#define	POPT_ADDSIGN		1005
#define	POPT_RESIGN		1006

/**
 */
static void signArgCallback( /*@unused@*/ poptContext con,
		/*@unused@*/ enum poptCallbackReason reason,
		const struct poptOption * opt, /*@unused@*/ const char * arg,
		/*@unused@*/ const void * data)
	/*@modifies rpmKArgs @*/
{
    struct rpmSignArguments_s * rka = &rpmKArgs;

    switch (opt->val) {
    case 'K':
	rka->addSign = RESIGN_CHK_SIGNATURE;
	rka->sign = 0;
	break;

    case POPT_RESIGN:
	rka->addSign = RESIGN_NEW_SIGNATURE;
	rka->sign = 1;
	break;

    case POPT_ADDSIGN:
	rka->addSign = RESIGN_ADD_SIGNATURE;
	rka->sign = 1;
	break;
    }
}

/**
 */
struct poptOption rpmSignPoptTable[] = {
 { NULL, '\0', POPT_ARG_CALLBACK | POPT_CBFLAG_INC_DATA,
	signArgCallback, 0, NULL, NULL },
 { "addsign", '\0', 0, 0, POPT_ADDSIGN,
	N_("add a signature to a package"), NULL },
 { "resign", '\0', 0, 0, POPT_RESIGN,
	N_("sign a package (discard current signature)"), NULL },
 { "sign", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmKArgs.sign, 0,
	N_("generate signature"), NULL },
 { "checksig", 'K', 0, 0, 'K',
	N_("verify package signature"), NULL },
 { "nogpg", '\0', POPT_BIT_CLR,
	&rpmKArgs.checksigFlags, CHECKSIG_GPG,
	N_("skip any GPG signatures"), NULL },
 { "nopgp", '\0', POPT_BIT_CLR|POPT_ARGFLAG_DOC_HIDDEN,
	&rpmKArgs.checksigFlags, CHECKSIG_PGP,
	N_("skip any PGP signatures"), NULL },
 { "nomd5", '\0', POPT_BIT_CLR,
	&rpmKArgs.checksigFlags, CHECKSIG_MD5,
	N_("do not verify file md5 checksums"), NULL },

   POPT_TABLEEND
};