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