]>
Commit | Line | Data |
---|---|---|
7ac48069 | 1 | /* $Id$ |
2 | * | |
3 | * This code handles the actual distribution of data files | |
4 | * to servers in the Moira server-update program. | |
5 | * | |
6 | * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology. | |
7 | * For copying and distribution information, please see the file | |
8 | * <mit-copyright.h>. | |
de56407f | 9 | */ |
10 | ||
546bc43b | 11 | #include <mit-copyright.h> |
7ac48069 | 12 | #include <moira.h> |
13 | #include "update.h" | |
14 | ||
de56407f | 15 | #include <stdio.h> |
7ac48069 | 16 | |
17 | #include <des.h> | |
7bd50861 | 18 | #include <gdb.h> |
de56407f | 19 | #include <krb.h> |
20 | ||
7ac48069 | 21 | RCSID("$Header$"); |
de56407f | 22 | |
7ac48069 | 23 | extern int dbg; |
24 | extern C_Block session; | |
de56407f | 25 | |
26 | CONNECTION conn; | |
de56407f | 27 | |
5eaef520 | 28 | int send_auth(char *host_name) |
de56407f | 29 | { |
5eaef520 | 30 | KTEXT_ST ticket_st; |
31 | KTEXT ticket = &ticket_st; | |
32 | STRING data; | |
44d12d58 | 33 | int code; |
5eaef520 | 34 | int response; |
35 | int auth_version = 2; | |
36 | ||
37 | code = get_mr_update_ticket(host_name, ticket); | |
38 | if (code) | |
39 | return code; | |
40 | STRING_DATA(data) = "AUTH_002"; | |
41 | MAX_STRING_SIZE(data) = 9; | |
42 | code = send_object(conn, (char *)&data, STRING_T); | |
43 | if (code) | |
44 | return connection_errno(conn); | |
45 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
46 | if (code) | |
47 | return connection_errno(conn); | |
48 | if (response) | |
49 | { | |
50 | STRING_DATA(data) = "AUTH_001"; | |
51 | MAX_STRING_SIZE(data) = 9; | |
52 | code = send_object(conn, (char *)&data, STRING_T); | |
53 | if (code) | |
54 | return connection_errno(conn); | |
55 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
56 | if (code) | |
57 | return connection_errno(conn); | |
58 | if (response) | |
59 | return response; | |
60 | auth_version = 1; | |
de56407f | 61 | } |
5eaef520 | 62 | STRING_DATA(data) = (char *)ticket->dat; |
63 | MAX_STRING_SIZE(data) = ticket->length; | |
64 | code = send_object(conn, (char *)&data, STRING_T); | |
65 | if (code) | |
66 | return connection_errno(conn); | |
67 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
68 | if (code) | |
69 | return connection_errno(conn); | |
70 | if (response) | |
71 | return response; | |
72 | ||
73 | if (auth_version == 2) | |
74 | { | |
75 | des_key_schedule sched; | |
76 | C_Block enonce; | |
77 | ||
78 | code = receive_object(conn, (char *)&data, STRING_T); | |
79 | if (code) | |
80 | return connection_errno(conn); | |
81 | des_key_sched(session, sched); | |
82 | des_ecb_encrypt(STRING_DATA(data), enonce, sched, 1); | |
83 | STRING_DATA(data) = enonce; | |
84 | code = send_object(conn, (char *)&data, STRING_T); | |
85 | if (code) | |
86 | return connection_errno(conn); | |
87 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
88 | if (code) | |
89 | return connection_errno(conn); | |
90 | if (response) | |
91 | return response; | |
be86b0c2 | 92 | } |
93 | ||
5eaef520 | 94 | return MR_SUCCESS; |
de56407f | 95 | } |
96 | ||
5eaef520 | 97 | int execute(char *path) |
de56407f | 98 | { |
5eaef520 | 99 | int response; |
100 | STRING data; | |
44d12d58 | 101 | int code; |
5eaef520 | 102 | |
103 | string_alloc(&data, BUFSIZ); | |
104 | sprintf(STRING_DATA(data), "EXEC_002 %s", path); | |
105 | code = send_object(conn, (char *)&data, STRING_T); | |
106 | if (code) | |
107 | return connection_errno(conn); | |
108 | code = receive_object(conn, (char *)&response, INTEGER_T); | |
109 | if (code) | |
110 | return connection_errno(conn); | |
111 | if (response) | |
112 | return response; | |
113 | return MR_SUCCESS; | |
de56407f | 114 | } |
115 | ||
7ac48069 | 116 | void send_quit(void) |
de56407f | 117 | { |
5eaef520 | 118 | STRING str; |
119 | if (!conn) | |
120 | return; | |
121 | string_alloc(&str, 5); | |
122 | strcpy(STRING_DATA(str), "quit"); | |
123 | send_object(conn, (char *)&str, STRING_T); | |
124 | string_free(&str); | |
de56407f | 125 | } |