| |
@@ -19,6 +19,8 @@
|
| |
|
| |
krb5_context kcontext;
|
| |
|
| |
+ static PyObject *has_creds(PyObject *self, PyObject *args);
|
| |
+
|
| |
static PyObject *
|
| |
get_username(PyObject *self, PyObject *args)
|
| |
{
|
| |
@@ -65,8 +67,29 @@
|
| |
Py_RETURN_NONE;
|
| |
}
|
| |
|
| |
+ static PyObject *
|
| |
+ has_creds(PyObject *self, PyObject *args)
|
| |
+ {
|
| |
+ krb5_error_code code;
|
| |
+ code = krb5_cccol_have_content(kcontext);
|
| |
+ if (code == 0)
|
| |
+ {
|
| |
+ Py_RETURN_TRUE;
|
| |
+ }
|
| |
+ else if (code == KRB5_CC_NOTFOUND)
|
| |
+ {
|
| |
+ Py_RETURN_FALSE;
|
| |
+ }
|
| |
+ else
|
| |
+ {
|
| |
+ PyErr_SetString(PyExc_RuntimeError, "Error checking content of credential cache.");
|
| |
+ return NULL;
|
| |
+ }
|
| |
+ }
|
| |
+
|
| |
static PyMethodDef CCColUtilsMethods[] = {
|
| |
{"get_user_for_realm", get_username, METH_VARARGS, "Get username for a realm"},
|
| |
+ {"has_creds", has_creds, METH_NOARGS, "Check if there is any credentials."},
|
| |
{NULL, NULL, 0, NULL}
|
| |
};
|
| |
|
| |
has_creds helps to determine if credential cache collection contains any
credentials, whatever
DIR:
orFILE:
is used.Signed-off-by: Chenxiong Qi cqi@redhat.com