]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Header$ | |
4 | */ | |
5 | ||
6 | #ifndef lint | |
7 | static char *rcsid_client2_c = "$Header$"; | |
8 | #endif lint | |
9 | ||
10 | /* | |
11 | * MODULE IDENTIFICATION: | |
12 | * $Header$ | |
546bc43b | 13 | * Copyright 1987, 1988 by the Massachusetts Institute of Technology. |
14 | * For copying and distribution information, please see the file | |
15 | * <mit-copyright.h>. | |
de56407f | 16 | * DESCRIPTION: |
17 | * This code handles the actual distribution of data files | |
2ad0a777 | 18 | * to servers in the MOIRA server-update program. |
de56407f | 19 | * AUTHOR: |
20 | * Ken Raeburn (spook@athena.MIT.EDU), | |
21 | * MIT Project Athena/MIT Information Systems. | |
22 | * DEFINED VALUES: | |
23 | * conn | |
2ad0a777 | 24 | * mr_update_server |
de56407f | 25 | */ |
26 | ||
546bc43b | 27 | #include <mit-copyright.h> |
de56407f | 28 | #include <stdio.h> |
7da203a3 | 29 | #include <stdlib.h> |
7b48c9f9 | 30 | #include <string.h> |
7bd50861 | 31 | #include <gdb.h> |
de56407f | 32 | #include <sys/param.h> |
7bd50861 | 33 | #include <sys/wait.h> |
f5b9994a | 34 | #include <sys/socket.h> |
7bd50861 | 35 | #include <update.h> |
de56407f | 36 | #include <errno.h> |
2ad0a777 | 37 | #include <moira.h> |
38 | #include <moira_site.h> | |
de56407f | 39 | #include <krb.h> |
40 | ||
bc6cbc65 | 41 | extern int errno, dbg; |
be86b0c2 | 42 | extern C_Block session; |
de56407f | 43 | |
de56407f | 44 | static char buf[BUFSIZ]; |
7bd50861 | 45 | static int code; |
de56407f | 46 | |
47 | CONNECTION conn; | |
de56407f | 48 | |
de56407f | 49 | |
50 | /* | |
51 | * FUNCTION: | |
52 | * initialize() | |
53 | * DESCRIPTION: | |
54 | * Insures that various libraries have a chance to get | |
55 | * initialized. | |
56 | * INPUT: | |
57 | * OUTPUT: | |
58 | * RETURN VALUE: | |
59 | * void | |
60 | * SIDE EFFECTS: | |
756e2c48 | 61 | * Initializes GDB library. |
de56407f | 62 | * PROBLEMS: |
63 | * | |
64 | */ | |
7bd50861 | 65 | static void |
de56407f | 66 | initialize() |
67 | { | |
68 | static int initialized = 0; | |
7bd50861 | 69 | |
de56407f | 70 | if (!initialized) { |
71 | gdb_init(); | |
de56407f | 72 | initialized++; |
73 | } | |
74 | } | |
75 | ||
7bd50861 | 76 | send_auth(host_name) |
77 | char *host_name; | |
de56407f | 78 | { |
79 | KTEXT_ST ticket_st; | |
80 | KTEXT ticket = &ticket_st; | |
81 | STRING data; | |
82 | register int code; | |
83 | int response; | |
be86b0c2 | 84 | int auth_version = 2; |
de56407f | 85 | |
2ad0a777 | 86 | code = get_mr_update_ticket(host_name, ticket); |
de56407f | 87 | if (code) { |
88 | return(code); | |
89 | } | |
be86b0c2 | 90 | STRING_DATA(data) = "AUTH_002"; |
de56407f | 91 | MAX_STRING_SIZE(data) = 9; |
92 | code = send_object(conn, (char *)&data, STRING_T); | |
93 | if (code) { | |
94 | return(connection_errno(conn)); | |
95 | } | |
96 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
97 | if (code) { | |
98 | return(connection_errno(conn)); | |
99 | } | |
100 | if (response) { | |
be86b0c2 | 101 | STRING_DATA(data) = "AUTH_001"; |
102 | MAX_STRING_SIZE(data) = 9; | |
103 | code = send_object(conn, (char *)&data, STRING_T); | |
104 | if (code) { | |
105 | return(connection_errno(conn)); | |
106 | } | |
107 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
108 | if (code) { | |
109 | return(connection_errno(conn)); | |
110 | } | |
111 | if (response) { | |
112 | return(response); | |
113 | } | |
114 | auth_version = 1; | |
de56407f | 115 | } |
116 | STRING_DATA(data) = (char *)ticket->dat; | |
117 | MAX_STRING_SIZE(data) = ticket->length; | |
118 | code = send_object(conn, (char *)&data, STRING_T); | |
119 | if (code) { | |
120 | return(connection_errno(conn)); | |
121 | } | |
122 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
123 | if (code) { | |
124 | return(connection_errno(conn)); | |
125 | } | |
126 | if (response) { | |
127 | return(response); | |
128 | } | |
be86b0c2 | 129 | |
130 | if (auth_version == 2) { | |
131 | des_key_schedule sched; | |
132 | C_Block enonce; | |
133 | ||
134 | code = receive_object(conn, (char *)&data, STRING_T); | |
135 | if (code) { | |
136 | return(connection_errno(conn)); | |
137 | } | |
98a7b0ee | 138 | des_key_sched(session, sched); |
be86b0c2 | 139 | des_ecb_encrypt(STRING_DATA(data), enonce, sched, 1); |
140 | STRING_DATA(data) = enonce; | |
141 | code = send_object(conn, (char *)&data, STRING_T); | |
142 | if (code) { | |
143 | return(connection_errno(conn)); | |
144 | } | |
145 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
146 | if (code) { | |
147 | return(connection_errno(conn)); | |
148 | } | |
149 | if (response) { | |
150 | return(response); | |
151 | } | |
152 | } | |
153 | ||
2ad0a777 | 154 | return(MR_SUCCESS); |
de56407f | 155 | } |
156 | ||
de56407f | 157 | execute(path) |
158 | char *path; | |
159 | { | |
1e447eb1 | 160 | int response; |
de56407f | 161 | STRING data; |
162 | register int code; | |
163 | ||
164 | string_alloc(&data, BUFSIZ); | |
165 | sprintf(STRING_DATA(data), "EXEC_002 %s", path); | |
166 | code = send_object(conn, (char *)&data, STRING_T); | |
167 | if (code) | |
168 | return(connection_errno(conn)); | |
169 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
170 | if (code) | |
171 | return(connection_errno(conn)); | |
1e447eb1 | 172 | if (response) |
173 | return(response); | |
2ad0a777 | 174 | return(MR_SUCCESS); |
de56407f | 175 | } |
176 | ||
177 | send_quit() | |
178 | { | |
179 | STRING str; | |
180 | if (!conn) | |
181 | return; | |
182 | string_alloc(&str, 5); | |
183 | (void) strcpy(STRING_DATA(str), "quit"); | |
184 | (void) send_object(conn, (char *)&str, STRING_T); | |
185 | string_free(&str); | |
186 | } |