]> andersk Git - moira.git/blob - update/client.c
KEYFILE is no longer a compile-time constant in krb5's krb4 compat
[moira.git] / update / client.c
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
19 #include <des.h>
20 #include <krb.h>
21
22 RCSID("$Header$");
23
24 extern des_cblock session;
25
26 int send_auth(int conn, char *host_name)
27 {
28   KTEXT_ST ticket_st;
29   int code, auth_version = 2;
30   long response;
31
32   code = get_mr_update_ticket(host_name, &ticket_st);
33   if (code)
34     return code;
35   code = send_string(conn, "AUTH_002", 9);
36   if (code)
37     return code;
38   code = recv_int(conn, &response);
39   if (code)
40     return code;
41   if (response)
42     {
43       code = send_string(conn, "AUTH_001", 9);
44       if (code)
45         return code;
46       code = recv_int(conn, &response);
47       if (code)
48         return code;
49       if (response)
50         return response;
51       auth_version = 1;
52     }
53   code = send_string(conn, (char *)ticket_st.dat, ticket_st.length);
54   if (code)
55     return code;
56   code = recv_int(conn, &response);
57   if (code)
58     return code;
59   if (response)
60     return response;
61
62   if (auth_version == 2)
63     {
64       des_key_schedule sched;
65       C_Block enonce;
66       char *data;
67       size_t size;
68
69       code = recv_string(conn, &data, &size);
70       if (code)
71         return code;
72       des_key_sched(session, sched);
73       des_ecb_encrypt(data, enonce, sched, 1);
74       free(data);
75       code = send_string(conn, (char *)enonce, sizeof(enonce));
76       if (code)
77         return code;
78       code = recv_int(conn, &response);
79       if (code)
80         return code;
81       if (response)
82         return response;
83     }
84
85   return MR_SUCCESS;
86 }
87
88 int execute(int conn, char *path)
89 {
90   long response;
91   char *data;
92   int code;
93
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);
100   if (code)
101     return code;
102   code = recv_int(conn, &response);
103   if (code)
104     return code;
105   if (response)
106     return response;
107
108   return MR_SUCCESS;
109 }
110
111 void send_quit(int conn)
112 {
113   send_string(conn, "quit", 5);
114 }
115
116 void fail(int conn, int err, char *msg)
117 {
118   return;
119 }
This page took 0.073139 seconds and 5 git commands to generate.