]> andersk Git - moira.git/blob - update/inst_001.c
Solaris changes
[moira.git] / update / inst_001.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5 /*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6 /*  For copying and distribution information, please see the file */
7 /*  <mit-copyright.h>. */
8
9 #ifndef lint
10 static char *rcsid_inst_001_c = "$Header$";
11 #endif  lint
12
13 #include <mit-copyright.h>
14 #include <stdio.h>
15 #include <errno.h>
16 #include <ctype.h>
17 #include <gdb.h>
18 #include <moira.h>
19
20 STRING instructions = { 0, 0 };
21 extern CONNECTION conn;
22 extern int have_instructions, have_authorization;
23 extern int code;
24 extern char *whoami;
25
26
27 /*
28  * instruction sequence transmission:
29  * syntax:
30  *      >>> (STRING) "inst_001"
31  *      <<< (int)0
32  *      >>> (STRING) instructions
33  *      <<< (int)0
34  */
35
36 inst_001(str)
37      char *str;
38 {
39     int file_size;
40     int checksum;
41     char *pathname;
42     
43     if (config_lookup("noinstructions")) {
44         code = EPERM;
45         code = send_object(conn, (char *)&code, INTEGER_T);
46         com_err(whoami, EPERM, "Not allowed to receive instructions");
47         return;
48     }
49
50     str += 8;
51     while (*str == ' ')
52         str++;
53     if (!*str) {
54     failure:
55         reject_call(MR_ARGS);
56         return;
57     }
58     file_size = atoi(str);
59     while (isdigit(*str))
60         str++;
61     while (*str == ' ')
62         str++;
63     checksum = atoi(str);
64     while (isdigit(*str))
65         str++;
66     while (*str == ' ')
67         str++;
68     if (*str != '/')
69         goto failure;
70     pathname = str;
71     if (!have_authorization) {
72         reject_call(MR_PERM);
73         return;
74     }
75     code = send_ok();
76     if (code)
77         lose("sending ok for file xfer (2)");
78     code = get_file(pathname, file_size, checksum, 0555, 0);
79     if (!code) {
80         char buf[BUFSIZ];
81         have_instructions = 1;
82         strcpy(buf, "transferred file ");
83         strcat(buf, pathname);
84         mr_log_info(buf);
85     }
86 #ifdef DEBUG
87     printf("got instructions: %s\n", STRING_DATA(instructions));
88 #endif
89 }
This page took 0.104317 seconds and 5 git commands to generate.