]> andersk Git - moira.git/blobdiff - update/client.c
Document new blanche exit status semantics. (Don't claim success
[moira.git] / update / client.c
index 3884bf8d7747c2a507ce7e98063a312e29d7bd8b..3033d265b404bf1d311788000470e3beb9ad8d2b 100644 (file)
@@ -26,7 +26,8 @@ static char *rcsid_client2_c = "$Header$";
 
 #include <mit-copyright.h>
 #include <stdio.h>
-#include <strings.h>
+#include <stdlib.h>
+#include <string.h>
 #include <gdb.h>
 #include <sys/param.h>
 #include <sys/wait.h>
@@ -38,8 +39,8 @@ static char *rcsid_client2_c = "$Header$";
 #include <moira_site.h>
 #include <krb.h>
 
-extern char *malloc();
 extern int errno, dbg;
+extern C_Block session;
 
 static char buf[BUFSIZ];
 static int code;
@@ -145,14 +146,13 @@ char *instructions;
     com_err(whoami, 0, "starting update for %s", service_updated);
     
     /* open connection */
+    gdb_Options |= GDB_OPT_KEEPALIVE;
     conn = start_server_connection(service_address, "");
     if (!conn || (connection_status(conn) == CON_STOPPED)) {
        com_err(whoami, connection_errno(conn),
                " can't connect to update %s", service_address);
        return(MR_CANT_CONNECT);
     }
-    on = 1;
-    setsockopt(conn->in.fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
     
     /* send authenticators */
     code = send_auth(machine);
@@ -162,7 +162,7 @@ char *instructions;
        goto update_failed;
     }
     
-    code = send_file(pathname, target_path, 0);
+    code = send_file(pathname, target_path, 1);
     if (code)
       goto update_failed;
 
@@ -193,8 +193,6 @@ char *instructions;
 #undef ASSERT
 }
 
-
-static
 send_auth(host_name)
 char *host_name;
 {
@@ -203,12 +201,13 @@ char *host_name;
     STRING data;
     register int code;
     int response;
+    int auth_version = 2;
     
     code = get_mr_update_ticket(host_name, ticket);
     if (code) {
        return(code);
     }
-    STRING_DATA(data) = "AUTH_001";
+    STRING_DATA(data) = "AUTH_002";
     MAX_STRING_SIZE(data) = 9;
     code = send_object(conn, (char *)&data, STRING_T);
     if (code) {
@@ -219,7 +218,20 @@ char *host_name;
        return(connection_errno(conn));
     }
     if (response) {
-       return(response);
+       STRING_DATA(data) = "AUTH_001";
+       MAX_STRING_SIZE(data) = 9;
+       code = send_object(conn, (char *)&data, STRING_T);
+       if (code) {
+           return(connection_errno(conn));
+       }
+       code = receive_object(conn, (char *)&response, INTEGER_T);
+       if (code) {
+           return(connection_errno(conn));
+       }
+       if (response) {
+           return(response);
+       }
+       auth_version = 1;
     }
     STRING_DATA(data) = (char *)ticket->dat;
     MAX_STRING_SIZE(data) = ticket->length;
@@ -234,10 +246,34 @@ char *host_name;
     if (response) {
        return(response);
     }
+    
+    if (auth_version == 2) {
+       des_key_schedule sched;
+       C_Block enonce;
+
+       code = receive_object(conn, (char *)&data, STRING_T);
+       if (code) {
+           return(connection_errno(conn));
+       }
+       des_key_sched(&session, &sched);
+       des_ecb_encrypt(STRING_DATA(data), enonce, sched, 1);
+       STRING_DATA(data) = enonce;
+       code = send_object(conn, (char *)&data, STRING_T);
+       if (code) {
+           return(connection_errno(conn));
+       }
+       code = receive_object(conn, (char *)&response, INTEGER_T);
+       if (code) {
+           return(connection_errno(conn));
+       }
+       if (response) {
+           return(response);
+       }
+    }
+
     return(MR_SUCCESS);
 }
 
-static
 execute(path)
     char *path;
 {
@@ -253,8 +289,6 @@ execute(path)
     code = receive_object(conn, (char *)&response, INTEGER_T);
     if (code)
        return(connection_errno(conn));
-    if (dbg & DBG_TRACE)
-      com_err(whoami, response, "execute returned %d", response);
     if (response)
       return(response);
     return(MR_SUCCESS);
This page took 0.038154 seconds and 4 git commands to generate.