S
snacktime
So I'm making some headway on a kerberos 5 extension for ruby. It's
limited at the moment to authorizing a user, changing a user password,
creating principals, and deleting principals, but it's working. Now
I'm trying to refactor it a bit and need some assistance. I've never
really coded in C before so bear with me..
In kerberos when doing an administration function I first need to
initialize the system with the credentials of an administrative user
like so, with handle being a void pointer initialized to NULL. The
following kerberos function will fill handle with a handle for the
connection which I can use in subsequent calls to other kadm5
functions.
kadm5_init_with_password(auser, apass, KADM5_ADMIN_SERVICE, NULL,
KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, &handle);
Now what I'd like is to return that handle to ruby and be able to pass
it back into my C extension when it's needed, such as when needing to
call the following kerberos function.
kadm5_create_principal(handle, &princ, mask, pass);
So how would I do this? If I understand void pointers correctly,
handle could be any type after the call to kadm5_init_with_password,
so it seems I would want to check it's type after it's set, then find
the right type/structure to convert it to or wrap it in before passing
it back to ruby? Not that I know how to do that
Chris
limited at the moment to authorizing a user, changing a user password,
creating principals, and deleting principals, but it's working. Now
I'm trying to refactor it a bit and need some assistance. I've never
really coded in C before so bear with me..
In kerberos when doing an administration function I first need to
initialize the system with the credentials of an administrative user
like so, with handle being a void pointer initialized to NULL. The
following kerberos function will fill handle with a handle for the
connection which I can use in subsequent calls to other kadm5
functions.
kadm5_init_with_password(auser, apass, KADM5_ADMIN_SERVICE, NULL,
KADM5_STRUCT_VERSION, KADM5_API_VERSION_2, &handle);
Now what I'd like is to return that handle to ruby and be able to pass
it back into my C extension when it's needed, such as when needing to
call the following kerberos function.
kadm5_create_principal(handle, &princ, mask, pass);
So how would I do this? If I understand void pointers correctly,
handle could be any type after the call to kadm5_init_with_password,
so it seems I would want to check it's type after it's set, then find
the right type/structure to convert it to or wrap it in before passing
it back to ruby? Not that I know how to do that
Chris