[BACK]Return to krcmd.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rlogin

Annotation of src/usr.bin/rlogin/krcmd.c, Revision 1.5

1.5     ! tholo       1: /*     $OpenBSD: krcmd.c,v 1.4 1996/07/22 10:09:25 deraadt Exp $       */
1.1       deraadt     2: /*     $NetBSD: krcmd.c,v 1.2 1995/03/21 07:58:36 cgd Exp $    */
                      3:
                      4: /*
                      5:  * Copyright (c) 1989, 1993
                      6:  *     The Regents of the University of California.  All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the University of
                     19:  *     California, Berkeley and its contributors.
                     20:  * 4. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  */
                     36:
                     37: #ifndef lint
                     38: #if 0
                     39: static char sccsid[] = "@(#)krcmd.c    8.1 (Berkeley) 6/6/93";
                     40: #else
1.5     ! tholo      41: static char rcsid[] = "$OpenBSD: krcmd.c,v 1.4 1996/07/22 10:09:25 deraadt Exp $";
1.1       deraadt    42: #endif
                     43: #endif /* not lint */
                     44:
                     45: /*
                     46:  *     $Header: /mit/kerberos/ucb/mit/kcmd/RCS/krcmd.c,v 5.1
                     47:  *             89/07/25 15:38:44 kfall Exp Locker: kfall
                     48:  */
                     49:
                     50: #ifdef KERBEROS
                     51: #include <sys/types.h>
                     52: #include <sys/socket.h>
                     53:
                     54: #include <netinet/in.h>
                     55:
                     56: #include <kerberosIV/des.h>
                     57: #include <kerberosIV/krb.h>
                     58:
                     59: #include <stdio.h>
                     60:
                     61: #define        SERVICE_NAME    "rcmd"
                     62:
                     63: int    kcmd __P((int *, char **, u_short, char *, char *, char *, int *,
                     64:            KTEXT, char *, char *, CREDENTIALS *, Key_schedule, MSG_DAT *,
                     65:            struct sockaddr_in *, struct sockaddr_in *, long));
                     66:
                     67: /*
                     68:  * krcmd: simplified version of Athena's "kcmd"
                     69:  *     returns a socket attached to the destination, -1 or krb error on error
                     70:  *     if fd2p is non-NULL, another socket is filled in for it
                     71:  */
                     72:
                     73: int
                     74: krcmd(ahost, rport, remuser, cmd, fd2p, realm)
                     75:        char    **ahost;
                     76:        u_short rport;
                     77:        char    *remuser, *cmd;
                     78:        int     *fd2p;
                     79:        char    *realm;
                     80: {
                     81:        int             sock = -1, err = 0;
                     82:        KTEXT_ST        ticket;
                     83:        long            authopts = 0L;
1.5     ! tholo      84:        char myrealm[REALM_SZ];
1.1       deraadt    85:
                     86:        err = kcmd(
                     87:                &sock,
                     88:                ahost,
                     89:                rport,
                     90:                NULL,   /* locuser not used */
                     91:                remuser,
                     92:                cmd,
                     93:                fd2p,
                     94:                &ticket,
                     95:                SERVICE_NAME,
                     96:                realm,
                     97:                (CREDENTIALS *)  NULL,          /* credentials not used */
                     98:                (bit_64 *) NULL,                /* key schedule not used */
                     99:                (MSG_DAT *) NULL,               /* MSG_DAT not used */
                    100:                (struct sockaddr_in *) NULL,    /* local addr not used */
                    101:                (struct sockaddr_in *) NULL,    /* foreign addr not used */
                    102:                authopts
                    103:        );
                    104:
                    105:        if (err > KSUCCESS && err < MAX_KRB_ERRORS) {
1.5     ! tholo     106:                if (krb_get_lrealm(myrealm, 0) == KSUCCESS)
        !           107:                        fprintf(stderr, "krcmd: %s\n", krb_err_txt[err]);
1.1       deraadt   108:                return(-1);
                    109:        }
                    110:        if (err < 0)
                    111:                return(-1);
                    112:        return(sock);
                    113: }
                    114:
                    115: int
                    116: krcmd_mutual(ahost, rport, remuser, cmd, fd2p, realm, cred, sched)
                    117:        char            **ahost;
                    118:        u_short         rport;
                    119:        char            *remuser, *cmd;
                    120:        int             *fd2p;
                    121:        char            *realm;
                    122:        CREDENTIALS     *cred;
                    123:        Key_schedule    sched;
                    124: {
                    125:        int             sock, err;
                    126:        KTEXT_ST        ticket;
                    127:        MSG_DAT         msg_dat;
                    128:        struct sockaddr_in      laddr, faddr;
                    129:        long authopts = KOPT_DO_MUTUAL;
1.5     ! tholo     130:        char myrealm[REALM_SZ];
1.1       deraadt   131:
                    132:        err = kcmd(
                    133:                &sock,
                    134:                ahost,
                    135:                rport,
                    136:                NULL,   /* locuser not used */
                    137:                remuser,
                    138:                cmd,
                    139:                fd2p,
                    140:                &ticket,
                    141:                SERVICE_NAME,
                    142:                realm,
                    143:                cred,           /* filled in */
                    144:                sched,          /* filled in */
                    145:                &msg_dat,       /* filled in */
                    146:                &laddr,         /* filled in */
                    147:                &faddr,         /* filled in */
                    148:                authopts
                    149:        );
                    150:
                    151:        if (err > KSUCCESS && err < MAX_KRB_ERRORS) {
1.5     ! tholo     152:                if (krb_get_lrealm(myrealm, 0) == KSUCCESS)
        !           153:                        fprintf(stderr, "krcmd_mutual: %s\n", krb_err_txt[err]);
1.1       deraadt   154:                return(-1);
                    155:        }
                    156:
                    157:        if (err < 0)
                    158:                return (-1);
                    159:        return(sock);
                    160: }
                    161: #endif /* KERBEROS */