Annotation of 43BSDReno/kerberosIV/krb/tkt_string.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * $Source: /usr/src/kerberosIV/krb/RCS/tkt_string.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_tkt_string_c =
        !            14: "$Header: /usr/src/kerberosIV/krb/RCS/tkt_string.c,v 4.7 90/06/25 20:57:33 kfall Exp $";
        !            15: #endif /* lint */
        !            16: 
        !            17: #include <mit-copyright.h>
        !            18: #include <stdio.h>
        !            19: #include <sys/types.h>
        !            20: #include <des.h>
        !            21: #include <krb.h>
        !            22: #include <string.h>
        !            23: #include <sys/param.h>
        !            24: 
        !            25: char *getenv();
        !            26: 
        !            27: /*
        !            28:  * This routine is used to generate the name of the file that holds
        !            29:  * the user's cache of server tickets and associated session keys.
        !            30:  *
        !            31:  * If it is set, krb_ticket_string contains the ticket file name.
        !            32:  * Otherwise, the filename is constructed as follows:
        !            33:  *
        !            34:  * If it is set, the environment variable "KRBTKFILE" will be used as
        !            35:  * the ticket file name.  Otherwise TKT_ROOT (defined in "krb.h") and
        !            36:  * the user's uid are concatenated to produce the ticket file name
        !            37:  * (e.g., "/tmp/tkt123").  A pointer to the string containing the ticket
        !            38:  * file name is returned.
        !            39:  */
        !            40: 
        !            41: static char krb_ticket_string[MAXPATHLEN] = "";
        !            42: 
        !            43: char *tkt_string()
        !            44: {
        !            45:     char *env;
        !            46:     uid_t getuid();
        !            47: 
        !            48:     if (!*krb_ticket_string) {
        !            49:         if (env = getenv("KRBTKFILE")) {
        !            50:            (void) strncpy(krb_ticket_string, env,
        !            51:                           sizeof(krb_ticket_string)-1);
        !            52:            krb_ticket_string[sizeof(krb_ticket_string)-1] = '\0';
        !            53:        } else {
        !            54:            /* 32 bits of signed integer will always fit in 11 characters
        !            55:             (including the sign), so no need to worry about overflow */
        !            56:            (void) sprintf(krb_ticket_string, "%s%d",TKT_ROOT,getuid());
        !            57:         }
        !            58:     }
        !            59:     return krb_ticket_string;
        !            60: }
        !            61: 
        !            62: /*
        !            63:  * This routine is used to set the name of the file that holds the user's
        !            64:  * cache of server tickets and associated session keys.
        !            65:  *
        !            66:  * The value passed in is copied into local storage.
        !            67:  *
        !            68:  * NOTE:  This routine should be called during initialization, before other
        !            69:  * Kerberos routines are called; otherwise tkt_string() above may be called
        !            70:  * and return an undesired ticket file name until this routine is called.
        !            71:  */
        !            72: 
        !            73: void
        !            74: krb_set_tkt_string(val)
        !            75: char *val;
        !            76: {
        !            77: 
        !            78:     (void) strncpy(krb_ticket_string, val, sizeof(krb_ticket_string)-1);
        !            79:     krb_ticket_string[sizeof(krb_ticket_string)-1] = '\0';
        !            80: 
        !            81:     return;
        !            82: }

unix.superglobalmegacorp.com

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