]> andersk Git - moira.git/blob - update/client.c
Remove all references to table locking, since
[moira.git] / update / client.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5
6 #ifndef lint
7 static char *rcsid_client2_c = "$Header$";
8 #endif  lint
9
10 /*
11  * MODULE IDENTIFICATION:
12  *      $Header$
13  *      Copyright 1987, 1988 by the Massachusetts Institute of Technology.
14  *      For copying and distribution information, please see the file
15  *      <mit-copyright.h>.
16  * DESCRIPTION:
17  *      This code handles the actual distribution of data files
18  *      to servers in the MOIRA server-update program.
19  * AUTHOR:
20  *      Ken Raeburn (spook@athena.MIT.EDU),
21  *              MIT Project Athena/MIT Information Systems.
22  * DEFINED VALUES:
23  *      conn
24  *      mr_update_server
25  */
26
27 #include <mit-copyright.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <gdb.h>
32 #include <sys/param.h>
33 #include <sys/wait.h>
34 #include <sys/socket.h>
35 #include <update.h>
36 #include <errno.h>
37 #include <moira.h>
38 #include <moira_site.h>
39 #include <krb.h>
40
41 extern int errno, dbg;
42 extern C_Block session;
43
44 static char buf[BUFSIZ];
45 static int code;
46
47 CONNECTION conn;
48
49
50 /*
51  * FUNCTION:
52  *      initialize()
53  * DESCRIPTION:
54  *      Insures that various libraries have a chance to get
55  *      initialized.
56  * INPUT:
57  * OUTPUT:
58  * RETURN VALUE:
59  *      void
60  * SIDE EFFECTS:
61  *      Initializes GDB library.
62  * PROBLEMS:
63  *
64  */
65 static void
66 initialize()
67 {
68     static int initialized = 0;
69
70     if (!initialized) {
71         gdb_init();
72         initialized++;
73     }
74 }
75
76 send_auth(host_name)
77 char *host_name;
78 {
79     KTEXT_ST ticket_st;
80     KTEXT ticket = &ticket_st;
81     STRING data;
82     register int code;
83     int response;
84     int auth_version = 2;
85     
86     code = get_mr_update_ticket(host_name, ticket);
87     if (code) {
88         return(code);
89     }
90     STRING_DATA(data) = "AUTH_002";
91     MAX_STRING_SIZE(data) = 9;
92     code = send_object(conn, (char *)&data, STRING_T);
93     if (code) {
94         return(connection_errno(conn));
95     }
96     code = receive_object(conn, (char *)&response, INTEGER_T);
97     if (code) {
98         return(connection_errno(conn));
99     }
100     if (response) {
101         STRING_DATA(data) = "AUTH_001";
102         MAX_STRING_SIZE(data) = 9;
103         code = send_object(conn, (char *)&data, STRING_T);
104         if (code) {
105             return(connection_errno(conn));
106         }
107         code = receive_object(conn, (char *)&response, INTEGER_T);
108         if (code) {
109             return(connection_errno(conn));
110         }
111         if (response) {
112             return(response);
113         }
114         auth_version = 1;
115     }
116     STRING_DATA(data) = (char *)ticket->dat;
117     MAX_STRING_SIZE(data) = ticket->length;
118     code = send_object(conn, (char *)&data, STRING_T);
119     if (code) {
120         return(connection_errno(conn));
121     }
122     code = receive_object(conn, (char *)&response, INTEGER_T);
123     if (code) {
124         return(connection_errno(conn));
125     }
126     if (response) {
127         return(response);
128     }
129     
130     if (auth_version == 2) {
131         des_key_schedule sched;
132         C_Block enonce;
133
134         code = receive_object(conn, (char *)&data, STRING_T);
135         if (code) {
136             return(connection_errno(conn));
137         }
138         des_key_sched(session, sched);
139         des_ecb_encrypt(STRING_DATA(data), enonce, sched, 1);
140         STRING_DATA(data) = enonce;
141         code = send_object(conn, (char *)&data, STRING_T);
142         if (code) {
143             return(connection_errno(conn));
144         }
145         code = receive_object(conn, (char *)&response, INTEGER_T);
146         if (code) {
147             return(connection_errno(conn));
148         }
149         if (response) {
150             return(response);
151         }
152     }
153
154     return(MR_SUCCESS);
155 }
156
157 execute(path)
158     char *path;
159 {
160     int response;
161     STRING data;
162     register int code;
163     
164     string_alloc(&data, BUFSIZ);
165     sprintf(STRING_DATA(data), "EXEC_002 %s", path);
166     code = send_object(conn, (char *)&data, STRING_T);
167     if (code)
168         return(connection_errno(conn));
169     code = receive_object(conn, (char *)&response, INTEGER_T);
170     if (code)
171         return(connection_errno(conn));
172     if (response)
173       return(response);
174     return(MR_SUCCESS);
175 }
176
177 send_quit()
178 {
179     STRING str;
180     if (!conn)
181         return;
182     string_alloc(&str, 5);
183     (void) strcpy(STRING_DATA(str), "quit");
184     (void) send_object(conn, (char *)&str, STRING_T);
185     string_free(&str);
186 }
This page took 0.060036 seconds and 5 git commands to generate.