Programmer error! Bad Admin server handle

Torsten Kurbad kerberos at
Thu Feb 14 11:30:04 EST 2008

> They changed the API for all the kadm5_init* functions
> somewhere around 1.6 to add a parameter:
> kadm5_ret_t    kadm5_init_with_password(char *client_name,
>                                         char *pass,
>                                         char *service_name,
>                                         kadm5_config_params *params,
>                                         krb5_ui_4 struct_version,
>                                         krb5_ui_4 api_version,
>    /* Heh, look at me, I'm new ----> */ char **db_args,
>                                         void **server_handle);
> Which has bit me more than once.

It's there indeed, even for 1.5.3.

That leaped me a great step forward. Now my snippet looks like this:

--- snip ---
static PyObject *getPrincipals(PyObject *self, PyObject *args)
    char *client;
    char *pass;
    char *realm;
    void *handle;
    char *db_args;

    char **princs;
    int *count;

    PyObject *result;

    krb5_context ctx;
    krb5_error_code code = 0;

    code = krb5_init_context(&ctx);
    RETURN_ON_ERROR("krb5_init_context()", code);

    if (!PyArg_ParseTuple(args, "sss", &client, &pass, &realm))
      return NULL;

    code = kadm5_init_with_password(client, pass, KADM5_ADMIN_SERVICE, realm,
    RETURN_ON_ERROR("kadm5_init_with_password()", code);

    if (handle == NULL)
      return Py_BuildValue("");

    code = kadm5_get_principals(handle, "*", &princs, &count);
    RETURN_ON_ERROR("kadm5_get_principals()", code);

    if (princs == NULL)
      return Py_BuildValue("");

    result = Py_BuildValue("si", princs[0], count);
    return result;
--- snap ---

So far, so good. Now I get the 0th principal and a count of 245,
which is exactly the number of princs in our current DB. But I need to
transform all 0 -> *count principals into a Python structure. Whenever
I try to access *count, e.g. do sth. (probably stupid) like
int i = *count;
I get a segmentation fault.

Any suggestions?

Thanks and best regards,
Fon: +49-7071-700240 | Fax: +49-7071-700241 |

  The best cure for insomnia is to get a lot of sleep. -W.C. Fields

More information about the krbdev mailing list