Programmer error! Bad Admin server handle
Moritz Bechler
mbechler at epplehaus.de
Thu Feb 14 05:41:49 EST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
>
> static PyObject *getPrincipals(PyObject *self, PyObject *args)
> {
> char *client;
> char *pass;
> char *realm;
> void **handle;
> char ***princs;
> int *count;
> 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, KADM5_STRUCT_VERSION_1, KADM5_API_VERSION_1,
> handle);
> RETURN_ON_ERROR("kadm5_init_with_password()", code);
>
> code = kadm5_get_principals(&handle, "*", princs, count);
> RETURN_ON_ERROR("kadm5_get_principals()", code);
>
> /* return Py_BuildValue("s", &princs); */
> return Py_BuildValue("");
> }
>
I'd say that your pointer usage is totally wrong here and this should
look like
void *handle;
// ...
code = kadm5_init_with_password(client, pass, KADM5_ADMIN_SERVICE,
realm, KADM5_STRUCT_VERSION_1, KADM5_API_VERSION_1,
&handle);
// ...
kadm5_get_principals(handle, "*", princs, count);
That also applies to your princs pointer - you really should have
another look at some C book to get it right. Also turning on compiler
warnings (and trying to understand them) is really useful for these cases.
with best regards
Moritz Bechler
PS: You might want have a look at my code at
http://phpsatk.eenterphace.org/svn/phpsatk/extensions/php_krb5/trunk/
which does basically the same thing for php.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHtBrtdLVsKnwBr9YRAuFaAKCKQ7j1xPL8PnFkMS7Qzmj/9AOMpACeNafI
AdKf7HVAdVQMOHIBVUjsHo4=
=zwSc
-----END PGP SIGNATURE-----
More information about the krbdev
mailing list