Annotation of 43BSDReno/usr.bin/rlogin/krcmd.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1989 The Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)krcmd.c    1.5 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: /*
        !            25:  *     $Source: /mit/kerberos/ucb/mit/kcmd/RCS/krcmd.c,v $
        !            26:  *     $Header: /mit/kerberos/ucb/mit/kcmd/RCS/krcmd.c,v 5.1
        !            27:  *             89/07/25 15:38:44 kfall Exp Locker: kfall $
        !            28:  * static char *rcsid_kcmd_c =
        !            29:  * "$Header: /mit/kerberos/ucb/mit/kcmd/RCS/krcmd.c,v 5.1 89/07/25 15:38:44
        !            30:  *     kfall Exp Locker: kfall $";
        !            31:  */
        !            32: 
        !            33: #include <sys/types.h>
        !            34: #include <stdio.h>
        !            35: #include <kerberosIV/des.h>
        !            36: #include <kerberosIV/krb.h>
        !            37: 
        !            38: #define        SERVICE_NAME    "rcmd"
        !            39: 
        !            40: /*
        !            41:  * krcmd: simplified version of Athena's "kcmd"
        !            42:  *     returns a socket attached to the destination, -1 or krb error on error 
        !            43:  *     if fd2p is non-NULL, another socket is filled in for it
        !            44:  */
        !            45: 
        !            46: int
        !            47: krcmd(ahost, rport, remuser, cmd, fd2p, realm)
        !            48:        char    **ahost;
        !            49:        u_short rport;
        !            50:        char    *remuser, *cmd;
        !            51:        int     *fd2p;
        !            52:        char    *realm;
        !            53: {
        !            54:        int             sock = -1, err = 0;
        !            55:        KTEXT_ST        ticket;
        !            56:        long            authopts = 0L;
        !            57: 
        !            58:        err = kcmd(
        !            59:                &sock,
        !            60:                ahost,
        !            61:                rport,
        !            62:                NULL,   /* locuser not used */
        !            63:                remuser,
        !            64:                cmd,
        !            65:                fd2p,
        !            66:                &ticket,
        !            67:                SERVICE_NAME,
        !            68:                realm,
        !            69:                (CREDENTIALS *)  NULL,          /* credentials not used */
        !            70:                (bit_64 *) NULL,                /* key schedule not used */
        !            71:                (MSG_DAT *) NULL,               /* MSG_DAT not used */
        !            72:                (struct sockaddr_in *) NULL,    /* local addr not used */
        !            73:                (struct sockaddr_in *) NULL,    /* foreign addr not used */
        !            74:                authopts
        !            75:        );
        !            76: 
        !            77:        if (err > KSUCCESS && err < MAX_KRB_ERRORS) {
        !            78:                fprintf(stderr, "krcmd: %s\n", krb_err_txt[err]);
        !            79:                return(-1);
        !            80:        }
        !            81:        if (err < 0)
        !            82:                return(-1);
        !            83:        return(sock);
        !            84: }
        !            85: 
        !            86: #include <sys/socket.h>
        !            87: #include <netinet/in.h>
        !            88: 
        !            89: int
        !            90: krcmd_mutual(ahost, rport, remuser, cmd, fd2p, realm, cred, sched)
        !            91:        char            **ahost;
        !            92:        u_short         rport;
        !            93:        char            *remuser, *cmd;
        !            94:        int             *fd2p;
        !            95:        char            *realm;
        !            96:        CREDENTIALS     *cred;
        !            97:        Key_schedule    sched;
        !            98: {
        !            99:        int             sock, err;
        !           100:        KTEXT_ST        ticket;
        !           101:        MSG_DAT         msg_dat;
        !           102:        struct sockaddr_in      laddr, faddr;
        !           103:        long authopts = KOPT_DO_MUTUAL;
        !           104: 
        !           105:        err = kcmd(
        !           106:                &sock,
        !           107:                ahost,
        !           108:                rport,
        !           109:                NULL,   /* locuser not used */
        !           110:                remuser,
        !           111:                cmd,
        !           112:                fd2p,
        !           113:                &ticket,
        !           114:                SERVICE_NAME,
        !           115:                realm,
        !           116:                cred,           /* filled in */
        !           117:                sched,          /* filled in */
        !           118:                &msg_dat,       /* filled in */
        !           119:                &laddr,         /* filled in */
        !           120:                &faddr,         /* filled in */
        !           121:                authopts
        !           122:        );
        !           123: 
        !           124:        if (err > KSUCCESS && err < MAX_KRB_ERRORS) {
        !           125:                fprintf(stderr, "krcmd_mutual: %s\n", krb_err_txt[err]);
        !           126:                return(-1);
        !           127:        }
        !           128: 
        !           129:        if (err < 0)
        !           130:                return (-1);
        !           131:        return(sock);
        !           132: }

unix.superglobalmegacorp.com

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