]> andersk Git - moira.git/blame_incremental - update/client.c
subnet status should be %s, not %d.
[moira.git] / update / client.c
... / ...
CommitLineData
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>.
9 */
10
11#include <mit-copyright.h>
12#include <moira.h>
13#include "update.h"
14
15#include <errno.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19
20#include <des.h>
21#include <krb.h>
22
23RCSID("$Header$");
24
25extern des_cblock session;
26extern char *whoami;
27
28int mr_send_auth(int conn, char *host_name)
29{
30 KTEXT_ST ticket_st;
31 int code, auth_version = 2;
32 long response;
33
34 code = get_mr_update_ticket(host_name, &ticket_st);
35 if (code)
36 return code;
37 code = send_string(conn, "AUTH_002", 9);
38 if (code)
39 return code;
40 code = recv_int(conn, &response);
41 if (code)
42 return code;
43 if (response)
44 {
45 code = send_string(conn, "AUTH_001", 9);
46 if (code)
47 return code;
48 code = recv_int(conn, &response);
49 if (code)
50 return code;
51 if (response)
52 return response;
53 auth_version = 1;
54 }
55 code = send_string(conn, (char *)ticket_st.dat, ticket_st.length);
56 if (code)
57 return code;
58 code = recv_int(conn, &response);
59 if (code)
60 return code;
61 if (response)
62 return response;
63
64 if (auth_version == 2)
65 {
66 des_key_schedule sched;
67 C_Block enonce;
68 char *data;
69 size_t size;
70
71 code = recv_string(conn, &data, &size);
72 if (code)
73 return code;
74 des_key_sched(session, sched);
75 des_ecb_encrypt(data, enonce, sched, 1);
76 free(data);
77 code = send_string(conn, (char *)enonce, sizeof(enonce));
78 if (code)
79 return code;
80 code = recv_int(conn, &response);
81 if (code)
82 return code;
83 if (response)
84 return response;
85 }
86
87 return MR_SUCCESS;
88}
89
90int mr_execute(int conn, char *path)
91{
92 long response;
93 char *data;
94 int code;
95
96 data = malloc(10 + strlen(path));
97 if (!data)
98 return ENOMEM;
99 sprintf(data, "EXEC_002 %s", path);
100 code = send_string(conn, data, strlen(data) + 1);
101 free(data);
102 if (code)
103 return code;
104 code = recv_int(conn, &response);
105 if (code)
106 return code;
107 if (response)
108 return response;
109
110 return MR_SUCCESS;
111}
112
113void mr_send_quit(int conn)
114{
115 send_string(conn, "quit", 5);
116}
117
118void fail(int conn, int err, char *msg)
119{
120 com_err(whoami, err, msg);
121 return;
122}
This page took 2.106443 seconds and 5 git commands to generate.