/*
* call-seq:
* get_init_creds_password(username, password)
*
* Call krb5_get_init_creds_password() to get credentials based on a username
* and password. Returns true on success, raises Krb5Auth::Krb5::Exception on
* failure.
*/
static VALUE Krb5_get_init_creds_password(VALUE self, VALUE _user, VALUE _pass)
{
char *user, *pass;
struct ruby_krb5 *kerb;
krb5_error_code krbret;
Check_Type(_user,T_STRING);
Check_Type(_pass,T_STRING);
user = StringValueCStr(_user);
pass = StringValueCStr(_pass);
Data_Get_Struct(self, struct ruby_krb5, kerb);
if (!kerb) {
NOSTRUCT_EXCEPT();
return Qfalse;
}
krbret = krb5_parse_name(kerb->ctx, user, &kerb->princ);
if (krbret) {
goto failed_pass;
}
krbret = krb5_get_init_creds_password(kerb->ctx, &kerb->creds, kerb->princ,
pass, 0, NULL, 0,NULL, NULL);
if (krbret) {
goto failed_pass;
}
return Qtrue;
failed_pass:
Krb5_register_error(krbret);
// we will never reach here, since Krb5_register_error will rb_raise(). just
// leave it to shut the compiler up
return Qfalse;
}