From b17837681019db570804e78333a3234f9bfa4f43 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Thu, 22 Aug 1996 19:02:56 +0000 Subject: [PATCH] Added support for afs_string_to_key. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@666 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/kauth.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/appl/ftp/ftp/kauth.c b/appl/ftp/ftp/kauth.c index b03b3bab8..f622c07d8 100644 --- a/appl/ftp/ftp/kauth.c +++ b/appl/ftp/ftp/kauth.c @@ -2,6 +2,8 @@ #include #endif +RCSID("$Id$"); + #include "ftp_locl.h" #include @@ -11,10 +13,11 @@ void kauth(int argc, char **argv) char buf[1024]; des_cblock key; des_key_schedule schedule; - KTEXT_ST tkt; + KTEXT_ST tkt, tktcopy; char *name; char *p; int overbose; + char passwd[100]; if(argc > 2){ printf("usage: %s [principal]\n", argv[0]); @@ -48,6 +51,7 @@ void kauth(int argc, char **argv) code = -1; return; } + tktcopy.length = tkt.length; p = strstr(reply_string, "P="); if(!p){ @@ -59,17 +63,28 @@ void kauth(int argc, char **argv) for(; *p && *p != ' ' && *p != '\r' && *p != '\n'; p++); *p = 0; - sprintf(buf, "Password for %s:", name); - des_read_password(&key, buf, 0); + if (des_read_pw_string (passwd, sizeof(passwd)-1, buf, 0)) + *passwd = '\0'; + des_string_to_key (passwd, &key); des_key_sched(&key, schedule); - des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tkt.dat, tkt.length, + des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tktcopy.dat, + tkt.length, schedule, &key, DES_DECRYPT); + if (strcmp (tktcopy.dat + 8, "krbtgt") != 0) { + afs_string_to_key (passwd, krb_realmofhost(hostname), &key); + des_key_sched (&key, schedule); + des_pcbc_encrypt((des_cblock*)tkt.dat, (des_cblock*)tktcopy.dat, + tkt.length, + schedule, &key, DES_DECRYPT); + } memset(key, 0, sizeof(key)); memset(schedule, 0, sizeof(schedule)); - base64_encode(tkt.dat, tkt.length, &p); + memset(passwd, 0, sizeof(passwd)); + base64_encode(tktcopy.dat, tktcopy.length, &p); + memset (tktcopy.dat, 0, tktcopy.length); ret = command("SITE KAUTH %s %s", name, p); free(p); if(ret != COMPLETE){