]>
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 | ||
85330553 | 15 | #include <errno.h> |
de56407f | 16 | #include <stdio.h> |
85330553 | 17 | #include <stdlib.h> |
802b0f62 | 18 | #include <string.h> |
7ac48069 | 19 | |
20 | #include <des.h> | |
de56407f | 21 | #include <krb.h> |
22 | ||
7ac48069 | 23 | RCSID("$Header$"); |
de56407f | 24 | |
85330553 | 25 | extern des_cblock session; |
de56407f | 26 | |
85330553 | 27 | int send_auth(int conn, char *host_name) |
de56407f | 28 | { |
5eaef520 | 29 | KTEXT_ST ticket_st; |
85330553 | 30 | int code, auth_version = 2; |
31 | long response; | |
5eaef520 | 32 | |
85330553 | 33 | code = get_mr_update_ticket(host_name, &ticket_st); |
5eaef520 | 34 | if (code) |
35 | return code; | |
85330553 | 36 | code = send_string(conn, "AUTH_002", 9); |
5eaef520 | 37 | if (code) |
85330553 | 38 | return code; |
39 | code = recv_int(conn, &response); | |
5eaef520 | 40 | if (code) |
85330553 | 41 | return code; |
5eaef520 | 42 | if (response) |
43 | { | |
85330553 | 44 | code = send_string(conn, "AUTH_001", 9); |
5eaef520 | 45 | if (code) |
85330553 | 46 | return code; |
47 | code = recv_int(conn, &response); | |
5eaef520 | 48 | if (code) |
85330553 | 49 | return code; |
5eaef520 | 50 | if (response) |
51 | return response; | |
52 | auth_version = 1; | |
de56407f | 53 | } |
85330553 | 54 | code = send_string(conn, (char *)ticket_st.dat, ticket_st.length); |
5eaef520 | 55 | if (code) |
85330553 | 56 | return code; |
57 | code = recv_int(conn, &response); | |
5eaef520 | 58 | if (code) |
85330553 | 59 | return code; |
5eaef520 | 60 | if (response) |
61 | return response; | |
62 | ||
63 | if (auth_version == 2) | |
64 | { | |
65 | des_key_schedule sched; | |
66 | C_Block enonce; | |
85330553 | 67 | char *data; |
68 | size_t size; | |
5eaef520 | 69 | |
85330553 | 70 | code = recv_string(conn, &data, &size); |
5eaef520 | 71 | if (code) |
85330553 | 72 | return code; |
5eaef520 | 73 | des_key_sched(session, sched); |
85330553 | 74 | des_ecb_encrypt(data, enonce, sched, 1); |
75 | free(data); | |
76 | code = send_string(conn, (char *)enonce, sizeof(enonce)); | |
5eaef520 | 77 | if (code) |
85330553 | 78 | return code; |
79 | code = recv_int(conn, &response); | |
5eaef520 | 80 | if (code) |
85330553 | 81 | return code; |
5eaef520 | 82 | if (response) |
83 | return response; | |
be86b0c2 | 84 | } |
85 | ||
5eaef520 | 86 | return MR_SUCCESS; |
de56407f | 87 | } |
88 | ||
85330553 | 89 | int execute(int conn, char *path) |
de56407f | 90 | { |
85330553 | 91 | long response; |
92 | char *data; | |
44d12d58 | 93 | int code; |
5eaef520 | 94 | |
85330553 | 95 | data = malloc(10 + strlen(path)); |
96 | if (!data) | |
97 | return ENOMEM; | |
98 | sprintf(data, "EXEC_002 %s", path); | |
99 | code = send_string(conn, data, strlen(data) + 1); | |
100 | free(data); | |
5eaef520 | 101 | if (code) |
85330553 | 102 | return code; |
103 | code = recv_int(conn, &response); | |
5eaef520 | 104 | if (code) |
85330553 | 105 | return code; |
5eaef520 | 106 | if (response) |
107 | return response; | |
85330553 | 108 | |
5eaef520 | 109 | return MR_SUCCESS; |
de56407f | 110 | } |
111 | ||
85330553 | 112 | void send_quit(int conn) |
113 | { | |
114 | send_string(conn, "quit", 5); | |
115 | } | |
116 | ||
117 | void fail(int conn, int err, char *msg) | |
de56407f | 118 | { |
85330553 | 119 | return; |
de56407f | 120 | } |