]>
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 | |
59ec8dae | 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 | */ | |
5eaef520 | 65 | static void initialize() |
de56407f | 66 | { |
5eaef520 | 67 | static int initialized = 0; |
7bd50861 | 68 | |
5eaef520 | 69 | if (!initialized) |
70 | { | |
71 | gdb_init(); | |
72 | initialized++; | |
de56407f | 73 | } |
74 | } | |
75 | ||
5eaef520 | 76 | int send_auth(char *host_name) |
de56407f | 77 | { |
5eaef520 | 78 | KTEXT_ST ticket_st; |
79 | KTEXT ticket = &ticket_st; | |
80 | STRING data; | |
44d12d58 | 81 | int code; |
5eaef520 | 82 | int response; |
83 | int auth_version = 2; | |
84 | ||
85 | code = get_mr_update_ticket(host_name, ticket); | |
86 | if (code) | |
87 | return code; | |
88 | STRING_DATA(data) = "AUTH_002"; | |
89 | MAX_STRING_SIZE(data) = 9; | |
90 | code = send_object(conn, (char *)&data, STRING_T); | |
91 | if (code) | |
92 | return connection_errno(conn); | |
93 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
94 | if (code) | |
95 | return connection_errno(conn); | |
96 | if (response) | |
97 | { | |
98 | STRING_DATA(data) = "AUTH_001"; | |
99 | MAX_STRING_SIZE(data) = 9; | |
100 | code = send_object(conn, (char *)&data, STRING_T); | |
101 | if (code) | |
102 | return connection_errno(conn); | |
103 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
104 | if (code) | |
105 | return connection_errno(conn); | |
106 | if (response) | |
107 | return response; | |
108 | auth_version = 1; | |
de56407f | 109 | } |
5eaef520 | 110 | STRING_DATA(data) = (char *)ticket->dat; |
111 | MAX_STRING_SIZE(data) = ticket->length; | |
112 | code = send_object(conn, (char *)&data, STRING_T); | |
113 | if (code) | |
114 | return connection_errno(conn); | |
115 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
116 | if (code) | |
117 | return connection_errno(conn); | |
118 | if (response) | |
119 | return response; | |
120 | ||
121 | if (auth_version == 2) | |
122 | { | |
123 | des_key_schedule sched; | |
124 | C_Block enonce; | |
125 | ||
126 | code = receive_object(conn, (char *)&data, STRING_T); | |
127 | if (code) | |
128 | return connection_errno(conn); | |
129 | des_key_sched(session, sched); | |
130 | des_ecb_encrypt(STRING_DATA(data), enonce, sched, 1); | |
131 | STRING_DATA(data) = enonce; | |
132 | code = send_object(conn, (char *)&data, STRING_T); | |
133 | if (code) | |
134 | return connection_errno(conn); | |
135 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
136 | if (code) | |
137 | return connection_errno(conn); | |
138 | if (response) | |
139 | return response; | |
be86b0c2 | 140 | } |
141 | ||
5eaef520 | 142 | return MR_SUCCESS; |
de56407f | 143 | } |
144 | ||
5eaef520 | 145 | int execute(char *path) |
de56407f | 146 | { |
5eaef520 | 147 | int response; |
148 | STRING data; | |
44d12d58 | 149 | int code; |
5eaef520 | 150 | |
151 | string_alloc(&data, BUFSIZ); | |
152 | sprintf(STRING_DATA(data), "EXEC_002 %s", path); | |
153 | code = send_object(conn, (char *)&data, STRING_T); | |
154 | if (code) | |
155 | return connection_errno(conn); | |
156 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
157 | if (code) | |
158 | return connection_errno(conn); | |
159 | if (response) | |
160 | return response; | |
161 | return MR_SUCCESS; | |
de56407f | 162 | } |
163 | ||
5eaef520 | 164 | send_quit(void) |
de56407f | 165 | { |
5eaef520 | 166 | STRING str; |
167 | if (!conn) | |
168 | return; | |
169 | string_alloc(&str, 5); | |
170 | strcpy(STRING_DATA(str), "quit"); | |
171 | send_object(conn, (char *)&str, STRING_T); | |
172 | string_free(&str); | |
de56407f | 173 | } |