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