Annotation of src/usr.bin/rlogin/krcmd.c, Revision 1.3
1.3 ! deraadt 1: /* $OpenBSD: krcmd.c,v 1.2 1995/03/21 07:58:36 cgd 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.3 ! deraadt 41: static char rcsid[] = "$OpenBSD: krcmd.c,v 1.2 1995/03/21 07:58:36 cgd Exp $";
1.1 deraadt 42: #endif
43: #endif /* not lint */
44:
45: /*
46: * $Source: /a/cvsroot/src/usr.bin/rlogin/krcmd.c,v
47: * $Header: /mit/kerberos/ucb/mit/kcmd/RCS/krcmd.c,v 5.1
48: * 89/07/25 15:38:44 kfall Exp Locker: kfall
49: * static char *rcsid_kcmd_c =
50: * "$Header: /mit/kerberos/ucb/mit/kcmd/RCS/krcmd.c,v 5.1 89/07/25 15:38:44
51: * kfall Exp Locker: kfall ";
52: */
53:
54: #ifdef KERBEROS
55: #include <sys/types.h>
56: #include <sys/socket.h>
57:
58: #include <netinet/in.h>
59:
60: #include <kerberosIV/des.h>
61: #include <kerberosIV/krb.h>
62:
63: #include <stdio.h>
64:
65: #define SERVICE_NAME "rcmd"
66:
67: int kcmd __P((int *, char **, u_short, char *, char *, char *, int *,
68: KTEXT, char *, char *, CREDENTIALS *, Key_schedule, MSG_DAT *,
69: struct sockaddr_in *, struct sockaddr_in *, long));
70:
71: /*
72: * krcmd: simplified version of Athena's "kcmd"
73: * returns a socket attached to the destination, -1 or krb error on error
74: * if fd2p is non-NULL, another socket is filled in for it
75: */
76:
77: int
78: krcmd(ahost, rport, remuser, cmd, fd2p, realm)
79: char **ahost;
80: u_short rport;
81: char *remuser, *cmd;
82: int *fd2p;
83: char *realm;
84: {
85: int sock = -1, err = 0;
86: KTEXT_ST ticket;
87: long authopts = 0L;
88:
89: err = kcmd(
90: &sock,
91: ahost,
92: rport,
93: NULL, /* locuser not used */
94: remuser,
95: cmd,
96: fd2p,
97: &ticket,
98: SERVICE_NAME,
99: realm,
100: (CREDENTIALS *) NULL, /* credentials not used */
101: (bit_64 *) NULL, /* key schedule not used */
102: (MSG_DAT *) NULL, /* MSG_DAT not used */
103: (struct sockaddr_in *) NULL, /* local addr not used */
104: (struct sockaddr_in *) NULL, /* foreign addr not used */
105: authopts
106: );
107:
108: if (err > KSUCCESS && err < MAX_KRB_ERRORS) {
109: fprintf(stderr, "krcmd: %s\n", krb_err_txt[err]);
110: return(-1);
111: }
112: if (err < 0)
113: return(-1);
114: return(sock);
115: }
116:
117: int
118: krcmd_mutual(ahost, rport, remuser, cmd, fd2p, realm, cred, sched)
119: char **ahost;
120: u_short rport;
121: char *remuser, *cmd;
122: int *fd2p;
123: char *realm;
124: CREDENTIALS *cred;
125: Key_schedule sched;
126: {
127: int sock, err;
128: KTEXT_ST ticket;
129: MSG_DAT msg_dat;
130: struct sockaddr_in laddr, faddr;
131: long authopts = KOPT_DO_MUTUAL;
132:
133: err = kcmd(
134: &sock,
135: ahost,
136: rport,
137: NULL, /* locuser not used */
138: remuser,
139: cmd,
140: fd2p,
141: &ticket,
142: SERVICE_NAME,
143: realm,
144: cred, /* filled in */
145: sched, /* filled in */
146: &msg_dat, /* filled in */
147: &laddr, /* filled in */
148: &faddr, /* filled in */
149: authopts
150: );
151:
152: if (err > KSUCCESS && err < MAX_KRB_ERRORS) {
153: fprintf(stderr, "krcmd_mutual: %s\n", krb_err_txt[err]);
154: return(-1);
155: }
156:
157: if (err < 0)
158: return (-1);
159: return(sock);
160: }
161: #endif /* KERBEROS */