From: Michael Tremer Date: Thu, 6 Oct 2022 13:00:11 +0000 (+0000) Subject: keys: Export UID X-Git-Tag: 0.9.28~275 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=227158683a35df60f5b1999fe44a8654d3a28627;p=pakfire.git keys: Export UID Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/key.c b/src/_pakfire/key.c index 4e9d098b2..686dc7ead 100644 --- a/src/_pakfire/key.c +++ b/src/_pakfire/key.c @@ -102,6 +102,18 @@ static PyObject* Key_get_fingerprint(KeyObject* self) { return PyUnicode_FromString(fingerprint); } +static PyObject* Key_get_uid(KeyObject* self) { + const char* uid = pakfire_key_get_uid(self->key); + + // Raise an error on no input + if (!uid) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } + + return PyUnicode_FromString(uid); +} + static PyObject* Key_export(KeyObject* self, PyObject* args) { PyObject* file = NULL; int secret = 0; @@ -181,7 +193,14 @@ static struct PyGetSetDef Key_getsetters[] = { (getter)Key_get_fingerprint, NULL, NULL, - NULL + NULL, + }, + { + "uid", + (getter)Key_get_uid, + NULL, + NULL, + NULL, }, { NULL }, };