Annotation of 43BSDReno/kerberosIV/krb/cr_err_reply.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * $Source: /usr/src/kerberosIV/krb/RCS/cr_err_reply.c,v $
                      3:  * $Author: kfall $
                      4:  *
                      5:  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
                      6:  * of Technology.
                      7:  *
                      8:  * For copying and distribution information, please see the file
                      9:  * <mit-copyright.h>.
                     10:  */
                     11: 
                     12: #ifndef lint
                     13: static char *rcsid_cr_err_reply_c =
                     14: "$Header: /usr/src/kerberosIV/krb/RCS/cr_err_reply.c,v 4.11 90/06/25 20:55:11 kfall Exp $";
                     15: #endif /* lint */
                     16: 
                     17: #include <mit-copyright.h>
                     18: #include <sys/types.h>
                     19: #include <des.h>
                     20: #include <krb.h>
                     21: #include <prot.h>
                     22: #include <strings.h>
                     23: 
                     24: extern int req_act_vno;                /* this is defined in the kerberos
                     25:                                 * server code */
                     26: 
                     27: /*
                     28:  * This routine is used by the Kerberos authentication server to
                     29:  * create an error reply packet to send back to its client.
                     30:  *
                     31:  * It takes a pointer to the packet to be built, the name, instance,
                     32:  * and realm of the principal, the client's timestamp, an error code
                     33:  * and an error string as arguments.  Its return value is undefined.
                     34:  *
                     35:  * The packet is built in the following format:
                     36:  * 
                     37:  * type                        variable           data
                     38:  *                     or constant
                     39:  * ----                        -----------        ----
                     40:  *
                     41:  * unsigned char       req_ack_vno        protocol version number
                     42:  * 
                     43:  * unsigned char       AUTH_MSG_ERR_REPLY protocol message type
                     44:  * 
                     45:  * [least significant  HOST_BYTE_ORDER    sender's (server's) byte
                     46:  * bit of above field]                    order
                     47:  * 
                     48:  * string              pname              principal's name
                     49:  * 
                     50:  * string              pinst              principal's instance
                     51:  * 
                     52:  * string              prealm             principal's realm
                     53:  * 
                     54:  * unsigned long       time_ws            client's timestamp
                     55:  * 
                     56:  * unsigned long       e                  error code
                     57:  * 
                     58:  * string              e_string           error text
                     59:  */
                     60: 
                     61: void
                     62: cr_err_reply(pkt,pname,pinst,prealm,time_ws,e,e_string)
                     63:     KTEXT pkt;
                     64:     char *pname;               /* Principal's name */
                     65:     char *pinst;               /* Principal's instance */
                     66:     char *prealm;              /* Principal's authentication domain */
                     67:     u_long time_ws;            /* Workstation time */
                     68:     u_long e;                  /* Error code */
                     69:     char *e_string;            /* Text of error */
                     70: {
                     71:     u_char *v = (u_char *) pkt->dat; /* Prot vers number */
                     72:     u_char *t = (u_char *)(pkt->dat+1); /* Prot message type */
                     73: 
                     74:     /* Create fixed part of packet */
                     75:     *v = (unsigned char) req_act_vno; /* KRB_PROT_VERSION; */
                     76:     *t = (unsigned char) AUTH_MSG_ERR_REPLY;
                     77:     *t |= HOST_BYTE_ORDER;
                     78: 
                     79:     /* Add the basic info */
                     80:     (void) strcpy((char *) (pkt->dat+2),pname);
                     81:     pkt->length = 3 + strlen(pname);
                     82:     (void) strcpy((char *)(pkt->dat+pkt->length),pinst);
                     83:     pkt->length += 1 + strlen(pinst);
                     84:     (void) strcpy((char *)(pkt->dat+pkt->length),prealm);
                     85:     pkt->length += 1 + strlen(prealm);
                     86:     /* ws timestamp */
                     87:     bcopy((char *) &time_ws,(char *)(pkt->dat+pkt->length),4);
                     88:     pkt->length += 4;
                     89:     /* err code */
                     90:     bcopy((char *) &e,(char *)(pkt->dat+pkt->length),4);
                     91:     pkt->length += 4;
                     92:     /* err text */
                     93:     (void) strcpy((char *)(pkt->dat+pkt->length),e_string);
                     94:     pkt->length += 1 + strlen(e_string);
                     95: 
                     96:     /* And return */
                     97:     return;
                     98: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.