X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/dd2e131ed2502e168ea24672718ad0961ae1ab7a..dcfa270ac1d2f55eb793c4da4bbd555903a88b09:/update/inst_001.c diff --git a/update/inst_001.c b/update/inst_001.c index e8366c0a..d2860346 100644 --- a/update/inst_001.c +++ b/update/inst_001.c @@ -2,19 +2,27 @@ * $Source$ * $Header$ */ +/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ +/* For copying and distribution information, please see the file */ +/* . */ #ifndef lint static char *rcsid_inst_001_c = "$Header$"; #endif lint +#include #include +#include +#include #include -#include "kludge.h" +#include STRING instructions = { 0, 0 }; extern CONNECTION conn; -extern int have_instructions; +extern int have_instructions, have_authorization; extern int code; +extern char *whoami; + /* * instruction sequence transmission: @@ -28,17 +36,54 @@ extern int code; inst_001(str) char *str; { - if (send_ok()) - lose("sending okay for inst_001"); - code = receive_object(conn, (char *)&instructions, STRING_T); - if (code) { - report_error("reporting failure to receive instructions"); - return; - } - have_instructions = 1; - if (send_ok()) - lose("sending okay after instructions"); + int file_size; + int checksum; + char *pathname; + + if (config_lookup("noinstructions")) { + code = EPERM; + code = send_object(conn, (char *)&code, INTEGER_T); + com_err(whoami, EPERM, "Not allowed to receive instructions"); + return; + } + + str += 8; + while (*str == ' ') + str++; + if (!*str) { + failure: + reject_call(MR_ARGS); + return; + } + file_size = atoi(str); + while (isdigit(*str)) + str++; + while (*str == ' ') + str++; + checksum = atoi(str); + while (isdigit(*str)) + str++; + while (*str == ' ') + str++; + if (*str != '/') + goto failure; + pathname = str; + if (!have_authorization) { + reject_call(MR_PERM); + return; + } + code = send_ok(); + if (code) + lose("sending ok for file xfer (2)"); + code = get_file(pathname, file_size, checksum, 0555, 0); + if (!code) { + char buf[BUFSIZ]; + have_instructions = 1; + strcpy(buf, "transferred file "); + strcat(buf, pathname); + mr_log_info(buf); + } #ifdef DEBUG - printf("got instructions: %s\n", STRING_DATA(instructions)); + printf("got instructions: %s\n", STRING_DATA(instructions)); #endif }