]> andersk Git - moira.git/blobdiff - update/client.c
Yet another special case for dealing with the gdss signatures.
[moira.git] / update / client.c
index e34f355e8abb68c86ee1ad9b979de489a2fa19b8..1a0babaa7db1670ec7c3d0b316cecc47eaff9d3b 100644 (file)
@@ -10,31 +10,36 @@ static char *rcsid_client2_c = "$Header$";
 /*
  * MODULE IDENTIFICATION:
  *     $Header$
- *     Copyright 1987 MIT Project Athena.
+ *     Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ *     For copying and distribution information, please see the file
+ *     <mit-copyright.h>.
  * DESCRIPTION:
  *     This code handles the actual distribution of data files
- *     to servers in the SMS server-update program.
+ *     to servers in the MOIRA server-update program.
  * AUTHOR:
  *     Ken Raeburn (spook@athena.MIT.EDU),
  *             MIT Project Athena/MIT Information Systems.
  * DEFINED VALUES:
  *     conn
- *     sms_update_server
+ *     mr_update_server
  */
 
+#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>
+#include <sys/socket.h>
 #include <update.h>
 #include <errno.h>
 #include <dcm.h>
-#include <sms.h>
+#include <moira.h>
+#include <moira_site.h>
 #include <krb.h>
 
-extern char *malloc();
-extern int errno;
+extern int errno, dbg;
 
 static char buf[BUFSIZ];
 static int code;
@@ -53,7 +58,7 @@ CONNECTION conn;
  * RETURN VALUE:
  *     void
  * SIDE EFFECTS:
- *     Initializes GDB library and SMSU error table.
+ *     Initializes GDB library.
  * PROBLEMS:
  *
  */
@@ -64,7 +69,6 @@ initialize()
 
     if (!initialized) {
        gdb_init();
-       init_smsU_err_tbl();
        initialized++;
     }
 }
@@ -72,16 +76,16 @@ initialize()
 
 /*
  * FUNCTION:
- *     sms_update_server(service, machine, target_path)
+ *     mr_update_server(service, machine, target_path)
  * DESCRIPTION:
  *     Attempts to perform an update to the named machine
- *     of the named service.  The file SMS_DIR/dcm/service.out
+ *     of the named service.  The file DCM_DIR/service.out
  *     will be sent, then the file SMS_DIR/bin/service.sh,
  *     the the shell script will be executed.
  * INPUT:
  *     service
  *             Name of service to be updated; used to find
- *             the source data file in the SMS data directory.
+ *             the source data file in the MR data directory.
  *     machine
  *     target_path
  *             Location to install the file.
@@ -96,7 +100,7 @@ initialize()
  */
 
 int
-sms_update_server(service, machine, target_path, instructions)
+mr_update_server(service, machine, target_path, instructions)
 char *service;
 char *machine;
 char *target_path;
@@ -110,41 +114,43 @@ char *instructions;
     (((str) != (char *)NULL) && (strlen(str) != 0))
 
     char *service_address, *service_updated, *pathname;
+    int on;
     
     /* some sanity checking of arguments while we build data */
-    ASSERT(NONNULL(machine), SMS_INTERNAL, " null host name");
-    ASSERT(NONNULL(service), SMS_INTERNAL, " null service name");
-    ASSERT((strlen(machine) + strlen(service) + 2 < BUFSIZ), SMS_ARG_TOO_LONG,
+    ASSERT(NONNULL(machine), MR_INTERNAL, " null host name");
+    ASSERT(NONNULL(service), MR_INTERNAL, " null service name");
+    ASSERT((strlen(machine) + strlen(service) + 2 < BUFSIZ), MR_ARG_TOO_LONG,
           " machine and service names");
     sprintf(buf, "%s:%s", machine, service);
     service_updated = strsave(buf);
-    ASSERT(NONNULL(service_updated), SMS_NO_MEM, " for service name");
-    ASSERT((strlen(machine)+strlen(SERVICE_NAME)+2 < BUFSIZ), SMS_ARG_TOO_LONG,
+    ASSERT(NONNULL(service_updated), MR_NO_MEM, " for service name");
+    ASSERT((strlen(machine)+strlen(SERVICE_NAME)+2 < BUFSIZ), MR_ARG_TOO_LONG,
           " machine and update service name");
     sprintf(buf, "%s:%s", machine, SERVICE_NAME);
     service_address = strsave(buf);
-    ASSERT(NONNULL(service_address), SMS_NO_MEM, " for service address");
-    ASSERT(NONNULL(target_path), SMS_INTERNAL, " null target pathname");
-    ASSERT((strlen(target_path) < MAXPATHLEN), SMS_ARG_TOO_LONG,
+    ASSERT(NONNULL(service_address), MR_NO_MEM, " for service address");
+    ASSERT(NONNULL(target_path), MR_INTERNAL, " null target pathname");
+    ASSERT((strlen(target_path) < MAXPATHLEN), MR_ARG_TOO_LONG,
           " target pathname");
-    ASSERT2(target_path[0] == '/', SMS_NOT_UNIQUE,
+    ASSERT2(target_path[0] == '/', MR_NOT_UNIQUE,
           " non-absolute pathname supplied \"%s\"", target_path);
-    sprintf(buf, "%s/dcm/%s.out", SMS_DIR, service);
+    sprintf(buf, "%s/%s.out", DCM_DIR, service);
     pathname = strsave(buf);
-    ASSERT(NONNULL(pathname), SMS_NO_MEM, " for pathname");
-    ASSERT(NONNULL(instructions), SMS_NO_MEM, " for instructions");
-    ASSERT((strlen(instructions) < MAXPATHLEN), SMS_ARG_TOO_LONG,
+    ASSERT(NONNULL(pathname), MR_NO_MEM, " for pathname");
+    ASSERT(NONNULL(instructions), MR_NO_MEM, " for instructions");
+    ASSERT((strlen(instructions) < MAXPATHLEN), MR_ARG_TOO_LONG,
           " instruction pathname");
     
     initialize();
     com_err(whoami, 0, "starting update for %s", service_updated);
     
     /* open connection */
-    conn = start_server_connection(service_address, 0);
+    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(SMS_CANT_CONNECT);
+       return(MR_CANT_CONNECT);
     }
     
     /* send authenticators */
@@ -155,14 +161,14 @@ char *instructions;
        goto update_failed;
     }
     
-    code = send_file(pathname, target_path);
+    code = send_file(pathname, target_path, 0);
     if (code)
       goto update_failed;
 
     /* send instructions for installation */
-    strcpy(buf, "/tmp/sms-update.XXXXXX");
+    strcpy(buf, "/tmp/moira-update.XXXXXX");
     mktemp(buf);
-    code = send_file(instructions, buf);
+    code = send_file(instructions, buf, 0);
     if (code)
       goto update_failed;
 
@@ -175,7 +181,7 @@ char *instructions;
     }
     
     /* finished updates */
-    code = SMS_SUCCESS;
+    code = MR_SUCCESS;
 
  update_failed:
     send_quit();
@@ -197,7 +203,7 @@ char *host_name;
     register int code;
     int response;
     
-    code = get_sms_update_ticket(host_name, ticket);
+    code = get_mr_update_ticket(host_name, ticket);
     if (code) {
        return(code);
     }
@@ -227,14 +233,14 @@ char *host_name;
     if (response) {
        return(response);
     }
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 }
 
 static
 execute(path)
     char *path;
 {
-    union wait response;
+    int response;
     STRING data;
     register int code;
     
@@ -246,16 +252,11 @@ execute(path)
     code = receive_object(conn, (char *)&response, INTEGER_T);
     if (code)
        return(connection_errno(conn));
-    if (response.w_retcode) {
-/****************************************************************
- * The following line is there because the current update servers
- * don't return the correct error code when an update fails.  Remove
- * this line when they are fixed.  -mar  7/26/88
- ****************************************************************/
-       return(SMS_INTERNAL);
-       return(response.w_retcode);
-    }
-    return(SMS_SUCCESS);
+    if (dbg & DBG_TRACE)
+      com_err(whoami, response, "execute returned %d", response);
+    if (response)
+      return(response);
+    return(MR_SUCCESS);
 }
 
 send_quit()
This page took 1.441045 seconds and 4 git commands to generate.