Example #1
0
static int loadKeyringFromFiles(rpmts ts)
{
    ARGV_t files = NULL;
    /* XXX TODO: deal with chroot path issues */
    char *pkpath = rpmGetPath(ts->rootDir, "%{_keyringpath}/*.key", NULL);
    int nkeys = 0;

    rpmlog(RPMLOG_DEBUG, "loading keyring from pubkeys in %s\n", pkpath);
    if (rpmGlob(pkpath, NULL, &files)) {
	rpmlog(RPMLOG_DEBUG, "couldn't find any keys in %s\n", pkpath);
	goto exit;
    }

    for (char **f = files; *f; f++) {
	rpmPubkey key = rpmPubkeyRead(*f);
	if (!key) {
	    rpmlog(RPMLOG_ERR, _("%s: reading of public key failed.\n"), *f);
	    continue;
	}
	if (rpmKeyringAddKey(ts->keyring, key) == 0) {
	    nkeys++;
	    rpmlog(RPMLOG_DEBUG, "added key %s to keyring\n", *f);
	}
	rpmPubkeyFree(key);
    }
exit:
    free(pkpath);
    argvFree(files);
    return nkeys;
}
Example #2
0
static PyObject *rpmPubkey_new(PyTypeObject *subtype, 
			   PyObject *args, PyObject *kwds)
	/*@*/
{
    PyObject *arg;
    char *kwlist[] = { "keypath", NULL };
    rpmPubkeyObject *self; 
    rpmPubkey pubkey = NULL;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &arg))
	return NULL;

    if (PyString_Check(arg)) {
	pubkey = rpmPubkeyRead(PyString_AsString(arg));
    } else {
	PyErr_SetString(PyExc_TypeError, "string expected");
	return NULL;
    }
    if (pubkey == NULL) {
	PyErr_SetString(PyExc_TypeError, "failure creating pubkey");
	return NULL;
    }

    self = PyObject_New(rpmPubkeyObject, subtype);
    self->pubkey = pubkey;
    return (PyObject *)self;
}