(doauth): use krb5_get_local_realms and krb5_verify_user_lrealm
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7052 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -105,7 +105,7 @@ doauth(SIAENTITY *entity, int pkgind, char *name)
|
|||||||
char pwbuf[1024];
|
char pwbuf[1024];
|
||||||
struct state *s = (struct state*)entity->mech[pkgind];
|
struct state *s = (struct state*)entity->mech[pkgind];
|
||||||
#ifdef SIA_KRB5
|
#ifdef SIA_KRB5
|
||||||
char *realm;
|
krb5_realm *realms, *r;
|
||||||
krb5_principal principal;
|
krb5_principal principal;
|
||||||
krb5_ccache ccache;
|
krb5_ccache ccache;
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
@@ -125,23 +125,22 @@ doauth(SIAENTITY *entity, int pkgind, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SIA_KRB5
|
#ifdef SIA_KRB5
|
||||||
ret = krb5_get_default_realm(s->context, &realm);
|
ret = krb5_get_default_realms(s->context, &realms);
|
||||||
krb5_build_principal(s->context, &principal,
|
|
||||||
strlen(realm),
|
|
||||||
realm,
|
|
||||||
entity->name,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
|
for (r = realms; *r != NULL; ++r) {
|
||||||
if(!krb5_kuserok(s->context, principal, entity->name))
|
krb5_make_principal (s->context, &principal, *r, entity->name, NULL);
|
||||||
|
|
||||||
|
if(krb5_kuserok(s->context, principal, entity->name))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
krb5_free_host_realm (context, realms);
|
||||||
|
if (*r == NULL)
|
||||||
return SIADFAIL;
|
return SIADFAIL;
|
||||||
|
|
||||||
sprintf(s->ticket, "FILE:/tmp/krb5_cc%d_%d", pwd->pw_uid, getpid());
|
sprintf(s->ticket, "FILE:/tmp/krb5_cc%d_%d", pwd->pw_uid, getpid());
|
||||||
ret = krb5_cc_resolve(s->context, s->ticket, &ccache);
|
ret = krb5_cc_resolve(s->context, s->ticket, &ccache);
|
||||||
if(ret)
|
if(ret)
|
||||||
return SIADFAIL;
|
return SIADFAIL;
|
||||||
ret = krb5_cc_initialize(s->context, ccache, principal);
|
|
||||||
if(ret)
|
|
||||||
return SIADFAIL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SIA_KRB4
|
#ifdef SIA_KRB4
|
||||||
@@ -181,8 +180,8 @@ doauth(SIAENTITY *entity, int pkgind, char *name)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIA_KRB5
|
#ifdef SIA_KRB5
|
||||||
ret = krb5_verify_user(s->context, principal, ccache,
|
ret = krb5_verify_user_lrealm(s->context, principal, ccache,
|
||||||
entity->password, 1, NULL);
|
entity->password, 1, NULL);
|
||||||
if(ret){
|
if(ret){
|
||||||
/* if this is most likely a local user (such as
|
/* if this is most likely a local user (such as
|
||||||
root), just silently return failure when the
|
root), just silently return failure when the
|
||||||
|
Reference in New Issue
Block a user