From d72a4591215df9891b2f361e8f95db3523660cb1 Mon Sep 17 00:00:00 2001 From: kcr Date: Wed, 20 Jun 2001 07:15:35 +0000 Subject: [PATCH] merge in changes from new snapshot git-svn-id: svn://svn.1ts.org/debian/trunk/zephyr@85 cbed1d16-5ef5-0310-b6a1-d4a37b08ba1f --- server/kopt.c | 139 +++++--------------------------------------------- zhm/zhm.c | 7 +-- 2 files changed, 17 insertions(+), 129 deletions(-) diff --git a/server/kopt.c b/server/kopt.c index 9b777f5..9f87d22 100644 --- a/server/kopt.c +++ b/server/kopt.c @@ -1,5 +1,6 @@ /* - * $Id: kopt.c,v 1.14 1999/01/22 23:19:44 ghudson Exp $ + * $Source: /afs/dev.mit.edu/source/repository/athena/lib/zephyr/server/kopt.c,v $ + * $Author: zacheiss $ * * Copyright 1985, 1986, 1987, 1988, 1990, 1991 by the Massachusetts * Institute of Technology. @@ -21,7 +22,7 @@ #ifndef lint #ifndef SABER static const char *rcsid_rd_req_c = - "$Id: kopt.c,v 1.14 1999/01/22 23:19:44 ghudson Exp $"; + "$Id: kopt.c,v 1.16 2001/02/27 04:48:01 zacheiss Exp $"; #endif /* lint */ #endif /* SABER */ @@ -296,8 +297,9 @@ krb_rd_req(authent,service,instance,from_addr,ad,fn) mutual = 0; #endif /* lint */ s_kvno = *ptr++; /* get server key version */ - strcpy(realm,ptr); /* And the realm of the issuing KDC */ - ptr += strlen(ptr) + 1; /* skip the realm "hint" */ + strncpy(realm,ptr,REALM_SZ);/* And the realm of the issuing KDC */ + realm[REALM_SZ-1] = '\0'; + ptr += strlen(realm) + 1; /* skip the realm "hint" */ /* * If "fn" is NULL, key info should already be set; don't @@ -377,16 +379,19 @@ krb_rd_req(authent,service,instance,from_addr,ad,fn) #define check_ptr() if ((ptr - (char *) req_id->dat) > req_id->length) return(RD_AP_MODIFIED); ptr = (char *) req_id->dat; - strcpy(r_aname,ptr); /* Authentication name */ + strncpy(r_aname, ptr, ANAME_SZ); /* Authentication name */ + r_aname[ANAME_SZ-1] = '\0'; ptr += strlen(r_aname) + 1; check_ptr(); - strcpy(r_inst,ptr); /* Authentication instance */ + strncpy(r_inst, ptr, INST_SZ); /* Authentication instance */ + r_inst[INST_SZ-1] = '\0'; ptr += strlen(r_inst) + 1; check_ptr(); - strcpy(r_realm,ptr); /* Authentication name */ + strncpy(r_realm, ptr, REALM_SZ); /* Authentication name */ + r_realm[REALM_SZ-1] = '\0'; ptr += strlen(r_realm) + 1; check_ptr(); - memcpy(&ad->checksum, ptr, 4); /* Checksum */ + memcpy(&ad->checksum, ptr, 4); /* Checksum */ ptr += 4; check_ptr(); if (swap_bytes) @@ -492,122 +497,4 @@ krb_find_ticket(authent, ticket) return RD_AP_OK; } - -static char local_realm_buffer[REALM_SZ+1]; - -int -krb_get_lrealm(r,n) - char *r; - int n; -{ - FILE *cnffile, *fopen(); - - if (n > 1) - return KFAILURE; /* Temporary restriction */ - - if (my_realm[0]) { - strcpy(r, my_realm); - return KSUCCESS; - } - - if (local_realm_buffer[0]) { - strcpy(r, local_realm_buffer); - return KSUCCESS; - } - - cnffile = fopen(KRB_CONF, "r"); - if (cnffile == NULL) { - if (n == 1) { - strcpy(r, KRB_REALM); - return KSUCCESS; - } else { - return KFAILURE; - } - } - - if (fscanf(cnffile,"%s",r) != 1) { - fclose(cnffile); - return KFAILURE; - } - fclose(cnffile); - return KSUCCESS; -} - -int -decomp_ticket(tkt, flags, pname, pinstance, prealm, paddress, session, - life, time_sec, sname, sinstance, key, key_s) - KTEXT tkt; /* The ticket to be decoded */ - unsigned char *flags; /* Kerberos ticket flags */ - char *pname; /* Authentication name */ - char *pinstance; /* Principal's instance */ - char *prealm; /* Principal's authentication domain */ - unsigned KRB4_32 *paddress; /* Net address of entity - * requesting ticket */ - C_Block session; /* Session key inserted in ticket */ - int *life; /* Lifetime of the ticket */ - unsigned KRB4_32 *time_sec; /* Issue time and date */ - char *sname; /* Service name */ - char *sinstance; /* Service instance */ - C_Block key; /* Service's secret key - * (to decrypt the ticket) */ - des_key_schedule key_s; /* The precomputed key schedule */ -{ - static int tkt_swap_bytes; - unsigned char *uptr; - char *ptr = (char *)tkt->dat; - -#ifndef NOENCRYPTION - /* Do the decryption */ - pcbc_encrypt((C_Block *)tkt->dat,(C_Block *)tkt->dat, - (long) tkt->length,key_s,(C_Block *) key,0); -#endif /* ! NOENCRYPTION */ - - *flags = *ptr; /* get flags byte */ - ptr += sizeof(*flags); - tkt_swap_bytes = 0; - if (HOST_BYTE_ORDER != ((*flags >> K_FLAG_ORDER)& 1)) - tkt_swap_bytes++; - - if (strlen(ptr) > ANAME_SZ) - return(KFAILURE); - strcpy(pname,ptr); /* pname */ - ptr += strlen(pname) + 1; - - if (strlen(ptr) > INST_SZ) - return(KFAILURE); - strcpy(pinstance,ptr); /* instance */ - ptr += strlen(pinstance) + 1; - - if (strlen(ptr) > REALM_SZ) - return(KFAILURE); - strcpy(prealm,ptr); /* realm */ - ptr += strlen(prealm) + 1; - /* temporary hack until realms are dealt with properly */ - if (*prealm == 0) - strcpy(prealm, ZGetRealm()); - - memcpy((char *)paddress, ptr, 4); /* net address */ - ptr += 4; - - memcpy((char *)session, ptr, 8); /* session key */ - ptr+= 8; - - /* get lifetime, being certain we don't get negative lifetimes */ - uptr = (unsigned char *) ptr++; - *life = (int) *uptr; - - memcpy((char *) time_sec, ptr, 4); /* issue time */ - ptr += 4; - if (tkt_swap_bytes) - swap_u_long(*time_sec); - - strcpy(sname,ptr); /* service name */ - ptr += 1 + strlen(sname); - - strcpy(sinstance,ptr); /* instance */ - ptr += 1 + strlen(sinstance); - - return(KSUCCESS); -} #endif /* HAVE_KRB4 */ - diff --git a/zhm/zhm.c b/zhm/zhm.c index ff06d5b..2b954ba 100644 --- a/zhm/zhm.c +++ b/zhm/zhm.c @@ -3,7 +3,7 @@ * * Created by: David C. Jedlinsky * - * $Id: zhm.c,v 1.61 2000/04/05 14:57:36 ghudson Exp $ + * $Id: zhm.c,v 1.62 2000/05/19 23:19:21 zacheiss Exp $ * * Copyright (c) 1987,1991 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -12,7 +12,7 @@ #include "zhm.h" -static const char rcsid_hm_c[] = "$Id: zhm.c,v 1.61 2000/04/05 14:57:36 ghudson Exp $"; +static const char rcsid_hm_c[] = "$Id: zhm.c,v 1.62 2000/05/19 23:19:21 zacheiss Exp $"; #ifdef HAVE_HESIOD int use_hesiod = 0; @@ -107,7 +107,8 @@ char *argv[]; break; } if (errflg) { - fprintf(stderr, "Usage: %s [-d] [-h] [-r] [-n] [server]\n", argv[0]); + fprintf(stderr, "Usage: %s [-d] [-h] [-r] [-n] [-f] [server]\n", + argv[0]); exit(2); } -- 2.45.2