Kerberized password checks.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@402 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
61
appl/ftp/ftpd/klogin.c
Normal file
61
appl/ftp/ftpd/klogin.c
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <krb.h>
|
||||||
|
#include <kafs.h>
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
int
|
||||||
|
klogin(char *name, char *password)
|
||||||
|
{
|
||||||
|
int kerror;
|
||||||
|
KTEXT_ST tkt;
|
||||||
|
AUTH_DAT ad;
|
||||||
|
char hostname[MAXHOSTNAMELEN];
|
||||||
|
char realm[REALM_SZ];
|
||||||
|
|
||||||
|
char *phost;
|
||||||
|
|
||||||
|
struct hostent *hp;
|
||||||
|
|
||||||
|
gethostname(hostname);
|
||||||
|
phost = krb_get_phost(hostname);
|
||||||
|
|
||||||
|
krb_get_lrealm(realm, 0);
|
||||||
|
|
||||||
|
kerror = krb_get_pw_in_tkt(name, "", realm,
|
||||||
|
"krbtgt", realm,
|
||||||
|
12, password);
|
||||||
|
if(kerror)
|
||||||
|
return kerror;
|
||||||
|
|
||||||
|
kerror = krb_mk_req(&tkt, "rcmd", phost, realm, 33);
|
||||||
|
if (kerror){
|
||||||
|
dest_tkt();
|
||||||
|
return kerror;
|
||||||
|
}
|
||||||
|
|
||||||
|
hp = gethostbyname(hostname);
|
||||||
|
|
||||||
|
if(!hp){
|
||||||
|
dest_tkt();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
kerror = krb_rd_req(&tkt, "rcmd", phost, *(unsigned int*)(hp->h_addr),
|
||||||
|
&ad, "");
|
||||||
|
|
||||||
|
if(kerror){
|
||||||
|
dest_tkt();
|
||||||
|
return kerror;
|
||||||
|
}
|
||||||
|
if(k_hasafs())
|
||||||
|
k_afsklog(0, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user